Skip to content

Commit

Permalink
UI: allow to resize rules table columns and remember position
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavo-iniguez-goya committed Jun 10, 2020
1 parent 39015bd commit a9e6220
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions ui/opensnitch/dialogs/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,6 @@ def __init__(self, parent=None, address=None, db=None, dbname="db"):
delegate=self.TABLES[self.TAB_NODES]['delegate'])
self.TABLES[self.TAB_RULES]['view'] = self._setup_table(QtWidgets.QTableView,
self.rulesTable, "rules",
resize_cols=(
self.COL_TIME,
self.COL_NODE,
self.COL_R_ENABLED,
self.COL_R_ACTION,
self.COL_R_DURATION,
self.COL_R_OP_TYPE,
self.COL_R_OP_OPERAND),
delegate=self.TABLES[self.TAB_RULES]['delegate'],
order_by="1")
self.TABLES[self.TAB_HOSTS]['view'] = self._setup_table(QtWidgets.QTableView,
Expand Down Expand Up @@ -411,6 +403,11 @@ def _load_settings(self):
if type(eventsColState) == QtCore.QByteArray:
header.restoreState(eventsColState)

rulesHeader = self.rulesTable.horizontalHeader()
rulesColState = self._cfg.getSettings("statsDialog/rules_columns_state")
if type(rulesColState) == QtCore.QByteArray:
rulesHeader.restoreState(rulesColState)

def _save_settings(self):
self._cfg.setSettings("statsDialog/geometry", self.saveGeometry())
self._cfg.setSettings("statsDialog/last_tab", self.tabWidget.currentIndex())
Expand All @@ -419,6 +416,8 @@ def _save_settings(self):

header = self.eventsTable.header()
self._cfg.setSettings("statsDialog/general_columns_state", header.saveState())
rulesHeader = self.rulesTable.horizontalHeader()
self._cfg.setSettings("statsDialog/rules_columns_state", rulesHeader.saveState())

def _del_rule(self, rule_name, node_addr):
rule = ui_pb2.Rule(name=rule_name)
Expand Down

0 comments on commit a9e6220

Please sign in to comment.