on 8.02+15.04.20150211-0ubuntu1 help sign in
unity8/qml/ScopeTool.qml
173 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 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 Image {
56 anchors.fill: dashContent
57 source: root.width > root.height ? "Dash/graphics/paper_landscape.png" : "Dash/graphics/paper_portrait.png"
58 fillMode: Image.PreserveAspectCrop
59 horizontalAlignment: Image.AlignRight
60 verticalAlignment: Image.AlignTop
61 }
63 DashContent {
64 id: dashContent
66 property var scope: scopes.getScope(currentIndex)
67 scopes: Scopes { }
69 anchors {
70 top: parent.top
71 bottom: parent.bottom
72 left: parent.left
73 right: controls.left
74 }
75 }
77 Rectangle {
78 id: controls
79 color: "lightgrey"
80 width: units.gu(40)
81 anchors {
82 top: parent.top
83 bottom: parent.bottom
84 right: parent.right
85 }
87 MouseArea {
88 anchors.fill: parent
89 }
91 Column {
92 anchors { fill: parent; margins: units.gu(1) }
93 spacing: units.gu(1)
95 Label {
96 text: "Search query"
97 }
99 TextField {
100 id: searchField
101 anchors { left: parent.left; right: parent.right }
103 onTextChanged: dashContent.scope.searchQuery = text
105 Connections {
106 target: dashContent.scope
107 onSearchQueryChanged: searchField.text = dashContent.scope.searchQuery
108 }
109 }
111 Label {
112 text: "Category"
113 height: units.gu(4)
114 verticalAlignment: Text.AlignBottom
115 }
117 OptionSelector {
118 id: categorySelector
119 anchors { left: parent.left; right: parent.right }
120 model: dashContent.scope ? dashContent.scope.categories : null
122 property Item selectedItem
124 delegate: OptionSelectorDelegate {
125 id: categoryDelegate
126 text: model.name
127 property string categoryId: model.categoryId
128 property string template: JSON.stringify(JSON.parse(model.rawRendererTemplate), null, " ");
130 onSelectedChanged: if (selected) categorySelector.selectedItem = categoryDelegate
131 }
132 }
134 TextArea {
135 id: categoryJson
136 width: parent.width
137 autoSize: true
138 readOnly: true
139 text: categorySelector.selectedItem && categorySelector.selectedItem.template
140 }
142 Button {
143 width: parent.width
144 text: "Override category"
145 onClicked: {
146 PopupUtils.open(categoryEditor)
147 }
148 }
149 }
150 }
152 Component {
153 id: categoryEditor
155 ComposerSheet {
156 id: sheet
157 title: "Editing category definition"
159 TextArea {
160 id: categoryEditorArea
161 anchors.fill: parent
162 wrapMode: Text.WordWrap
163 text: categoryJson.text
164 }
166 onCancelClicked: PopupUtils.close(sheet)
167 onConfirmClicked: {
168 PopupUtils.close(sheet);
169 dashContent.scope.categories.overrideCategoryJson(categorySelector.selectedItem.categoryId, categoryEditorArea.text);
170 }
171 }
172 }