Add tooltips to theme combox box items, providing a description

This commit is contained in:
Laurent Monin
2021-03-18 10:06:14 +01:00
parent 574f3bad60
commit 1eb22dcd95
2 changed files with 24 additions and 5 deletions

View File

@@ -58,6 +58,7 @@ from picard.ui.theme import (
AVAILABLE_UI_THEMES,
OS_SUPPORTS_THEMES,
UiTheme,
theme_enum_to_desc,
theme_enum_to_label,
)
from picard.ui.ui_options_interface import Ui_InterfaceOptionsPage
@@ -175,6 +176,8 @@ class InterfaceOptionsPage(OptionsPage):
self.ui.ui_theme.clear()
for theme in AVAILABLE_UI_THEMES:
self.ui.ui_theme.addItem(_(theme_enum_to_label(theme)), theme)
idx = self.ui.ui_theme.findData(theme)
self.ui.ui_theme.setItemData(idx, _(theme_enum_to_desc(theme)), QtCore.Qt.ToolTipRole)
self.ui.ui_theme.setCurrentIndex(self.ui.ui_theme.findData(UiTheme.DEFAULT))
self.ui.ui_language.addItem(_('System default'), '')

View File

@@ -73,15 +73,31 @@ class UiTheme(Enum):
# example to display translated "System" theme name: _(UI_THEMES[UiTheme.DEFAULT])
# here strings are just marked for translation
_UI_THEME_LABELS = {
UiTheme.DEFAULT: N_('Default'),
UiTheme.DARK: N_('Dark'),
UiTheme.LIGHT: N_('Light'),
UiTheme.SYSTEM: N_('System'),
UiTheme.DEFAULT: {
'label': N_('Default'),
'desc': N_('The default color scheme based on the operating system display settings'),
},
UiTheme.DARK: {
'label': N_('Dark'),
'desc': N_('A dark display theme'),
},
UiTheme.LIGHT: {
'label': N_('Light'),
'desc': N_('A light display theme'),
},
UiTheme.SYSTEM: {
'label': N_('System'),
'desc': N_('The Qt5 theme configured in the desktop environment'),
},
}
def theme_enum_to_label(theme):
return _UI_THEME_LABELS[theme]
return _UI_THEME_LABELS[theme]['label']
def theme_enum_to_desc(theme):
return _UI_THEME_LABELS[theme]['desc']
AVAILABLE_UI_THEMES = [UiTheme.DEFAULT]