Skip to content

Commit

Permalink
UI: Options: Make "Explorer Integration" for user, not system
Browse files Browse the repository at this point in the history
  • Loading branch information
tnodir committed Dec 30, 2023
1 parent 1b6283e commit 471992a
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 35 deletions.
2 changes: 1 addition & 1 deletion deploy/FortFirewall.iss
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 0 additions & 19 deletions src/ui/conf/confmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,6 @@ void ConfManager::initConfToEdit()
auto newConf = createConf();
newConf->copy(*conf());

loadExtFlags(newConf->ini());

setConfToEdit(newConf);
}

Expand Down Expand Up @@ -548,10 +546,6 @@ bool ConfManager::saveConf(FirewallConf &conf)

IoC<FortSettings>()->writeConfIni(conf);

if (conf.iniEdited()) {
saveExtFlags(conf.ini());
}

if (conf.taskEdited()) {
saveTasksByIni(conf.ini());
}
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions src/ui/conf/confmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 0 additions & 6 deletions src/ui/conf/inioptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_"); }
Expand Down
21 changes: 16 additions & 5 deletions src/ui/form/opt/pages/optionspage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions src/ui/form/opt/pages/optionspage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/ui/util/startuputil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 471992a

Please sign in to comment.