on 7.84+14.04.20140307-0ubuntu1 help sign in
unity8/qml/ScopeTool.qml
175 lines 4.6 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.1
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 DashContent {
65 id: dashContent
67 model: filteredScopes
68 searchHistory: SearchHistoryModel { }
69 property Scope scope: scopes.get(currentIndex)
71 anchors {
72 top: parent.top
73 bottom: parent.bottom
74 left: parent.left
75 right: controls.left
76 }
77 }
79 Rectangle {
80 id: controls
81 color: "lightgrey"
82 width: units.gu(40)
83 anchors {
84 top: parent.top
85 bottom: parent.bottom
86 right: parent.right
87 }
89 MouseArea {
90 anchors.fill: parent
91 }
93 Column {
94 anchors { fill: parent; margins: units.gu(1) }
95 spacing: units.gu(1)
97 Label {
98 text: "Search query"
99 }
101 TextField {
102 id: searchField
103 anchors { left: parent.left; right: parent.right }
105 onTextChanged: dashContent.scope.searchQuery = text
107 Connections {
108 target: dashContent.scope
109 onSearchQueryChanged: searchField.text = dashContent.scope.searchQuery
110 }
111 }
113 Label {
114 text: "Category"
115 height: units.gu(4)
116 verticalAlignment: Text.AlignBottom
117 }
119 OptionSelector {
120 id: categorySelector
121 anchors { left: parent.left; right: parent.right }
122 model: dashContent.scope ? dashContent.scope.categories : null
124 property Item selectedItem
126 delegate: OptionSelectorDelegate {
127 id: categoryDelegate
128 text: model.name
129 property string categoryId: model.categoryId
130 property string template: JSON.stringify(JSON.parse(model.rawRendererTemplate), null, " ");
132 onSelectedChanged: if (selected) categorySelector.selectedItem = categoryDelegate
133 }
134 }
136 TextArea {
137 id: categoryJson
138 width: parent.width
139 autoSize: true
140 readOnly: true
141 text: categorySelector.selectedItem && categorySelector.selectedItem.template
142 }
144 Button {
145 width: parent.width
146 text: "Override category"
147 onClicked: {
148 PopupUtils.open(categoryEditor)
149 }
150 }
151 }
152 }
154 Component {
155 id: categoryEditor
157 ComposerSheet {
158 id: sheet
159 title: "Editing category definition"
161 TextArea {
162 id: categoryEditorArea
163 anchors.fill: parent
164 wrapMode: Text.WordWrap
165 text: categoryJson.text
166 }
168 onCancelClicked: PopupUtils.close(sheet)
169 onConfirmClicked: {
170 PopupUtils.close(sheet);
171 dashContent.scope.categories.overrideCategoryJson(categorySelector.selectedItem.categoryId, categoryEditorArea.text);
172 }
173 }
174 }