refactor: Remove use of DESKFLOW_RESET_ALL and all users to pass --reset switch to deskflow-gui instead

This commit is contained in:
sithlord48 2025-05-02 07:35:54 -04:00 committed by Nick Bolton
parent 97863bda7c
commit 903401796e
2 changed files with 6 additions and 6 deletions

View file

@ -55,13 +55,13 @@ int main(int argc, char *argv[])
// Add Command Line Options // Add Command Line Options
auto helpOption = QCommandLineOption("help", "Display Help on the command line"); auto helpOption = QCommandLineOption("help", "Display Help on the command line");
auto versionOption = QCommandLineOption("version", "Display version information"); auto versionOption = QCommandLineOption("version", "Display version information");
auto noResetOption = QCommandLineOption("no-reset", "Prevent settings reset if DESKFLOW_RESET_ALL is set"); auto resetOption = QCommandLineOption("reset", "Reset all settings");
QCommandLineParser parser; QCommandLineParser parser;
parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
parser.addOption(helpOption); parser.addOption(helpOption);
parser.addOption(versionOption); parser.addOption(versionOption);
parser.addOption(noResetOption); parser.addOption(resetOption);
parser.parse(QCoreApplication::arguments()); parser.parse(QCoreApplication::arguments());
const auto header = QStringLiteral("%1: %2\n").arg(kAppName, kDisplayVersion); const auto header = QStringLiteral("%1: %2\n").arg(kAppName, kDisplayVersion);
@ -132,8 +132,7 @@ int main(int argc, char *argv[])
#endif #endif
// --no-reset // --no-reset
const auto resetEnvVar = QVariant(qEnvironmentVariable("DESKFLOW_RESET_ALL")).toBool(); if (parser.isSet(resetOption)) {
if (resetEnvVar && !parser.isSet(noResetOption)) {
diagnostic::clearSettings(false); diagnostic::clearSettings(false);
} }

View file

@ -19,8 +19,9 @@ void restart()
QString program = QCoreApplication::applicationFilePath(); QString program = QCoreApplication::applicationFilePath();
QStringList arguments = QCoreApplication::arguments(); QStringList arguments = QCoreApplication::arguments();
// prevent infinite reset loop when env var set. // look for and remove --reset option if found
arguments << "--no-reset"; if (int resetIndex = arguments.indexOf("--reset"); resetIndex != -1)
arguments.remove(resetIndex);
qInfo("launching new process: %s", qPrintable(program)); qInfo("launching new process: %s", qPrintable(program));
QProcess::startDetached(program, arguments); QProcess::startDetached(program, arguments);