refactor: use QVariant().toBool() in place of StringUtils::StrToBool, remove StringUtils
This commit is contained in:
@ -22,7 +22,6 @@
|
||||
#include "common/UrlConstants.h"
|
||||
#include "gui/Logger.h"
|
||||
#include "gui/Messages.h"
|
||||
#include "gui/StringUtils.h"
|
||||
#include "gui/Styles.h"
|
||||
#include "gui/core/CoreProcess.h"
|
||||
#include "gui/ipc/DaemonIpcClient.h"
|
||||
@ -677,7 +676,7 @@ void MainWindow::createMenuBar()
|
||||
menuBar->addMenu(menuEdit);
|
||||
menuBar->addMenu(menuHelp);
|
||||
|
||||
const auto enableTestMenu = strToTrue(qEnvironmentVariable("DESKFLOW_TEST_MENU"));
|
||||
const auto enableTestMenu = QVariant(qEnvironmentVariable("DESKFLOW_TEST_MENU")).toBool();
|
||||
if (enableTestMenu || kDebugBuild) {
|
||||
auto testMenu = new QMenu(tr("Test"));
|
||||
menuBar->addMenu(testMenu);
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
#include "gui/DotEnv.h"
|
||||
#include "gui/Logger.h"
|
||||
#include "gui/Messages.h"
|
||||
#include "gui/StringUtils.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
@ -135,7 +134,7 @@ int main(int argc, char *argv[])
|
||||
// --no-reset
|
||||
QStringList arguments = QCoreApplication::arguments();
|
||||
const auto noReset = hasArg("--no-reset", arguments);
|
||||
const auto resetEnvVar = strToTrue(qEnvironmentVariable("DESKFLOW_RESET_ALL"));
|
||||
const auto resetEnvVar = QVariant(qEnvironmentVariable("DESKFLOW_RESET_ALL")).toBool();
|
||||
if (resetEnvVar && !noReset) {
|
||||
diagnostic::clearSettings(false);
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@ add_library(${target} STATIC
|
||||
Logger.h
|
||||
Messages.cpp
|
||||
Messages.h
|
||||
StringUtils.h
|
||||
Styles.h
|
||||
config/IServerConfig.h
|
||||
config/Screen.cpp
|
||||
|
||||
@ -6,8 +6,6 @@
|
||||
|
||||
#include "Logger.h"
|
||||
|
||||
#include "StringUtils.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
@ -59,15 +57,8 @@ QString printLine(FILE *out, const QString &type, const QString &message, const
|
||||
|
||||
void Logger::loadEnvVars()
|
||||
{
|
||||
const auto debugEnvVar = qEnvironmentVariable("DESKFLOW_GUI_DEBUG");
|
||||
if (!debugEnvVar.isEmpty()) {
|
||||
m_debug = strToTrue(debugEnvVar);
|
||||
}
|
||||
|
||||
const auto verboseEnvVar = qEnvironmentVariable("DESKFLOW_GUI_VERBOSE");
|
||||
if (!verboseEnvVar.isEmpty()) {
|
||||
m_verbose = strToTrue(verboseEnvVar);
|
||||
}
|
||||
m_debug = QVariant(qEnvironmentVariable("DESKFLOW_GUI_DEBUG")).toBool();
|
||||
m_verbose = QVariant(qEnvironmentVariable("DESKFLOW_GUI_VERBOSE")).toBool();
|
||||
}
|
||||
|
||||
void Logger::logVerbose(const QString &message) const
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2024 Symless Ltd.
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
/**
|
||||
* @brief Useful for environment variables that have string boolean values.
|
||||
*/
|
||||
inline bool strToTrue(const QString &str)
|
||||
{
|
||||
return str.toLower() == "true" || str == "1";
|
||||
}
|
||||
Reference in New Issue
Block a user