Skip to content

Commit

Permalink
UI: added help menu to rules editor dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavo-iniguez-goya committed Jun 13, 2020
1 parent 10f74b9 commit 970d04f
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 84 deletions.
2 changes: 2 additions & 0 deletions ui/opensnitch/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
class Config:
__instance = None

HELP_URL = "https://github.com/gustavo-iniguez-goya/opensnitch/wiki/Configurations"

@staticmethod
def init():
Config.__instance = Config()
Expand Down
5 changes: 5 additions & 0 deletions ui/opensnitch/dialogs/ruleseditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import ui_pb2
import time

from config import Config
from nodes import Nodes
from database import Database

Expand All @@ -33,6 +34,7 @@ def __init__(self, parent=None, _rule=None):
self.buttonBox.button(QtWidgets.QDialogButtonBox.Reset).clicked.connect(self._cb_reset_clicked)
self.buttonBox.button(QtWidgets.QDialogButtonBox.Close).clicked.connect(self._cb_close_clicked)
self.buttonBox.button(QtWidgets.QDialogButtonBox.Apply).clicked.connect(self._cb_apply_clicked)
self.buttonBox.button(QtWidgets.QDialogButtonBox.Help).clicked.connect(self._cb_help_clicked)
self.procCheck.toggled.connect(self._cb_proc_check_toggled)
self.cmdlineCheck.toggled.connect(self._cb_cmdline_check_toggled)
self.dstPortCheck.toggled.connect(self._cb_dstport_check_toggled)
Expand All @@ -52,6 +54,9 @@ def _cb_close_clicked(self):
def _cb_reset_clicked(self):
self._reset_state()

def _cb_help_clicked(self):
QtGui.QDesktopServices.openUrl(QtCore.QUrl(Config.HELP_URL))

def _cb_proc_check_toggled(self, state):
self.procLine.setEnabled(state)

Expand Down
179 changes: 98 additions & 81 deletions ui/opensnitch/res/ruleseditor.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,43 @@
<string>Rule</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="6" column="1">
<item row="7" column="1">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="8" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Close|QDialogButtonBox::Help|QDialogButtonBox::Reset</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
Expand Down Expand Up @@ -48,7 +78,7 @@
</item>
</layout>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QLabel" name="statusLabel">
<property name="enabled">
<bool>true</bool>
Expand Down Expand Up @@ -84,14 +114,7 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="enableCheck">
<property name="text">
<string>Enable</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QGroupBox" name="enableGroup">
<property name="flat">
<bool>false</bool>
Expand Down Expand Up @@ -146,6 +169,50 @@
</property>
</widget>
</item>
<item row="3" column="3">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="actionDenyRadio">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Deny</string>
</property>
<property name="icon">
<iconset theme="emblem-important">
<normaloff>../../../../../../../../.designer/backup</normaloff>../../../../../../../../.designer/backup</iconset>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="actionAllowRadio">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Allow</string>
</property>
<property name="icon">
<iconset theme="emblem-default">
<normaloff>../../../../../../../../.designer/backup</normaloff>../../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
Expand Down Expand Up @@ -288,8 +355,8 @@
</property>
</widget>
</item>
<item row="8" column="1" colspan="2">
<spacer name="horizontalSpacer_2">
<item row="4" column="1">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand All @@ -301,59 +368,8 @@
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Duration</string>
</property>
</widget>
</item>
<item row="3" column="3">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="actionDenyRadio">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Deny</string>
</property>
<property name="icon">
<iconset theme="emblem-important">
<normaloff>../../../../../../../../.designer/backup</normaloff>../../../../../../../../.designer/backup</iconset>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="actionAllowRadio">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Allow</string>
</property>
<property name="icon">
<iconset theme="emblem-default">
<normaloff>../../../../../../../../.designer/backup</normaloff>../../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="1">
<spacer name="horizontalSpacer_5">
<item row="8" column="1" colspan="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand All @@ -365,13 +381,27 @@
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Duration</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="7" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<spacer name="horizontalSpacer_6">
<widget class="QCheckBox" name="enableCheck">
<property name="text">
<string>Enable</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand All @@ -383,19 +413,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Close|QDialogButtonBox::Reset</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand Down
4 changes: 1 addition & 3 deletions ui/opensnitch/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class UIService(ui_pb2_grpc.UIServicer, QtWidgets.QGraphicsObject):
_version_warning_trigger = QtCore.pyqtSignal(str, str)
_status_change_trigger = QtCore.pyqtSignal()

HELP_URL = "https://github.com/gustavo-iniguez-goya/opensnitch/wiki/Configurations"

def __init__(self, app, on_exit):
super(UIService, self).__init__()

Expand Down Expand Up @@ -127,7 +125,7 @@ def _setup_tray(self):
self._tray.setContextMenu(self._menu)

self._menu.addAction("Help").triggered.connect(
lambda: QtGui.QDesktopServices.openUrl(QtCore.QUrl(self.HELP_URL))
lambda: QtGui.QDesktopServices.openUrl(QtCore.QUrl(Config.HELP_URL))
)

self._stats_action.triggered.connect(self._show_stats_dialog)
Expand Down

0 comments on commit 970d04f

Please sign in to comment.