diff --git a/src/ui/fortmanager.cpp b/src/ui/fortmanager.cpp index ea03b9ee..09273b71 100644 --- a/src/ui/fortmanager.cpp +++ b/src/ui/fortmanager.cpp @@ -145,12 +145,12 @@ void FortManager::showErrorBox(const QString &text) QMessageBox::critical(&m_window, QString(), text); } -bool FortManager::saveConf() +bool FortManager::saveConf(bool onlyFlags) { - return saveSettings(m_firewallConfToEdit); + return saveSettings(m_firewallConfToEdit, onlyFlags); } -bool FortManager::applyConf() +bool FortManager::applyConf(bool onlyFlags) { Q_ASSERT(m_firewallConfToEdit != nullConf()); @@ -158,7 +158,7 @@ bool FortManager::applyConf() newConf->copyTempFlags(*m_firewallConf); - return saveSettings(newConf); + return saveSettings(newConf, onlyFlags); } void FortManager::setFirewallConfToEdit(FirewallConf *conf) @@ -182,9 +182,10 @@ bool FortManager::loadSettings(FirewallConf *conf) return updateDriverConf(conf); } -bool FortManager::saveSettings(FirewallConf *newConf) +bool FortManager::saveSettings(FirewallConf *newConf, bool onlyFlags) { - if (!m_fortSettings->writeConf(*newConf)) { + if (!(onlyFlags ? m_fortSettings->writeConfFlags(*newConf) + : m_fortSettings->writeConf(*newConf))) { showErrorBox(m_fortSettings->errorMessage()); return false; } @@ -194,7 +195,8 @@ bool FortManager::saveSettings(FirewallConf *newConf) updateTrayMenu(); - return updateDriverConf(m_firewallConf); + return onlyFlags ? updateDriverConfFlags(m_firewallConf) + : updateDriverConf(m_firewallConf); } bool FortManager::updateDriverConf(FirewallConf *conf) diff --git a/src/ui/fortmanager.h b/src/ui/fortmanager.h index 678518ed..09b39a0a 100644 --- a/src/ui/fortmanager.h +++ b/src/ui/fortmanager.h @@ -43,8 +43,8 @@ public slots: void showErrorBox(const QString &text); - bool saveConf(); - bool applyConf(); + bool saveConf(bool onlyFlags = false); + bool applyConf(bool onlyFlags = false); void setAppLogBlocked(bool enable); @@ -63,7 +63,7 @@ private: void setupEngine(); bool loadSettings(FirewallConf *conf); - bool saveSettings(FirewallConf *newConf); + bool saveSettings(FirewallConf *newConf, bool onlyFlags = false); bool updateDriverConf(FirewallConf *conf); bool updateDriverConfFlags(FirewallConf *conf); diff --git a/src/ui/qml/pages/ApplicationsPage.qml b/src/ui/qml/pages/ApplicationsPage.qml index 6061f945..032bf730 100644 --- a/src/ui/qml/pages/ApplicationsPage.qml +++ b/src/ui/qml/pages/ApplicationsPage.qml @@ -19,6 +19,8 @@ BasePage { firewallConf.addAppGroupByName(editGroupName.text); barGroups.currentIndex = lastIndex; resetGroupName(); + + setConfEdited(); } function removeAppGroup(index) { @@ -26,12 +28,16 @@ BasePage { var lastIndex = appGroupsCount - 1; barGroups.currentIndex = (index < appGroupsCount) ? index : appGroupsCount - 1; + + setConfEdited(); } function renameAppGroup() { const appGroup = appsColumn.appGroup; appGroup.name = editGroupName.text; resetGroupName(); + + setConfEdited(); } function moveAppGroup(index, step) { @@ -43,6 +49,8 @@ BasePage { firewallConf.moveAppGroup(index, toIndex); barGroups.currentIndex = toIndex; + + setConfEdited(); } ColumnLayout { @@ -74,6 +82,8 @@ BasePage { checked: firewallConf.appBlockAll onToggled: { firewallConf.appBlockAll = checked; + + setConfFlagsEdited(); } } CheckBox { @@ -81,6 +91,8 @@ BasePage { checked: firewallConf.appAllowAll onToggled: { firewallConf.appAllowAll = checked; + + setConfFlagsEdited(); } } } diff --git a/src/ui/qml/pages/MainPage.qml b/src/ui/qml/pages/MainPage.qml index 2b389b05..9f961980 100644 --- a/src/ui/qml/pages/MainPage.qml +++ b/src/ui/qml/pages/MainPage.qml @@ -10,7 +10,25 @@ Page { signal closed() signal saved() + property bool confFlagsEdited + property bool confEdited + + function setConfFlagsEdited() { + confFlagsEdited = true; + } + + function setConfEdited() { + confEdited = true; + } + + function resetConfEdited() { + confFlagsEdited = false; + confEdited = false; + } + onOpened: { + resetConfEdited(); + tabBar.currentItem.forceActiveFocus(); } @@ -52,17 +70,23 @@ Page { anchors.right: parent.right Button { + enabled: confFlagsEdited || confEdited text: QT_TRANSLATE_NOOP("qml", "OK") onClicked: { - if (fortManager.saveConf()) { + if (fortManager.saveConf(confFlagsEdited)) { mainPage.saved(); closeWindow(); } } } Button { + enabled: confFlagsEdited || confEdited text: QT_TRANSLATE_NOOP("qml", "Apply") - onClicked: fortManager.applyConf() + onClicked: { + if (fortManager.applyConf(confFlagsEdited)) { + resetConfEdited(); + } + } } Button { text: QT_TRANSLATE_NOOP("qml", "Cancel") diff --git a/src/ui/qml/pages/OptionsPage.qml b/src/ui/qml/pages/OptionsPage.qml index 55cac5b2..0a8d0d0d 100644 --- a/src/ui/qml/pages/OptionsPage.qml +++ b/src/ui/qml/pages/OptionsPage.qml @@ -20,6 +20,9 @@ BasePage { id: cbStart text: QT_TRANSLATE_NOOP("qml", "Start with Windows") checked: fortSettings.startWithWindows + onToggled: { + setConfFlagsEdited(); + } } CheckBox { id: cbFilter @@ -27,6 +30,8 @@ BasePage { checked: firewallConf.filterEnabled onToggled: { firewallConf.filterEnabled = checked; + + setConfFlagsEdited(); } } } diff --git a/src/ui/qml/pages/addresses/AddressesColumn.qml b/src/ui/qml/pages/addresses/AddressesColumn.qml index 1c64cac8..435b67a8 100644 --- a/src/ui/qml/pages/addresses/AddressesColumn.qml +++ b/src/ui/qml/pages/addresses/AddressesColumn.qml @@ -25,6 +25,8 @@ ColumnLayout { checked: addressGroup.useAll onToggled: { addressGroup.useAll = checked; + + setConfFlagsEdited(); } } } @@ -46,6 +48,8 @@ ColumnLayout { onEditingFinished: { addressGroup.text = textArea.text; + + setConfEdited(); } } } diff --git a/src/ui/qml/pages/apps/AppsColumn.qml b/src/ui/qml/pages/apps/AppsColumn.qml index eadad506..b55dd293 100644 --- a/src/ui/qml/pages/apps/AppsColumn.qml +++ b/src/ui/qml/pages/apps/AppsColumn.qml @@ -31,6 +31,8 @@ ColumnLayout { checked: appGroup.enabled onToggled: { appGroup.enabled = checked; + + setConfFlagsEdited(); } } } @@ -54,6 +56,8 @@ C:\\Program Files\\Internet Explorer\\iexplore.exe onEditingFinished: { appGroup.blockText = textArea.text; + + setConfEdited(); } } @@ -72,6 +76,8 @@ C:\\Program Files\\Skype\\Phone\\Skype.exe onEditingFinished: { appGroup.allowText = textArea.text; + + setConfEdited(); } } }