Skip to content

Commit 0c7c6b8

Browse files
ui: allow to open multiple rules editors
now you can open multiple rules editor dialogs from the rules list. Right click on the rules list to edit the selected rule, then right click on another rule to edit a new rule. When editing a rule from the detailed view (after double clicking on a rule), it'll only allow to open one dialog. Closes #1455.
1 parent 0260693 commit 0c7c6b8

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

ui/opensnitch/dialogs/ruleseditor.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class RulesEditorDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
5454

5555
_notification_callback = QtCore.pyqtSignal(str, ui_pb2.NotificationReply)
5656

57-
def __init__(self, parent=None, _rule=None, appicon=None):
57+
def __init__(self, parent=None, modal=True, appicon=None):
5858
super(RulesEditorDialog, self).__init__(parent)
5959

6060
self._notifications_sent = {}
@@ -65,8 +65,10 @@ def __init__(self, parent=None, _rule=None, appicon=None):
6565
self._old_rule_name = None
6666

6767
self.setupUi(self)
68+
self.setModal(modal)
6869
self.load_aliases_into_menu()
69-
self.setWindowIcon(appicon)
70+
if appicon != None:
71+
self.setWindowIcon(appicon)
7072

7173
self.ruleNameValidator = qvalidator.RestrictChars(RulesEditorDialog.INVALID_RULE_NAME_CHARS)
7274
self.ruleNameValidator.result.connect(self._cb_rule_name_validator_result)
@@ -119,9 +121,6 @@ def __init__(self, parent=None, _rule=None, appicon=None):
119121
self.selectNetsListButton.setIcon(openIcon)
120122
self.selectIPsListButton.setIcon(openIcon)
121123

122-
if _rule != None:
123-
self._load_rule(rule=_rule)
124-
125124
def load_aliases_into_menu(self):
126125
aliases = NetworkAliases.get_alias_all()
127126

@@ -1244,7 +1243,9 @@ def edit_rule(self, records, _addr=None):
12441243
self._old_rule_name = records.value(RuleFields.Name)
12451244

12461245
if self._load_rule(addr=_addr, rule=self.rule):
1246+
# show() is needed to open the dialog
12471247
self.show()
1248+
self.exec()
12481249

12491250
def new_rule(self):
12501251
self.WORK_MODE = self.ADD_RULE

ui/opensnitch/dialogs/stats.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,8 @@ def _table_menu_edit(self, cur_idx, model, selection):
16291629
QC.translate("stats", "Rule not found by that name and node"),
16301630
QtWidgets.QMessageBox.Icon.Warning)
16311631
return
1632-
self._rules_dialog.edit_rule(records, node)
1632+
r = RulesEditorDialog(modal=False)
1633+
r.edit_rule(records, node)
16331634
break
16341635

16351636
elif cur_idx == self.TAB_RULES and self.fwTable.isVisible():

0 commit comments

Comments
 (0)