diff --git a/src/lib/common/Settings.cpp b/src/lib/common/Settings.cpp index 00de92bac..60a6cb728 100644 --- a/src/lib/common/Settings.cpp +++ b/src/lib/common/Settings.cpp @@ -75,7 +75,8 @@ void Settings::cleanSettings() QVariant Settings::defaultValue(const QString &key) { if ((key == Gui::Autohide) || (key == Core::StartedBefore) || (key == Core::PreventSleep) || - (key == Server::ExternalConfig) || (key == Client::InvertScrollDirection) || (key == Log::ToFile)) { + (key == Server::ExternalConfig) || (key == Client::InvertScrollDirection) || (key == Log::ToFile) || + (key == Core::StopOnDeskSwitch)) { return false; } diff --git a/src/lib/common/Settings.h b/src/lib/common/Settings.h index df5021250..561982738 100644 --- a/src/lib/common/Settings.h +++ b/src/lib/common/Settings.h @@ -48,6 +48,7 @@ public: inline static const auto PreventSleep = QStringLiteral("core/preventSleep"); inline static const auto ProcessMode = QStringLiteral("core/processMode"); inline static const auto ScreenName = QStringLiteral("core/screenName"); + inline static const auto StopOnDeskSwitch = QStringLiteral("core/stopOnDeskSwitch"); inline static const auto StartedBefore = QStringLiteral("core/startedBefore"); inline static const auto UpdateUrl = QStringLiteral("core/updateUrl"); }; @@ -189,6 +190,7 @@ private: , Settings::Core::ProcessMode , Settings::Core::ScreenName , Settings::Core::StartedBefore + , Settings::Core::StopOnDeskSwitch , Settings::Core::UpdateUrl , Settings::Daemon::Command , Settings::Daemon::Elevate diff --git a/src/lib/gui/core/CoreProcess.cpp b/src/lib/gui/core/CoreProcess.cpp index 163b9dc05..8d9d27bfd 100644 --- a/src/lib/gui/core/CoreProcess.cpp +++ b/src/lib/gui/core/CoreProcess.cpp @@ -470,8 +470,7 @@ bool CoreProcess::addGenericArgs(QStringList &args, const ProcessMode processMod // unnecessary restarts when deskflow was started elevated or // when it is not allowed to elevate. In these cases restarting // the server is fruitless. - auto elevateMode = Settings::value(Settings::Core::ElevateMode).value(); - if (elevateMode == Settings::ElevateMode::Automatic) { + if (Settings::value(Settings::Core::StopOnDeskSwitch).toBool()) { args << "--stop-on-desk-switch"; } #endif diff --git a/src/lib/gui/dialogs/SettingsDialog.cpp b/src/lib/gui/dialogs/SettingsDialog.cpp index 5aee40f63..e2e664fbb 100644 --- a/src/lib/gui/dialogs/SettingsDialog.cpp +++ b/src/lib/gui/dialogs/SettingsDialog.cpp @@ -132,6 +132,7 @@ void SettingsDialog::accept() Settings::setValue(Settings::Log::Level, ui->comboLogLevel->currentIndex()); Settings::setValue(Settings::Log::ToFile, ui->cbLogToFile->isChecked()); Settings::setValue(Settings::Log::File, ui->lineLogFilename->text()); + Settings::setValue(Settings::Core::StopOnDeskSwitch, ui->cbStopOnDeskSwitch->isChecked()); Settings::setValue(Settings::Core::ElevateMode, ui->comboElevate->currentIndex()); Settings::setValue(Settings::Gui::Autohide, ui->cbAutoHide->isChecked()); Settings::setValue(Settings::Gui::AutoUpdateCheck, ui->cbAutoUpdate->isChecked()); @@ -167,6 +168,7 @@ void SettingsDialog::loadFromConfig() ui->cbLanguageSync->setChecked(Settings::value(Settings::Client::LanguageSync).toBool()); ui->cbScrollDirection->setChecked(Settings::value(Settings::Client::InvertScrollDirection).toBool()); ui->cbCloseToTray->setChecked(Settings::value(Settings::Gui::CloseToTray).toBool()); + ui->cbStopOnDeskSwitch->setChecked(Settings::value(Settings::Core::StopOnDeskSwitch).toBool()); ui->comboElevate->setCurrentIndex(Settings::value(Settings::Core::ElevateMode).toInt()); ui->cbAutoUpdate->setChecked(Settings::value(Settings::Gui::AutoUpdateCheck).toBool()); @@ -267,6 +269,7 @@ void SettingsDialog::updateControls() if (Settings::isNativeMode()) { ui->groupService->setEnabled(writable); ui->widgetElevate->setEnabled(writable && serviceChecked); + ui->cbStopOnDeskSwitch->setEnabled(writable && serviceChecked); } else if (ui->groupService->isVisibleTo(ui->tabAdvanced)) { ui->groupService->setVisible(false); const int bottomMargin = ui->tabAdvanced->layout()->contentsMargins().bottom() + diff --git a/src/lib/gui/dialogs/SettingsDialog.ui b/src/lib/gui/dialogs/SettingsDialog.ui index 6f359f886..f72d11fa2 100644 --- a/src/lib/gui/dialogs/SettingsDialog.ui +++ b/src/lib/gui/dialogs/SettingsDialog.ui @@ -22,9 +22,6 @@ - - 0 - @@ -557,7 +554,7 @@ false - + @@ -632,6 +629,16 @@ + + + + + + + Run as system only when at the login screen and UAC prompt + + +