From 4afa22c5b52bedf40691cf2a3084f7415db9ac5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20I=C3=B1iguez=20Goia?= Date: Mon, 10 Feb 2025 00:20:16 +0100 Subject: [PATCH] ui: fixed displaying icons In some distros like Ubuntu 25, we were not displaying the fw button icon, which made the button practically hidden to the user. We assumed that if 'document-new' or 'emblem' icons were available, the rest of the icons would be available as well, so we wouldn't need to fallback to Qt's builtin icons. However on Ubuntu 25 for example, despite of 'document-new' being available, the icon 'security-high' was not being displayed when it was loaded from the stats.ui file. Loading it from code with QIcon.fromTheme() works fine, and even if it's not found (which sometimes happens), we'd fallback to Qt's builtin icons. Other icons may be optional, but icons without text need to have an icon always. - minor formatting change. - removed unused code. --- ui/opensnitch/dialogs/firewall.py | 4 ---- ui/opensnitch/dialogs/firewall_rule.py | 12 ++++++------ ui/opensnitch/dialogs/preferences.py | 3 --- ui/opensnitch/dialogs/processdetails.py | 3 --- ui/opensnitch/dialogs/ruleseditor.py | 3 --- ui/opensnitch/dialogs/stats.py | 3 --- 6 files changed, 6 insertions(+), 22 deletions(-) diff --git a/ui/opensnitch/dialogs/firewall.py b/ui/opensnitch/dialogs/firewall.py index fd282742..7a7bbb40 100644 --- a/ui/opensnitch/dialogs/firewall.py +++ b/ui/opensnitch/dialogs/firewall.py @@ -74,9 +74,6 @@ class FirewallDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]): # blocked. self.comboOutput.currentIndexChanged.connect(lambda: self._cb_combo_policy_changed(self.COMBO_OUT)) - if QtGui.QIcon.hasThemeIcon("document-new"): - return - closeIcon = Icons.new(self, "window-close") excludeIcon = Icons.new(self, "go-up") allowInIcon = Icons.new(self, "go-down") @@ -94,7 +91,6 @@ class FirewallDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]): self.comboOutput.setEnabled(True) if reply.id in self._notifications_sent: if reply.code == ui_pb2.OK: - rep = self._notifications_sent[reply.id] self._set_status_successful(QC.translate("firewall", "Configuration applied.")) else: diff --git a/ui/opensnitch/dialogs/firewall_rule.py b/ui/opensnitch/dialogs/firewall_rule.py index aeeb8eeb..9f7335bd 100644 --- a/ui/opensnitch/dialogs/firewall_rule.py +++ b/ui/opensnitch/dialogs/firewall_rule.py @@ -348,11 +348,6 @@ The value must be in the format: VALUE/UNITS/TIME, for example: # setTabVisible not available on <= 5.14 #self.tabWidget.setTabVisible(0, True) - if QtGui.QIcon.hasThemeIcon("emblem-default"): - return - - # ----------------------------------------------------------- - saveIcon = Icons.new(self, "document-save") closeIcon = Icons.new(self, "window-close") delIcon = Icons.new(self, "edit-delete") @@ -422,7 +417,12 @@ The value must be in the format: VALUE/UNITS/TIME, for example: if 'uuid' in rep and rep['uuid'] in reply.data: errormsg = QC.translate("firewall", "Error saving rule") else: - self._set_status_message(QC.translate("firewall", "Rule saved, but there're other rules with errors (REVIEW):\n{0}".format(reply.data))) + self._set_status_message( + QC.translate( + "firewall", + "Rule saved, but there're other rules with errors (REVIEW):\n{0}".format(reply.data) + ) + ) return self._set_status_error(errormsg) diff --git a/ui/opensnitch/dialogs/preferences.py b/ui/opensnitch/dialogs/preferences.py index 00ca7788..1d949e37 100644 --- a/ui/opensnitch/dialogs/preferences.py +++ b/ui/opensnitch/dialogs/preferences.py @@ -130,9 +130,6 @@ class PreferencesDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]): self.comboNodeDuration.setVisible(False) self.labelNodeDuration.setVisible(False) - if QtGui.QIcon.hasThemeIcon("emblem-default"): - return - saveIcon = Icons.new(self, "document-save") applyIcon = Icons.new(self, "emblem-default") delIcon = Icons.new(self, "edit-delete") diff --git a/ui/opensnitch/dialogs/processdetails.py b/ui/opensnitch/dialogs/processdetails.py index 3fb62197..44ffed15 100644 --- a/ui/opensnitch/dialogs/processdetails.py +++ b/ui/opensnitch/dialogs/processdetails.py @@ -96,9 +96,6 @@ class ProcessDetailsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]) self.iconStart = QtGui.QIcon.fromTheme("media-playback-start") self.iconPause = QtGui.QIcon.fromTheme("media-playback-pause") - if QtGui.QIcon.hasThemeIcon("window-close"): - return - closeIcon = Icons.new(self, "window-close") self.cmdClose.setIcon(closeIcon) self.iconStart = Icons.new(self, "media-playback-start") diff --git a/ui/opensnitch/dialogs/ruleseditor.py b/ui/opensnitch/dialogs/ruleseditor.py index 03e2b9a0..f6f57756 100644 --- a/ui/opensnitch/dialogs/ruleseditor.py +++ b/ui/opensnitch/dialogs/ruleseditor.py @@ -107,9 +107,6 @@ class RulesEditorDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]): self._users_list = pwd.getpwall() - if QtGui.QIcon.hasThemeIcon("emblem-default"): - return - applyIcon = Icons.new(self, "emblem-default") denyIcon = Icons.new(self, "emblem-important") rejectIcon = Icons.new(self, "window-close") diff --git a/ui/opensnitch/dialogs/stats.py b/ui/opensnitch/dialogs/stats.py index 5c6412a1..d54e5c49 100644 --- a/ui/opensnitch/dialogs/stats.py +++ b/ui/opensnitch/dialogs/stats.py @@ -890,13 +890,10 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]): print("stats._configure_plugins() exception:", name, "-", e) def _configure_buttons_icons(self): - if QtGui.QIcon.hasThemeIcon("document-new"): - return newRuleIcon = Icons.new(self, "document-new") delRuleIcon = Icons.new(self, "edit-delete") editRuleIcon = Icons.new(self, "accessories-text-editor") - saveIcon = Icons.new(self, "document-save") prefsIcon = Icons.new(self, "preferences-system") searchIcon = Icons.new(self, "system-search") clearIcon = Icons.new(self, "edit-clear-all")