From bf1d1cc6b2ad37cb586f44b56fa2438ed3a5dbfc Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 7 Jun 2017 18:22:34 +0200 Subject: [PATCH] don't switch colors on new themes new themes as breeze aren't supposed to just use the button graphics on top, that also mean, don't switch palette on top if the new prefix is there --- src/declarativeimports/core/framesvgitem.cpp | 10 ++++++++++ src/declarativeimports/core/framesvgitem.h | 9 +++++++++ .../plasmastyle/ToolButtonStyle.qml | 13 ++++++++++--- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/declarativeimports/core/framesvgitem.cpp b/src/declarativeimports/core/framesvgitem.cpp index 8484a2c23..33ef94ef0 100644 --- a/src/declarativeimports/core/framesvgitem.cpp +++ b/src/declarativeimports/core/framesvgitem.cpp @@ -349,6 +349,11 @@ QVariant FrameSvgItem::prefix() const return m_prefixes; } +QString FrameSvgItem::usedPrefix() const +{ + return m_frameSvg->prefix(); +} + FrameSvgItemMargins *FrameSvgItem::margins() const { return m_margins; @@ -561,6 +566,8 @@ void FrameSvgItem::applyPrefixes() return; } + const QString oldPrefix = m_frameSvg->prefix(); + if (m_prefixes.isEmpty()) { m_frameSvg->setElementPrefix(QString()); return; @@ -578,6 +585,9 @@ void FrameSvgItem::applyPrefixes() //this setElementPrefix is done to keep the same behavior as before, when it was a simple string m_frameSvg->setElementPrefix(m_prefixes.last()); } + if (oldPrefix != m_frameSvg->prefix()) { + emit usedPrefixChanged(); + } } } // Plasma namespace diff --git a/src/declarativeimports/core/framesvgitem.h b/src/declarativeimports/core/framesvgitem.h index f7203acc2..57939c4d0 100644 --- a/src/declarativeimports/core/framesvgitem.h +++ b/src/declarativeimports/core/framesvgitem.h @@ -126,6 +126,12 @@ class FrameSvgItem : public QQuickItem */ Q_PROPERTY(QVariant prefix READ prefix WRITE setPrefix NOTIFY prefixChanged) + /** + * the actual prefix that was used, if a fallback chain array was set as "prefix" + * @since 5.34 + */ + Q_PROPERTY(QString usedPrefix READ usedPrefix NOTIFY usedPrefixChanged) + /** * The margins of the frame, read only * @see FrameSvgItemMargins @@ -192,6 +198,8 @@ public: void setPrefix(const QVariant &prefix); QVariant prefix() const; + QString usedPrefix() const; + void setEnabledBorders(const Plasma::FrameSvg::EnabledBorders borders); Plasma::FrameSvg::EnabledBorders enabledBorders() const; @@ -232,6 +240,7 @@ Q_SIGNALS: void colorGroupChanged(); void repaintNeeded(); void statusChanged(); + void usedPrefixChanged(); private Q_SLOTS: void doUpdate(); diff --git a/src/declarativeimports/plasmastyle/ToolButtonStyle.qml b/src/declarativeimports/plasmastyle/ToolButtonStyle.qml index 192aa5b52..76bacaad5 100644 --- a/src/declarativeimports/plasmastyle/ToolButtonStyle.qml +++ b/src/declarativeimports/plasmastyle/ToolButtonStyle.qml @@ -83,6 +83,14 @@ QtQuickControlStyle.ButtonStyle { colorGroup: controlHovered || !flat ? PlasmaCore.Theme.ButtonColorGroup : PlasmaCore.ColorScope.colorGroup } + //NOTE: this is used only to check elements existence + PlasmaCore.FrameSvgItem { + id: buttonsurfaceChecker + visible: false + imagePath: "widgets/button" + prefix: style.flat ? ["toolbutton-hover", "normal"] : "normal" + } + PlasmaComponents.Label { id: label anchors.verticalCenter: parent.verticalCenter @@ -91,7 +99,7 @@ QtQuickControlStyle.ButtonStyle { font: control.font || theme.defaultFont visible: control.text != "" Layout.fillWidth: true - color: controlHovered || !flat ? theme.buttonTextColor : PlasmaCore.ColorScope.textColor + color: (controlHovered || !flat) && buttonsurfaceChecker.usedPrefix != "toolbutton-hover" ? theme.buttonTextColor : PlasmaCore.ColorScope.textColor horizontalAlignment: icon.valid ? Text.AlignLeft : Text.AlignHCenter elide: Text.ElideRight } @@ -113,7 +121,7 @@ QtQuickControlStyle.ButtonStyle { visible: control.menu !== null svg: PlasmaCore.Svg { imagePath: "widgets/arrows" - colorGroup: style.controlHovered || !style.flat ? PlasmaCore.Theme.ButtonColorGroup : PlasmaCore.ColorScope.colorGroup + colorGroup: (style.controlHovered || !style.flat) && buttonsurfaceChecker.usedPrefix != "toolbutton-hover" ? PlasmaCore.Theme.ButtonColorGroup : PlasmaCore.ColorScope.colorGroup } elementId: "down-arrow" } @@ -224,7 +232,6 @@ QtQuickControlStyle.ButtonStyle { } } - //This code is duplicated here and Button and ToolButton //maybe we can make an AbstractButton class? PlasmaCore.FrameSvgItem {