Changeset View
Changeset View
Standalone View
Standalone View
org.kde.desktop/SwitchDelegate.qml
Show All 15 Lines | |||||
16 | * Software Foundation and appearing in the file LICENSE.GPL included in | 16 | * Software Foundation and appearing in the file LICENSE.GPL included in | ||
17 | * the packaging of this file. Please review the following information to | 17 | * the packaging of this file. Please review the following information to | ||
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.5 | 23 | import QtQuick 2.5 | ||
24 | import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate | 24 | import org.kde.kirigami 2.2 as Kirigami | ||
25 | import QtQuick.Templates 2.0 as T | 25 | import QtQuick.Templates 2.0 as T | ||
26 | import "private" | 26 | import "private" | ||
27 | 27 | | |||
28 | T.SwitchDelegate { | 28 | T.SwitchDelegate { | ||
29 | id: controlRoot | 29 | id: controlRoot | ||
30 | 30 | | |||
31 | implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding | 31 | implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding | ||
32 | implicitHeight: Math.max(contentItem.implicitHeight, | 32 | implicitHeight: Math.max(contentItem.implicitHeight, | ||
33 | indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding | 33 | indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding | ||
34 | hoverEnabled: true | 34 | hoverEnabled: true | ||
35 | 35 | | |||
36 | padding: 4 | 36 | padding: 4 | ||
37 | spacing: 4 | 37 | spacing: 4 | ||
38 | rightPadding: 20 | 38 | rightPadding: 20 | ||
39 | 39 | | |||
40 | contentItem: Label { | 40 | contentItem: Label { | ||
41 | leftPadding: controlRoot.mirrored ? (controlRoot.indicator ? controlRoot.indicator.width : 0) + controlRoot.spacing : 0 | 41 | leftPadding: controlRoot.mirrored ? (controlRoot.indicator ? controlRoot.indicator.width : 0) + controlRoot.spacing : 0 | ||
42 | rightPadding: !controlRoot.mirrored ? (controlRoot.indicator ? controlRoot.indicator.width : 0) + controlRoot.spacing : 0 | 42 | rightPadding: !controlRoot.mirrored ? (controlRoot.indicator ? controlRoot.indicator.width : 0) + controlRoot.spacing : 0 | ||
43 | 43 | | |||
44 | text: controlRoot.text | 44 | text: controlRoot.text | ||
45 | font: controlRoot.font | 45 | font: controlRoot.font | ||
46 | color: (controlRoot.pressed && !controlRoot.checked && !controlRoot.sectionDelegate) ? StylePrivate.SystemPaletteSingleton.highlightedText(controlRoot.enabled) : StylePrivate.SystemPaletteSingleton.text(controlRoot.enabled) | 46 | color: (controlRoot.pressed && !controlRoot.checked && !controlRoot.sectionDelegate) ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor | ||
47 | elide: Text.ElideRight | 47 | elide: Text.ElideRight | ||
48 | visible: controlRoot.text | 48 | visible: controlRoot.text | ||
49 | horizontalAlignment: Text.AlignLeft | 49 | horizontalAlignment: Text.AlignLeft | ||
50 | verticalAlignment: Text.AlignVCenter | 50 | verticalAlignment: Text.AlignVCenter | ||
51 | } | 51 | } | ||
52 | 52 | | |||
53 | indicator: SwitchIndicator { | 53 | indicator: SwitchIndicator { | ||
54 | x: controlRoot.mirrored ? controlRoot.leftPadding : controlRoot.width - width - controlRoot.rightPadding | 54 | x: controlRoot.mirrored ? controlRoot.leftPadding : controlRoot.width - width - controlRoot.rightPadding | ||
55 | y: controlRoot.topPadding + (controlRoot.availableHeight - height) / 2 | 55 | y: controlRoot.topPadding + (controlRoot.availableHeight - height) / 2 | ||
56 | 56 | | |||
57 | control: controlRoot | 57 | control: controlRoot | ||
58 | } | 58 | } | ||
59 | 59 | | |||
60 | background: DefaultListItemBackground {} | 60 | background: DefaultListItemBackground {} | ||
61 | } | 61 | } |