Commit cf45c854 authored by Thorben Kroeger's avatar Thorben Kroeger Committed by Orgad Shaneh
Browse files

Theming: allow to override base style



Change-Id: I48e2d03b83fccf3d6eb4b508bd77912dbdaea1d0
Reviewed-by: default avatarThorben Kroeger <thorbenkroeger@gmail.com>
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent 82bbc6f5
[General]
ThemeName=dark
PreferredStyles=Fusion
[Palette]
shadowBackground=ff232323
......
[General]
ThemeName=default
PreferredStyles=
[Palette]
brightText = ffffffff
......
......@@ -30,6 +30,7 @@
#include "theme.h"
#include "theme_p.h"
#include "../algorithm.h"
#include "../qtcassert.h"
#include <QApplication>
......@@ -80,6 +81,11 @@ Theme::WidgetStyle Theme::widgetStyle() const
return d->widgetStyle;
}
QStringList Theme::preferredStyles() const
{
return d->preferredStyles;
}
bool Theme::flag(Theme::Flag f) const
{
return d->flags[f];
......@@ -171,6 +177,7 @@ void Theme::writeSettings(const QString &filename) const
const QMetaObject &m = *metaObject();
{
settings.setValue(QLatin1String("ThemeName"), d->name);
settings.setValue(QLatin1String("PreferredStyles"), d->preferredStyles);
}
{
settings.beginGroup(QLatin1String("Palette"));
......@@ -249,6 +256,7 @@ void Theme::readSettings(QSettings &settings)
{
d->name = settings.value(QLatin1String("ThemeName"), QLatin1String("unnamed")).toString();
d->preferredStyles = settings.value(QLatin1String("PreferredStyles")).toStringList();
}
{
settings.beginGroup(QLatin1String("Palette"));
......
......@@ -199,6 +199,7 @@ public:
QString imageFile(ImageFile imageFile, const QString &fallBack) const;
QGradientStops gradient(Gradient role) const;
QPalette palette(const QPalette &base) const;
QStringList preferredStyles() const;
QString fileName() const;
void setName(const QString &name);
......
......@@ -46,6 +46,7 @@ public:
QString fileName;
QString name;
QStringList preferredStyles;
QVector<QPair<QColor, QString> > colors;
QVector<QString> imageFiles;
QVector<QGradientStops> gradients;
......
......@@ -166,7 +166,18 @@ MainWindow::MainWindow() :
&& baseName == QLatin1String("windows")) {
baseName = QLatin1String("fusion");
}
qApp->setStyle(new ManhattanStyle(baseName));
// if the user has specified as base style in the theme settings,
// prefer that
const QStringList available = QStyleFactory::keys();
foreach (const QString &s, Utils::creatorTheme()->preferredStyles()) {
if (available.contains(s, Qt::CaseInsensitive)) {
baseName = s;
break;
}
}
QApplication::setStyle(new ManhattanStyle(baseName));
setDockNestingEnabled(true);
......
......@@ -236,6 +236,7 @@ void ThemeSettingsTableModel::initFrom(Theme *theme)
m_widgetStyle = theme->widgetStyle();
m_name = theme->d->name;
m_preferredStyles = theme->d->preferredStyles;
}
void ThemeSettingsTableModel::toTheme(Theme *t) const
......@@ -265,6 +266,7 @@ void ThemeSettingsTableModel::toTheme(Theme *t) const
theme->widgetStyle = m_widgetStyle;
theme->name = m_name;
theme->preferredStyles = m_preferredStyles;
emit t->changed();
}
......
......@@ -78,6 +78,7 @@ public:
void toTheme(Utils::Theme *theme) const;
QString m_name;
QStringList m_preferredStyles;
public:
ThemeColors::Ptr m_colors;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment