Theme Settings: Fix that options page switched back to current theme

- Changing the theme settings and reopening options page switched back
  to current theme
- When passing a theme on the command line, closing the options dialog
  would state that the theme change takes effect after restart, even if
  theme was not changed

Fix these issues by showing the current theme setting in the options
page, ignoring the currently active theme, and showing a label telling
the currently active theme instead.

Task-number: QTCREATORBUG-15852
Change-Id: I343fc729c33f17fcb15a8e9facd7a49076d0e0d1
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Eike Ziller
2016-11-01 11:26:09 +01:00
parent 05bf915c03
commit 583d8ced5a

View File

@@ -38,6 +38,7 @@
#include <QDebug>
#include <QDir>
#include <QHBoxLayout>
#include <QLabel>
#include <QMessageBox>
#include <QSettings>
#include <QSpacerItem>
@@ -136,13 +137,17 @@ ThemeChooserPrivate::ThemeChooserPrivate(QWidget *widget)
{
QHBoxLayout *layout = new QHBoxLayout(widget);
layout->addWidget(m_themeComboBox);
auto overriddenLabel = new QLabel;
overriddenLabel->setText(ThemeChooser::tr("Current theme: %1")
.arg(creatorTheme()->displayName()));
layout->addWidget(overriddenLabel);
layout->setMargin(0);
auto horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
layout->addSpacerItem(horizontalSpacer);
m_themeComboBox->setModel(m_themeListModel);
const QList<ThemeEntry> themes = ThemeEntry::availableThemes();
const Id activeTheme = Id::fromString(creatorTheme()->id());
const int selected = Utils::indexOf(themes, Utils::equal(&ThemeEntry::id, activeTheme));
const Id themeSetting = ThemeEntry::themeSetting();
const int selected = Utils::indexOf(themes, Utils::equal(&ThemeEntry::id, themeSetting));
m_themeListModel->setThemes(themes);
if (selected >= 0)
m_themeComboBox->setCurrentIndex(selected);