diff --git a/src/declarativeimports/core/colorscope.cpp b/src/declarativeimports/core/colorscope.cpp index 3c6de03ea..e7e6872c8 100644 --- a/src/declarativeimports/core/colorscope.cpp +++ b/src/declarativeimports/core/colorscope.cpp @@ -1,239 +1,313 @@ /*************************************************************************** * 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 ColorScope::s_attachedScopes = QHash(); +QHash ColorScopeAttached::s_attachedScopes = QHash(); -QWeakPointer ColorScope::s_theme; +QWeakPointer ColorScopeAttached::s_theme; -ColorScope::ColorScope(QQuickItem *parent, QObject *parentObject) - : QQuickItem(parent), +ColorScopeAttached::ColorScopeAttached(QObject *parent) + : QObject(parent), m_inherit(false), m_group(Plasma::Theme::NormalColorGroup), - m_parent(parentObject), + m_parent(parent), 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, &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); + 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); } + findParentScope(); } -ColorScope::~ColorScope() +ColorScopeAttached::~ColorScopeAttached() { m_deleting = true; s_attachedScopes.remove(m_parent); } -ColorScope *ColorScope::qmlAttachedProperties(QObject *object) +void ColorScopeAttached::setParentScope(ColorScopeAttached* parentScope) { - const auto cs = s_attachedScopes.value(object); - if (cs) { - return cs; + if (parentScope == m_parentScope) + return; + + if (m_parentScope) { + disconnect(m_parentScope.data(), &ColorScopeAttached::colorGroupChanged, + this, &ColorScopeAttached::checkColorGroupChanged); } - ColorScope *s = new ColorScope(nullptr, object); - s_attachedScopes[object] = s; - s->m_inherit = true; - s->setParent(object); - s->checkColorGroupChanged(); + m_parentScope = parentScope; - return s; + if (parentScope) { + connect(parentScope, &ColorScopeAttached::colorGroupChanged, + this, &ColorScopeAttached::checkColorGroupChanged); + } } -void ColorScope::setParentScope(ColorScope* parentScope) +void ColorScopeAttached::setColorGroup(Plasma::Theme::ColorGroup group) { - if (parentScope == m_parentScope) + if (m_group == group) { return; - - if (m_parentScope) { - disconnect(m_parentScope.data(), &ColorScope::colorGroupChanged, - this, &ColorScope::checkColorGroupChanged); } - m_parentScope = parentScope; + m_group = group; - if (parentScope) { - connect(parentScope, &ColorScope::colorGroupChanged, - this, &ColorScope::checkColorGroupChanged); + 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; } + m_inherit = inherit; + emit inheritChanged(); + checkColorGroupChanged(); } -ColorScope *ColorScope::findParentScope() +void ColorScopeAttached::checkColorGroupChanged() { - QObject *candidate = parentItem(); - if (!candidate) { - candidate = parent(); + const auto last = m_actualGroup; + if (m_inherit) { + findParentScope(); + m_actualGroup = m_parentScope ? m_parentScope->colorGroup() : m_group; + } else { + m_actualGroup = m_group; + } + + if (m_actualGroup != last) { + Q_EMIT colorGroupChanged(); } +} + +ColorScopeAttached *ColorScopeAttached::findParentScope() +{ + QObject *candidate = parent(); while (candidate) { auto *quickCandidate = qobject_cast(candidate); if (quickCandidate && quickCandidate->parentItem()) { candidate = quickCandidate->parentItem(); } else { candidate = candidate->parent(); } - ColorScope *s = qobject_cast(candidate); - if (!s) { - // Make sure AppletInterface always has a ColorScope - s = static_cast(qmlAttachedPropertiesObject(candidate, qobject_cast(candidate))); - } + // Make sure AppletInterface always has a ColorScopeAttached + ColorScopeAttached *s = static_cast(qmlAttachedPropertiesObject(candidate, qobject_cast(candidate))); + if (s && !s->m_deleting) { setParentScope(s); return s; } } return nullptr; } -void ColorScope::setColorGroup(Plasma::Theme::ColorGroup group) + +///////////////////////////////////////////////////// + + +ColorScope::ColorScope(QQuickItem *parent) + : QQuickItem(parent) { - if (m_group == group) { - return; - } + 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); +} - m_group = group; +ColorScope::~ColorScope() +{} - checkColorGroupChanged(); +void ColorScope::setColorGroup(Plasma::Theme::ColorGroup group) +{ + m_ownAttached->setColorGroup(group); } Plasma::Theme::ColorGroup ColorScope::colorGroup() const { - return m_actualGroup; + return m_ownAttached->colorGroup(); } QColor ColorScope::textColor() const { - return m_theme->color(Plasma::Theme::TextColor, colorGroup()); + return m_ownAttached->textColor(); } QColor ColorScope::highlightColor() const { - return m_theme->color(Plasma::Theme::HighlightColor, colorGroup()); + return m_ownAttached->highlightColor(); } QColor ColorScope::highlightedTextColor() const { - return m_theme->color(Plasma::Theme::HighlightedTextColor, colorGroup()); + return m_ownAttached->highlightedTextColor(); } QColor ColorScope::backgroundColor() const { - return m_theme->color(Plasma::Theme::BackgroundColor, colorGroup()); + return m_ownAttached->backgroundColor(); } QColor ColorScope::positiveTextColor() const { - return m_theme->color(Plasma::Theme::PositiveTextColor, colorGroup()); + return m_ownAttached->positiveTextColor(); } QColor ColorScope::neutralTextColor() const { - return m_theme->color(Plasma::Theme::NeutralTextColor, colorGroup()); + return m_ownAttached->neutralTextColor(); } QColor ColorScope::negativeTextColor() const { - return m_theme->color(Plasma::Theme::NegativeTextColor, colorGroup()); + return m_ownAttached->negativeTextColor(); } QColor ColorScope::disabledTextColor() const { - return m_theme->color(Plasma::Theme::DisabledTextColor, colorGroup()); + return m_ownAttached->disabledTextColor(); } bool ColorScope::inherit() const { - return m_inherit; + return m_ownAttached->inherit(); } void ColorScope::setInherit(bool inherit) { - if (m_inherit == inherit) { - return; - } - m_inherit = inherit; - emit inheritChanged(); - checkColorGroupChanged(); + m_ownAttached->setInherit(inherit); } void ColorScope::itemChange(ItemChange change, const ItemChangeData &value) { if (change == QQuickItem::ItemSceneChange) { //we have a window: create the representations if needed if (value.window) { - findParentScope(); - checkColorGroupChanged(); + m_ownAttached->findParentScope(); + m_ownAttached->checkColorGroupChanged(); } } QQuickItem::itemChange(change, value); } -void ColorScope::checkColorGroupChanged() +ColorScopeAttached *ColorScope::qmlAttachedProperties(QObject *object) { - const auto last = m_actualGroup; - if (m_inherit) { - findParentScope(); - m_actualGroup = m_parentScope ? m_parentScope->colorGroup() : m_group; - } else { - m_actualGroup = m_group; + const auto cs = ColorScopeAttached::s_attachedScopes.value(object); + if (cs) { + return cs; } - if (m_actualGroup != last) { - Q_EMIT colorGroupChanged(); - } + ColorScopeAttached *s = new ColorScopeAttached(object); + ColorScopeAttached::s_attachedScopes[object] = s; + s->m_inherit = true; + s->setParent(object); + s->checkColorGroupChanged(); + + return s; } #include "moc_colorscope.cpp" diff --git a/src/declarativeimports/core/colorscope.h b/src/declarativeimports/core/colorscope.h index 3d9bddec8..19531cb23 100644 --- a/src/declarativeimports/core/colorscope.h +++ b/src/declarativeimports/core/colorscope.h @@ -1,147 +1,238 @@ /*************************************************************************** * 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, QObject *parentObject = nullptr); + explicit ColorScope(QQuickItem *parent = 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 ColorScope *qmlAttachedProperties(QObject *object); + static ColorScopeAttached *qmlAttachedProperties(QObject *object); /// @endcond ColorScope *findParentScope(); void itemChange(ItemChange change, const ItemChangeData &value) override; Q_SIGNALS: void colorGroupChanged(); void colorsChanged(); void inheritChanged(); private: - 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; + ColorScopeAttached *m_ownAttached; }; QML_DECLARE_TYPEINFO(ColorScope, QML_HAS_ATTACHED_PROPERTIES) #endif diff --git a/src/declarativeimports/plasmacomponents3/Button.qml b/src/declarativeimports/plasmacomponents3/Button.qml index 83ff82276..4d2316fd8 100644 --- a/src/declarativeimports/plasmacomponents3/Button.qml +++ b/src/declarativeimports/plasmacomponents3/Button.qml @@ -1,117 +1,118 @@ /* * 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: RowLayout { + 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 { //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 af892f3a6..ec3d13f64 100644 --- a/src/declarativeimports/plasmacomponents3/TabButton.qml +++ b/src/declarativeimports/plasmacomponents3/TabButton.qml @@ -1,48 +1,63 @@ /* * 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.Controls @QQC2_VERSION@ import QtQml.Models 2.1 import QtQuick.Templates @QQC2_VERSION@ as T import org.kde.plasma.core 2.0 as PlasmaCore T.TabButton { id: control implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding implicitHeight: contentItem.implicitHeight + topPadding + bottomPadding baselineOffset: contentItem.y + contentItem.baselineOffset padding: units.smallSpacing hoverEnabled: true - contentItem: Label { - text: control.text - font: control.font - elide: Text.ElideRight - opacity: enabled ? 1 : 0.3 - color: PlasmaCore.ColorScope.textColor - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter + 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 {} }