forked from qt-creator/qt-creator
Theme: fix saving default theme on dark systems
Change-Id: I08fbe6441b87c05c93ae30f816eb0d6f79bfb4da Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -171,6 +171,12 @@ ThemeChooser::~ThemeChooser()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QString defaultThemeId()
|
||||||
|
{
|
||||||
|
return Theme::systemUsesDarkMode() ? QString(Constants::DEFAULT_DARK_THEME)
|
||||||
|
: QString(Constants::DEFAULT_THEME);
|
||||||
|
}
|
||||||
|
|
||||||
void ThemeChooser::apply()
|
void ThemeChooser::apply()
|
||||||
{
|
{
|
||||||
const int index = d->m_themeComboBox->currentIndex();
|
const int index = d->m_themeComboBox->currentIndex();
|
||||||
@@ -181,9 +187,7 @@ void ThemeChooser::apply()
|
|||||||
const QString currentThemeId = ThemeEntry::themeSetting().toString();
|
const QString currentThemeId = ThemeEntry::themeSetting().toString();
|
||||||
if (currentThemeId != themeId) {
|
if (currentThemeId != themeId) {
|
||||||
// save filename of selected theme in global config
|
// save filename of selected theme in global config
|
||||||
settings->setValueWithDefault(Constants::SETTINGS_THEME,
|
settings->setValueWithDefault(Constants::SETTINGS_THEME, themeId, defaultThemeId());
|
||||||
themeId,
|
|
||||||
QString(Constants::DEFAULT_THEME));
|
|
||||||
RestartDialog restartDialog(ICore::dialogParent(),
|
RestartDialog restartDialog(ICore::dialogParent(),
|
||||||
tr("The theme change will take effect after restart."));
|
tr("The theme change will take effect after restart."));
|
||||||
restartDialog.exec();
|
restartDialog.exec();
|
||||||
@@ -225,10 +229,8 @@ QList<ThemeEntry> ThemeEntry::availableThemes()
|
|||||||
|
|
||||||
Id ThemeEntry::themeSetting()
|
Id ThemeEntry::themeSetting()
|
||||||
{
|
{
|
||||||
auto defaultId = Theme::systemUsesDarkMode() ? Constants::DEFAULT_DARK_THEME
|
|
||||||
: Constants::DEFAULT_THEME;
|
|
||||||
const Id setting = Id::fromSetting(
|
const Id setting = Id::fromSetting(
|
||||||
ICore::settings()->value(Constants::SETTINGS_THEME, defaultId));
|
ICore::settings()->value(Constants::SETTINGS_THEME, defaultThemeId()));
|
||||||
|
|
||||||
const QList<ThemeEntry> themes = availableThemes();
|
const QList<ThemeEntry> themes = availableThemes();
|
||||||
if (themes.empty())
|
if (themes.empty())
|
||||||
|
|||||||
Reference in New Issue
Block a user