diff --git a/src/declarativeimports/core/colorscope.cpp b/src/declarativeimports/core/colorscope.cpp index e7e6872c8..3c6de03ea 100644 --- a/src/declarativeimports/core/colorscope.cpp +++ b/src/declarativeimports/core/colorscope.cpp @@ -1,313 +1,239 @@ /*************************************************************************** * Copyright 2011 Marco Martin * * Copyright 2011 Artur Duque de Souza * * Copyright 2013 Sebastian Kügler * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #include "colorscope.h" #include #include #include #include #include -QHash ColorScopeAttached::s_attachedScopes = QHash(); +QHash ColorScope::s_attachedScopes = QHash(); -QWeakPointer ColorScopeAttached::s_theme; +QWeakPointer ColorScope::s_theme; -ColorScopeAttached::ColorScopeAttached(QObject *parent) - : QObject(parent), +ColorScope::ColorScope(QQuickItem *parent, QObject *parentObject) + : QQuickItem(parent), m_inherit(false), m_group(Plasma::Theme::NormalColorGroup), - m_parent(parent), + m_parent(parentObject), m_actualGroup(Plasma::Theme::NormalColorGroup) { m_theme = s_theme.toStrongRef(); if (!m_theme) { QSharedPointer themePtr(new Plasma::Theme); s_theme = themePtr; m_theme = s_theme.toStrongRef(); } - connect(m_theme.data(), &Plasma::Theme::themeChanged, this, &ColorScopeAttached::colorsChanged); - - connect(this, &ColorScopeAttached::colorGroupChanged, this, &ColorScopeAttached::colorsChanged); - - QQuickItem *parentItem = qobject_cast(m_parent); - - auto scopeChange = [this] () { - findParentScope(); - checkColorGroupChanged(); - }; - - if (parentItem) { - connect(parentItem, &QQuickItem::windowChanged, - this, scopeChange); - - connect(parentItem, &QQuickItem::parentChanged, - this, scopeChange); + connect(m_theme.data(), &Plasma::Theme::themeChanged, this, &ColorScope::colorsChanged); + + connect(this, &ColorScope::colorGroupChanged, this, &ColorScope::colorsChanged); + + if (parentObject && qobject_cast(parentObject)) { + connect(static_cast(parentObject), &QQuickItem::windowChanged, + this, [this]() { + findParentScope(); + checkColorGroupChanged(); + }); + + connect(static_cast(parentObject), &QQuickItem::parentChanged, + this, [this]() { + findParentScope(); + checkColorGroupChanged(); + }); + } else if (parent) { + connect(parent, &QQuickItem::parentChanged, + this, &ColorScope::checkColorGroupChanged); } - findParentScope(); } -ColorScopeAttached::~ColorScopeAttached() +ColorScope::~ColorScope() { m_deleting = true; s_attachedScopes.remove(m_parent); } -void ColorScopeAttached::setParentScope(ColorScopeAttached* parentScope) +ColorScope *ColorScope::qmlAttachedProperties(QObject *object) { - if (parentScope == m_parentScope) - return; - - if (m_parentScope) { - disconnect(m_parentScope.data(), &ColorScopeAttached::colorGroupChanged, - this, &ColorScopeAttached::checkColorGroupChanged); + const auto cs = s_attachedScopes.value(object); + if (cs) { + return cs; } - m_parentScope = parentScope; + ColorScope *s = new ColorScope(nullptr, object); + s_attachedScopes[object] = s; + s->m_inherit = true; + s->setParent(object); + s->checkColorGroupChanged(); - if (parentScope) { - connect(parentScope, &ColorScopeAttached::colorGroupChanged, - this, &ColorScopeAttached::checkColorGroupChanged); - } + return s; } -void ColorScopeAttached::setColorGroup(Plasma::Theme::ColorGroup group) +void ColorScope::setParentScope(ColorScope* parentScope) { - if (m_group == group) { + if (parentScope == m_parentScope) return; - } - - m_group = group; - - checkColorGroupChanged(); -} - -Plasma::Theme::ColorGroup ColorScopeAttached::colorGroup() const -{ - return m_actualGroup; -} - -QColor ColorScopeAttached::textColor() const -{ - return m_theme->color(Plasma::Theme::TextColor, colorGroup()); -} - -QColor ColorScopeAttached::highlightColor() const -{ - return m_theme->color(Plasma::Theme::HighlightColor, colorGroup()); -} - -QColor ColorScopeAttached::highlightedTextColor() const -{ - return m_theme->color(Plasma::Theme::HighlightedTextColor, colorGroup()); -} - -QColor ColorScopeAttached::backgroundColor() const -{ - return m_theme->color(Plasma::Theme::BackgroundColor, colorGroup()); -} - -QColor ColorScopeAttached::positiveTextColor() const -{ - return m_theme->color(Plasma::Theme::PositiveTextColor, colorGroup()); -} - -QColor ColorScopeAttached::neutralTextColor() const -{ - return m_theme->color(Plasma::Theme::NeutralTextColor, colorGroup()); -} - -QColor ColorScopeAttached::negativeTextColor() const -{ - return m_theme->color(Plasma::Theme::NegativeTextColor, colorGroup()); -} - -QColor ColorScopeAttached::disabledTextColor() const -{ - return m_theme->color(Plasma::Theme::DisabledTextColor, colorGroup()); -} - -bool ColorScopeAttached::inherit() const -{ - return m_inherit; -} -void ColorScopeAttached::setInherit(bool inherit) -{ - if (m_inherit == inherit) { - return; + if (m_parentScope) { + disconnect(m_parentScope.data(), &ColorScope::colorGroupChanged, + this, &ColorScope::checkColorGroupChanged); } - m_inherit = inherit; - emit inheritChanged(); - checkColorGroupChanged(); -} -void ColorScopeAttached::checkColorGroupChanged() -{ - const auto last = m_actualGroup; - if (m_inherit) { - findParentScope(); - m_actualGroup = m_parentScope ? m_parentScope->colorGroup() : m_group; - } else { - m_actualGroup = m_group; - } + m_parentScope = parentScope; - if (m_actualGroup != last) { - Q_EMIT colorGroupChanged(); + if (parentScope) { + connect(parentScope, &ColorScope::colorGroupChanged, + this, &ColorScope::checkColorGroupChanged); } } -ColorScopeAttached *ColorScopeAttached::findParentScope() +ColorScope *ColorScope::findParentScope() { - QObject *candidate = parent(); + QObject *candidate = parentItem(); + if (!candidate) { + candidate = parent(); + } while (candidate) { auto *quickCandidate = qobject_cast(candidate); if (quickCandidate && quickCandidate->parentItem()) { candidate = quickCandidate->parentItem(); } else { candidate = candidate->parent(); } - // Make sure AppletInterface always has a ColorScopeAttached - ColorScopeAttached *s = static_cast(qmlAttachedPropertiesObject(candidate, qobject_cast(candidate))); - + ColorScope *s = qobject_cast(candidate); + if (!s) { + // Make sure AppletInterface always has a ColorScope + s = static_cast(qmlAttachedPropertiesObject(candidate, qobject_cast(candidate))); + } if (s && !s->m_deleting) { setParentScope(s); return s; } } return nullptr; } - -///////////////////////////////////////////////////// - - -ColorScope::ColorScope(QQuickItem *parent) - : QQuickItem(parent) +void ColorScope::setColorGroup(Plasma::Theme::ColorGroup group) { - m_ownAttached = qobject_cast(qmlAttachedPropertiesObject(this, true)); - - connect(m_ownAttached, &ColorScopeAttached::colorGroupChanged, - this, &ColorScope::colorGroupChanged); - connect(m_ownAttached, &ColorScopeAttached::colorsChanged, - this, &ColorScope::colorsChanged); - connect(m_ownAttached, &ColorScopeAttached::inheritChanged, - this, &ColorScope::inheritChanged); -} + if (m_group == group) { + return; + } -ColorScope::~ColorScope() -{} + m_group = group; -void ColorScope::setColorGroup(Plasma::Theme::ColorGroup group) -{ - m_ownAttached->setColorGroup(group); + checkColorGroupChanged(); } Plasma::Theme::ColorGroup ColorScope::colorGroup() const { - return m_ownAttached->colorGroup(); + return m_actualGroup; } QColor ColorScope::textColor() const { - return m_ownAttached->textColor(); + return m_theme->color(Plasma::Theme::TextColor, colorGroup()); } QColor ColorScope::highlightColor() const { - return m_ownAttached->highlightColor(); + return m_theme->color(Plasma::Theme::HighlightColor, colorGroup()); } QColor ColorScope::highlightedTextColor() const { - return m_ownAttached->highlightedTextColor(); + return m_theme->color(Plasma::Theme::HighlightedTextColor, colorGroup()); } QColor ColorScope::backgroundColor() const { - return m_ownAttached->backgroundColor(); + return m_theme->color(Plasma::Theme::BackgroundColor, colorGroup()); } QColor ColorScope::positiveTextColor() const { - return m_ownAttached->positiveTextColor(); + return m_theme->color(Plasma::Theme::PositiveTextColor, colorGroup()); } QColor ColorScope::neutralTextColor() const { - return m_ownAttached->neutralTextColor(); + return m_theme->color(Plasma::Theme::NeutralTextColor, colorGroup()); } QColor ColorScope::negativeTextColor() const { - return m_ownAttached->negativeTextColor(); + return m_theme->color(Plasma::Theme::NegativeTextColor, colorGroup()); } QColor ColorScope::disabledTextColor() const { - return m_ownAttached->disabledTextColor(); + return m_theme->color(Plasma::Theme::DisabledTextColor, colorGroup()); } bool ColorScope::inherit() const { - return m_ownAttached->inherit(); + return m_inherit; } void ColorScope::setInherit(bool inherit) { - m_ownAttached->setInherit(inherit); + if (m_inherit == inherit) { + return; + } + m_inherit = inherit; + emit inheritChanged(); + checkColorGroupChanged(); } void ColorScope::itemChange(ItemChange change, const ItemChangeData &value) { if (change == QQuickItem::ItemSceneChange) { //we have a window: create the representations if needed if (value.window) { - m_ownAttached->findParentScope(); - m_ownAttached->checkColorGroupChanged(); + findParentScope(); + checkColorGroupChanged(); } } QQuickItem::itemChange(change, value); } -ColorScopeAttached *ColorScope::qmlAttachedProperties(QObject *object) +void ColorScope::checkColorGroupChanged() { - const auto cs = ColorScopeAttached::s_attachedScopes.value(object); - if (cs) { - return cs; + const auto last = m_actualGroup; + if (m_inherit) { + findParentScope(); + m_actualGroup = m_parentScope ? m_parentScope->colorGroup() : m_group; + } else { + m_actualGroup = m_group; } - ColorScopeAttached *s = new ColorScopeAttached(object); - ColorScopeAttached::s_attachedScopes[object] = s; - s->m_inherit = true; - s->setParent(object); - s->checkColorGroupChanged(); - - return s; + if (m_actualGroup != last) { + Q_EMIT colorGroupChanged(); + } } #include "moc_colorscope.cpp" diff --git a/src/declarativeimports/core/colorscope.h b/src/declarativeimports/core/colorscope.h index 19531cb23..3d9bddec8 100644 --- a/src/declarativeimports/core/colorscope.h +++ b/src/declarativeimports/core/colorscope.h @@ -1,238 +1,147 @@ /*************************************************************************** * Copyright 2014 Marco Martin * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #ifndef COLORSCOPE_H #define COLORSCOPE_H #include #include #include #include #include #include class QQuickItem; -class ColorScope; - -class ColorScopeAttached : public QObject -{ - Q_OBJECT - - /** - * Specifies the color group to use for this ColorScope - */ - Q_PROPERTY(Plasma::Theme::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged) - - /** - * The main foreground color within this colorscope - */ - Q_PROPERTY(QColor textColor READ textColor NOTIFY colorsChanged) - - /** - * The highlight color within this colorscope - */ - Q_PROPERTY(QColor highlightColor READ highlightColor NOTIFY colorsChanged) - - /** - * The highlighted text color within this colorscope - */ - Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor NOTIFY colorsChanged) - - /** - * The background color that should be used within this colorscope - */ - Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY colorsChanged) - - /** - * Color of foreground objects with a "positive message" connotation (usually green) - */ - Q_PROPERTY(QColor positiveTextColor READ positiveTextColor NOTIFY colorsChanged) - - /** - * Color of foreground objects with a "neutral message" connotation (usually yellow) - */ - Q_PROPERTY(QColor neutralTextColor READ neutralTextColor NOTIFY colorsChanged) - - /** - * Color of foreground objects with a "negative message" connotation (usually red) - */ - Q_PROPERTY(QColor negativeTextColor READ negativeTextColor NOTIFY colorsChanged) - - /** - * Color of disabled text @since 5.64 - */ - Q_PROPERTY(QColor disabledTextColor READ disabledTextColor NOTIFY colorsChanged) - - /** - * true if the scope inherits from its parent scope - * @since 5.39 - */ - Q_PROPERTY(bool inherit READ inherit WRITE setInherit NOTIFY inheritChanged) - -public: - ColorScopeAttached(QObject *parent); - ~ColorScopeAttached(); - - void setColorGroup(Plasma::Theme::ColorGroup group); - Plasma::Theme::ColorGroup colorGroup() const; - - QColor textColor() const; - QColor highlightColor() const; - QColor highlightedTextColor() const; - QColor backgroundColor() const; - QColor positiveTextColor() const; - QColor neutralTextColor() const; - QColor negativeTextColor() const; - QColor disabledTextColor() const; - - bool inherit() const; - void setInherit(bool inherit); - -/// @endcond - - ColorScopeAttached *findParentScope(); - - void checkColorGroupChanged(); - -Q_SIGNALS: - void colorGroupChanged(); - void colorsChanged(); - void inheritChanged(); - -private: - - void setParentScope(ColorScopeAttached * parentScope); - - bool m_inherit; - Plasma::Theme::ColorGroup m_group; - QPointer m_parentScope; - QObject *const m_parent; - Plasma::Theme::ColorGroup m_actualGroup; - bool m_deleting = false; - - static QHash s_attachedScopes; - - static QWeakPointer s_theme; - QSharedPointer m_theme; - friend class ColorScope; -}; /** * @class ColorScope * * @short Sets the colour scheme to be used by all child items * * It is exposed as org.kde.plasma.core.ColorScope */ class ColorScope : public QQuickItem { Q_OBJECT /** * Specifies the color group to use for this ColorScope */ Q_PROPERTY(Plasma::Theme::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged) /** * The main foreground color within this colorscope */ Q_PROPERTY(QColor textColor READ textColor NOTIFY colorsChanged) /** * The highlight color within this colorscope */ Q_PROPERTY(QColor highlightColor READ highlightColor NOTIFY colorsChanged) /** * The highlighted text color within this colorscope */ Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor NOTIFY colorsChanged) /** * The background color that should be used within this colorscope */ Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY colorsChanged) /** * Color of foreground objects with a "positive message" connotation (usually green) */ Q_PROPERTY(QColor positiveTextColor READ positiveTextColor NOTIFY colorsChanged) /** * Color of foreground objects with a "neutral message" connotation (usually yellow) */ Q_PROPERTY(QColor neutralTextColor READ neutralTextColor NOTIFY colorsChanged) /** * Color of foreground objects with a "negative message" connotation (usually red) */ Q_PROPERTY(QColor negativeTextColor READ negativeTextColor NOTIFY colorsChanged) /** * Color of disabled text @since 5.64 */ Q_PROPERTY(QColor disabledTextColor READ disabledTextColor NOTIFY colorsChanged) /** * true if the scope inherits from its parent scope * @since 5.39 */ Q_PROPERTY(bool inherit READ inherit WRITE setInherit NOTIFY inheritChanged) public: /// @cond INTERNAL_DOCS - explicit ColorScope(QQuickItem *parent = nullptr); + explicit ColorScope(QQuickItem *parent = nullptr, QObject *parentObject = nullptr); ~ColorScope() override; void setColorGroup(Plasma::Theme::ColorGroup group); Plasma::Theme::ColorGroup colorGroup() const; QColor textColor() const; QColor highlightColor() const; QColor highlightedTextColor() const; QColor backgroundColor() const; QColor positiveTextColor() const; QColor neutralTextColor() const; QColor negativeTextColor() const; QColor disabledTextColor() const; bool inherit() const; void setInherit(bool inherit); ////NEEDED BY QML TO CREATE ATTACHED PROPERTIES - static ColorScopeAttached *qmlAttachedProperties(QObject *object); + static ColorScope *qmlAttachedProperties(QObject *object); /// @endcond ColorScope *findParentScope(); void itemChange(ItemChange change, const ItemChangeData &value) override; Q_SIGNALS: void colorGroupChanged(); void colorsChanged(); void inheritChanged(); private: - ColorScopeAttached *m_ownAttached; + void checkColorGroupChanged(); + void setParentScope(ColorScope * parentScope); + + bool m_inherit; + Plasma::Theme::ColorGroup m_group; + QPointer m_parentScope; + QObject *const m_parent; + Plasma::Theme::ColorGroup m_actualGroup; + bool m_deleting = false; + + static QHash s_attachedScopes; + + static QWeakPointer s_theme; + QSharedPointer m_theme; }; QML_DECLARE_TYPEINFO(ColorScope, QML_HAS_ATTACHED_PROPERTIES) #endif diff --git a/src/declarativeimports/plasmacomponents3/Button.qml b/src/declarativeimports/plasmacomponents3/Button.qml index 4d2316fd8..83ff82276 100644 --- a/src/declarativeimports/plasmacomponents3/Button.qml +++ b/src/declarativeimports/plasmacomponents3/Button.qml @@ -1,118 +1,117 @@ /* * Copyright 2016 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.6 import QtQuick.Layouts 1.2 import QtQuick.Templates @QQC2_VERSION@ as T import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.kirigami 2.5 as Kirigami import "private" as Private T.Button { id: control implicitWidth: Math.max(background.implicitWidth, contentItem.implicitWidth + leftPadding + rightPadding) implicitHeight: Math.max(background.implicitHeight, contentItem.implicitHeight + topPadding + bottomPadding) leftPadding: surfaceNormal.margins.left topPadding: surfaceNormal.margins.top rightPadding: surfaceNormal.margins.right bottomPadding: surfaceNormal.margins.bottom hoverEnabled: !Kirigami.Settings.tabletMode Kirigami.MnemonicData.enabled: control.enabled && control.visible Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.SecondaryControl Kirigami.MnemonicData.label: control.text - contentItem: GridLayout { - columns: control.display == T.AbstractButton.TextBesideIcon ? 2 : 1 + contentItem: RowLayout { PlasmaCore.IconItem { id: icon Layout.fillWidth: true Layout.fillHeight: true colorGroup: PlasmaCore.Theme.ButtonColorGroup visible: source.length > 0 source: control.icon ? (control.icon.name || control.icon.source) : "" status: buttonSvg.hasElement("hint-focus-highlighted-background") && control.activeFocus && !control.pressed && !control.checked ? PlasmaCore.Svg.Selected : PlasmaCore.Svg.Normal } Label { Layout.fillWidth: true Layout.fillHeight: true visible: text.length > 0 text: control.Kirigami.MnemonicData.richTextLabel font: control.font opacity: enabled || control.highlighted || control.checked ? 1 : 0.4 color: buttonSvg.hasElement("hint-focus-highlighted-background") && control.activeFocus && !control.down ? theme.highlightedTextColor : theme.buttonTextColor horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter elide: Text.ElideRight } } background: Item { //retrocompatibility with old controls implicitHeight: units.gridUnit * 1.6 Private.ButtonShadow { anchors.fill: parent visible: (!control.flat || control.hovered) && (!control.pressed || !control.checked) state: { if (control.pressed) { return "hidden" } else if (control.hovered) { return "hover" } else if (control.activeFocus) { return "focus" } else { return "shadow" } } } PlasmaCore.Svg { id: buttonSvg imagePath: "widgets/button" } PlasmaCore.FrameSvgItem { id: surfaceNormal anchors.fill: parent imagePath: "widgets/button" prefix: control.activeFocus ? ["focus-background", "normal"] : "normal" opacity: (!control.flat || control.hovered) && (!control.pressed || !control.checked) ? 1 : 0 Behavior on opacity { OpacityAnimator { duration: units.longDuration easing.type: Easing.InOutQuad } } } PlasmaCore.FrameSvgItem { anchors.fill: parent imagePath: "widgets/button" prefix: "pressed" opacity: control.checked || control.pressed ? 1 : 0 Behavior on opacity { OpacityAnimator { duration: units.longDuration easing.type: Easing.InOutQuad } } } } } diff --git a/src/declarativeimports/plasmacomponents3/TabButton.qml b/src/declarativeimports/plasmacomponents3/TabButton.qml index edb269937..d9fccb254 100644 --- a/src/declarativeimports/plasmacomponents3/TabButton.qml +++ b/src/declarativeimports/plasmacomponents3/TabButton.qml @@ -1,69 +1,68 @@ /* * Copyright 2016 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.6 import QtQuick.Layouts 1.2 import QtQuick.Controls @QQC2_VERSION@ import QtQml.Models 2.1 import QtQuick.Templates @QQC2_VERSION@ as T import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.kirigami 2.5 as Kirigami T.TabButton { id: control implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding implicitHeight: contentItem.implicitHeight + topPadding + bottomPadding baselineOffset: contentItem.y + contentItem.baselineOffset padding: units.smallSpacing hoverEnabled: true Kirigami.MnemonicData.enabled: control.enabled && control.visible Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.SecondaryControl Kirigami.MnemonicData.label: control.text contentItem: GridLayout { columns: control.display == T.AbstractButton.TextBesideIcon ? 2 : 1 PlasmaCore.IconItem { id: icon Layout.fillWidth: true Layout.fillHeight: true colorGroup: PlasmaCore.Theme.ButtonColorGroup visible: source.length > 0 source: control.icon ? (control.icon.name || control.icon.source) : "" status: buttonSvg.hasElement("hint-focus-highlighted-background") && control.activeFocus && !control.pressed && !control.checked ? PlasmaCore.Svg.Selected : PlasmaCore.Svg.Normal } Label { Layout.fillWidth: true Layout.fillHeight: true visible: text.length > 0 text: control.Kirigami.MnemonicData.richTextLabel font: control.font opacity: enabled || control.highlighted || control.checked ? 1 : 0.4 color: buttonSvg.hasElement("hint-focus-highlighted-background") && control.activeFocus && !control.down ? theme.highlightedTextColor : theme.buttonTextColor horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter elide: Text.ElideRight } - } background: Item {} }