on 4e77f91 help sign in
unity8/qml/ScopeTool.qml
182 lines 4.9 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 Utils 0.1
21import Unity 0.2
22import "Components"
23import "Dash"
25Rectangle {
26 id: root
27 width: units.gu(80)
28 height: units.gu(72)
29 color: "#88FFFFFF"
31 // Fake shell object
32 QtObject {
33 id: shell
34 }
36 // Fake greeter object
37 QtObject {
38 id: greeter
39 property bool shown
40 }
42 // Fake panel object
43 QtObject {
44 id: panel
45 signal searchClicked
46 }
48 SortFilterProxyModel {
49 id: filteredScopes
50 model: Scopes {
51 id: scopes
52 }
53 dynamicSortFilter: true
55 filterRole: Scopes.RoleVisible
56 filterRegExp: RegExp("^true$")
57 }
59 Rectangle {
60 anchors.fill: dashContent
61 color: "#FCFCFC"
62 }
64 Image {
65 anchors.fill: dashContent
66 source: root.width > root.height ? "Dash/graphics/paper_landscape.png" : "Dash/graphics/paper_portrait.png"
67 fillMode: Image.PreserveAspectCrop
68 horizontalAlignment: Image.AlignRight
69 verticalAlignment: Image.AlignTop
70 }
72 DashContent {
73 id: dashContent
75 model: filteredScopes
76 property var scope: scopes.getScope(currentIndex)
78 anchors {
79 top: parent.top
80 bottom: parent.bottom
81 left: parent.left
82 right: controls.left
83 }
84 }
86 Rectangle {
87 id: controls
88 color: "lightgrey"
89 width: units.gu(40)
90 anchors {
91 top: parent.top
92 bottom: parent.bottom
93 right: parent.right
94 }
96 MouseArea {
97 anchors.fill: parent
98 }
100 Column {
101 anchors { fill: parent; margins: units.gu(1) }
102 spacing: units.gu(1)
104 Label {
105 text: "Search query"
106 }
108 TextField {
109 id: searchField
110 anchors { left: parent.left; right: parent.right }
112 onTextChanged: dashContent.scope.searchQuery = text
114 Connections {
115 target: dashContent.scope
116 onSearchQueryChanged: searchField.text = dashContent.scope.searchQuery
117 }
118 }
120 Label {
121 text: "Category"
122 height: units.gu(4)
123 verticalAlignment: Text.AlignBottom
124 }
126 OptionSelector {
127 id: categorySelector
128 anchors { left: parent.left; right: parent.right }
129 model: dashContent.scope ? dashContent.scope.categories : null
131 property Item selectedItem
133 delegate: OptionSelectorDelegate {
134 id: categoryDelegate
135 text: model.name
136 property string categoryId: model.categoryId
137 property string template: JSON.stringify(JSON.parse(model.rawRendererTemplate), null, " ");
139 onSelectedChanged: if (selected) categorySelector.selectedItem = categoryDelegate
140 }
141 }
143 TextArea {
144 id: categoryJson
145 width: parent.width
146 autoSize: true
147 readOnly: true
148 text: categorySelector.selectedItem && categorySelector.selectedItem.template
149 }
151 Button {
152 width: parent.width
153 text: "Override category"
154 onClicked: {
155 PopupUtils.open(categoryEditor)
156 }
157 }
158 }
159 }
161 Component {
162 id: categoryEditor
164 ComposerSheet {
165 id: sheet
166 title: "Editing category definition"
168 TextArea {
169 id: categoryEditorArea
170 anchors.fill: parent
171 wrapMode: Text.WordWrap
172 text: categoryJson.text
173 }
175 onCancelClicked: PopupUtils.close(sheet)
176 onConfirmClicked: {
177 PopupUtils.close(sheet);
178 dashContent.scope.categories.overrideCategoryJson(categorySelector.selectedItem.categoryId, categoryEditorArea.text);
179 }
180 }
181 }