on bb09f86 help sign in
unity8/qml/ScopeTool.qml
165 lines 4.4 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.4
18import Ubuntu.Components 1.3
19import Ubuntu.Components.Popups 1.3
20import Ubuntu.Thumbnailer 0.1 // Register support for image://thumbnailer/ and image://albumart/
21import Utils 0.1
22import Unity 0.2
23import "Components"
24import "Dash"
26Rectangle {
27 id: root
28 width: units.gu(80)
29 height: units.gu(72)
30 color: "#88FFFFFF"
32 // Fake shell object
33 QtObject {
34 id: shell
35 }
37 // Fake greeter object
38 QtObject {
39 id: greeter
40 property bool shown
41 }
43 // Fake panel object
44 QtObject {
45 id: panel
46 signal searchClicked
47 }
50 Rectangle {
51 anchors.fill: dashContent
52 color: "#FCFCFC"
53 }
55 DashContent {
56 id: dashContent
58 property var scope: scopes.getScope(currentIndex)
59 scopes: Scopes { }
61 anchors {
62 top: parent.top
63 bottom: parent.bottom
64 left: parent.left
65 right: controls.left
66 }
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 MouseArea {
80 anchors.fill: parent
81 }
83 Column {
84 anchors { fill: parent; margins: units.gu(1) }
85 spacing: units.gu(1)
87 Label {
88 text: "Search query"
89 }
91 TextField {
92 id: searchField
93 anchors { left: parent.left; right: parent.right }
95 onTextChanged: dashContent.scope.searchQuery = text
97 Connections {
98 target: dashContent.scope
99 onSearchQueryChanged: searchField.text = dashContent.scope.searchQuery
100 }
101 }
103 Label {
104 text: "Category"
105 height: units.gu(4)
106 verticalAlignment: Text.AlignBottom
107 }
109 OptionSelector {
110 id: categorySelector
111 anchors { left: parent.left; right: parent.right }
112 model: dashContent.scope ? dashContent.scope.categories : null
114 property Item selectedItem
116 delegate: OptionSelectorDelegate {
117 id: categoryDelegate
118 text: model.name
119 property string categoryId: model.categoryId
120 property string template: JSON.stringify(JSON.parse(model.rawRendererTemplate), null, " ");
122 onSelectedChanged: if (selected) categorySelector.selectedItem = categoryDelegate
123 }
124 }
126 TextArea {
127 id: categoryJson
128 width: parent.width
129 autoSize: true
130 readOnly: true
131 text: categorySelector.selectedItem && categorySelector.selectedItem.template
132 }
134 Button {
135 width: parent.width
136 text: "Override category"
137 onClicked: {
138 PopupUtils.open(categoryEditor)
139 }
140 }
141 }
142 }
144 Component {
145 id: categoryEditor
147 ComposerSheet {
148 id: sheet
149 title: "Editing category definition"
151 TextArea {
152 id: categoryEditorArea
153 anchors.fill: parent
154 wrapMode: Text.WordWrap
155 text: categoryJson.text
156 }
158 onCancelClicked: PopupUtils.close(sheet)
159 onConfirmClicked: {
160 PopupUtils.close(sheet);
161 dashContent.scope.categories.overrideCategoryJson(categorySelector.selectedItem.categoryId, categoryEditorArea.text);
162 }
163 }
164 }