UI: Options: Add "Check password on Uninstall" flag

This commit is contained in:
Nodir Temirkhodjaev 2023-03-10 12:02:25 +03:00
parent c6e1bdc1b0
commit e1d0c281ef
4 changed files with 30 additions and 0 deletions

View File

@ -1321,6 +1321,12 @@ void ConfManager::saveExtFlags(const IniOptions &ini)
if (ini.explorerIntegratedSet()) {
StartupUtil::setExplorerIntegrated(ini.explorerIntegrated());
}
// Check password on Uninstall
if (ini.checkPasswordOnUninstallSet() || ini.hasPasswordSet()) {
StartupUtil::setRegistryPasswordHash(
ini.checkPasswordOnUninstall() ? IoC<FortSettings>()->passwordHash() : QString());
}
}
void ConfManager::saveTasksByIni(const IniOptions &ini)

View File

@ -22,6 +22,7 @@ public:
void setLogConsole(bool v) { setValue("base/console", v); }
bool hasPasswordSet() const { return contains("base/hasPassword_"); }
bool hasPassword() const { return valueBool("base/hasPassword_"); }
void setHasPassword(bool v) { setValue("base/hasPassword_", v); }
@ -42,6 +43,11 @@ public:
bool noServiceControl() const { return valueBool("protect/noServiceControl"); }
void setNoServiceControl(bool v) { setValue("protect/noServiceControl", v); }
bool checkPasswordOnUninstallSet() const
{
return contains("protect/checkPasswordOnUninstall");
}
bool checkPasswordOnUninstall() const { return valueBool("protect/checkPasswordOnUninstall"); }
void setCheckPasswordOnUninstall(bool v) { setValue("protect/checkPasswordOnUninstall", v); }

View File

@ -269,6 +269,22 @@ void StartupUtil::setExplorerIntegrated(bool integrate)
}
}
void StartupUtil::setRegistryPasswordHash(const QString &passwordHash)
{
const bool isAdding = !passwordHash.isEmpty();
RegKey regApp(RegKey::HKLM, R"(SOFTWARE)",
isAdding ? RegKey::DefaultCreate : RegKey::DefaultReadWrite);
RegKey reg(regApp, APP_NAME, RegKey::DefaultCreate);
if (isAdding) {
reg.setValue("passwordHash", passwordHash);
} else {
reg.removeValue("passwordHash");
}
}
void StartupUtil::setPortable(bool portable)
{
const QString readmePortablePath = FileUtil::nativeAppBinLocation() + "/README.portable";

View File

@ -21,6 +21,8 @@ public:
static bool isExplorerIntegrated();
static void setExplorerIntegrated(bool integrate);
static void setRegistryPasswordHash(const QString &passwordHash);
static void setPortable(bool portable);
};