Skip to content

Commit

Permalink
(qt_gui) extended theme logic to get icons
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsBurgh committed Aug 17, 2023
1 parent d9397f1 commit b4a08d3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions qt_gui/src/qt_gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,21 @@ def _set_theme_if_necessary(self):
os.path.join(package_path, 'share', 'tango_icons_vendor', 'resource', 'icons')
] + icon_paths
QIcon.setThemeSearchPaths(icon_paths)

# Use Tango if possible, fall back to system default
original_theme = QIcon.themeName()
if original_theme == 'Tango':
# We don't have any back-up behaviour in case Tango is the default
return
# Set Tango as default and try to get an icon
QIcon.setThemeName('Tango')
if QIcon.fromTheme('document-save').isNull():
# When Tango icon can't be found, use the system default theme
QIcon.setThemeName(original_theme)
return
# In case we overruled the default theme to be Tango, set fallback theme to the original
# theme. Any original fallback theme is dropped in this case.
QIcon.setFallbackThemeName(original_theme)

def create_application(self, argv):
from python_qt_binding.QtCore import Qt
Expand Down

0 comments on commit b4a08d3

Please sign in to comment.