on dc8aa4d help sign in
unity8/qml/ScopeTool.qml
177 lines 4.7 kB history raw
1/*
2* Copyright (C) 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 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.
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.0
18import Ubuntu.Components 0.1
19import Ubuntu.Components.Popups 0.1
20import Unity 0.1
21import "Dash"
23Rectangle {
24 id: root
25 width: units.gu(80)
26 height: units.gu(72)
27 color: "#88FFFFFF"
29 // Fake shell object
30 QtObject {
31 id: shell
32 }
34 // Fake greeter object
35 QtObject {
36 id: greeter
37 property bool shown
38 }
40 // Fake panel object
41 QtObject {
42 id: panel
43 signal searchClicked
44 }
47 Scopes {
48 id: scopes
49 }
51 Rectangle {
52 anchors.fill: scopeView
53 color: "#FCFCFC"
54 }
56 GenericScopeView {
57 id: scopeView
59 anchors {
60 top: parent.top
61 bottom: parent.bottom
62 left: parent.left
63 right: controls.left
64 }
66 scope: scopes.loaded ? scopes.get(scopeSelector.selectedIndex) : undefined
67 }
69 Rectangle {
70 id: controls
71 color: "lightgrey"
72 width: units.gu(40)
73 anchors {
74 top: parent.top
75 bottom: parent.bottom
76 right: parent.right
77 }
79 Column {
80 anchors { fill: parent; margins: units.gu(1) }
81 spacing: units.gu(1)
83 Label {
84 text: "Search query"
85 }
87 TextField {
88 id: searchField
89 anchors { left: parent.left; right: parent.right }
91 onTextChanged: scopeView.scope.searchQuery = text
93 Connections {
94 target: scopeView.scope
95 onSearchQueryChanged: searchField.text = scopeView.scope.searchQuery
96 }
97 }
99 Label {
100 text: "Scope selection"
101 height: units.gu(4)
102 verticalAlignment: Text.AlignBottom
103 }
105 OptionSelector {
106 id: scopeSelector
107 anchors { left: parent.left; right: parent.right }
109 model: scopes
110 delegate: OptionSelectorDelegate {
111 text: model.title
112 }
113 }
115 Label {
116 text: "Category"
117 height: units.gu(4)
118 verticalAlignment: Text.AlignBottom
119 }
121 OptionSelector {
122 id: categorySelector
123 anchors { left: parent.left; right: parent.right }
124 model: scopeView.scope ? scopeView.scope.categories : null
126 property Item selectedItem
128 delegate: OptionSelectorDelegate {
129 id: categoryDelegate
130 text: model.name
131 property string categoryId: model.categoryId
132 property string template: JSON.stringify(JSON.parse(model.rawRendererTemplate), null, " ");
134 onSelectedChanged: if (selected) categorySelector.selectedItem = categoryDelegate
135 }
136 }
138 TextArea {
139 id: categoryJson
140 width: parent.width
141 autoSize: true
142 readOnly: true
143 text: categorySelector.selectedItem && categorySelector.selectedItem.template
144 }
146 Button {
147 width: parent.width
148 text: "Override category"
149 onClicked: {
150 PopupUtils.open(categoryEditor)
151 }
152 }
153 }
154 }
156 Component {
157 id: categoryEditor
159 ComposerSheet {
160 id: sheet
161 title: "Editing category definition"
163 TextArea {
164 id: categoryEditorArea
165 anchors.fill: parent
166 wrapMode: Text.WordWrap
167 text: categoryJson.text
168 }
170 onCancelClicked: PopupUtils.close(sheet)
171 onConfirmClicked: {
172 PopupUtils.close(sheet);
173 scopeView.scope.categories.overrideCategoryJson(categorySelector.selectedItem.categoryId, categoryEditorArea.text);
174 }
175 }
176 }