on 67edfcc help sign in
unity8/qml/ScopeTool.qml
183 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 searchHistory: SearchHistoryModel { }
77 property Scope scope: scopes.get(currentIndex)
79 anchors {
80 top: parent.top
81 bottom: parent.bottom
82 left: parent.left
83 right: controls.left
84 }
85 }
87 Rectangle {
88 id: controls
89 color: "lightgrey"
90 width: units.gu(40)
91 anchors {
92 top: parent.top
93 bottom: parent.bottom
94 right: parent.right
95 }
97 MouseArea {
98 anchors.fill: parent
99 }
101 Column {
102 anchors { fill: parent; margins: units.gu(1) }
103 spacing: units.gu(1)
105 Label {
106 text: "Search query"
107 }
109 TextField {
110 id: searchField
111 anchors { left: parent.left; right: parent.right }
113 onTextChanged: dashContent.scope.searchQuery = text
115 Connections {
116 target: dashContent.scope
117 onSearchQueryChanged: searchField.text = dashContent.scope.searchQuery
118 }
119 }
121 Label {
122 text: "Category"
123 height: units.gu(4)
124 verticalAlignment: Text.AlignBottom
125 }
127 OptionSelector {
128 id: categorySelector
129 anchors { left: parent.left; right: parent.right }
130 model: dashContent.scope ? dashContent.scope.categories : null
132 property Item selectedItem
134 delegate: OptionSelectorDelegate {
135 id: categoryDelegate
136 text: model.name
137 property string categoryId: model.categoryId
138 property string template: JSON.stringify(JSON.parse(model.rawRendererTemplate), null, " ");
140 onSelectedChanged: if (selected) categorySelector.selectedItem = categoryDelegate
141 }
142 }
144 TextArea {
145 id: categoryJson
146 width: parent.width
147 autoSize: true
148 readOnly: true
149 text: categorySelector.selectedItem && categorySelector.selectedItem.template
150 }
152 Button {
153 width: parent.width
154 text: "Override category"
155 onClicked: {
156 PopupUtils.open(categoryEditor)
157 }
158 }
159 }
160 }
162 Component {
163 id: categoryEditor
165 ComposerSheet {
166 id: sheet
167 title: "Editing category definition"
169 TextArea {
170 id: categoryEditorArea
171 anchors.fill: parent
172 wrapMode: Text.WordWrap
173 text: categoryJson.text
174 }
176 onCancelClicked: PopupUtils.close(sheet)
177 onConfirmClicked: {
178 PopupUtils.close(sheet);
179 dashContent.scope.categories.overrideCategoryJson(categorySelector.selectedItem.categoryId, categoryEditorArea.text);
180 }
181 }
182 }