diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2014-11-17 08:07:28 +0200 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2014-11-20 11:35:11 +0100 |
commit | 3ec16fe4d89bb8baa027d06de2b13f9a4755567c (patch) | |
tree | 01e995f380423c63b03fd234e74119c0d7feb3cf /src | |
parent | ab83c30f872cb1d02eb91ab75388fb3c4df656b3 (diff) | |
download | qt-creator-3ec16fe4d89bb8baa027d06de2b13f9a4755567c.tar.gz |
Theming: Store initial palette
Change-Id: Iea8b74534a59d8410814f9dd41225b88e1e81f75
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/utils/theme/theme.cpp | 12 | ||||
-rw-r--r-- | src/libs/utils/theme/theme.h | 8 | ||||
-rw-r--r-- | src/plugins/coreplugin/coreplugin.cpp | 3 | ||||
-rw-r--r-- | src/plugins/coreplugin/themesettingswidget.cpp | 2 |
4 files changed, 18 insertions, 7 deletions
diff --git a/src/libs/utils/theme/theme.cpp b/src/libs/utils/theme/theme.cpp index 95b03c9c86..ccfba5f6fc 100644 --- a/src/libs/utils/theme/theme.cpp +++ b/src/libs/utils/theme/theme.cpp @@ -324,14 +324,20 @@ void Theme::readSettings(QSettings &settings) } } -QPalette Theme::palette(const QPalette &base) const +QPalette Theme::initialPalette() { + static QPalette palette = QApplication::palette(); + return palette; +} + +QPalette Theme::palette() const +{ + QPalette pal = initialPalette(); if (!flag(DerivePaletteFromTheme)) - return base; + return pal; // FIXME: introduce some more color roles for this - QPalette pal = base; pal.setColor(QPalette::All, QPalette::Window, color(Theme::BackgroundColorNormal)); pal.setBrush(QPalette::All, QPalette::WindowText, color(Theme::TextColorNormal)); pal.setColor(QPalette::All, QPalette::Base, color(Theme::BackgroundColorNormal)); diff --git a/src/libs/utils/theme/theme.h b/src/libs/utils/theme/theme.h index 64411b2dd1..8c6aa9bf63 100644 --- a/src/libs/utils/theme/theme.h +++ b/src/libs/utils/theme/theme.h @@ -33,8 +33,9 @@ #include "../utils_global.h" -#include <QStyle> #include <QFlags> +#include <QPalette> +#include <QStyle> QT_FORWARD_DECLARE_CLASS(QSettings) @@ -199,7 +200,7 @@ public: QColor color(Color role) const; QString imageFile(ImageFile imageFile, const QString &fallBack) const; QGradientStops gradient(Gradient role) const; - QPalette palette(const QPalette &base) const; + QPalette palette() const; QStringList preferredStyles() const; QString fileName() const; @@ -209,6 +210,9 @@ public: void writeSettings(const QString &filename) const; void readSettings(QSettings &settings); + + static QPalette initialPalette(); + ThemePrivate *d; signals: diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index cd50daf04b..e84be25ac6 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -133,7 +133,7 @@ void CorePlugin::parseArguments(const QStringList &arguments) theme->readSettings(themeSettings); setCreatorTheme(theme); if (theme->flag(Theme::ApplyThemePaletteGlobally)) - QApplication::setPalette(creatorTheme()->palette(QApplication::palette())); + QApplication::setPalette(creatorTheme()->palette()); // defer creation of these widgets until here, // because they need a valid theme set @@ -148,6 +148,7 @@ void CorePlugin::parseArguments(const QStringList &arguments) bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage) { + Theme::initialPalette(); // Initialize palette before setting it qsrand(QDateTime::currentDateTime().toTime_t()); parseArguments(arguments); const bool success = m_mainWindow->init(errorMessage); diff --git a/src/plugins/coreplugin/themesettingswidget.cpp b/src/plugins/coreplugin/themesettingswidget.cpp index ab75331960..fd29e64363 100644 --- a/src/plugins/coreplugin/themesettingswidget.cpp +++ b/src/plugins/coreplugin/themesettingswidget.cpp @@ -419,7 +419,7 @@ void ThemeSettingsWidget::apply() { d->m_ui->editor->model()->toTheme(creatorTheme()); if (creatorTheme()->flag(Theme::ApplyThemePaletteGlobally)) - QApplication::setPalette(creatorTheme()->palette(QApplication::palette())); + QApplication::setPalette(creatorTheme()->palette()); foreach (QWidget *w, QApplication::topLevelWidgets()) w->update(); } |