diff options
Diffstat (limited to 'src/imports/controls/universal/qquickuniversalstyle.cpp')
-rw-r--r-- | src/imports/controls/universal/qquickuniversalstyle.cpp | 76 |
1 files changed, 42 insertions, 34 deletions
diff --git a/src/imports/controls/universal/qquickuniversalstyle.cpp b/src/imports/controls/universal/qquickuniversalstyle.cpp index 2f9c86cb..17a214f4 100644 --- a/src/imports/controls/universal/qquickuniversalstyle.cpp +++ b/src/imports/controls/universal/qquickuniversalstyle.cpp @@ -154,27 +154,30 @@ QQuickUniversalStyle::Theme QQuickUniversalStyle::theme() const void QQuickUniversalStyle::setTheme(Theme theme) { m_hasTheme = true; - if (m_theme != theme) { - m_theme = theme; - propagateTheme(); - emit themeChanged(); - emit paletteChanged(); - } + if (m_theme == theme) + return; + + m_theme = theme; + propagateTheme(); + emit themeChanged(); + emit paletteChanged(); } void QQuickUniversalStyle::inheritTheme(Theme theme) { - if (!m_hasTheme && m_theme != theme) { - m_theme = theme; - propagateTheme(); - emit themeChanged(); - emit paletteChanged(); - } + if (m_hasTheme || m_theme == theme) + return; + + m_theme = theme; + propagateTheme(); + emit themeChanged(); + emit paletteChanged(); } void QQuickUniversalStyle::propagateTheme() { - foreach (QQuickStyle *child, childStyles()) { + const auto styles = childStyles(); + for (QQuickStyle *child : styles) { QQuickUniversalStyle *universal = qobject_cast<QQuickUniversalStyle *>(child); if (universal) universal->inheritTheme(m_theme); @@ -183,11 +186,12 @@ void QQuickUniversalStyle::propagateTheme() void QQuickUniversalStyle::resetTheme() { - if (m_hasTheme) { - m_hasTheme = false; - QQuickUniversalStyle *universal = qobject_cast<QQuickUniversalStyle *>(parentStyle()); - inheritTheme(universal ? universal->theme() : DefaultTheme); - } + if (!m_hasTheme) + return; + + m_hasTheme = false; + QQuickUniversalStyle *universal = qobject_cast<QQuickUniversalStyle *>(parentStyle()); + inheritTheme(universal ? universal->theme() : DefaultTheme); } QVariant QQuickUniversalStyle::accent() const @@ -220,25 +224,28 @@ void QQuickUniversalStyle::setAccent(const QVariant &var) } m_hasAccent = true; - if (m_accent != accent) { - m_accent = accent; - propagateAccent(); - emit accentChanged(); - } + if (m_accent == accent) + return; + + m_accent = accent; + propagateAccent(); + emit accentChanged(); } void QQuickUniversalStyle::inheritAccent(QRgb accent) { - if (!m_hasAccent && m_accent != accent) { - m_accent = accent; - propagateAccent(); - emit accentChanged(); - } + if (m_hasAccent || m_accent == accent) + return; + + m_accent = accent; + propagateAccent(); + emit accentChanged(); } void QQuickUniversalStyle::propagateAccent() { - foreach (QQuickStyle *child, childStyles()) { + const auto styles = childStyles(); + for (QQuickStyle *child : styles) { QQuickUniversalStyle *universal = qobject_cast<QQuickUniversalStyle *>(child); if (universal) universal->inheritAccent(m_accent); @@ -247,11 +254,12 @@ void QQuickUniversalStyle::propagateAccent() void QQuickUniversalStyle::resetAccent() { - if (m_hasAccent) { - m_hasAccent = false; - QQuickUniversalStyle *universal = qobject_cast<QQuickUniversalStyle *>(parentStyle()); - inheritAccent(universal ? universal->m_accent : DefaultAccent); - } + if (!m_hasAccent) + return; + + m_hasAccent = false; + QQuickUniversalStyle *universal = qobject_cast<QQuickUniversalStyle *>(parentStyle()); + inheritAccent(universal ? universal->m_accent : DefaultAccent); } QColor QQuickUniversalStyle::altHighColor() const |