From 3de1c2462eda58048170b90277eae983c86edfd7 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 14 Feb 2020 12:33:13 +0100 Subject: [PATCH] support icon.width/height Summary: support the icon size hint of the control. Reinstate it in ToolButton and add the support for the other controls CCBUG:417514 Test Plan: possible to control buttons icon sizes mediacontroller taskbar tooltip with icons set to small: {F8103363} Reviewers: #plasma, broulik Reviewed By: #plasma, broulik Subscribers: broulik, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D27396 --- src/declarativeimports/plasmacomponents3/Button.qml | 8 ++++++-- src/declarativeimports/plasmacomponents3/TabButton.qml | 9 ++++++--- src/declarativeimports/plasmacomponents3/ToolButton.qml | 8 ++++++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/declarativeimports/plasmacomponents3/Button.qml b/src/declarativeimports/plasmacomponents3/Button.qml index 83ff82276..b642c029d 100644 --- a/src/declarativeimports/plasmacomponents3/Button.qml +++ b/src/declarativeimports/plasmacomponents3/Button.qml @@ -45,8 +45,12 @@ T.Button { contentItem: RowLayout { PlasmaCore.IconItem { id: icon - Layout.fillWidth: true - Layout.fillHeight: true + + Layout.fillWidth: control.icon.width <= 0 + Layout.fillHeight: control.icon.height <= 0 + Layout.preferredWidth: control.icon.width > 0 ? control.icon.width : units.iconSizes.small + Layout.preferredHeight: control.icon.height > 0 ? control.icon.height : units.iconSizes.small + colorGroup: PlasmaCore.Theme.ButtonColorGroup visible: source.length > 0 source: control.icon ? (control.icon.name || control.icon.source) : "" diff --git a/src/declarativeimports/plasmacomponents3/TabButton.qml b/src/declarativeimports/plasmacomponents3/TabButton.qml index bfa5c4df4..b500e808e 100644 --- a/src/declarativeimports/plasmacomponents3/TabButton.qml +++ b/src/declarativeimports/plasmacomponents3/TabButton.qml @@ -44,8 +44,12 @@ T.TabButton { columns: control.display == T.AbstractButton.TextBesideIcon ? 2 : 1 PlasmaCore.IconItem { id: icon - Layout.fillWidth: true - Layout.fillHeight: true + + Layout.fillWidth: control.icon.width <= 0 + Layout.fillHeight: control.icon.height <= 0 + Layout.preferredWidth: control.icon.width > 0 ? control.icon.width : units.iconSizes.smallMedium + Layout.preferredHeight: control.icon.height > 0 ? control.icon.height : units.iconSizes.smallMedium + colorGroup: PlasmaCore.Theme.ButtonColorGroup visible: source.length > 0 source: control.icon ? (control.icon.name || control.icon.source) : "" @@ -58,7 +62,6 @@ T.TabButton { text: control.Kirigami.MnemonicData.richTextLabel font: control.font opacity: enabled || control.highlighted || control.checked ? 1 : 0.4 - color: control.activeFocus && !control.down ? theme.highlightedTextColor : theme.buttonTextColor horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter elide: Text.ElideRight diff --git a/src/declarativeimports/plasmacomponents3/ToolButton.qml b/src/declarativeimports/plasmacomponents3/ToolButton.qml index 4949393d0..113a9c675 100644 --- a/src/declarativeimports/plasmacomponents3/ToolButton.qml +++ b/src/declarativeimports/plasmacomponents3/ToolButton.qml @@ -49,8 +49,12 @@ T.ToolButton { columns: control.display == T.AbstractButton.TextBesideIcon ? 2 : 1 PlasmaCore.IconItem { id: icon - Layout.fillWidth: true - Layout.fillHeight: true + + Layout.fillWidth: control.icon.width <= 0 + Layout.fillHeight: control.icon.height <= 0 + Layout.preferredWidth: control.icon.width > 0 ? control.icon.width : units.iconSizes.smallMedium + Layout.preferredHeight: control.icon.height > 0 ? control.icon.height : units.iconSizes.smallMedium + colorGroup: PlasmaCore.Theme.ButtonColorGroup visible: source.length > 0 source: control.icon ? (control.icon.name || control.icon.source) : ""