diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2016-08-19 15:29:02 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2016-08-19 14:11:42 +0000 |
commit | c3ea95281f30be06ee016451d300365ae600ee1c (patch) | |
tree | 7a52b3c80cb6fb3142f1d3704962a6d3ece50bef /src | |
parent | 93b68f9a12198f226a8d59717bc1cd36d47c5dbe (diff) |
Material: rename defaultX variables to globalX
For example, defaultPrimary will become globalPrimary. This better
reflects the reality that these are not true defaults because they can
be overridden by settings and makes it easier to read the code.
Change-Id: Idf09e5b0c6a2d91663730c00e3d32f2be49e15c6
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/controls/material/qquickmaterialstyle.cpp | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/src/imports/controls/material/qquickmaterialstyle.cpp b/src/imports/controls/material/qquickmaterialstyle.cpp index 7e9ba001..8220d83d 100644 --- a/src/imports/controls/material/qquickmaterialstyle.cpp +++ b/src/imports/controls/material/qquickmaterialstyle.cpp @@ -369,15 +369,15 @@ static const QRgb colors[][14] = { } }; -static QQuickMaterialStyle::Theme defaultTheme = QQuickMaterialStyle::Light; -static uint defaultPrimary = QQuickMaterialStyle::Indigo; -static uint defaultAccent = QQuickMaterialStyle::Pink; -static uint defaultForeground = 0xDD000000; // primaryTextColorLight -static uint defaultBackground = 0xFFFAFAFA; // backgroundColorLight -static bool defaultPrimaryCustom = false; -static bool defaultAccentCustom = false; -static bool defaultForegroundCustom = true; -static bool defaultBackgroundCustom = true; +static QQuickMaterialStyle::Theme globalTheme = QQuickMaterialStyle::Light; +static uint globalPrimary = QQuickMaterialStyle::Indigo; +static uint globalAccent = QQuickMaterialStyle::Pink; +static uint globalForeground = 0xDD000000; // primaryTextColorLight +static uint globalBackground = 0xFFFAFAFA; // backgroundColorLight +static bool globalPrimaryCustom = false; +static bool globalAccentCustom = false; +static bool globalForegroundCustom = true; +static bool globalBackgroundCustom = true; static const QRgb backgroundColorLight = 0xFFFAFAFA; static const QRgb backgroundColorDark = 0xFF303030; @@ -434,17 +434,17 @@ QQuickMaterialStyle::QQuickMaterialStyle(QObject *parent) : QQuickStyleAttached( m_explicitAccent(false), m_explicitForeground(false), m_explicitBackground(false), - m_customPrimary(defaultPrimaryCustom), - m_customAccent(defaultAccentCustom), - m_customForeground(defaultForegroundCustom), - m_customBackground(defaultBackgroundCustom), + m_customPrimary(globalPrimaryCustom), + m_customAccent(globalAccentCustom), + m_customForeground(globalForegroundCustom), + m_customBackground(globalBackgroundCustom), m_hasForeground(false), m_hasBackground(false), - m_theme(defaultTheme), - m_primary(defaultPrimary), - m_accent(defaultAccent), - m_foreground(defaultForeground), - m_background(defaultBackground), + m_theme(globalTheme), + m_primary(globalPrimary), + m_accent(globalAccent), + m_foreground(globalForeground), + m_background(globalBackground), m_elevation(0) { init(); @@ -508,7 +508,7 @@ void QQuickMaterialStyle::resetTheme() m_explicitTheme = false; QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(parentStyle()); - inheritTheme(material ? material->theme() : defaultTheme); + inheritTheme(material ? material->theme() : globalTheme); } QVariant QQuickMaterialStyle::primary() const @@ -567,7 +567,7 @@ void QQuickMaterialStyle::resetPrimary() if (material) inheritPrimary(material->m_primary, material->m_customPrimary); else - inheritPrimary(defaultPrimary, false); + inheritPrimary(globalPrimary, false); } QVariant QQuickMaterialStyle::accent() const @@ -626,7 +626,7 @@ void QQuickMaterialStyle::resetAccent() if (material) inheritAccent(material->m_accent, material->m_customAccent); else - inheritAccent(defaultAccent, false); + inheritAccent(globalAccent, false); } QVariant QQuickMaterialStyle::foreground() const @@ -683,7 +683,7 @@ void QQuickMaterialStyle::resetForeground() m_customForeground = false; m_explicitForeground = false; QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(parentStyle()); - inheritForeground(material ? material->m_foreground : defaultForeground, true, material ? material->m_hasForeground : false); + inheritForeground(material ? material->m_foreground : globalForeground, true, material ? material->m_hasForeground : false); } QVariant QQuickMaterialStyle::background() const @@ -741,7 +741,7 @@ void QQuickMaterialStyle::resetBackground() m_customBackground = false; m_explicitBackground = false; QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(parentStyle()); - inheritBackground(material ? material->m_background : defaultBackground, true, material ? material->m_hasBackground : false); + inheritBackground(material ? material->m_background : globalBackground, true, material ? material->m_hasBackground : false); } int QQuickMaterialStyle::elevation() const @@ -1200,28 +1200,28 @@ static QByteArray resolveSetting(const QByteArray &env, const QSharedPointer<QSe void QQuickMaterialStyle::init() { - static bool defaultsInitialized = false; - if (!defaultsInitialized) { + static bool globalsInitialized = false; + if (!globalsInitialized) { QSharedPointer<QSettings> settings = QQuickStyleAttached::settings(QStringLiteral("Material")); bool ok = false; QByteArray themeValue = resolveSetting("QT_QUICK_CONTROLS_MATERIAL_THEME", settings, QStringLiteral("Theme")); Theme themeEnum = toEnumValue<Theme>(themeValue, &ok); if (ok) - defaultTheme = m_theme = themeEnum; + globalTheme = m_theme = themeEnum; else if (!themeValue.isEmpty()) qWarning().nospace().noquote() << "Material: unknown theme value: " << themeValue; QByteArray primaryValue = resolveSetting("QT_QUICK_CONTROLS_MATERIAL_PRIMARY", settings, QStringLiteral("Primary")); Color primaryEnum = toEnumValue<Color>(primaryValue, &ok); if (ok) { - defaultPrimaryCustom = m_customPrimary = false; - defaultPrimary = m_primary = primaryEnum; + globalPrimaryCustom = m_customPrimary = false; + globalPrimary = m_primary = primaryEnum; } else { QColor color(primaryValue.constData()); if (color.isValid()) { - defaultPrimaryCustom = m_customPrimary = true; - defaultPrimary = m_primary = color.rgba(); + globalPrimaryCustom = m_customPrimary = true; + globalPrimary = m_primary = color.rgba(); } else if (!primaryValue.isEmpty()) { qWarning().nospace().noquote() << "Material: unknown primary value: " << primaryValue; } @@ -1230,13 +1230,13 @@ void QQuickMaterialStyle::init() QByteArray accentValue = resolveSetting("QT_QUICK_CONTROLS_MATERIAL_ACCENT", settings, QStringLiteral("Accent")); Color accentEnum = toEnumValue<Color>(accentValue, &ok); if (ok) { - defaultAccentCustom = m_customAccent = false; - defaultAccent = m_accent = accentEnum; + globalAccentCustom = m_customAccent = false; + globalAccent = m_accent = accentEnum; } else if (!accentValue.isEmpty()) { QColor color(accentValue.constData()); if (color.isValid()) { - defaultAccentCustom = m_customAccent = true; - defaultAccent = m_accent = color.rgba(); + globalAccentCustom = m_customAccent = true; + globalAccent = m_accent = color.rgba(); } else { qWarning().nospace().noquote() << "Material: unknown accent value: " << accentValue; } @@ -1245,13 +1245,13 @@ void QQuickMaterialStyle::init() QByteArray foregroundValue = resolveSetting("QT_QUICK_CONTROLS_MATERIAL_FOREGROUND", settings, QStringLiteral("Foreground")); Color foregroundEnum = toEnumValue<Color>(foregroundValue, &ok); if (ok) { - defaultForegroundCustom = m_customForeground = false; - defaultForeground = m_foreground = foregroundEnum; + globalForegroundCustom = m_customForeground = false; + globalForeground = m_foreground = foregroundEnum; } else if (!foregroundValue.isEmpty()) { QColor color(foregroundValue.constData()); if (color.isValid()) { - defaultForegroundCustom = m_customForeground = true; - defaultForeground = m_foreground = color.rgba(); + globalForegroundCustom = m_customForeground = true; + globalForeground = m_foreground = color.rgba(); } else { qWarning().nospace().noquote() << "Material: unknown foreground value: " << foregroundValue; } @@ -1260,19 +1260,19 @@ void QQuickMaterialStyle::init() QByteArray backgroundValue = resolveSetting("QT_QUICK_CONTROLS_MATERIAL_BACKGROUND", settings, QStringLiteral("Background")); Color backgroundEnum = toEnumValue<Color>(backgroundValue, &ok); if (ok) { - defaultBackgroundCustom = m_customBackground = false; - defaultBackground = m_background = backgroundEnum; + globalBackgroundCustom = m_customBackground = false; + globalBackground = m_background = backgroundEnum; } else if (!backgroundValue.isEmpty()) { QColor color(backgroundValue.constData()); if (color.isValid()) { - defaultBackgroundCustom = m_customBackground = true; - defaultBackground = m_background = color.rgba(); + globalBackgroundCustom = m_customBackground = true; + globalBackground = m_background = color.rgba(); } else { qWarning().nospace().noquote() << "Material: unknown background value: " << backgroundValue; } } - defaultsInitialized = true; + globalsInitialized = true; } QQuickStyleAttached::init(); // TODO: lazy init? |