Skip to content

Commit

Permalink
ui, preferences: better DB selection
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavo-iniguez-goya committed Feb 26, 2023
1 parent a586e0d commit 303c7f7
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions ui/opensnitch/dialogs/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ def _reset_node_settings(self):

def _save_settings(self):
self._save_ui_config()
self._save_db_config()
if not self._save_db_config():
return

if self.tabWidget.currentIndex() == self.TAB_NODES:
self._show_status_label()
Expand Down Expand Up @@ -372,10 +373,6 @@ def _save_settings(self):
def _save_db_config(self):
dbtype = self.comboDBType.currentIndex()
db_name = self._cfg.getSettings(self._cfg.DEFAULT_DB_FILE_KEY)
self._cfg.setSettings(Config.DEFAULT_DB_TYPE_KEY, dbtype)
self._cfg.setSettings(Config.DEFAULT_DB_PURGE_OLDEST, bool(self.checkDBMaxDays.isChecked()))
self._cfg.setSettings(Config.DEFAULT_DB_MAX_DAYS, int(self.spinDBMaxDays.value()))
self._cfg.setSettings(Config.DEFAULT_DB_PURGE_INTERVAL, int(self.spinDBPurgeInterval.value()))

if self.dbLabel.text() != "" and \
(self.comboDBType.currentIndex() != self.dbType or db_name != self.dbLabel.text()):
Expand All @@ -392,10 +389,17 @@ def _save_db_config(self):
QC.translate("preferences", "Warning"),
QC.translate("preferences", "You must select a file for the database<br>or choose \"In memory\" type."),
QtWidgets.QMessageBox.Warning)
return
self.dbLabel.setText("")
return False

self._cfg.setSettings(Config.DEFAULT_DB_TYPE_KEY, dbtype)
self._cfg.setSettings(Config.DEFAULT_DB_PURGE_OLDEST, bool(self.checkDBMaxDays.isChecked()))
self._cfg.setSettings(Config.DEFAULT_DB_MAX_DAYS, int(self.spinDBMaxDays.value()))
self._cfg.setSettings(Config.DEFAULT_DB_PURGE_INTERVAL, int(self.spinDBPurgeInterval.value()))
self.dbType = self.comboDBType.currentIndex()

return True

def _save_ui_config(self):
self._save_ui_columns_config()

Expand Down

0 comments on commit 303c7f7

Please sign in to comment.