Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(qt_gui) setFallbackThemeName(original_theme) #279

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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