From 4000db08b8a67272ed3a5530385ef108df7171f0 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Sat, 7 Aug 2021 13:59:30 +0300 Subject: [PATCH] UI: Options: Fix password checking. --- src/ui/form/opt/pages/optionspage.cpp | 17 ++++++++++++++--- src/ui/form/opt/pages/optionspage.h | 5 +++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/ui/form/opt/pages/optionspage.cpp b/src/ui/form/opt/pages/optionspage.cpp index b94ffcf0..f5741768 100644 --- a/src/ui/form/opt/pages/optionspage.cpp +++ b/src/ui/form/opt/pages/optionspage.cpp @@ -65,6 +65,11 @@ OptionsPage::OptionsPage(OptionsController *ctrl, QWidget *parent) : OptBasePage setupUi(); } +void OptionsPage::setPasswordEdited(bool v) +{ + m_passwordEdited = v; +} + void OptionsPage::onAboutToSave() { // Startup @@ -72,8 +77,12 @@ void OptionsPage::onAboutToSave() saveService(m_cbService->isChecked()); // Password - if (!settings()->hasPassword() && ini()->hasPassword() && ini()->password().isEmpty()) { - m_cbPassword->setChecked(false); + if (passwordEdited()) { + if (!settings()->hasPassword() && ini()->hasPassword() && ini()->password().isEmpty()) { + m_cbPassword->setChecked(false); + } + } else if (conf()->iniEdited()) { + ini()->setHasPassword(settings()->hasPassword()); } } @@ -125,6 +134,7 @@ void OptionsPage::saveService(bool isService) void OptionsPage::onEditResetted() { + setPasswordEdited(false); retranslateEditPassword(); } @@ -385,13 +395,14 @@ QLayout *OptionsPage::setupPasswordLayout() auto layout = new QHBoxLayout(); layout->setSpacing(6); - m_cbPassword = ControlUtil::createCheckBox(ini()->hasPassword(), [&](bool checked) { + m_cbPassword = ControlUtil::createCheckBox(settings()->hasPassword(), [&](bool checked) { if (checked) { m_editPassword->setFocus(); } else { m_editPassword->clear(); } + setPasswordEdited(true); ini()->setHasPassword(checked); ctrl()->setIniEdited(); }); diff --git a/src/ui/form/opt/pages/optionspage.h b/src/ui/form/opt/pages/optionspage.h index f1a32e50..6c3bbebf 100644 --- a/src/ui/form/opt/pages/optionspage.h +++ b/src/ui/form/opt/pages/optionspage.h @@ -10,6 +10,9 @@ class OptionsPage : public OptBasePage public: explicit OptionsPage(OptionsController *ctrl = nullptr, QWidget *parent = nullptr); + bool passwordEdited() const { return m_passwordEdited; } + void setPasswordEdited(bool v); + protected slots: void onAboutToSave() override; void onEditResetted() override; @@ -45,6 +48,8 @@ private: void setupNewVersionUpdate(); private: + bool m_passwordEdited = false; + qint8 m_currentAutoRunMode = 0; QGroupBox *m_gbStartup = nullptr;