Skip to content

Commit

Permalink
(qt_gui) extended theme logic to get icons (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsBurgh authored Nov 14, 2023
1 parent b865ee3 commit bad1d9a
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 bad1d9a

Please sign in to comment.