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; return m_prefixes;
} }
QString FrameSvgItem::usedPrefix() const
{
return m_frameSvg->prefix();
}
FrameSvgItemMargins *FrameSvgItem::margins() const FrameSvgItemMargins *FrameSvgItem::margins() const
{ {
return m_margins; return m_margins;
@ -561,6 +566,8 @@ void FrameSvgItem::applyPrefixes()
return; return;
} }
const QString oldPrefix = m_frameSvg->prefix();
if (m_prefixes.isEmpty()) { if (m_prefixes.isEmpty()) {
m_frameSvg->setElementPrefix(QString()); m_frameSvg->setElementPrefix(QString());
return; 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 //this setElementPrefix is done to keep the same behavior as before, when it was a simple string
m_frameSvg->setElementPrefix(m_prefixes.last()); m_frameSvg->setElementPrefix(m_prefixes.last());
} }
if (oldPrefix != m_frameSvg->prefix()) {
emit usedPrefixChanged();
}
} }
} // Plasma namespace } // Plasma namespace

View File

@ -126,6 +126,12 @@ class FrameSvgItem : public QQuickItem
*/ */
Q_PROPERTY(QVariant prefix READ prefix WRITE setPrefix NOTIFY prefixChanged) 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 * The margins of the frame, read only
* @see FrameSvgItemMargins * @see FrameSvgItemMargins
@ -192,6 +198,8 @@ public:
void setPrefix(const QVariant &prefix); void setPrefix(const QVariant &prefix);
QVariant prefix() const; QVariant prefix() const;
QString usedPrefix() const;
void setEnabledBorders(const Plasma::FrameSvg::EnabledBorders borders); void setEnabledBorders(const Plasma::FrameSvg::EnabledBorders borders);
Plasma::FrameSvg::EnabledBorders enabledBorders() const; Plasma::FrameSvg::EnabledBorders enabledBorders() const;
@ -232,6 +240,7 @@ Q_SIGNALS:
void colorGroupChanged(); void colorGroupChanged();
void repaintNeeded(); void repaintNeeded();
void statusChanged(); void statusChanged();
void usedPrefixChanged();
private Q_SLOTS: private Q_SLOTS:
void doUpdate(); void doUpdate();

View File

@ -83,6 +83,14 @@ QtQuickControlStyle.ButtonStyle {
colorGroup: controlHovered || !flat ? PlasmaCore.Theme.ButtonColorGroup : PlasmaCore.ColorScope.colorGroup 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 { PlasmaComponents.Label {
id: label id: label
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -91,7 +99,7 @@ QtQuickControlStyle.ButtonStyle {
font: control.font || theme.defaultFont font: control.font || theme.defaultFont
visible: control.text != "" visible: control.text != ""
Layout.fillWidth: true 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 horizontalAlignment: icon.valid ? Text.AlignLeft : Text.AlignHCenter
elide: Text.ElideRight elide: Text.ElideRight
} }
@ -113,7 +121,7 @@ QtQuickControlStyle.ButtonStyle {
visible: control.menu !== null visible: control.menu !== null
svg: PlasmaCore.Svg { svg: PlasmaCore.Svg {
imagePath: "widgets/arrows" 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" elementId: "down-arrow"
} }
@ -224,7 +232,6 @@ QtQuickControlStyle.ButtonStyle {
} }
} }
//This code is duplicated here and Button and ToolButton //This code is duplicated here and Button and ToolButton
//maybe we can make an AbstractButton class? //maybe we can make an AbstractButton class?
PlasmaCore.FrameSvgItem { PlasmaCore.FrameSvgItem {