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
auto helpOption = QCommandLineOption("help", "Display Help on the command line");
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;
parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
parser.addOption(helpOption);
parser.addOption(versionOption);
parser.addOption(noResetOption);
parser.addOption(resetOption);
parser.parse(QCoreApplication::arguments());
const auto header = QStringLiteral("%1: %2\n").arg(kAppName, kDisplayVersion);
@ -132,8 +132,7 @@ int main(int argc, char *argv[])
#endif
// --no-reset
const auto resetEnvVar = QVariant(qEnvironmentVariable("DESKFLOW_RESET_ALL")).toBool();
if (resetEnvVar && !parser.isSet(noResetOption)) {
if (parser.isSet(resetOption)) {
diagnostic::clearSettings(false);
}

View file

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