Unity 8
IndicatorRepresentation.qml
1 /*
2  * Copyright 2013 Canonical Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authors:
17  * Renato Araujo Oliveira Filho <renato@canonical.com>
18  * Nick Dedekind <nick.dedekind@canonical.com>
19  */
20 
21 import QtQuick 2.4
22 import Ubuntu.Components 1.3
23 import "../.."
24 
25 Page {
26  id: root
27  property variant indicatorProperties
28 
29  header: PageHeader {
30  title: indicatorProperties && indicatorProperties.title ? indicatorProperties.title :
31  indicatorProperties && indicatorProperties.accessibleName ? indicatorProperties.accessibleName
32  : identifier
33  }
34 
35  anchors.fill: parent
36 
37  ListItem {
38  color: theme.palette.highlighted.background
39  id: visualCheckItem
40 
41  anchors {
42  top: header.bottom
43  left: parent.left
44  right: parent.right
45  }
46 
47  height: selectorLayout.height
48  onClicked: visualCheck.checked = !visualCheck.checked
49 
50  ListItemLayout {
51  id: selectorLayout
52  title.text: "Enable Visual Representation"
53 
54  Switch {
55  id: visualCheck
56  checked: true
57  SlotsLayout.position: SlotsLayout.Trailing
58  }
59  }
60  }
61 
62  Loader {
63  id: pageLoader
64  objectName: "pageLoader"
65  clip:true
66  asynchronous: true
67 
68  anchors {
69  top: visualCheckItem.bottom
70  left: parent.left
71  right: parent.right
72  bottom: buttons.top
73  topMargin: units.gu(2)
74  bottomMargin: units.gu(2)
75  }
76  sourceComponent: visualCheck.checked ? page : tree
77 
78  Component {
79  id: page
80  IndicatorPage {
81  identifier: model.identifier
82  busName: indicatorProperties.busName
83  actionsObjectPath: indicatorProperties.actionsObjectPath
84  menuObjectPath: indicatorProperties.menuObjectPath
85  }
86  }
87  Component {
88  id: tree
89  IndicatorsTree {
90  identifier: model.identifier
91  busName: indicatorProperties.busName
92  actionsObjectPath: indicatorProperties.actionsObjectPath
93  menuObjectPath: indicatorProperties.menuObjectPath
94  }
95  }
96  }
97 
98  Item {
99  id: buttons
100  anchors {
101  left: parent.left
102  right: parent.right
103  bottom: parent.bottom
104  margins: units.gu(1)
105  }
106  height: childrenRect.height
107  }
108 }