diff --git a/src/ui/conf/firewallconf.cpp b/src/ui/conf/firewallconf.cpp index 60fa08b0..ae93a41c 100644 --- a/src/ui/conf/firewallconf.cpp +++ b/src/ui/conf/firewallconf.cpp @@ -190,14 +190,6 @@ void FirewallConf::setQuotaMonthMb(quint32 quotaMonthMb) } } -void FirewallConf::setPasswordHash(const QString &passwordHash) -{ - if (m_passwordHash != passwordHash) { - m_passwordHash = passwordHash; - emit passwordHashChanged(); - } -} - quint32 FirewallConf::appGroupBits() const { quint32 groupBits = 0; @@ -284,7 +276,6 @@ void FirewallConf::copyFlags(const FirewallConf &o) setStopInetTraffic(o.stopInetTraffic()); setAppBlockAll(o.appBlockAll()); setAppAllowAll(o.appAllowAll()); - setPasswordHash(o.passwordHash()); setAppGroupBits(o.appGroupBits()); setActivePeriodEnabled(o.activePeriodEnabled()); @@ -314,8 +305,6 @@ QVariant FirewallConf::toVariant() const { QVariantMap map; - map["passwordHash"] = m_passwordHash; - QVariantList addresses; for (const AddressGroup *addressGroup : addressGroupsList()) { addresses.append(addressGroup->toVariant()); @@ -335,8 +324,6 @@ void FirewallConf::fromVariant(const QVariant &v) { const QVariantMap map = v.toMap(); - m_passwordHash = map["passwordHash"].toString(); - const QVariantList addresses = map["addressGroups"].toList(); int addrGroupIndex = 0; for (const QVariant &av : addresses) { diff --git a/src/ui/conf/firewallconf.h b/src/ui/conf/firewallconf.h index aa14b9ae..77d2f049 100644 --- a/src/ui/conf/firewallconf.h +++ b/src/ui/conf/firewallconf.h @@ -37,8 +37,6 @@ class FirewallConf : public QObject Q_PROPERTY(int trafUnit READ trafUnit WRITE setTrafUnit NOTIFY trafUnitChanged) Q_PROPERTY(quint32 quotaDayMb READ quotaDayMb WRITE setQuotaDayMb NOTIFY quotaDayMbChanged) Q_PROPERTY(quint32 quotaMonthMb READ quotaMonthMb WRITE setQuotaMonthMb NOTIFY quotaMonthMbChanged) - Q_PROPERTY(bool hasPassword READ hasPassword NOTIFY passwordHashChanged) - Q_PROPERTY(QString passwordHash READ passwordHash WRITE setPasswordHash NOTIFY passwordHashChanged) Q_PROPERTY(AddressGroup *inetAddressGroup READ inetAddressGroup NOTIFY addressGroupsChanged) Q_PROPERTY(QQmlListProperty addressGroups READ addressGroups NOTIFY addressGroupsChanged) Q_PROPERTY(QQmlListProperty appGroups READ appGroups NOTIFY appGroupsChanged) @@ -117,11 +115,6 @@ public: quint32 quotaMonthMb() const { return m_quotaMonthMb; } void setQuotaMonthMb(quint32 quotaMonthMb); - bool hasPassword() const { return !m_passwordHash.isEmpty(); } - - QString passwordHash() const { return m_passwordHash; } - void setPasswordHash(const QString &passwordHash); - quint32 appGroupBits() const; void setAppGroupBits(quint32 groupBits); @@ -164,7 +157,6 @@ signals: void trafUnitChanged(); void quotaDayMbChanged(); void quotaMonthMbChanged(); - void passwordHashChanged(); void addressGroupsChanged(); void appGroupsChanged(); @@ -205,8 +197,6 @@ private: QString m_activePeriodFrom; QString m_activePeriodTo; - QString m_passwordHash; - QList m_addressGroups; QList m_appGroups; }; diff --git a/src/ui/fortmanager.cpp b/src/ui/fortmanager.cpp index 1bc16165..9bfb20ce 100644 --- a/src/ui/fortmanager.cpp +++ b/src/ui/fortmanager.cpp @@ -433,7 +433,7 @@ void FortManager::exit(int retcode) bool FortManager::checkPassword() { - const QString passwordHash = firewallConf()->passwordHash(); + const QString passwordHash = fortSettings()->passwordHash(); if (passwordHash.isEmpty()) return true; @@ -687,7 +687,7 @@ void FortManager::updateTrayMenu() addHotKey(m_graphWindowAction, fortSettings()->hotKeyGraph(), conf.logStat()); - if (!conf.hasPassword() && !m_firewallConfToEdit) { + if (!fortSettings()->hasPassword() && !m_firewallConfToEdit) { menu->addSeparator(); m_filterEnabledAction = addAction( @@ -730,7 +730,7 @@ void FortManager::updateTrayMenu() } } - if (!conf.hasPassword()) { + if (!fortSettings()->hasPassword()) { menu->addSeparator(); QAction *quitAction = addAction( menu, QIcon(":/images/cross.png"), tr("Quit"), diff --git a/src/ui/fortsettings.h b/src/ui/fortsettings.h index 833dc395..bb709e2e 100644 --- a/src/ui/fortsettings.h +++ b/src/ui/fortsettings.h @@ -18,6 +18,8 @@ class FortSettings : public QObject Q_OBJECT Q_PROPERTY(bool debug READ debug WRITE setDebug NOTIFY iniChanged) Q_PROPERTY(QString language READ language WRITE setLanguage NOTIFY iniChanged) + Q_PROPERTY(bool hasPassword READ hasPassword NOTIFY iniChanged) + Q_PROPERTY(QString passwordHash READ passwordHash WRITE setPasswordHash NOTIFY iniChanged) Q_PROPERTY(qreal windowAddrSplit READ windowAddrSplit WRITE setWindowAddrSplit NOTIFY iniChanged) Q_PROPERTY(qreal windowAppsSplit READ windowAppsSplit WRITE setWindowAppsSplit NOTIFY iniChanged) Q_PROPERTY(bool graphWindowVisible READ graphWindowVisible WRITE setGraphWindowVisible NOTIFY iniChanged) @@ -59,6 +61,11 @@ public: QString language() const { return iniText("base/language", "en"); } void setLanguage(const QString &v) { setIniValue("base/language", v); } + bool hasPassword() const { return !passwordHash().isEmpty(); } + + QString passwordHash() const { return iniText("base/passwordHash"); } + void setPasswordHash(const QString &v) { setIniValue("base/passwordHash", v); } + int iniVersion() const { return iniInt("base/version"); } void setIniVersion(int v) { setIniValue("base/version", v); } diff --git a/src/ui/qml/pages/OptionsPage.qml b/src/ui/qml/pages/OptionsPage.qml index cc7385e2..45890164 100644 --- a/src/ui/qml/pages/OptionsPage.qml +++ b/src/ui/qml/pages/OptionsPage.qml @@ -21,7 +21,7 @@ BasePage { function onAboutToSave() { // override const password = editPassword.text; if (password) { - firewallConf.passwordHash = stringUtil.cryptoHash(password); + fortSettings.passwordHash = stringUtil.cryptoHash(password); editPassword.text = ""; } } @@ -133,10 +133,10 @@ BasePage { id: cbPassword text: translationManager.trTrigger && qsTranslate("qml", "Password:") - checked: firewallConf.hasPassword + checked: fortSettings.hasPassword onToggled: { if (!checked) { - firewallConf.passwordHash = + fortSettings.passwordHash = editPassword.text = ""; } else { editPassword.forceActiveFocus(); @@ -150,9 +150,9 @@ BasePage { width: 180 echoMode: TextInput.Password passwordMaskDelay: 300 - readOnly: firewallConf.hasPassword || !cbPassword.checked + readOnly: fortSettings.hasPassword || !cbPassword.checked placeholderText: translationManager.trTrigger - && (firewallConf.hasPassword + && (fortSettings.hasPassword ? qsTranslate("qml", "Installed") : qsTranslate("qml", "Not Installed")) }