on 1c84fce help sign in
unity8/qml/Wizard/CheckableSetting.qml
90 lines 2.5 kB history raw
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17import QtQuick 2.3
18import Ubuntu.Components 1.2
19import Ubuntu.Components.ListItems 1.0 as ListItem
21ListItem.Empty {
22 id: listItem
24 property alias text: label.text
25 property bool checked: false
26 property real leftMargin
27 property real rightMargin
29 readonly property real labelOffset: label.x
31 signal linkActivated(string link)
33 implicitHeight: Math.max(label.height, checkBox.height)
35 FocusScope {
36 anchors.fill: parent
37 focus: true
39 CheckBox {
40 id: checkBox
42 anchors {
43 left: parent.left
44 top: parent.top
45 leftMargin: listItem.leftMargin
46 }
48 Component.onCompleted: {
49 checked = listItem.checked;
50 }
52 onClicked: {
53 listItem.checked = checked
54 listItem.triggered(listItem.checked)
55 }
57 Connections {
58 target: listItem
59 onCheckedChanged: checkBox.checked = listItem.checked
60 }
62 Connections {
63 target: listItem.__mouseArea
64 onClicked: {
65 listItem.checked = !listItem.checked
66 listItem.triggered(listItem.checked)
67 }
68 }
69 }
71 Label {
72 id: label
73 anchors {
74 left: checkBox.right
75 right: parent.right
76 verticalCenter: parent.verticalCenter
77 leftMargin: units.gu(2)
78 rightMargin: listItem.rightMargin
79 }
80 wrapMode: Text.Wrap
81 linkColor: "#dd4814"
82 color: "#525252"
83 font.weight: Font.Light
84 fontSize: "small"
85 onLinkActivated: listItem.linkActivated(link)
86 }
88 Keys.onSpacePressed: checkBox.trigger()
89 }