diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2016-08-19 15:42:00 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2016-08-19 14:11:47 +0000 |
commit | dd5f02754320086797e83bb77418c995d6b4d522 (patch) | |
tree | dbeb8de45d9db41875ffd1d0b490e4e37114e5f4 /src | |
parent | c3ea95281f30be06ee016451d300365ae600ee1c (diff) |
Material: ensure setting background/foreground works
- Add hasGlobalForeground and hasGlobalBackground. These are set
to true when a foreground/background color is specified via settings
(qtquickcontrols2.conf file or environment variables), and then used
to initialize each attached style object's m_hasForeground and
m_hasBackground property.
- Add tst_qquickmaterialstyleconf auto test to ensure that global
settings are respected.
Change-Id: I436773e355c6d470215fb9cfe8fbff402d2979d9
Task-number: QTBUG-55366
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/controls/material/qquickmaterialstyle.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/imports/controls/material/qquickmaterialstyle.cpp b/src/imports/controls/material/qquickmaterialstyle.cpp index 8220d83d..beb2b49b 100644 --- a/src/imports/controls/material/qquickmaterialstyle.cpp +++ b/src/imports/controls/material/qquickmaterialstyle.cpp @@ -374,6 +374,10 @@ static uint globalPrimary = QQuickMaterialStyle::Indigo; static uint globalAccent = QQuickMaterialStyle::Pink; static uint globalForeground = 0xDD000000; // primaryTextColorLight static uint globalBackground = 0xFFFAFAFA; // backgroundColorLight +// These represent whether a global foreground/background was set. +// Each style's m_hasForeground/m_hasBackground are initialized to these values. +static bool hasGlobalForeground = false; +static bool hasGlobalBackground = false; static bool globalPrimaryCustom = false; static bool globalAccentCustom = false; static bool globalForegroundCustom = true; @@ -438,8 +442,8 @@ QQuickMaterialStyle::QQuickMaterialStyle(QObject *parent) : QQuickStyleAttached( m_customAccent(globalAccentCustom), m_customForeground(globalForegroundCustom), m_customBackground(globalBackgroundCustom), - m_hasForeground(false), - m_hasBackground(false), + m_hasForeground(hasGlobalForeground), + m_hasBackground(hasGlobalBackground), m_theme(globalTheme), m_primary(globalPrimary), m_accent(globalAccent), @@ -1247,11 +1251,13 @@ void QQuickMaterialStyle::init() if (ok) { globalForegroundCustom = m_customForeground = false; globalForeground = m_foreground = foregroundEnum; + hasGlobalForeground = m_hasForeground = true; } else if (!foregroundValue.isEmpty()) { QColor color(foregroundValue.constData()); if (color.isValid()) { globalForegroundCustom = m_customForeground = true; globalForeground = m_foreground = color.rgba(); + hasGlobalForeground = m_hasForeground = true; } else { qWarning().nospace().noquote() << "Material: unknown foreground value: " << foregroundValue; } @@ -1262,11 +1268,13 @@ void QQuickMaterialStyle::init() if (ok) { globalBackgroundCustom = m_customBackground = false; globalBackground = m_background = backgroundEnum; + hasGlobalBackground = m_hasBackground = true; } else if (!backgroundValue.isEmpty()) { QColor color(backgroundValue.constData()); if (color.isValid()) { globalBackgroundCustom = m_customBackground = true; globalBackground = m_background = color.rgba(); + hasGlobalBackground = m_hasBackground = true; } else { qWarning().nospace().noquote() << "Material: unknown background value: " << backgroundValue; } |