Debian Codegraph @

plugins/ubuntu-plugin/imports/utils/DevPanel.qml

raw
1 /* Copyright (C) 2016 - 2017 Dan Chapman <[email protected]>
2
3 This file is part of Dekko email client for Ubuntu devices
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 import QtQuick 2.4
19 import QtQuick.Window 2.2
20 import QtQuick.Controls.Suru 2.2
21 import Dekko.Components 1.0
22 import Dekko.Mail 1.0
23 import Lomiri.Components 1.3
24 import Lomiri.PerformanceMetrics 1.0
25 import Dekko.Lomiri.Components 1.0
26 import Dekko.Lomiri.Constants 1.0
27
28 Rectangle {
29 id: devPanel
30 anchors.fill: parent
31 color: Style.devPanelBackground
32 clip: true
33 StretchRow {
34 anchors.fill: parent
35 spacing: 0
36 PanelContainer {
37 resizable: true
38 minSize: units.gu(25)
39 maxSize: units.gu(40)
40 height: parent.height
41 activeEdge: Item.Right
42 StretchColumn {
43 anchors.fill: parent
44 Stretcher {
45 implicitWidth: parent.width
46 anchors {
47 left: parent.left
48 right: parent.right
49 }
50 ListView {
51 id: sq
52 anchors {
53 fill: parent
54 margins: units.gu(0.5)
55 }
56 clip: true
57 header: Component {
58 Item {
59 width: parent.width
60 height: units.gu(3)
61 Label {
62 anchors.centerIn: parent
63 text: "Service actions"
64 color: LomiriColors.orange
65 }
66 }
67 }
68 model: Client.service.serviceActionQueue
69 delegate: Label {
70 anchors {
71 left: parent.left
72 right: parent.right
73 }
74
75 text: model.qtObject.description
76 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
77 color: Suru.secondaryBackgroundColor
78 }
79 }
80 }
81 PanelContainer {
82 width: parent.width
83 activeEdge: Item.Top
84 size: parent.height / 2
85 ListView {
86 anchors {
87 fill: parent
88 margins: units.gu(0.5)
89 }
90 clip: true
91 header: Component {
92 Item {
93 width: parent.width
94 height: units.gu(3)
95 Label {
96 anchors.centerIn: parent
97 text: "Undoable actions"
98 Suru.highlightType: Suru.PositiveHighlight
99 color: Suru.highlightColor
100 }
101 }
102 }
103 model: Client.service.undoActionQueue
104 delegate: Label {
105 width: units.gu(25)
106 text: model.qtObject.description
107 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
108 color: Suru.secondaryBackgroundColor
109 }
110 }
111 }
112 }
113 }
114 PanelContainer {
115 resizable: true
116 minSize: units.gu(30)
117 maxSize: units.gu(60)
118 size: units.gu(60)
119 height: parent.height
120 activeEdge: Item.Right
121 ListView {
122 id: qmlLog
123 anchors.fill: parent
124 anchors.margins: units.gu(0.5)
125 model: LogRecorder.model
126 clip: true
127 delegate: Label {
128 width: parent.width
129 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
130 text: model.qtObject.message
131 }
132 onCountChanged: positionViewAtEnd()
133 Connections {
134 target: LogRecorder.model
135 onCountChanged: {
136 if (!logPositionTimer.running)
137 logPositionTimer.start()
138 }
139 }
140 Timer {
141 id: logPositionTimer
142 interval: 300
143 repeat: false
144 onTriggered: qmlLog.positionViewAtEnd()
145 }
146 }
147 }
148
149 Stretcher {
150 implicitHeight: parent.height
151 PerformanceOverlay {
152 anchors {
153 centerIn: parent
154 }
155 }
156
157 }
158 }
159 HeaderButton {
160 anchors {
161 top: parent.top
162 right: parent.right
163 }
164 height: units.gu(5)
165 width: height
166 iconName: "view-fullscreen"
167 onClicked: detach()
168 }
169
170 function detach () {
171 if (d.subWindow === null) {
172 var rootItem = Introspector.window (devPanel);
173 var abspos = rootItem.contentItem.mapFromItem(devPanel, 0 , 0);
174 d.subWindow = compoWindow.createObject(Introspector.window(devPanel), {
175 "x" : (abspos.x + rootItem.x),
176 "y" : (abspos.y + rootItem.y),
177 });
178 devPanel.parent = d.subWindow.contentItem;
179 // pc.visible = false
180 }
181 }
182
183 function attach () {
184 if (d.subWindow !== null) {
185 devPanel.parent = pc.container;
186 // pc.visible = true
187 d.subWindow.destroy();
188 }
189 }
190
191 Component {
192 id: compoWindow;
193 DevWindow {}
194 }
195 QtObject {
196 id: d
197 property Window subWindow : null
198 }
199 }
200