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
This commit is contained in:
Marco Martin 2017-06-07 18:22:34 +02:00
parent 0c8cac7849
commit bf1d1cc6b2
3 changed files with 29 additions and 3 deletions

View File

@ -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

View File

@ -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();

View File

@ -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 {