UI: WindowManager: Improve checkPassword()

This commit is contained in:
Nodir Temirkhodjaev 2024-04-21 13:27:33 +03:00
parent 0dfd762620
commit 968b3390eb
3 changed files with 15 additions and 7 deletions

View File

@ -273,7 +273,7 @@ bool ControlManager::processCommandProgAction(const ProcessCommandArgs &p, bool
return false;
}
if (!IoC<WindowManager>()->checkPassword()) {
if (!IoC<WindowManager>()->checkPassword(/*temporary=*/true)) {
p.errorMessage = "Password required";
return false;
}

View File

@ -608,7 +608,7 @@ bool WindowManager::checkWindowPassword(WindowCode code)
return (WindowPasswordProtected & code) == 0 || checkPassword();
}
bool WindowManager::checkPassword()
bool WindowManager::checkPassword(bool temporary)
{
if (isAnyWindowOpen(WindowPasswordDialog)) {
activateModalWidget();
@ -627,14 +627,22 @@ bool WindowManager::checkPassword()
QString password;
int unlockType = FortSettings::UnlockDisabled;
if (showPasswordDialog(password, &unlockType) && IoC<ConfManager>()->checkPassword(password)) {
settings->setPasswordChecked(
/*checked=*/true, static_cast<FortSettings::UnlockType>(unlockType));
bool passwordChecked = false;
if (showPasswordDialog(password, &unlockType) // input the password
&& IoC<ConfManager>()->checkPassword(password)) {
if (!temporary || unlockType != FortSettings::UnlockWindow) {
settings->setPasswordChecked(
/*checked=*/true, FortSettings::UnlockType(unlockType));
}
passwordChecked = true;
}
windowClosed(WindowPasswordDialog);
return settings->passwordChecked();
return passwordChecked;
}
void WindowManager::showErrorBox(const QString &text, const QString &title, QWidget *parent)

View File

@ -120,7 +120,7 @@ public slots:
void processRestartRequired(const QString &info = {});
bool checkWindowPassword(WindowCode code);
bool checkPassword();
bool checkPassword(bool temporary = false);
virtual void showErrorBox(
const QString &text, const QString &title = QString(), QWidget *parent = nullptr);