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.
This commit is contained in:
Gustavo Iñiguez Goia 2025-02-10 00:20:16 +01:00
parent 2a68561557
commit 4afa22c5b5
Failed to generate hash of commit
6 changed files with 6 additions and 22 deletions

View file

@ -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:

View file

@ -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)

View file

@ -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")

View file

@ -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")

View file

@ -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")

View file

@ -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")