Commit 4fca423f authored by Alessandro Portale's avatar Alessandro Portale Committed by hjk

Theming: Unify namings

The names for Color[Role] and Gradient[Stop] are not used consistently.
This patch unfifies the naming.

Change-Id: Idd06978a628427cb448a158d620bea561752750d
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 34ba0c27
......@@ -45,9 +45,9 @@ ThemePrivate::ThemePrivate()
: widgetStyle(Theme::StyleDefault)
{
const QMetaObject &m = Theme::staticMetaObject;
colors.resize (m.enumerator(m.indexOfEnumerator("ColorRole")).keyCount());
colors.resize (m.enumerator(m.indexOfEnumerator("Color")).keyCount());
imageFiles.resize (m.enumerator(m.indexOfEnumerator("ImageFile")).keyCount());
gradientStops.resize (m.enumerator(m.indexOfEnumerator("GradientRole")).keyCount());
gradients.resize (m.enumerator(m.indexOfEnumerator("Gradient")).keyCount());
flags.resize (m.enumerator(m.indexOfEnumerator("Flag")).keyCount());
}
......@@ -83,7 +83,7 @@ bool Theme::flag(Theme::Flag f) const
return d->flags[f];
}
QColor Theme::color(Theme::ColorRole role) const
QColor Theme::color(Theme::Color role) const
{
return d->colors[role].first;
}
......@@ -94,9 +94,9 @@ QString Theme::imageFile(Theme::ImageFile imageFile, const QString &fallBack) co
return file.isEmpty() ? fallBack : file;
}
QGradientStops Theme::gradient(Theme::GradientRole role) const
QGradientStops Theme::gradient(Theme::Gradient role) const
{
return d->gradientStops[role];
return d->gradients[role];
}
QPair<QColor, QString> Theme::readNamedColor(const QString &color) const
......@@ -128,7 +128,7 @@ QVariantHash Theme::values() const
QVariantHash result;
const QMetaObject &m = *metaObject();
{
const QMetaEnum e = m.enumerator(m.indexOfEnumerator("ColorRole"));
const QMetaEnum e = m.enumerator(m.indexOfEnumerator("Color"));
for (int i = 0, total = e.keyCount(); i < total; ++i) {
const QString key = QLatin1String(e.key(i));
const QPair<QColor, QString> &var = d->colors.at(i);
......@@ -182,7 +182,7 @@ void Theme::writeSettings(const QString &filename) const
}
{
settings.beginGroup(QLatin1String("Colors"));
const QMetaEnum e = m.enumerator(m.indexOfEnumerator("ColorRole"));
const QMetaEnum e = m.enumerator(m.indexOfEnumerator("Color"));
for (int i = 0, total = e.keyCount(); i < total; ++i) {
const QString key = QLatin1String(e.key(i));
const QPair<QColor, QString> var = d->colors[i];
......@@ -206,10 +206,10 @@ void Theme::writeSettings(const QString &filename) const
}
{
settings.beginGroup(QLatin1String("Gradients"));
const QMetaEnum e = m.enumerator(m.indexOfEnumerator("GradientRole"));
const QMetaEnum e = m.enumerator(m.indexOfEnumerator("Gradient"));
for (int i = 0, total = e.keyCount(); i < total; ++i) {
const QString key = QLatin1String(e.key(i));
QGradientStops stops = gradient(static_cast<Theme::GradientRole>(i));
QGradientStops stops = gradient(static_cast<Theme::Gradient>(i));
settings.beginWriteArray(key);
int k = 0;
foreach (const QGradientStop stop, stops) {
......@@ -265,7 +265,7 @@ void Theme::readSettings(QSettings &settings)
}
{
settings.beginGroup(QLatin1String("Colors"));
QMetaEnum e = m.enumerator(m.indexOfEnumerator("ColorRole"));
QMetaEnum e = m.enumerator(m.indexOfEnumerator("Color"));
for (int i = 0, total = e.keyCount(); i < total; ++i) {
const QString key = QLatin1String(e.key(i));
QTC_ASSERT(settings.contains(key), return);;
......@@ -284,7 +284,7 @@ void Theme::readSettings(QSettings &settings)
}
{
settings.beginGroup(QLatin1String("Gradients"));
QMetaEnum e = m.enumerator(m.indexOfEnumerator("GradientRole"));
QMetaEnum e = m.enumerator(m.indexOfEnumerator("Gradient"));
for (int i = 0, total = e.keyCount(); i < total; ++i) {
const QString key = QLatin1String(e.key(i));
QGradientStops stops;
......@@ -298,7 +298,7 @@ void Theme::readSettings(QSettings &settings)
stops.append(qMakePair(pos, c));
}
settings.endArray();
d->gradientStops[i] = stops;
d->gradients[i] = stops;
}
settings.endGroup();
}
......
......@@ -46,9 +46,9 @@ class QTCREATOR_UTILS_EXPORT Theme : public QObject
{
Q_OBJECT
Q_ENUMS(ColorRole)
Q_ENUMS(Color)
Q_ENUMS(ImageFile)
Q_ENUMS(GradientRole)
Q_ENUMS(Gradient)
Q_ENUMS(Flag)
Q_ENUMS(WidgetStyle)
......@@ -56,7 +56,7 @@ public:
Theme(QObject *parent = 0);
~Theme();
enum ColorRole {
enum Color {
BackgroundColorAlternate,
BackgroundColorDark,
BackgroundColorHover,
......@@ -153,7 +153,7 @@ public:
Welcome_SessionItemExpanded_BackgroundColorHover
};
enum GradientRole {
enum Gradient {
DetailsWidgetHeaderGradient,
Welcome_Button_GradientNormal,
Welcome_Button_GradientPressed
......@@ -193,9 +193,9 @@ public:
WidgetStyle widgetStyle() const;
bool flag(Flag f) const;
QColor color(ColorRole role) const;
QColor color(Color role) const;
QString imageFile(ImageFile imageFile, const QString &fallBack) const;
QGradientStops gradient(GradientRole role) const;
QGradientStops gradient(Gradient role) const;
QPalette palette(const QPalette &base) const;
QString fileName() const;
......
......@@ -48,7 +48,7 @@ public:
QString name;
QVector<QPair<QColor, QString> > colors;
QVector<QString> imageFiles;
QVector<QGradientStops> gradientStops;
QVector<QGradientStops> gradients;
QVector<bool> flags;
Theme::WidgetStyle widgetStyle;
QMap<QString, QColor> palette;
......
......@@ -200,11 +200,11 @@ void ThemeSettingsTableModel::initFrom(Theme *theme)
const QMetaObject &metaObject = Theme::staticMetaObject;
// Colors
{
QMetaEnum e = metaObject.enumerator(metaObject.indexOfEnumerator("ColorRole"));
QMetaEnum e = metaObject.enumerator(metaObject.indexOfEnumerator("Color"));
QMap<QString, ColorVariable::Ptr> varLookup;
for (int i = 0, total = e.keyCount(); i < total; ++i) {
const QString key = QLatin1String(e.key(i));
QPair<QColor, QString> c = theme->d->colors[static_cast<Theme::ColorRole>(i)];
QPair<QColor, QString> c = theme->d->colors[static_cast<Theme::Color>(i)];
if (c.second.isEmpty()) {
ColorVariable::Ptr v = colors()->createVariable(c.first);
colors()->createRole(key, v);
......@@ -243,7 +243,7 @@ void ThemeSettingsTableModel::toTheme(Theme *t) const
ThemePrivate *theme = t->d;
// Colors
{
QMetaEnum e = Theme::staticMetaObject.enumerator(Theme::staticMetaObject.indexOfEnumerator("ColorRole"));
QMetaEnum e = Theme::staticMetaObject.enumerator(Theme::staticMetaObject.indexOfEnumerator("Color"));
for (int i = 0, total = e.keyCount(); i < total; ++i) {
ColorRole::Ptr role = colors()->colorRole(i);
ColorVariable::Ptr var = role->colorVariable();
......
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