Changeset View
Changeset View
Standalone View
Standalone View
src/declarativeimports/plasmacomponents3/ToolButton.qml
Show All 18 Lines | |||||
19 | 19 | | |||
20 | import QtQuick 2.6 | 20 | import QtQuick 2.6 | ||
21 | import QtQuick.Layouts 1.2 | 21 | import QtQuick.Layouts 1.2 | ||
22 | import QtQuick.Templates @QQC2_VERSION@ as T | 22 | import QtQuick.Templates @QQC2_VERSION@ as T | ||
23 | import org.kde.plasma.core 2.0 as PlasmaCore | 23 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
24 | import org.kde.kirigami 2.5 as Kirigami | 24 | import org.kde.kirigami 2.5 as Kirigami | ||
25 | import "private" as Private | 25 | import "private" as Private | ||
26 | 26 | | |||
27 | | ||||
27 | T.ToolButton { | 28 | T.ToolButton { | ||
28 | id: control | 29 | id: control | ||
29 | 30 | | |||
30 | implicitWidth: Math.max(background.implicitWidth, | 31 | implicitWidth: Math.max(background.implicitWidth, | ||
31 | contentItem.implicitWidth + leftPadding + rightPadding) | 32 | contentItem.implicitWidth + leftPadding + rightPadding) | ||
32 | implicitHeight: Math.max(background.implicitHeight, contentItem.implicitHeight + topPadding + bottomPadding) | 33 | implicitHeight: Math.max(background.implicitHeight, contentItem.implicitHeight + topPadding + bottomPadding) | ||
33 | 34 | | |||
34 | leftPadding: surfaceNormal.margins.left | 35 | leftPadding: surfaceNormal.margins.left | ||
35 | topPadding: surfaceNormal.margins.top | 36 | topPadding: surfaceNormal.margins.top | ||
36 | rightPadding: surfaceNormal.margins.right | 37 | rightPadding: surfaceNormal.margins.right | ||
37 | bottomPadding: surfaceNormal.margins.bottom | 38 | bottomPadding: surfaceNormal.margins.bottom | ||
38 | 39 | | |||
39 | hoverEnabled: !Kirigami.Settings.tabletMode | 40 | hoverEnabled: !Kirigami.Settings.tabletMode | ||
40 | 41 | | |||
41 | Kirigami.MnemonicData.enabled: control.enabled && control.visible | 42 | Kirigami.MnemonicData.enabled: control.enabled && control.visible | ||
42 | Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.SecondaryControl | 43 | Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.SecondaryControl | ||
43 | Kirigami.MnemonicData.label: control.text | 44 | Kirigami.MnemonicData.label: control.text | ||
44 | 45 | | |||
45 | flat: true | 46 | flat: true | ||
46 | 47 | | |||
47 | contentItem: RowLayout { | 48 | contentItem: RowLayout { | ||
48 | PlasmaCore.IconItem { | 49 | PlasmaCore.IconItem { | ||
49 | Layout.fillWidth: true | 50 | id: icon | ||
50 | Layout.fillHeight: true | | |||
51 | colorGroup: PlasmaCore.ColorScope.colorGroup | | |||
52 | visible: source.length > 0 | 51 | visible: source.length > 0 | ||
52 | Layout.fillWidth: control.icon.width <= 0 | ||||
53 | Layout.fillHeight: control.icon.height <= 0 | ||||
54 | Layout.preferredWidth: control.icon.width > 0 ? control.icon.width : -1 | ||||
55 | Layout.preferredHeight: control.icon.height > 0 ? control.icon.height : -1 | ||||
56 | colorGroup: PlasmaCore.ColorScope.colorGroup | ||||
53 | source: control.icon ? (control.icon.name || control.icon.source) : "" | 57 | source: control.icon ? (control.icon.name || control.icon.source) : "" | ||
54 | } | 58 | } | ||
mart: this further item enclosing is not necessary, is an object instantation more for no functional… | |||||
55 | Label { | 59 | Label { | ||
56 | Layout.fillWidth: true | 60 | Layout.fillWidth: true | ||
57 | visible: text.length > 0 | 61 | visible: text.length > 0 | ||
58 | text: control.Kirigami.MnemonicData.richTextLabel | 62 | text: control.Kirigami.MnemonicData.richTextLabel | ||
59 | font: control.font | 63 | font: control.font | ||
60 | opacity: enabled || control.highlighted || control.checked ? 1 : 0.4 | 64 | opacity: enabled || control.highlighted || control.checked ? 1 : 0.4 | ||
This was ok as it was, including fillwidth/fillheight (perhaps) mart: This was ok as it was, including fillwidth/fillheight (perhaps)
but with the line:
Layout. | |||||
61 | color: theme.buttonTextColor | 65 | color: theme.buttonTextColor | ||
That's always the case, isn't it? if a parent isn't visible, an item will never be visible. apol: That's always the case, isn't it? if a parent isn't visible, an item will never be visible. | |||||
camiloh: yes. you're right. | |||||
This fixes the icons to a single size no matter what, and wether it fits or not, and is going to break badly any time a bigger or smaller buttons is needed, as shown by breaking media controller. I have to revert this now, the icon should scale only to "standard" sizes, but still scale with the button size. mart: This fixes the icons to a single size no matter what, and wether it fits or not, and is going… | |||||
62 | horizontalAlignment: Text.AlignHCenter | 66 | horizontalAlignment: Text.AlignHCenter | ||
63 | verticalAlignment: Text.AlignVCenter | 67 | verticalAlignment: Text.AlignVCenter | ||
64 | elide: Text.ElideRight | 68 | elide: Text.ElideRight | ||
65 | } | 69 | } | ||
66 | } | 70 | } | ||
67 | 71 | | |||
68 | background: Item { | 72 | background: Item { | ||
69 | visible: (!control.flat || control.hovered) && (!control.pressed || !control.checked) | 73 | visible: (!control.flat || control.hovered) && (!control.pressed || !control.checked) | ||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |
this further item enclosing is not necessary, is an object instantation more for no functional gain