Changeset View
Changeset View
Standalone View
Standalone View
org.kde.desktop/CheckBox.qml
Show All 17 Lines | |||||
18 | * ensure the GNU General Public License version 2.0 requirements will be | 18 | * ensure the GNU General Public License version 2.0 requirements will be | ||
19 | * met: http://www.gnu.org/licenses/gpl-2.0.html. | 19 | * met: http://www.gnu.org/licenses/gpl-2.0.html. | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | 22 | | |||
23 | import QtQuick 2.6 | 23 | import QtQuick 2.6 | ||
24 | import QtQuick.Templates @QQC2_VERSION@ as T | 24 | import QtQuick.Templates @QQC2_VERSION@ as T | ||
25 | import QtQuick.Controls @QQC2_VERSION@ | 25 | import QtQuick.Controls @QQC2_VERSION@ | ||
26 | import org.kde.kirigami 2.2 as Kirigami | 26 | import org.kde.kirigami 2.3 as Kirigami | ||
27 | 27 | | |||
28 | T.CheckBox { | 28 | T.CheckBox { | ||
29 | id: controlRoot | 29 | id: controlRoot | ||
30 | 30 | | |||
31 | implicitWidth: Math.max(background ? background.implicitWidth : 0, | 31 | implicitWidth: Math.max(background ? background.implicitWidth : 0, | ||
32 | contentItem.implicitWidth + leftPadding + rightPadding) | 32 | contentItem.implicitWidth + leftPadding + rightPadding) | ||
33 | implicitHeight: Math.max(background ? background.implicitHeight : 0, | 33 | implicitHeight: Math.max(background ? background.implicitHeight : 0, | ||
34 | Math.max(contentItem.implicitHeight, | 34 | Math.max(contentItem.implicitHeight, | ||
Show All 10 Lines | 43 | indicator: CheckIndicator { | |||
45 | LayoutMirroring.childrenInherit: true | 45 | LayoutMirroring.childrenInherit: true | ||
46 | anchors { | 46 | anchors { | ||
47 | left: parent.left | 47 | left: parent.left | ||
48 | verticalCenter: parent.verticalCenter | 48 | verticalCenter: parent.verticalCenter | ||
49 | } | 49 | } | ||
50 | control: controlRoot | 50 | control: controlRoot | ||
51 | } | 51 | } | ||
52 | 52 | | |||
53 | Kirigami.MnemonicData.enabled: controlRoot.enabled && controlRoot.visible | ||||
54 | Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.ActionElement | ||||
55 | Kirigami.MnemonicData.label: controlRoot.text | ||||
56 | Shortcut { | ||||
57 | //in case of explicit & the button manages it by itself | ||||
58 | enabled: !(RegExp(/\&[^\&]/).test(controlRoot.text)) | ||||
59 | sequence: controlRoot.Kirigami.MnemonicData.sequence | ||||
60 | onActivated: controlRoot.toggle(); | ||||
61 | } | ||||
62 | | ||||
53 | contentItem: Label { | 63 | contentItem: Label { | ||
54 | leftPadding: controlRoot.indicator && !controlRoot.mirrored ? controlRoot.indicator.width + controlRoot.spacing : 0 | 64 | leftPadding: controlRoot.indicator && !controlRoot.mirrored ? controlRoot.indicator.width + controlRoot.spacing : 0 | ||
55 | rightPadding: controlRoot.indicator && controlRoot.mirrored ? controlRoot.indicator.width + controlRoot.spacing : 0 | 65 | rightPadding: controlRoot.indicator && controlRoot.mirrored ? controlRoot.indicator.width + controlRoot.spacing : 0 | ||
56 | opacity: controlRoot.enabled ? 1 : 0.6 | 66 | opacity: controlRoot.enabled ? 1 : 0.6 | ||
57 | text: controlRoot.text | 67 | text: controlRoot.Kirigami.MnemonicData.richTextLabel | ||
58 | font: controlRoot.font | 68 | font: controlRoot.font | ||
59 | elide: Text.ElideRight | 69 | elide: Text.ElideRight | ||
60 | visible: controlRoot.text | 70 | visible: controlRoot.text | ||
61 | horizontalAlignment: Text.AlignLeft | 71 | horizontalAlignment: Text.AlignLeft | ||
62 | verticalAlignment: Text.AlignVCenter | 72 | verticalAlignment: Text.AlignVCenter | ||
63 | } | 73 | } | ||
64 | } | 74 | } |