Changeset View
Changeset View
Standalone View
Standalone View
src/declarativeimports/plasmacomponents3/ToolButton.qml
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 28 | T.ToolButton { | |||
---|---|---|---|---|---|
45 | 45 | | |||
46 | flat: true | 46 | flat: true | ||
47 | 47 | | |||
48 | contentItem: GridLayout { | 48 | contentItem: GridLayout { | ||
49 | columns: control.display == T.AbstractButton.TextBesideIcon ? 2 : 1 | 49 | columns: control.display == T.AbstractButton.TextBesideIcon ? 2 : 1 | ||
50 | PlasmaCore.IconItem { | 50 | PlasmaCore.IconItem { | ||
51 | id: icon | 51 | id: icon | ||
52 | 52 | | |||
53 | Layout.fillWidth: control.icon.width <= 0 | 53 | Layout.alignment: Qt.AlignCenter | ||
54 | Layout.fillHeight: control.icon.height <= 0 | | |||
55 | Layout.preferredWidth: control.icon.width > 0 ? control.icon.width : units.iconSizes.smallMedium | 54 | Layout.preferredWidth: control.icon.width > 0 ? control.icon.width : units.iconSizes.smallMedium | ||
56 | Layout.preferredHeight: control.icon.height > 0 ? control.icon.height : units.iconSizes.smallMedium | 55 | Layout.preferredHeight: control.icon.height > 0 ? control.icon.height : units.iconSizes.smallMedium | ||
57 | 56 | | |||
58 | colorGroup: PlasmaCore.Theme.ButtonColorGroup | 57 | colorGroup: PlasmaCore.Theme.ButtonColorGroup | ||
59 | visible: source.length > 0 | 58 | visible: source.length > 0 | ||
60 | source: control.icon ? (control.icon.name || control.icon.source) : "" | 59 | source: control.icon ? (control.icon.name || control.icon.source) : "" | ||
61 | status: control.activeFocus && !control.pressed && !control.checked ? PlasmaCore.Svg.Selected : PlasmaCore.Svg.Normal | 60 | status: control.activeFocus && !control.pressed && !control.checked ? PlasmaCore.Svg.Selected : PlasmaCore.Svg.Normal | ||
62 | } | 61 | } | ||
63 | PlasmaCore.FrameSvgItem { | 62 | | ||
64 | id: buttonsurfaceChecker | | |||
65 | visible: false | | |||
66 | imagePath: "widgets/button" | | |||
67 | prefix: control.flat ? ["toolbutton-hover", "normal"] : "normal" | | |||
68 | } | | |||
69 | Label { | 63 | Label { | ||
70 | Layout.fillWidth: true | 64 | Layout.fillWidth: true | ||
71 | visible: text.length > 0 | 65 | visible: text.length > 0 | ||
72 | text: control.Kirigami.MnemonicData.richTextLabel | 66 | text: control.Kirigami.MnemonicData.richTextLabel | ||
73 | font: control.font | 67 | font: control.font | ||
74 | opacity: enabled || control.highlighted || control.checked ? 1 : 0.4 | 68 | opacity: enabled || control.highlighted || control.checked ? 1 : 0.4 | ||
75 | color: (control.hovered || !control.flat) && buttonsurfaceChecker.usedPrefix != "toolbutton-hover" ? theme.buttonTextColor : PlasmaCore.ColorScope.textColor | 69 | color: (control.hovered || !control.flat) && buttonsurfaceChecker.usedPrefix != "toolbutton-hover" ? theme.buttonTextColor : PlasmaCore.ColorScope.textColor | ||
76 | horizontalAlignment: Text.AlignHCenter | 70 | horizontalAlignment: Text.AlignHCenter | ||
77 | verticalAlignment: Text.AlignVCenter | 71 | verticalAlignment: Text.AlignVCenter | ||
78 | elide: Text.ElideRight | 72 | elide: Text.ElideRight | ||
73 | | ||||
74 | PlasmaCore.FrameSvgItem { | ||||
75 | id: buttonsurfaceChecker | ||||
76 | visible: false | ||||
77 | imagePath: "widgets/button" | ||||
78 | prefix: control.flat ? ["toolbutton-hover", "normal"] : "normal" | ||||
79 | } | ||||
79 | } | 80 | } | ||
80 | } | 81 | } | ||
81 | 82 | | |||
82 | background: Item { | 83 | background: Item { | ||
83 | //retrocompatibility with old controls | 84 | //retrocompatibility with old controls | ||
84 | implicitWidth: units.gridUnit * 1.6 | 85 | implicitWidth: Math.floor(units.gridUnit * 1.6) + Math.floor(units.gridUnit * 1.6) % 2 | ||
85 | implicitHeight: units.gridUnit * 1.6 | 86 | implicitHeight: implicitWidth | ||
86 | Private.ButtonShadow { | 87 | Private.ButtonShadow { | ||
87 | anchors.fill: parent | 88 | anchors.fill: parent | ||
88 | visible: (!control.flat || control.hovered) && (!control.pressed || !control.checked) | 89 | visible: (!control.flat || control.hovered) && (!control.pressed || !control.checked) | ||
89 | state: { | 90 | state: { | ||
90 | if (control.pressed) { | 91 | if (control.pressed) { | ||
91 | return "hidden" | 92 | return "hidden" | ||
92 | } else if (control.hovered) { | 93 | } else if (control.hovered) { | ||
93 | return "hover" | 94 | return "hover" | ||
Show All 34 Lines |