diff --git a/deploy/FortFirewall.iss b/deploy/FortFirewall.iss index 37f7b47b0..5f20cd7a1 100644 --- a/deploy/FortFirewall.iss +++ b/deploy/FortFirewall.iss @@ -88,7 +88,7 @@ Filename: "{app}\driver\scripts\reinstall.bat"; Description: "Re-install driver" Filename: "{#APP_EXE}"; Parameters: "-i portable"; Tasks: portable Filename: "{#APP_EXE}"; Parameters: "-i service"; Tasks: service -Filename: "{#APP_EXE}"; Parameters: "-i explorer"; Tasks: explorer +Filename: "{#APP_EXE}"; Parameters: "-i explorer"; Flags: runasoriginaluser; Tasks: explorer Filename: "sc.exe"; Parameters: "start {#APP_SVC_NAME}"; Description: "Start service"; \ Flags: nowait; Tasks: service diff --git a/src/ui/conf/confmanager.cpp b/src/ui/conf/confmanager.cpp index f142cfb95..682174a8d 100644 --- a/src/ui/conf/confmanager.cpp +++ b/src/ui/conf/confmanager.cpp @@ -443,8 +443,6 @@ void ConfManager::initConfToEdit() auto newConf = createConf(); newConf->copy(*conf()); - loadExtFlags(newConf->ini()); - setConfToEdit(newConf); } @@ -548,10 +546,6 @@ bool ConfManager::saveConf(FirewallConf &conf) IoC()->writeConfIni(conf); - if (conf.iniEdited()) { - saveExtFlags(conf.ini()); - } - if (conf.taskEdited()) { saveTasksByIni(conf.ini()); } @@ -831,19 +825,6 @@ bool ConfManager::saveToDb(const FirewallConf &conf) return commitTransaction(ok); } -void ConfManager::loadExtFlags(IniOptions &ini) -{ - ini.cacheExplorerIntegrated(StartupUtil::isExplorerIntegrated()); -} - -void ConfManager::saveExtFlags(const IniOptions &ini) -{ - // Windows Explorer integration - if (ini.explorerIntegratedSet()) { - StartupUtil::setExplorerIntegrated(ini.explorerIntegrated()); - } -} - void ConfManager::saveTasksByIni(const IniOptions &ini) { // Task Info List diff --git a/src/ui/conf/confmanager.h b/src/ui/conf/confmanager.h index e4e96948f..dbbb5c30c 100644 --- a/src/ui/conf/confmanager.h +++ b/src/ui/conf/confmanager.h @@ -82,9 +82,6 @@ class ConfManager : public QObject, public IocService bool loadFromDb(FirewallConf &conf, bool &isNew); bool saveToDb(const FirewallConf &conf); - void loadExtFlags(IniOptions &ini); - void saveExtFlags(const IniOptions &ini); - void saveTasksByIni(const IniOptions &ini); bool loadTask(TaskInfo *taskInfo); diff --git a/src/ui/conf/inioptions.h b/src/ui/conf/inioptions.h index 1b4fbdd05..0a298a54f 100644 --- a/src/ui/conf/inioptions.h +++ b/src/ui/conf/inioptions.h @@ -29,12 +29,6 @@ class IniOptions : public MapSettings QString password() const { return valueText("base/password_"); } void setPassword(const QString &v) { setValue("base/password_", v); } - bool explorerIntegratedSet() const { return contains("ext/explorerIntegrated_"); } - void cacheExplorerIntegrated(bool v) { setCacheValue("ext/explorerIntegrated_", v); } - - bool explorerIntegrated() const { return valueBool("ext/explorerIntegrated_"); } - void setExplorerIntegrated(bool v) { setValue("ext/explorerIntegrated_", v); } - bool taskInfoListSet() const { return contains("task/infoList_"); } QVariant taskInfoList() const { return value("task/infoList_"); } diff --git a/src/ui/form/opt/pages/optionspage.cpp b/src/ui/form/opt/pages/optionspage.cpp index 9a4c90f03..4cadbe2ce 100644 --- a/src/ui/form/opt/pages/optionspage.cpp +++ b/src/ui/form/opt/pages/optionspage.cpp @@ -67,6 +67,11 @@ void OptionsPage::onAboutToSave() } else if (conf()->iniEdited()) { ini()->setHasPassword(settings()->hasPassword()); } + + // Explorer + if (explorerEdited()) { + StartupUtil::setExplorerIntegrated(m_cbExplorerMenu->isChecked()); + } } void OptionsPage::onEditResetted() @@ -80,6 +85,12 @@ void OptionsPage::onEditResetted() setLanguageEdited(false); translationManager()->switchLanguageByName(confManager()->iniUser().language()); } + + // Explorer + if (explorerEdited()) { + setExplorerEdited(false); + m_cbExplorerMenu->setChecked(StartupUtil::isExplorerIntegrated()); + } } void OptionsPage::saveAutoRunMode(int mode) @@ -575,11 +586,11 @@ QLayout *OptionsPage::setupColumn2() void OptionsPage::setupGlobalBox() { - m_cbExplorerMenu = ControlUtil::createCheckBox(ini()->explorerIntegrated(), [&](bool checked) { - ini()->setExplorerIntegrated(checked); - ctrl()->setIniEdited(); - }); - m_cbExplorerMenu->setEnabled(settings()->hasMasterAdmin()); + m_cbExplorerMenu = + ControlUtil::createCheckBox(StartupUtil::isExplorerIntegrated(), [&](bool /*checked*/) { + setExplorerEdited(true); + ctrl()->setIniUserEdited(); + }); m_cbUseSystemLocale = ControlUtil::createCheckBox(iniUser()->useSystemLocale(), [&](bool checked) { diff --git a/src/ui/form/opt/pages/optionspage.h b/src/ui/form/opt/pages/optionspage.h index f38767307..0737d6a0e 100644 --- a/src/ui/form/opt/pages/optionspage.h +++ b/src/ui/form/opt/pages/optionspage.h @@ -16,6 +16,9 @@ class OptionsPage : public OptBasePage bool languageEdited() const { return m_languageEdited; } void setLanguageEdited(bool v) { m_languageEdited = v; } + bool explorerEdited() const { return m_explorerEdited; } + void setExplorerEdited(bool v) { m_explorerEdited = v; } + protected slots: void onAboutToSave() override; void onEditResetted() override; @@ -64,6 +67,7 @@ protected slots: private: bool m_passwordEdited : 1 = false; bool m_languageEdited : 1 = false; + bool m_explorerEdited: 1 = false; qint8 m_currentAutoRunMode = 0; diff --git a/src/ui/util/startuputil.cpp b/src/ui/util/startuputil.cpp index 1764907fd..d13358ace 100644 --- a/src/ui/util/startuputil.cpp +++ b/src/ui/util/startuputil.cpp @@ -21,7 +21,7 @@ const char *const regCurUserRun = R"(SOFTWARE\Microsoft\Windows\CurrentVersion\R constexpr RegKey::Root regAllUsersRoot = RegKey::HKLM; const char *const regAllUsersRun = R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Run)"; -constexpr RegKey::Root regShellRoot = RegKey::HKLM; +constexpr RegKey::Root regShellRoot = RegKey::HKCU; const char *const regShellMenu = R"(SOFTWARE\Classes\SystemFileAssociations\.exe\Shell)"; const wchar_t *const serviceNameStr = L"" APP_BASE_L L"Svc";