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
This commit is contained in:
Marco Martin 2020-02-14 12:33:13 +01:00
parent 1ed47e7c41
commit 3de1c2462e
3 changed files with 18 additions and 7 deletions

View File

@ -45,8 +45,12 @@ T.Button {
contentItem: RowLayout { contentItem: RowLayout {
PlasmaCore.IconItem { PlasmaCore.IconItem {
id: icon 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 colorGroup: PlasmaCore.Theme.ButtonColorGroup
visible: source.length > 0 visible: source.length > 0
source: control.icon ? (control.icon.name || control.icon.source) : "" source: control.icon ? (control.icon.name || control.icon.source) : ""

View File

@ -44,8 +44,12 @@ T.TabButton {
columns: control.display == T.AbstractButton.TextBesideIcon ? 2 : 1 columns: control.display == T.AbstractButton.TextBesideIcon ? 2 : 1
PlasmaCore.IconItem { PlasmaCore.IconItem {
id: icon 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 colorGroup: PlasmaCore.Theme.ButtonColorGroup
visible: source.length > 0 visible: source.length > 0
source: control.icon ? (control.icon.name || control.icon.source) : "" source: control.icon ? (control.icon.name || control.icon.source) : ""
@ -58,7 +62,6 @@ T.TabButton {
text: control.Kirigami.MnemonicData.richTextLabel text: control.Kirigami.MnemonicData.richTextLabel
font: control.font font: control.font
opacity: enabled || control.highlighted || control.checked ? 1 : 0.4 opacity: enabled || control.highlighted || control.checked ? 1 : 0.4
color: control.activeFocus && !control.down ? theme.highlightedTextColor : theme.buttonTextColor
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight elide: Text.ElideRight

View File

@ -49,8 +49,12 @@ T.ToolButton {
columns: control.display == T.AbstractButton.TextBesideIcon ? 2 : 1 columns: control.display == T.AbstractButton.TextBesideIcon ? 2 : 1
PlasmaCore.IconItem { PlasmaCore.IconItem {
id: icon 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 colorGroup: PlasmaCore.Theme.ButtonColorGroup
visible: source.length > 0 visible: source.length > 0
source: control.icon ? (control.icon.name || control.icon.source) : "" source: control.icon ? (control.icon.name || control.icon.source) : ""