Skip to content

Commit b2f2e44

Browse files
ui: improved diplaying default icons
In some DEs, like Enlightenment, some builtins icons may be empty. The icon is not Null, but there're no available sizes, and the pixmap is empty. For now we'll use SP_FileIcon as the default icon, which exists in this scenario, but we should create a new default icon, and distribute it with the GUI.
1 parent f2eb3fa commit b2f2e44

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ui/opensnitch/utils/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,13 @@ def new(widget, icon_name):
512512
icon = QtGui.QIcon.fromTheme(icon_name, QtGui.QIcon.fromTheme(icon_name + "-symbolic"))
513513
if icon.isNull():
514514
try:
515-
return widget.style().standardIcon(getattr(QtWidgets.QStyle, Icons.defaults[icon_name]))
515+
icon = widget.style().standardIcon(getattr(QtWidgets.QStyle, Icons.defaults[icon_name]))
516+
# in some DEs, like Enlightenment, some builtins icons may be
517+
# empty. The icon is not Null, but there're no available sizes,
518+
# and the pixmap is empty.
519+
# TODO: Create a default icon, and distribute it as resource.
520+
if len(icon.availableSizes()) == 0:
521+
icon = widget.style().standardIcon(getattr(QtWidgets.QStyle, 'SP_FileIcon'))
516522
except Exception as e:
517523
print("Qt standardIcon exception:", icon_name, ",", e)
518524

0 commit comments

Comments
 (0)