Merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/devicepage into lp:qtcreator-plugin-ubuntu
- devicepage
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 134 | ||||||||
Proposed branch: | lp:~zeller-benjamin/qtcreator-plugin-ubuntu/devicepage | ||||||||
Merge into: | lp:qtcreator-plugin-ubuntu | ||||||||
Diff against target: |
3275 lines (+2562/-68) 34 files modified
manifest.json (+15/-0) share/qtcreator/ubuntu/devicespage/DeviceAdvancedTab.qml (+92/-0) share/qtcreator/ubuntu/devicespage/DeviceBuilderTab.qml (+42/-0) share/qtcreator/ubuntu/devicespage/DeviceLogTab.qml (+12/-0) share/qtcreator/ubuntu/devicespage/DevicePage.qml (+105/-0) share/qtcreator/ubuntu/devicespage/DeviceStatusTab.qml (+108/-0) share/qtcreator/ubuntu/devicespage/EmulatorPage.qml (+150/-0) share/qtcreator/ubuntu/devicespage/FeatureStateItem.qml (+46/-0) share/qtcreator/ubuntu/devicespage/LogPage.qml (+24/-0) share/qtcreator/ubuntu/devicespage/NewEmulatorDialog.qml (+46/-0) share/qtcreator/ubuntu/devicespage/devicespage.qmlproject (+20/-0) share/qtcreator/ubuntu/devicespage/dummydata/devicesModel.qml (+52/-0) share/qtcreator/ubuntu/devicespage/main.qml (+25/-0) share/qtcreator/ubuntu/devicespage/test.qml# (+18/-0) share/qtcreator/ubuntu/scripts/local_start_emulator (+0/-1) src/ubuntu/resources.qrc (+2/-0) src/ubuntu/ubuntu.pro (+27/-5) src/ubuntu/ubuntuconstants.h (+4/-2) src/ubuntu/ubuntudevice.cpp (+125/-20) src/ubuntu/ubuntudevice.h (+9/-4) src/ubuntu/ubuntudevicemode.cpp (+91/-9) src/ubuntu/ubuntudevicemode.h (+42/-2) src/ubuntu/ubuntudevicesmodel.cpp (+734/-0) src/ubuntu/ubuntudevicesmodel.h (+169/-0) src/ubuntu/ubuntuemulatormodel.cpp (+408/-0) src/ubuntu/ubuntuemulatormodel.h (+102/-0) src/ubuntu/ubuntukitmanager.cpp (+50/-1) src/ubuntu/ubuntukitmanager.h (+3/-0) src/ubuntu/ubuntumenu.cpp (+9/-4) src/ubuntu/ubuntuplugin.cpp (+4/-1) src/ubuntu/ubuntuprocess.cpp (+5/-6) src/ubuntu/ubuntuprocess.h (+3/-2) src/ubuntu/ubunturemoterunconfiguration.cpp (+20/-10) src/ubuntu/ubuntusettingsdeviceconnectivitywidget.cpp (+0/-1) |
||||||||
To merge this branch: | bzr merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/devicepage | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Zoltan Balogh | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email:
|
Commit message
- Added new QML based devices mode
- Reworked backend that handles devices and emulators and put
it into QAbstractListModel derived classes to control them from QML
- Fixed a bug with starting applications on the device that don't use
a launcher
- Switched to the RemoteLinux configuration widget , it provides better
informations about the device state in the options dialog
- Easy creation of Kits for devices that are not assigned (Autocreate Kit)
Description of the change
New devices page
- 149. By Benjamin Zeller
-
Removed user file (how did they get in there?)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Zoltan Balogh (bzoltan) wrote : | # |
Is the welcome.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Benjamin Zeller (zeller-benjamin) wrote : | # |
> Is the welcome.
Meh, of course not, also not the manifest and apparmor files
- 150. By Benjamin Zeller
-
Removed other not required files
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:150
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Zoltan Balogh (bzoltan) wrote : | # |
what about the share/qtcreator
- 151. By Benjamin Zeller
-
deleted more files
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:151
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === added file '.excludes' | |||
2 | === added file 'manifest.json' | |||
3 | --- manifest.json 1970-01-01 00:00:00 +0000 | |||
4 | +++ manifest.json 2014-04-27 13:29:17 +0000 | |||
5 | @@ -0,0 +1,15 @@ | |||
6 | 1 | { | ||
7 | 2 | "architecture": "all", | ||
8 | 3 | "description": "description of qtcreator-plugin-ubuntu", | ||
9 | 4 | "framework": "ubuntu-sdk-13.10", | ||
10 | 5 | "hooks": { | ||
11 | 6 | "qtcreator-plugin-ubuntu": { | ||
12 | 7 | "apparmor": "qtcreator-plugin-ubuntu.json", | ||
13 | 8 | "desktop": "qtcreator-plugin-ubuntu.desktop" | ||
14 | 9 | } | ||
15 | 10 | }, | ||
16 | 11 | "maintainer": "Benjamin Zeller <benjamin.zeller@canonical.com>", | ||
17 | 12 | "name": "com.ubuntu.developer.zeller-benjamin.qtcreator-plugin-ubuntu", | ||
18 | 13 | "title": "qtcreator-plugin-ubuntu", | ||
19 | 14 | "version": "0.1" | ||
20 | 15 | } | ||
21 | 0 | \ No newline at end of file | 16 | \ No newline at end of file |
22 | 1 | 17 | ||
23 | === added directory 'share/qtcreator/ubuntu/devicespage' | |||
24 | === added file 'share/qtcreator/ubuntu/devicespage/.excludes' | |||
25 | === added file 'share/qtcreator/ubuntu/devicespage/DeviceAdvancedTab.qml' | |||
26 | --- share/qtcreator/ubuntu/devicespage/DeviceAdvancedTab.qml 1970-01-01 00:00:00 +0000 | |||
27 | +++ share/qtcreator/ubuntu/devicespage/DeviceAdvancedTab.qml 2014-04-27 13:29:17 +0000 | |||
28 | @@ -0,0 +1,92 @@ | |||
29 | 1 | import QtQuick 2.0 | ||
30 | 2 | import QtQuick.Controls 1.0 as Controls | ||
31 | 3 | import QtQuick.Layouts 1.0 | ||
32 | 4 | import Ubuntu.Components 0.1 | ||
33 | 5 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
34 | 6 | |||
35 | 7 | |||
36 | 8 | RowLayout { | ||
37 | 9 | Controls.ScrollView { | ||
38 | 10 | Layout.fillHeight: true | ||
39 | 11 | Layout.minimumWidth: units.gu(78) | ||
40 | 12 | UbuntuListView { | ||
41 | 13 | model: VisualItemModel{ | ||
42 | 14 | Label { | ||
43 | 15 | text: "Device Control" | ||
44 | 16 | fontSize: "large" | ||
45 | 17 | anchors.left: parent.left | ||
46 | 18 | } | ||
47 | 19 | ListItem.Standard { | ||
48 | 20 | text:"Clone time config from Host to Device" | ||
49 | 21 | control: Button{ | ||
50 | 22 | text: "Execute" | ||
51 | 23 | enabled: !deviceItemView.deviceBusy | ||
52 | 24 | onClicked: devicesModel.triggerCloneTimeConfig(deviceId) | ||
53 | 25 | } | ||
54 | 26 | } | ||
55 | 27 | ListItem.Standard { | ||
56 | 28 | text:"Enable port forwarding" | ||
57 | 29 | control: Button{ | ||
58 | 30 | text: "Execute" | ||
59 | 31 | enabled: !deviceItemView.deviceBusy | ||
60 | 32 | onClicked: devicesModel.triggerPortForwarding(deviceId) | ||
61 | 33 | } | ||
62 | 34 | } | ||
63 | 35 | ListItem.Standard { | ||
64 | 36 | text:"Setup public key authentication" | ||
65 | 37 | control: Button{ | ||
66 | 38 | text: "Execute" | ||
67 | 39 | enabled: !deviceItemView.deviceBusy | ||
68 | 40 | onClicked: devicesModel.triggerSSHSetup(deviceId) | ||
69 | 41 | } | ||
70 | 42 | } | ||
71 | 43 | ListItem.Standard { | ||
72 | 44 | text:"Open SSH connection to the device" | ||
73 | 45 | control: Button{ | ||
74 | 46 | text: "Execute" | ||
75 | 47 | enabled: !deviceItemView.deviceBusy | ||
76 | 48 | onClicked: devicesModel.triggerSSHConnection(deviceId) | ||
77 | 49 | } | ||
78 | 50 | } | ||
79 | 51 | ListItem.Divider{} | ||
80 | 52 | Label { | ||
81 | 53 | text: "Device Mode" | ||
82 | 54 | fontSize: "large" | ||
83 | 55 | } | ||
84 | 56 | ListItem.Standard { | ||
85 | 57 | text:"Reboot" | ||
86 | 58 | control: Button{ | ||
87 | 59 | text: "Execute" | ||
88 | 60 | enabled: !deviceItemView.deviceBusy | ||
89 | 61 | onClicked: devicesModel.triggerReboot(deviceId) | ||
90 | 62 | } | ||
91 | 63 | } | ||
92 | 64 | ListItem.Standard { | ||
93 | 65 | text:"Reboot to bootloader" | ||
94 | 66 | control: Button{ | ||
95 | 67 | text: "Execute" | ||
96 | 68 | enabled: !deviceItemView.deviceBusy | ||
97 | 69 | onClicked: devicesModel.triggerRebootBootloader(deviceId) | ||
98 | 70 | } | ||
99 | 71 | } | ||
100 | 72 | ListItem.Standard { | ||
101 | 73 | text:"Reboot to recovery" | ||
102 | 74 | control: Button{ | ||
103 | 75 | text: "Execute" | ||
104 | 76 | enabled: !deviceItemView.deviceBusy | ||
105 | 77 | onClicked: devicesModel.triggerRebootRecovery(deviceId) | ||
106 | 78 | } | ||
107 | 79 | } | ||
108 | 80 | ListItem.Standard { | ||
109 | 81 | text:"Shutdown" | ||
110 | 82 | control: Button{ | ||
111 | 83 | text: "Execute" | ||
112 | 84 | enabled: !deviceItemView.deviceBusy | ||
113 | 85 | onClicked: devicesModel.triggerShutdown(deviceId) | ||
114 | 86 | } | ||
115 | 87 | } | ||
116 | 88 | } | ||
117 | 89 | } | ||
118 | 90 | } | ||
119 | 91 | } | ||
120 | 92 | |||
121 | 0 | 93 | ||
122 | === added file 'share/qtcreator/ubuntu/devicespage/DeviceBuilderTab.qml' | |||
123 | --- share/qtcreator/ubuntu/devicespage/DeviceBuilderTab.qml 1970-01-01 00:00:00 +0000 | |||
124 | +++ share/qtcreator/ubuntu/devicespage/DeviceBuilderTab.qml 2014-04-27 13:29:17 +0000 | |||
125 | @@ -0,0 +1,42 @@ | |||
126 | 1 | import QtQuick 2.0 | ||
127 | 2 | import QtQuick.Controls 1.0 as Controls | ||
128 | 3 | import QtQuick.Layouts 1.0 | ||
129 | 4 | import Ubuntu.Components 0.1 | ||
130 | 5 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
131 | 6 | |||
132 | 7 | RowLayout { | ||
133 | 8 | spacing: units.gu(1) | ||
134 | 9 | Controls.ScrollView { | ||
135 | 10 | Layout.fillHeight: true | ||
136 | 11 | Layout.minimumWidth: units.gu(78) | ||
137 | 12 | |||
138 | 13 | ColumnLayout { | ||
139 | 14 | Layout.fillWidth: true | ||
140 | 15 | Label { | ||
141 | 16 | text: "Platform development" | ||
142 | 17 | fontSize: "large" | ||
143 | 18 | anchors.left: parent.left | ||
144 | 19 | Layout.fillWidth: true | ||
145 | 20 | } | ||
146 | 21 | Label { | ||
147 | 22 | text: "The connected device can be turned to be a native development environment.\n Use this feature with care and only if you know what are you doing." | ||
148 | 23 | } | ||
149 | 24 | FeatureStateItem { | ||
150 | 25 | text: "Has writeable image" | ||
151 | 26 | input: hasWriteableImage | ||
152 | 27 | inputRole: "hasWriteableImage" | ||
153 | 28 | height: 24 | ||
154 | 29 | width: 300 | ||
155 | 30 | checkable: !deviceItemView.deviceBusy | ||
156 | 31 | } | ||
157 | 32 | FeatureStateItem { | ||
158 | 33 | text: "Has device developer tools" | ||
159 | 34 | input: hasDeveloperTools | ||
160 | 35 | inputRole: "hasDeveloperTools" | ||
161 | 36 | height: 24 | ||
162 | 37 | width: 300 | ||
163 | 38 | checkable: !deviceItemView.deviceBusy | ||
164 | 39 | } | ||
165 | 40 | } | ||
166 | 41 | } | ||
167 | 42 | } | ||
168 | 0 | 43 | ||
169 | === added file 'share/qtcreator/ubuntu/devicespage/DeviceLogTab.qml' | |||
170 | --- share/qtcreator/ubuntu/devicespage/DeviceLogTab.qml 1970-01-01 00:00:00 +0000 | |||
171 | +++ share/qtcreator/ubuntu/devicespage/DeviceLogTab.qml 2014-04-27 13:29:17 +0000 | |||
172 | @@ -0,0 +1,12 @@ | |||
173 | 1 | import QtQuick 2.0 | ||
174 | 2 | import QtQuick.Controls 1.0 as Controls | ||
175 | 3 | import QtQuick.Layouts 1.0 | ||
176 | 4 | import Ubuntu.Components 0.1 | ||
177 | 5 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
178 | 6 | |||
179 | 7 | |||
180 | 8 | Controls.TextArea { | ||
181 | 9 | readOnly: true | ||
182 | 10 | text: deviceLog | ||
183 | 11 | textFormat: TextEdit.AutoText | ||
184 | 12 | } | ||
185 | 0 | 13 | ||
186 | === added file 'share/qtcreator/ubuntu/devicespage/DevicePage.qml' | |||
187 | --- share/qtcreator/ubuntu/devicespage/DevicePage.qml 1970-01-01 00:00:00 +0000 | |||
188 | +++ share/qtcreator/ubuntu/devicespage/DevicePage.qml 2014-04-27 13:29:17 +0000 | |||
189 | @@ -0,0 +1,105 @@ | |||
190 | 1 | import QtQuick 2.0 | ||
191 | 2 | import QtQuick.Layouts 1.0 | ||
192 | 3 | import QtQuick.Controls 1.0 as Controls | ||
193 | 4 | |||
194 | 5 | import Ubuntu.Components 0.1 | ||
195 | 6 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
196 | 7 | import Ubuntu.DevicesModel 0.1 | ||
197 | 8 | |||
198 | 9 | Page { | ||
199 | 10 | flickable: null | ||
200 | 11 | |||
201 | 12 | Controls.SplitView { | ||
202 | 13 | orientation: Qt.Horizontal | ||
203 | 14 | anchors.fill: parent | ||
204 | 15 | Controls.SplitView { | ||
205 | 16 | orientation: Qt.Vertical | ||
206 | 17 | width: 200 | ||
207 | 18 | Layout.minimumWidth: 200 | ||
208 | 19 | Layout.maximumWidth: 400 | ||
209 | 20 | |||
210 | 21 | Controls.ScrollView { | ||
211 | 22 | Layout.fillHeight: true | ||
212 | 23 | UbuntuListView { | ||
213 | 24 | id: devicesList | ||
214 | 25 | objectName: "devicesList" | ||
215 | 26 | model: devicesModel | ||
216 | 27 | currentIndex: 0 | ||
217 | 28 | delegate: ListItem.Standard { | ||
218 | 29 | id: delegate | ||
219 | 30 | text: display | ||
220 | 31 | selected: devicesList.currentIndex == index | ||
221 | 32 | onClicked: devicesList.currentIndex = index | ||
222 | 33 | } | ||
223 | 34 | onCurrentIndexChanged: deviceMode.deviceSelected(currentIndex) | ||
224 | 35 | } | ||
225 | 36 | } | ||
226 | 37 | Controls.ToolBar { | ||
227 | 38 | Layout.fillWidth: true | ||
228 | 39 | Layout.minimumHeight: units.gu(5) | ||
229 | 40 | Layout.maximumHeight: units.gu(5) | ||
230 | 41 | Row{ | ||
231 | 42 | anchors.fill: parent | ||
232 | 43 | spacing: units.gu(2) | ||
233 | 44 | Controls.ToolButton { | ||
234 | 45 | text: i18n.tr("Refresh devices") | ||
235 | 46 | tooltip: text | ||
236 | 47 | iconSource: "qrc:/ubuntu/images/view-refresh.png" | ||
237 | 48 | onClicked: devicesModel.refresh() | ||
238 | 49 | } | ||
239 | 50 | } | ||
240 | 51 | } | ||
241 | 52 | } | ||
242 | 53 | Item { | ||
243 | 54 | id: centerItem | ||
244 | 55 | Layout.minimumWidth: 400 | ||
245 | 56 | Layout.fillWidth: true | ||
246 | 57 | property int currentIndex: devicesList.currentIndex | ||
247 | 58 | Repeater { | ||
248 | 59 | model: devicesModel | ||
249 | 60 | anchors.fill: parent | ||
250 | 61 | Rectangle{ | ||
251 | 62 | id: deviceItemView | ||
252 | 63 | property bool deviceBusy: (detectionState != States.Done && detectionState != States.NotStarted) | ||
253 | 64 | anchors.fill: parent | ||
254 | 65 | anchors.margins: 12 | ||
255 | 66 | |||
256 | 67 | color: Qt.rgba(0.0, 0.0, 0.0, 0.01) | ||
257 | 68 | visible: index == devicesList.currentIndex | ||
258 | 69 | |||
259 | 70 | Controls.TabView { | ||
260 | 71 | id: pagesTabView | ||
261 | 72 | anchors.fill: parent | ||
262 | 73 | visible: connectionState === States.DeviceReadyToUse || connectionState === States.DeviceConnected | ||
263 | 74 | Controls.Tab { | ||
264 | 75 | title: "Device" | ||
265 | 76 | DeviceStatusTab{ | ||
266 | 77 | } | ||
267 | 78 | } | ||
268 | 79 | Controls.Tab { | ||
269 | 80 | title: "Advanced" | ||
270 | 81 | DeviceAdvancedTab{ | ||
271 | 82 | } | ||
272 | 83 | } | ||
273 | 84 | Controls.Tab { | ||
274 | 85 | title: "Builder" | ||
275 | 86 | DeviceBuilderTab{ | ||
276 | 87 | } | ||
277 | 88 | } | ||
278 | 89 | Controls.Tab { | ||
279 | 90 | title: "Log" | ||
280 | 91 | DeviceLogTab{} | ||
281 | 92 | } | ||
282 | 93 | } | ||
283 | 94 | Label { | ||
284 | 95 | visible: !pagesTabView.visible | ||
285 | 96 | anchors.centerIn: parent | ||
286 | 97 | text: "The device is currently not connected" | ||
287 | 98 | fontSize: "large" | ||
288 | 99 | } | ||
289 | 100 | } | ||
290 | 101 | } | ||
291 | 102 | } | ||
292 | 103 | } | ||
293 | 104 | } | ||
294 | 105 | |||
295 | 0 | 106 | ||
296 | === added file 'share/qtcreator/ubuntu/devicespage/DeviceStatusTab.qml' | |||
297 | --- share/qtcreator/ubuntu/devicespage/DeviceStatusTab.qml 1970-01-01 00:00:00 +0000 | |||
298 | +++ share/qtcreator/ubuntu/devicespage/DeviceStatusTab.qml 2014-04-27 13:29:17 +0000 | |||
299 | @@ -0,0 +1,108 @@ | |||
300 | 1 | import QtQuick 2.0 | ||
301 | 2 | import QtQuick.Controls 1.0 as Controls | ||
302 | 3 | import QtQuick.Layouts 1.0 | ||
303 | 4 | import Ubuntu.Components 0.1 | ||
304 | 5 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
305 | 6 | import Ubuntu.DevicesModel 0.1 | ||
306 | 7 | |||
307 | 8 | RowLayout { | ||
308 | 9 | Controls.ScrollView { | ||
309 | 10 | id: scrollView | ||
310 | 11 | Layout.fillHeight: true | ||
311 | 12 | Layout.minimumWidth: units.gu(78) | ||
312 | 13 | ColumnLayout { | ||
313 | 14 | width: scrollView.width | ||
314 | 15 | Row { | ||
315 | 16 | Label { | ||
316 | 17 | text:"Device Status: "+detectionStateString | ||
317 | 18 | fontSize: "large" | ||
318 | 19 | } | ||
319 | 20 | Item { | ||
320 | 21 | width: units.gu(2) | ||
321 | 22 | height: parent.height | ||
322 | 23 | } | ||
323 | 24 | ActivityIndicator{ | ||
324 | 25 | visible: deviceItemView.deviceBusy | ||
325 | 26 | running: true | ||
326 | 27 | } | ||
327 | 28 | } | ||
328 | 29 | ListItem.SingleValue { | ||
329 | 30 | text:i18n.tr("Serial ID") | ||
330 | 31 | Layout.fillWidth: true | ||
331 | 32 | value: serial | ||
332 | 33 | } | ||
333 | 34 | ListItem.SingleValue { | ||
334 | 35 | text:i18n.tr("Device") | ||
335 | 36 | Layout.fillWidth: true | ||
336 | 37 | value: deviceInfo | ||
337 | 38 | } | ||
338 | 39 | ListItem.SingleValue { | ||
339 | 40 | text:i18n.tr("Model") | ||
340 | 41 | Layout.fillWidth: true | ||
341 | 42 | value: modelInfo | ||
342 | 43 | } | ||
343 | 44 | ListItem.SingleValue { | ||
344 | 45 | text:i18n.tr("Product") | ||
345 | 46 | Layout.fillWidth: true | ||
346 | 47 | value: productInfo | ||
347 | 48 | } | ||
348 | 49 | FeatureStateItem { | ||
349 | 50 | text: "Has network connection" | ||
350 | 51 | input: hasNetworkConnection | ||
351 | 52 | inputRole: "hasNetworkConnection" | ||
352 | 53 | Layout.fillWidth: true | ||
353 | 54 | checkable: hasNetworkConnection == States.NotAvailable && !deviceItemView.deviceBusy | ||
354 | 55 | } | ||
355 | 56 | FeatureStateItem { | ||
356 | 57 | text: "Has devloper mode enabled" | ||
357 | 58 | input: developerModeEnabled | ||
358 | 59 | inputRole: "developerModeEnabled" | ||
359 | 60 | Layout.fillWidth: true | ||
360 | 61 | checkable: !deviceItemView.deviceBusy | ||
361 | 62 | } | ||
362 | 63 | ListItem.Divider{} | ||
363 | 64 | |||
364 | 65 | Label { | ||
365 | 66 | text: "Device Kits" | ||
366 | 67 | fontSize: "large" | ||
367 | 68 | anchors.left: parent.left | ||
368 | 69 | } | ||
369 | 70 | Repeater { | ||
370 | 71 | model: kits | ||
371 | 72 | delegate: ListItem.Standard { | ||
372 | 73 | text: modelData.displayName | ||
373 | 74 | Layout.fillWidth: true | ||
374 | 75 | control: Button{ | ||
375 | 76 | text: "Remove" | ||
376 | 77 | enabled: !deviceItemView.deviceBusy | ||
377 | 78 | onClicked: devicesModel.triggerKitRemove(deviceId,modelData.id) | ||
378 | 79 | } | ||
379 | 80 | } | ||
380 | 81 | } | ||
381 | 82 | Item { | ||
382 | 83 | clip: true | ||
383 | 84 | visible: kits.length === 0 | ||
384 | 85 | Layout.minimumHeight: units.gu(25) | ||
385 | 86 | Layout.fillWidth: true | ||
386 | 87 | Label { | ||
387 | 88 | id:label | ||
388 | 89 | anchors.centerIn: parent | ||
389 | 90 | anchors.bottom: button.top | ||
390 | 91 | fontSize: "large" | ||
391 | 92 | text: "There is currently no Kit defined for your device.\n In order to use the device in your Projects,\n you can either add a existing Kit " | ||
392 | 93 | +"\nor let Qt Creator autocreate one for you." | ||
393 | 94 | } | ||
394 | 95 | Button { | ||
395 | 96 | id: button | ||
396 | 97 | anchors.left: label.left | ||
397 | 98 | anchors.right: label.right | ||
398 | 99 | anchors.top: label.bottom | ||
399 | 100 | anchors.topMargin: units.gu(2) | ||
400 | 101 | text: "Autocreate" | ||
401 | 102 | enabled: !deviceItemView.deviceBusy | ||
402 | 103 | onClicked: devicesModel.triggerKitAutocreate(deviceId) | ||
403 | 104 | } | ||
404 | 105 | } | ||
405 | 106 | } | ||
406 | 107 | } | ||
407 | 108 | } | ||
408 | 0 | 109 | ||
409 | === added file 'share/qtcreator/ubuntu/devicespage/EmulatorPage.qml' | |||
410 | --- share/qtcreator/ubuntu/devicespage/EmulatorPage.qml 1970-01-01 00:00:00 +0000 | |||
411 | +++ share/qtcreator/ubuntu/devicespage/EmulatorPage.qml 2014-04-27 13:29:17 +0000 | |||
412 | @@ -0,0 +1,150 @@ | |||
413 | 1 | import QtQuick 2.0 | ||
414 | 2 | import QtQuick.Layouts 1.0 | ||
415 | 3 | import QtQuick.Controls 1.0 as Controls | ||
416 | 4 | |||
417 | 5 | import Ubuntu.Components 0.1 | ||
418 | 6 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
419 | 7 | import Ubuntu.Components.Popups 0.1 | ||
420 | 8 | |||
421 | 9 | Page { | ||
422 | 10 | flickable: null | ||
423 | 11 | id: myPage | ||
424 | 12 | |||
425 | 13 | Item { | ||
426 | 14 | anchors.fill: parent | ||
427 | 15 | visible: emulatorModel.busy | ||
428 | 16 | |||
429 | 17 | Column { | ||
430 | 18 | anchors.centerIn: parent | ||
431 | 19 | spacing: units.gu(1) | ||
432 | 20 | |||
433 | 21 | ActivityIndicator{ | ||
434 | 22 | anchors.horizontalCenter: parent.horizontalCenter | ||
435 | 23 | running: emulatorModel.busy | ||
436 | 24 | } | ||
437 | 25 | Label { | ||
438 | 26 | text: i18n.tr("There is currently a process running in the background, please check the logs for details") | ||
439 | 27 | fontSize: "large" | ||
440 | 28 | anchors.left: parent.left | ||
441 | 29 | } | ||
442 | 30 | Button { | ||
443 | 31 | visible: emulatorModel.cancellable | ||
444 | 32 | anchors.horizontalCenter: parent.horizontalCenter | ||
445 | 33 | text: "cancel" | ||
446 | 34 | onClicked: emulatorModel.cancel() | ||
447 | 35 | } | ||
448 | 36 | } | ||
449 | 37 | } | ||
450 | 38 | |||
451 | 39 | Controls.SplitView { | ||
452 | 40 | orientation: Qt.Horizontal | ||
453 | 41 | anchors.fill: parent | ||
454 | 42 | visible: !emulatorModel.busy | ||
455 | 43 | |||
456 | 44 | Controls.SplitView { | ||
457 | 45 | orientation: Qt.Vertical | ||
458 | 46 | width: 200 | ||
459 | 47 | Layout.minimumWidth: 200 | ||
460 | 48 | Layout.maximumWidth: 400 | ||
461 | 49 | |||
462 | 50 | Controls.ScrollView { | ||
463 | 51 | Layout.fillHeight: true | ||
464 | 52 | Layout.fillWidth: true | ||
465 | 53 | |||
466 | 54 | UbuntuListView { | ||
467 | 55 | id: emulatorList | ||
468 | 56 | objectName: "emulatorList" | ||
469 | 57 | model: emulatorModel | ||
470 | 58 | currentIndex: 0 | ||
471 | 59 | delegate: ListItem.Standard { | ||
472 | 60 | id: delegate | ||
473 | 61 | text: display | ||
474 | 62 | selected: emulatorList.currentIndex == index | ||
475 | 63 | onClicked: emulatorList.currentIndex = index | ||
476 | 64 | } | ||
477 | 65 | } | ||
478 | 66 | } | ||
479 | 67 | |||
480 | 68 | Controls.ToolBar { | ||
481 | 69 | Layout.fillWidth: true | ||
482 | 70 | Layout.minimumHeight: units.gu(5) | ||
483 | 71 | Layout.maximumHeight: units.gu(5) | ||
484 | 72 | Row{ | ||
485 | 73 | anchors.fill: parent | ||
486 | 74 | spacing: units.gu(2) | ||
487 | 75 | Controls.ToolButton { | ||
488 | 76 | text: i18n.tr("Add Emulator") | ||
489 | 77 | tooltip: text | ||
490 | 78 | iconSource: "qrc:/ubuntu/images/list-add.png" | ||
491 | 79 | onClicked: PopupUtils.open(resourceRoot+"/NewEmulatorDialog.qml",myPage); | ||
492 | 80 | } | ||
493 | 81 | Controls.ToolButton { | ||
494 | 82 | text: i18n.tr("Refresh emulators") | ||
495 | 83 | tooltip: text | ||
496 | 84 | iconSource: "qrc:/ubuntu/images/view-refresh.png" | ||
497 | 85 | onClicked: emulatorModel.findEmulatorImages() | ||
498 | 86 | } | ||
499 | 87 | } | ||
500 | 88 | } | ||
501 | 89 | } | ||
502 | 90 | Item { | ||
503 | 91 | id: centerItem | ||
504 | 92 | Layout.minimumWidth: units.gu(78) | ||
505 | 93 | Layout.fillWidth: true | ||
506 | 94 | property int currentIndex: emulatorList.currentIndex | ||
507 | 95 | Repeater { | ||
508 | 96 | model: emulatorModel | ||
509 | 97 | anchors.fill: parent | ||
510 | 98 | Rectangle{ | ||
511 | 99 | id: deviceItemView | ||
512 | 100 | anchors.fill: parent | ||
513 | 101 | anchors.margins: 12 | ||
514 | 102 | |||
515 | 103 | color: Qt.rgba(0.0, 0.0, 0.0, 0.01) | ||
516 | 104 | visible: index == emulatorList.currentIndex && !emulatorModel.busy | ||
517 | 105 | |||
518 | 106 | UbuntuListView { | ||
519 | 107 | anchors.left: parent.left | ||
520 | 108 | anchors.top: parent.top | ||
521 | 109 | height: units.gu(50) | ||
522 | 110 | width: units.gu(50) | ||
523 | 111 | model: VisualItemModel { | ||
524 | 112 | ListItem.SingleValue { | ||
525 | 113 | text: i18n.tr("Ubuntu version") | ||
526 | 114 | value: ubuntuVersion | ||
527 | 115 | } | ||
528 | 116 | ListItem.SingleValue { | ||
529 | 117 | text: i18n.tr("Device version") | ||
530 | 118 | value: deviceVersion | ||
531 | 119 | } | ||
532 | 120 | ListItem.SingleValue { | ||
533 | 121 | text: i18n.tr("Image version") | ||
534 | 122 | value: imageVersion | ||
535 | 123 | } | ||
536 | 124 | ListItem.SingleControl { | ||
537 | 125 | control: Button { | ||
538 | 126 | text: "Start emulator" | ||
539 | 127 | onClicked: emulatorModel.startEmulator(display) | ||
540 | 128 | } | ||
541 | 129 | } | ||
542 | 130 | /* | ||
543 | 131 | ListItem.SingleControl { | ||
544 | 132 | control: Button { | ||
545 | 133 | text: "Delete emulator" | ||
546 | 134 | } | ||
547 | 135 | } | ||
548 | 136 | */ | ||
549 | 137 | } | ||
550 | 138 | } | ||
551 | 139 | |||
552 | 140 | Label { | ||
553 | 141 | visible: emulatorModel.busy | ||
554 | 142 | anchors.centerIn: parent | ||
555 | 143 | text: emulatorModel.state | ||
556 | 144 | fontSize: "large" | ||
557 | 145 | } | ||
558 | 146 | } | ||
559 | 147 | } | ||
560 | 148 | } | ||
561 | 149 | } | ||
562 | 150 | } | ||
563 | 0 | 151 | ||
564 | === added file 'share/qtcreator/ubuntu/devicespage/FeatureStateItem.qml' | |||
565 | --- share/qtcreator/ubuntu/devicespage/FeatureStateItem.qml 1970-01-01 00:00:00 +0000 | |||
566 | +++ share/qtcreator/ubuntu/devicespage/FeatureStateItem.qml 2014-04-27 13:29:17 +0000 | |||
567 | @@ -0,0 +1,46 @@ | |||
568 | 1 | import QtQuick 2.0 | ||
569 | 2 | import QtQuick.Layouts 1.0 | ||
570 | 3 | import Ubuntu.Components 0.1 | ||
571 | 4 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
572 | 5 | import Ubuntu.DevicesModel 0.1 | ||
573 | 6 | |||
574 | 7 | ListItem.Standard { | ||
575 | 8 | id: item | ||
576 | 9 | property var input: null | ||
577 | 10 | property string inputRole | ||
578 | 11 | property alias checkable: switchbox.enabled | ||
579 | 12 | |||
580 | 13 | onInputChanged: { | ||
581 | 14 | console.log("INPUT CHANGED !!!!!"+input); | ||
582 | 15 | if(input == States.Available) | ||
583 | 16 | switchbox.checked = true; | ||
584 | 17 | else | ||
585 | 18 | switchbox.checked = false; | ||
586 | 19 | } | ||
587 | 20 | |||
588 | 21 | selected: false | ||
589 | 22 | control: Row { | ||
590 | 23 | ActivityIndicator { | ||
591 | 24 | visible: input === States.Detecting | ||
592 | 25 | running: true | ||
593 | 26 | } | ||
594 | 27 | Switch { | ||
595 | 28 | id: switchbox | ||
596 | 29 | visible: input !== States.Detecting | ||
597 | 30 | checked: input === States.Available | ||
598 | 31 | enabled: checkable | ||
599 | 32 | onCheckedChanged: { | ||
600 | 33 | console.log("!!!!!!!!!!!!!!!!!!!!!!!!!!Checked changed!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | ||
601 | 34 | |||
602 | 35 | if (checked && input == States.NotAvailable) { | ||
603 | 36 | devicesModel.set(index,inputRole,true); | ||
604 | 37 | checked = true; | ||
605 | 38 | } | ||
606 | 39 | else if ((!checked) && input == States.Available) { | ||
607 | 40 | devicesModel.set(index,inputRole,false); | ||
608 | 41 | checked = false; | ||
609 | 42 | } | ||
610 | 43 | } | ||
611 | 44 | } | ||
612 | 45 | } | ||
613 | 46 | } | ||
614 | 0 | 47 | ||
615 | === added file 'share/qtcreator/ubuntu/devicespage/LogPage.qml' | |||
616 | --- share/qtcreator/ubuntu/devicespage/LogPage.qml 1970-01-01 00:00:00 +0000 | |||
617 | +++ share/qtcreator/ubuntu/devicespage/LogPage.qml 2014-04-27 13:29:17 +0000 | |||
618 | @@ -0,0 +1,24 @@ | |||
619 | 1 | import QtQuick 2.0 | ||
620 | 2 | import QtQuick.Layouts 1.0 | ||
621 | 3 | import QtQuick.Controls 1.0 as Controls | ||
622 | 4 | |||
623 | 5 | import Ubuntu.Components 0.1 | ||
624 | 6 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
625 | 7 | import Ubuntu.Components.Popups 0.1 | ||
626 | 8 | |||
627 | 9 | Page { | ||
628 | 10 | flickable: null | ||
629 | 11 | |||
630 | 12 | Controls.TextArea { | ||
631 | 13 | id: logTextArea | ||
632 | 14 | anchors.fill: parent | ||
633 | 15 | readOnly: true | ||
634 | 16 | textFormat: TextEdit.AutoText | ||
635 | 17 | Component.onCompleted: { | ||
636 | 18 | deviceMode.appendText.connect(appendToLog); | ||
637 | 19 | } | ||
638 | 20 | function appendToLog (txt) { | ||
639 | 21 | logTextArea.append(txt); | ||
640 | 22 | } | ||
641 | 23 | } | ||
642 | 24 | } | ||
643 | 0 | 25 | ||
644 | === added file 'share/qtcreator/ubuntu/devicespage/NewEmulatorDialog.qml' | |||
645 | --- share/qtcreator/ubuntu/devicespage/NewEmulatorDialog.qml 1970-01-01 00:00:00 +0000 | |||
646 | +++ share/qtcreator/ubuntu/devicespage/NewEmulatorDialog.qml 2014-04-27 13:29:17 +0000 | |||
647 | @@ -0,0 +1,46 @@ | |||
648 | 1 | import QtQuick 2.0 | ||
649 | 2 | import Ubuntu.Components 0.1 | ||
650 | 3 | import Ubuntu.Components.Popups 0.1 | ||
651 | 4 | |||
652 | 5 | Dialog { | ||
653 | 6 | id: dialogue | ||
654 | 7 | title: i18n.tr("Create emulator") | ||
655 | 8 | text: i18n.tr("Please select a name for the emulator") | ||
656 | 9 | modal: true | ||
657 | 10 | TextField { | ||
658 | 11 | id: inputName | ||
659 | 12 | placeholderText: i18n.tr("Emulator name") | ||
660 | 13 | property string lastError | ||
661 | 14 | property bool hasError | ||
662 | 15 | onTextChanged: validate() | ||
663 | 16 | Component.onCompleted: validate() | ||
664 | 17 | function validate() { | ||
665 | 18 | var result = emulatorModel.validateEmulatorName(text); | ||
666 | 19 | hasError = !result.valid; | ||
667 | 20 | lastError = result.error; | ||
668 | 21 | } | ||
669 | 22 | } | ||
670 | 23 | Label { | ||
671 | 24 | horizontalAlignment: Text.AlignHCenter | ||
672 | 25 | text: inputName.lastError | ||
673 | 26 | color: "red" | ||
674 | 27 | visible: inputName.hasError | ||
675 | 28 | } | ||
676 | 29 | |||
677 | 30 | Button { | ||
678 | 31 | text: "cancel" | ||
679 | 32 | onClicked: PopupUtils.close(dialogue) | ||
680 | 33 | } | ||
681 | 34 | Button { | ||
682 | 35 | text: "create" | ||
683 | 36 | color: UbuntuColors.orange | ||
684 | 37 | enabled: !inputName.hasError | ||
685 | 38 | onClicked: { | ||
686 | 39 | if(inputName.hasError) | ||
687 | 40 | return; | ||
688 | 41 | emulatorModel.createEmulatorImage(inputName.text); | ||
689 | 42 | PopupUtils.close(dialogue); | ||
690 | 43 | } | ||
691 | 44 | } | ||
692 | 45 | } | ||
693 | 46 | |||
694 | 0 | 47 | ||
695 | === added file 'share/qtcreator/ubuntu/devicespage/devicespage.qmlproject' | |||
696 | --- share/qtcreator/ubuntu/devicespage/devicespage.qmlproject 1970-01-01 00:00:00 +0000 | |||
697 | +++ share/qtcreator/ubuntu/devicespage/devicespage.qmlproject 2014-04-27 13:29:17 +0000 | |||
698 | @@ -0,0 +1,20 @@ | |||
699 | 1 | /* File generated by Qt Creator, version 2.7.0 */ | ||
700 | 2 | |||
701 | 3 | import QmlProject 1.1 | ||
702 | 4 | |||
703 | 5 | Project { | ||
704 | 6 | mainFile: "devicespage.qml" | ||
705 | 7 | |||
706 | 8 | /* Include .qml, .js, and image files from current directory and subdirectories */ | ||
707 | 9 | QmlFiles { | ||
708 | 10 | directory: "." | ||
709 | 11 | } | ||
710 | 12 | JavaScriptFiles { | ||
711 | 13 | directory: "." | ||
712 | 14 | } | ||
713 | 15 | ImageFiles { | ||
714 | 16 | directory: "." | ||
715 | 17 | } | ||
716 | 18 | /* List of plugin directories passed to QML runtime */ | ||
717 | 19 | // importPaths: [ "../exampleplugin" ] | ||
718 | 20 | } | ||
719 | 0 | 21 | ||
720 | === added directory 'share/qtcreator/ubuntu/devicespage/dummydata' | |||
721 | === added file 'share/qtcreator/ubuntu/devicespage/dummydata/devicesModel.qml' | |||
722 | --- share/qtcreator/ubuntu/devicespage/dummydata/devicesModel.qml 1970-01-01 00:00:00 +0000 | |||
723 | +++ share/qtcreator/ubuntu/devicespage/dummydata/devicesModel.qml 2014-04-27 13:29:17 +0000 | |||
724 | @@ -0,0 +1,52 @@ | |||
725 | 1 | import QtQuick 2.0 | ||
726 | 2 | |||
727 | 3 | ListModel { | ||
728 | 4 | id: devicesModel | ||
729 | 5 | ListElement { | ||
730 | 6 | display: "Ubuntu Device Nexus S" | ||
731 | 7 | isEmulator: false | ||
732 | 8 | connectionState: 1 | ||
733 | 9 | connectionStateString: "Connected" | ||
734 | 10 | developerModeEnabled: 0 | ||
735 | 11 | hasNetworkConnection: 0 | ||
736 | 12 | hasWriteableImage: 1 | ||
737 | 13 | hasDeveloperTools: 2 | ||
738 | 14 | kits: [ | ||
739 | 15 | ListElement{ | ||
740 | 16 | kitId: "1" | ||
741 | 17 | displayName: "Nexus S UbuntuSDK for armhf (GCC ubuntu-sdk-14.04-trusty)" | ||
742 | 18 | } | ||
743 | 19 | ] | ||
744 | 20 | deviceLog: "<p><strong>Checking for network.....</strong><strong> </strong><br/>available</p><p><strong>Checking for readable Image....</strong><br/>not available</p>" | ||
745 | 21 | } | ||
746 | 22 | ListElement { | ||
747 | 23 | display: "Ubuntu Emulator" | ||
748 | 24 | isEmulator: true | ||
749 | 25 | connectionState: 1 | ||
750 | 26 | connectionStateString: "Connected" | ||
751 | 27 | developerModeEnabled: 1 | ||
752 | 28 | hasNetworkConnection: 1 | ||
753 | 29 | hasWriteableImage: 1 | ||
754 | 30 | hasDeveloperTools: 1 | ||
755 | 31 | kits: [ | ||
756 | 32 | ] | ||
757 | 33 | deviceLog: "<p><strong>Checking for network.....</strong><strong> </strong><br/>available</p><p><strong>Checking for readable Image....</strong><br/>not available</p>" | ||
758 | 34 | } | ||
759 | 35 | ListElement { | ||
760 | 36 | display: "Ubuntu Device Tablet" | ||
761 | 37 | isEmulator: false | ||
762 | 38 | connectionState: 0 | ||
763 | 39 | connectionStateString: "Disconnected" | ||
764 | 40 | developerModeEnabled: 0 | ||
765 | 41 | hasNetworkConnection: 0 | ||
766 | 42 | hasWriteableImage: 0 | ||
767 | 43 | hasDeveloperTools: 0 | ||
768 | 44 | kits: [ | ||
769 | 45 | ListElement{ | ||
770 | 46 | kitId: "1" | ||
771 | 47 | displayName: "Tablet UbuntuSDK for armhf (GCC ubuntu-sdk-14.04-trusty)" | ||
772 | 48 | } | ||
773 | 49 | ] | ||
774 | 50 | deviceLog: "<p><strong>Checking for network.....</strong><strong> </strong><br/>available</p><p><strong>Checking for readable Image....</strong><br/>not available</p>" | ||
775 | 51 | } | ||
776 | 52 | } | ||
777 | 0 | 53 | ||
778 | === added file 'share/qtcreator/ubuntu/devicespage/main.qml' | |||
779 | --- share/qtcreator/ubuntu/devicespage/main.qml 1970-01-01 00:00:00 +0000 | |||
780 | +++ share/qtcreator/ubuntu/devicespage/main.qml 2014-04-27 13:29:17 +0000 | |||
781 | @@ -0,0 +1,25 @@ | |||
782 | 1 | import QtQuick 2.0 | ||
783 | 2 | import Ubuntu.Components 0.1 | ||
784 | 3 | |||
785 | 4 | |||
786 | 5 | MainView { | ||
787 | 6 | id: modeRoot | ||
788 | 7 | width: 860 | ||
789 | 8 | height: 548 | ||
790 | 9 | |||
791 | 10 | Tabs { | ||
792 | 11 | Tab { | ||
793 | 12 | title: "Ubuntu Devices" | ||
794 | 13 | page: DevicePage{} | ||
795 | 14 | } | ||
796 | 15 | Tab { | ||
797 | 16 | title: "Emulators" | ||
798 | 17 | page: EmulatorPage{} | ||
799 | 18 | } | ||
800 | 19 | Tab { | ||
801 | 20 | title: "Log" | ||
802 | 21 | page: LogPage{} | ||
803 | 22 | } | ||
804 | 23 | } | ||
805 | 24 | } | ||
806 | 25 | |||
807 | 0 | 26 | ||
808 | === added file 'share/qtcreator/ubuntu/devicespage/test.qml#' | |||
809 | --- share/qtcreator/ubuntu/devicespage/test.qml# 1970-01-01 00:00:00 +0000 | |||
810 | +++ share/qtcreator/ubuntu/devicespage/test.qml# 2014-04-27 13:29:17 +0000 | |||
811 | @@ -0,0 +1,18 @@ | |||
812 | 1 | import QtQuick 2.0 | ||
813 | 2 | import QtQuick.Layouts 1.0 | ||
814 | 3 | import Ubuntu.Components 0.1 | ||
815 | 4 | |||
816 | 5 | MainView { | ||
817 | 6 | height: 640 | ||
818 | 7 | width: 480 | ||
819 | 8 | |||
820 | 9 | Page { | ||
821 | 10 | title: "Hello World" | ||
822 | 11 | ActivityIndicator { | ||
823 | 12 | anchors.fill: parent | ||
824 | 13 | visible: true | ||
825 | 14 | running: true | ||
826 | 15 | } | ||
827 | 16 | } | ||
828 | 17 | |||
829 | 18 | } | ||
830 | 0 | 19 | ||
831 | === modified file 'share/qtcreator/ubuntu/scripts/local_start_emulator' | |||
832 | --- share/qtcreator/ubuntu/scripts/local_start_emulator 2014-02-05 12:13:31 +0000 | |||
833 | +++ share/qtcreator/ubuntu/scripts/local_start_emulator 2014-04-27 13:29:17 +0000 | |||
834 | @@ -19,5 +19,4 @@ | |||
835 | 19 | ubuntu-emulator run ${EMULATOR} & | 19 | ubuntu-emulator run ${EMULATOR} & |
836 | 20 | set +e | 20 | set +e |
837 | 21 | adb wait-for-device | 21 | adb wait-for-device |
838 | 22 | adb forward tcp:9999 tcp:22 | ||
839 | 23 | set -e | 22 | set -e |
840 | 24 | 23 | ||
841 | === added file 'share/qtcreator/ubuntu/welcome/.excludes' | |||
842 | === added file 'src/ubuntu/images/list-add.png' | |||
843 | 25 | Binary files src/ubuntu/images/list-add.png 1970-01-01 00:00:00 +0000 and src/ubuntu/images/list-add.png 2014-04-27 13:29:17 +0000 differ | 24 | Binary files src/ubuntu/images/list-add.png 1970-01-01 00:00:00 +0000 and src/ubuntu/images/list-add.png 2014-04-27 13:29:17 +0000 differ |
844 | === added file 'src/ubuntu/images/list-remove.png' | |||
845 | 26 | Binary files src/ubuntu/images/list-remove.png 1970-01-01 00:00:00 +0000 and src/ubuntu/images/list-remove.png 2014-04-27 13:29:17 +0000 differ | 25 | Binary files src/ubuntu/images/list-remove.png 1970-01-01 00:00:00 +0000 and src/ubuntu/images/list-remove.png 2014-04-27 13:29:17 +0000 differ |
846 | === added file 'src/ubuntu/images/view-refresh.png' | |||
847 | 27 | Binary files src/ubuntu/images/view-refresh.png 1970-01-01 00:00:00 +0000 and src/ubuntu/images/view-refresh.png 2014-04-27 13:29:17 +0000 differ | 26 | Binary files src/ubuntu/images/view-refresh.png 1970-01-01 00:00:00 +0000 and src/ubuntu/images/view-refresh.png 2014-04-27 13:29:17 +0000 differ |
848 | === modified file 'src/ubuntu/resources.qrc' | |||
849 | --- src/ubuntu/resources.qrc 2013-09-04 15:30:00 +0000 | |||
850 | +++ src/ubuntu/resources.qrc 2014-04-27 13:29:17 +0000 | |||
851 | @@ -14,5 +14,7 @@ | |||
852 | 14 | <file>manifest.json.template</file> | 14 | <file>manifest.json.template</file> |
853 | 15 | <file>myapp.json.template</file> | 15 | <file>myapp.json.template</file> |
854 | 16 | <file>manifestlib.js</file> | 16 | <file>manifestlib.js</file> |
855 | 17 | <file>images/view-refresh.png</file> | ||
856 | 18 | <file>images/list-add.png</file> | ||
857 | 17 | </qresource> | 19 | </qresource> |
858 | 18 | </RCC> | 20 | </RCC> |
859 | 19 | 21 | ||
860 | === modified file 'src/ubuntu/ubuntu.pro' | |||
861 | --- src/ubuntu/ubuntu.pro 2014-04-03 12:28:13 +0000 | |||
862 | +++ src/ubuntu/ubuntu.pro 2014-04-27 13:29:17 +0000 | |||
863 | @@ -26,11 +26,29 @@ | |||
864 | 26 | RESOURCES += \ | 26 | RESOURCES += \ |
865 | 27 | resources.qrc | 27 | resources.qrc |
866 | 28 | 28 | ||
867 | 29 | #QML files | ||
868 | 30 | QML_ROOT="$${PWD}/../../share/qtcreator/ubuntu" | ||
869 | 31 | QML_FILES += \ | ||
870 | 32 | $$QML_ROOT/welcome/welcome.qml \ | ||
871 | 33 | $$QML_ROOT/welcome/Link.qml \ | ||
872 | 34 | $$QML_ROOT/welcome/NewsBox.qml\ | ||
873 | 35 | $$QML_ROOT/devicespage/main.qml \ | ||
874 | 36 | $$QML_ROOT/devicespage/DeviceAdvancedTab.qml \ | ||
875 | 37 | $$QML_ROOT/devicespage/DeviceBuilderTab.qml \ | ||
876 | 38 | $$QML_ROOT/devicespage/DeviceLogTab.qml \ | ||
877 | 39 | $$QML_ROOT/devicespage/DevicePage.qml \ | ||
878 | 40 | $$QML_ROOT/devicespage/DeviceStatusTab.qml \ | ||
879 | 41 | $$QML_ROOT/devicespage/EmulatorPage.qml \ | ||
880 | 42 | $$QML_ROOT/devicespage/FeatureStateItem.qml \ | ||
881 | 43 | $$QML_ROOT/devicespage/NewEmulatorDialog.qml \ | ||
882 | 44 | $$QML_ROOT/devicespage/LogPage.qml | ||
883 | 45 | |||
884 | 29 | OTHER_FILES += \ | 46 | OTHER_FILES += \ |
885 | 30 | UbuntuProject.mimetypes.xml \ | 47 | UbuntuProject.mimetypes.xml \ |
886 | 31 | manifest.json.template \ | 48 | manifest.json.template \ |
887 | 32 | myapp.json.template \ | 49 | myapp.json.template \ |
889 | 33 | manifestlib.js | 50 | manifestlib.js \ |
890 | 51 | $$QML_FILES | ||
891 | 34 | 52 | ||
892 | 35 | SOURCES += \ | 53 | SOURCES += \ |
893 | 36 | ubuntuplugin.cpp \ | 54 | ubuntuplugin.cpp \ |
894 | @@ -55,7 +73,7 @@ | |||
895 | 55 | ubuntuclickmanifest.cpp \ | 73 | ubuntuclickmanifest.cpp \ |
896 | 56 | ubuntuwebmode.cpp \ | 74 | ubuntuwebmode.cpp \ |
897 | 57 | ubuntupastebinmode.cpp \ | 75 | ubuntupastebinmode.cpp \ |
899 | 58 | ubuntudeviceswidget.cpp \ | 76 | #ubuntudeviceswidget.cpp \ |
900 | 59 | ubuntudevicemode.cpp \ | 77 | ubuntudevicemode.cpp \ |
901 | 60 | ubuntuprocess.cpp \ | 78 | ubuntuprocess.cpp \ |
902 | 61 | ubuntudevicenotifier.cpp \ | 79 | ubuntudevicenotifier.cpp \ |
903 | @@ -88,7 +106,9 @@ | |||
904 | 88 | ubunturemotedeployconfiguration.cpp \ | 106 | ubunturemotedeployconfiguration.cpp \ |
905 | 89 | ubuntulocalrunconfigurationfactory.cpp \ | 107 | ubuntulocalrunconfigurationfactory.cpp \ |
906 | 90 | ubunturemoteruncontrolfactory.cpp \ | 108 | ubunturemoteruncontrolfactory.cpp \ |
908 | 91 | ubuntulocalrunconfiguration.cpp | 109 | ubuntulocalrunconfiguration.cpp \ |
909 | 110 | ubuntudevicesmodel.cpp \ | ||
910 | 111 | ubuntuemulatormodel.cpp | ||
911 | 92 | 112 | ||
912 | 93 | HEADERS += \ | 113 | HEADERS += \ |
913 | 94 | ubuntuplugin.h \ | 114 | ubuntuplugin.h \ |
914 | @@ -117,7 +137,7 @@ | |||
915 | 117 | ubuntuwebmode.h \ | 137 | ubuntuwebmode.h \ |
916 | 118 | ubuntupastebinmode.h \ | 138 | ubuntupastebinmode.h \ |
917 | 119 | ubuntudevicemode.h \ | 139 | ubuntudevicemode.h \ |
919 | 120 | ubuntudeviceswidget.h \ | 140 | #ubuntudeviceswidget.h \ |
920 | 121 | ubuntuprocess.h \ | 141 | ubuntuprocess.h \ |
921 | 122 | ubuntudevicenotifier.h \ | 142 | ubuntudevicenotifier.h \ |
922 | 123 | ubuntusettingspage.h \ | 143 | ubuntusettingspage.h \ |
923 | @@ -149,5 +169,7 @@ | |||
924 | 149 | ubunturemotedeployconfiguration.h \ | 169 | ubunturemotedeployconfiguration.h \ |
925 | 150 | ubuntulocalrunconfigurationfactory.h \ | 170 | ubuntulocalrunconfigurationfactory.h \ |
926 | 151 | ubunturemoteruncontrolfactory.h \ | 171 | ubunturemoteruncontrolfactory.h \ |
928 | 152 | ubuntulocalrunconfiguration.h | 172 | ubuntulocalrunconfiguration.h \ |
929 | 173 | ubuntudevicesmodel.h \ | ||
930 | 174 | ubuntuemulatormodel.h | ||
931 | 153 | 175 | ||
932 | 154 | 176 | ||
933 | === modified file 'src/ubuntu/ubuntuconstants.h' | |||
934 | --- src/ubuntu/ubuntuconstants.h 2014-04-10 15:59:28 +0000 | |||
935 | +++ src/ubuntu/ubuntuconstants.h 2014-04-27 13:29:17 +0000 | |||
936 | @@ -120,7 +120,7 @@ | |||
937 | 120 | const char UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR[] = "Creating new emulator instance."; | 120 | const char UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR[] = "Creating new emulator instance."; |
938 | 121 | const char UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR_SCRIPT[] = "%0/local_create_emulator %1 %2"; | 121 | const char UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR_SCRIPT[] = "%0/local_create_emulator %1 %2"; |
939 | 122 | const char UBUNTUDEVICESWIDGET_LOCAL_START_EMULATOR[] = "Starting the selected emulator."; | 122 | const char UBUNTUDEVICESWIDGET_LOCAL_START_EMULATOR[] = "Starting the selected emulator."; |
941 | 123 | const char UBUNTUDEVICESWIDGET_LOCAL_START_EMULATOR_SCRIPT[] = "%0/local_start_emulator %1"; | 123 | const char UBUNTUDEVICESWIDGET_LOCAL_START_EMULATOR_SCRIPT[] = "%0/local_start_emulator"; |
942 | 124 | 124 | ||
943 | 125 | 125 | ||
944 | 126 | const char UBUNTUDEVICESWIDGET_STARTSSHSERVICE[] = "Start ssh service on device.."; | 126 | const char UBUNTUDEVICESWIDGET_STARTSSHSERVICE[] = "Start ssh service on device.."; |
945 | @@ -213,7 +213,7 @@ | |||
946 | 213 | const char UBUNTUDEVICESWIDGET_DETECTOPENSSH[] = "Detecting if openssh-server is installed.."; | 213 | const char UBUNTUDEVICESWIDGET_DETECTOPENSSH[] = "Detecting if openssh-server is installed.."; |
947 | 214 | const char UBUNTUDEVICESWIDGET_DETECTOPENSSH_SCRIPT[] = "%0/openssh_version %1"; | 214 | const char UBUNTUDEVICESWIDGET_DETECTOPENSSH_SCRIPT[] = "%0/openssh_version %1"; |
948 | 215 | const char UBUNTUDEVICESWIDGET_DETECTDEVICES[] = "Detecting device.."; | 215 | const char UBUNTUDEVICESWIDGET_DETECTDEVICES[] = "Detecting device.."; |
950 | 216 | const char UBUNTUDEVICESWIDGET_DETECTDEVICES_SCRIPT[] = "%0/device_search %1"; | 216 | const char UBUNTUDEVICESWIDGET_DETECTDEVICES_SCRIPT[] = "%0/device_search"; |
951 | 217 | const char UBUNTUDEVICESWIDGET_SSHCONNECT_SCRIPT[] = "%0/openssh_connect"; | 217 | const char UBUNTUDEVICESWIDGET_SSHCONNECT_SCRIPT[] = "%0/openssh_connect"; |
952 | 218 | const char UBUNTUDEVICESWIDGET_SSHCONNECT[] = "Opening ssh connection to device"; | 218 | const char UBUNTUDEVICESWIDGET_SSHCONNECT[] = "Opening ssh connection to device"; |
953 | 219 | 219 | ||
954 | @@ -241,6 +241,8 @@ | |||
955 | 241 | #endif | 241 | #endif |
956 | 242 | 242 | ||
957 | 243 | const QString UBUNTU_WELCOMESCREEN_QML = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/welcome/welcome.qml"); | 243 | const QString UBUNTU_WELCOMESCREEN_QML = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/welcome/welcome.qml"); |
958 | 244 | const QString UBUNTU_DEVICESCREEN_QML = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/devicespage/main.qml"); | ||
959 | 245 | const QString UBUNTU_DEVICESCREEN_ROOT = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/devicespage"); | ||
960 | 244 | const QString UBUNTU_TEMPLATESPATH = UBUNTU_RESOURCE_PATH + QLatin1String("/templates/wizards/ubuntu/"); | 246 | const QString UBUNTU_TEMPLATESPATH = UBUNTU_RESOURCE_PATH + QLatin1String("/templates/wizards/ubuntu/"); |
961 | 245 | const QString UBUNTU_MENUPATH = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/"); | 247 | const QString UBUNTU_MENUPATH = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/"); |
962 | 246 | const QString UBUNTU_SHAREPATH = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/"); | 248 | const QString UBUNTU_SHAREPATH = UBUNTU_RESOURCE_PATH + QLatin1String("/ubuntu/"); |
963 | 247 | 249 | ||
964 | === modified file 'src/ubuntu/ubuntudevice.cpp' | |||
965 | --- src/ubuntu/ubuntudevice.cpp 2014-04-10 19:03:23 +0000 | |||
966 | +++ src/ubuntu/ubuntudevice.cpp 2014-04-27 13:29:17 +0000 | |||
967 | @@ -24,6 +24,7 @@ | |||
968 | 24 | #include "localportsmanager.h" | 24 | #include "localportsmanager.h" |
969 | 25 | 25 | ||
970 | 26 | #include <projectexplorer/devicesupport/devicemanager.h> | 26 | #include <projectexplorer/devicesupport/devicemanager.h> |
971 | 27 | #include <remotelinux/genericlinuxdeviceconfigurationwidget.h> | ||
972 | 27 | #include <coreplugin/messagemanager.h> | 28 | #include <coreplugin/messagemanager.h> |
973 | 28 | #include <ssh/sshconnection.h> | 29 | #include <ssh/sshconnection.h> |
974 | 29 | #include <utils/portlist.h> | 30 | #include <utils/portlist.h> |
975 | @@ -32,11 +33,15 @@ | |||
976 | 32 | #include <QCoreApplication> | 33 | #include <QCoreApplication> |
977 | 33 | #include <QDir> | 34 | #include <QDir> |
978 | 34 | #include <QDebug> | 35 | #include <QDebug> |
979 | 36 | #include <QRegularExpression> | ||
980 | 35 | 37 | ||
981 | 36 | namespace Ubuntu { | 38 | namespace Ubuntu { |
982 | 37 | namespace Internal { | 39 | namespace Internal { |
983 | 38 | 40 | ||
984 | 39 | const QLatin1String DEVICE_INFO_KEY("UbuntuDevice.InfoString"); | 41 | const QLatin1String DEVICE_INFO_KEY("UbuntuDevice.InfoString"); |
985 | 42 | const QLatin1String DEVICE_PRODUCT_INFO_KEY("UbuntuDevice.Product.InfoString"); | ||
986 | 43 | const QLatin1String DEVICE_MODEL_INFO_KEY("UbuntuDevice.Model.InfoString"); | ||
987 | 44 | const QLatin1String DEVICE_DEVICE_INFO_KEY("UbuntuDevice.Device.InfoString"); | ||
988 | 40 | 45 | ||
989 | 41 | /*! | 46 | /*! |
990 | 42 | * \class UbuntuDeviceHelper | 47 | * \class UbuntuDeviceHelper |
991 | @@ -125,8 +130,8 @@ | |||
992 | 125 | m_clonedNwCount = 0; | 130 | m_clonedNwCount = 0; |
993 | 126 | if(m_dev->m_hasNetworkConnection != UbuntuDevice::Available) { | 131 | if(m_dev->m_hasNetworkConnection != UbuntuDevice::Available) { |
994 | 127 | m_dev->m_hasNetworkConnection = UbuntuDevice::Available; | 132 | m_dev->m_hasNetworkConnection = UbuntuDevice::Available; |
995 | 128 | emit featureDetected(); | ||
996 | 129 | } | 133 | } |
997 | 134 | emit featureDetected(); | ||
998 | 130 | detectOpenSsh(); | 135 | detectOpenSsh(); |
999 | 131 | 136 | ||
1000 | 132 | } else { | 137 | } else { |
1001 | @@ -137,9 +142,9 @@ | |||
1002 | 137 | //we tried to enable network and failed | 142 | //we tried to enable network and failed |
1003 | 138 | if(m_dev->m_hasNetworkConnection != UbuntuDevice::NotAvailable) { | 143 | if(m_dev->m_hasNetworkConnection != UbuntuDevice::NotAvailable) { |
1004 | 139 | m_dev->m_hasNetworkConnection = UbuntuDevice::NotAvailable; | 144 | m_dev->m_hasNetworkConnection = UbuntuDevice::NotAvailable; |
1005 | 140 | emit featureDetected(); | ||
1006 | 141 | emit deviceNeedsSetup(); | ||
1007 | 142 | } | 145 | } |
1008 | 146 | emit featureDetected(); | ||
1009 | 147 | emit deviceNeedsSetup(); | ||
1010 | 143 | //detect other features | 148 | //detect other features |
1011 | 144 | detectOpenSsh(); | 149 | detectOpenSsh(); |
1012 | 145 | } | 150 | } |
1013 | @@ -157,8 +162,8 @@ | |||
1014 | 157 | 162 | ||
1015 | 158 | if(m_dev->m_hasOpenSSHServer != UbuntuDevice::Available) { | 163 | if(m_dev->m_hasOpenSSHServer != UbuntuDevice::Available) { |
1016 | 159 | m_dev->m_hasOpenSSHServer = UbuntuDevice::Available; | 164 | m_dev->m_hasOpenSSHServer = UbuntuDevice::Available; |
1017 | 160 | emit featureDetected(); | ||
1018 | 161 | } | 165 | } |
1019 | 166 | emit featureDetected(); | ||
1020 | 162 | 167 | ||
1021 | 163 | ProjectExplorer::DeviceManager::instance()->setDeviceState(m_dev->id(),ProjectExplorer::IDevice::DeviceConnected); | 168 | ProjectExplorer::DeviceManager::instance()->setDeviceState(m_dev->id(),ProjectExplorer::IDevice::DeviceConnected); |
1022 | 164 | endAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_SSH_IS_INSTALLED).arg(m_reply.trimmed())); | 169 | endAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_SSH_IS_INSTALLED).arg(m_reply.trimmed())); |
1023 | @@ -170,9 +175,9 @@ | |||
1024 | 170 | 175 | ||
1025 | 171 | if(m_dev->m_hasOpenSSHServer != UbuntuDevice::NotAvailable) { | 176 | if(m_dev->m_hasOpenSSHServer != UbuntuDevice::NotAvailable) { |
1026 | 172 | m_dev->m_hasOpenSSHServer = UbuntuDevice::NotAvailable; | 177 | m_dev->m_hasOpenSSHServer = UbuntuDevice::NotAvailable; |
1027 | 173 | emit featureDetected(); | ||
1028 | 174 | emit deviceNeedsSetup(); | ||
1029 | 175 | } | 178 | } |
1030 | 179 | emit featureDetected(); | ||
1031 | 180 | emit deviceNeedsSetup(); | ||
1032 | 176 | 181 | ||
1033 | 177 | endAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_SSH_NOT_INSTALLED)); | 182 | endAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_SSH_NOT_INSTALLED)); |
1034 | 178 | 183 | ||
1035 | @@ -242,7 +247,6 @@ | |||
1036 | 242 | m_dev->m_hasDeveloperTools = UbuntuDevice::Available; | 247 | m_dev->m_hasDeveloperTools = UbuntuDevice::Available; |
1037 | 243 | endAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_DEVELOPERTOOLS_INSTALLED)); | 248 | endAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_DEVELOPERTOOLS_INSTALLED)); |
1038 | 244 | } | 249 | } |
1039 | 245 | |||
1040 | 246 | emit featureDetected(); | 250 | emit featureDetected(); |
1041 | 247 | break; | 251 | break; |
1042 | 248 | } | 252 | } |
1043 | @@ -297,6 +301,10 @@ | |||
1044 | 297 | void UbuntuDeviceHelper::detectOpenSsh() | 301 | void UbuntuDeviceHelper::detectOpenSsh() |
1045 | 298 | { | 302 | { |
1046 | 299 | setProcessState(UbuntuDevice::DetectOpenSSH); | 303 | setProcessState(UbuntuDevice::DetectOpenSSH); |
1047 | 304 | |||
1048 | 305 | m_dev->m_hasOpenSSHServer = UbuntuDevice::Unknown; | ||
1049 | 306 | emit featureDetected(); | ||
1050 | 307 | |||
1051 | 300 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DETECTOPENSSH)); | 308 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DETECTOPENSSH)); |
1052 | 301 | 309 | ||
1053 | 302 | stopProcess(); | 310 | stopProcess(); |
1054 | @@ -323,6 +331,9 @@ | |||
1055 | 323 | setProcessState(UbuntuDevice::InstallOpenSSH); | 331 | setProcessState(UbuntuDevice::InstallOpenSSH); |
1056 | 324 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_INSTALL)); | 332 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_INSTALL)); |
1057 | 325 | 333 | ||
1058 | 334 | m_dev->m_hasOpenSSHServer = UbuntuDevice::Unknown; | ||
1059 | 335 | emit featureDetected(); | ||
1060 | 336 | |||
1061 | 326 | stopProcess(); | 337 | stopProcess(); |
1062 | 327 | 338 | ||
1063 | 328 | startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_INSTALL_SCRIPT) | 339 | startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_INSTALL_SCRIPT) |
1064 | @@ -335,6 +346,9 @@ | |||
1065 | 335 | setProcessState(UbuntuDevice::RemoveOpenSSH); | 346 | setProcessState(UbuntuDevice::RemoveOpenSSH); |
1066 | 336 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_REMOVE)); | 347 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_REMOVE)); |
1067 | 337 | 348 | ||
1068 | 349 | m_dev->m_hasOpenSSHServer = UbuntuDevice::Unknown; | ||
1069 | 350 | emit featureDetected(); | ||
1070 | 351 | |||
1071 | 338 | stopProcess(); | 352 | stopProcess(); |
1072 | 339 | 353 | ||
1073 | 340 | startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_REMOVE_SCRIPT) | 354 | startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_SSH_REMOVE_SCRIPT) |
1074 | @@ -348,6 +362,10 @@ | |||
1075 | 348 | // adb shell nmcli dev list iface <intfc> | grep IP4.ADDRESS | 362 | // adb shell nmcli dev list iface <intfc> | grep IP4.ADDRESS |
1076 | 349 | // to find out the devices ip address | 363 | // to find out the devices ip address |
1077 | 350 | setProcessState(UbuntuDevice::DetectNetworkConnection); | 364 | setProcessState(UbuntuDevice::DetectNetworkConnection); |
1078 | 365 | |||
1079 | 366 | m_dev->m_hasNetworkConnection = UbuntuDevice::Unknown; | ||
1080 | 367 | emit featureDetected(); | ||
1081 | 368 | |||
1082 | 351 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_HASNETWORK)); | 369 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_HASNETWORK)); |
1083 | 352 | 370 | ||
1084 | 353 | stopProcess(); | 371 | stopProcess(); |
1085 | @@ -372,6 +390,10 @@ | |||
1086 | 372 | void UbuntuDeviceHelper::detectDeviceWritableImage() | 390 | void UbuntuDeviceHelper::detectDeviceWritableImage() |
1087 | 373 | { | 391 | { |
1088 | 374 | setProcessState(UbuntuDevice::DetectDeviceWriteableImage); | 392 | setProcessState(UbuntuDevice::DetectDeviceWriteableImage); |
1089 | 393 | |||
1090 | 394 | m_dev->m_hasWriteableImage = UbuntuDevice::Unknown; | ||
1091 | 395 | emit featureDetected(); | ||
1092 | 396 | |||
1093 | 375 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DETECTWRITABLEIMAGE)); | 397 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DETECTWRITABLEIMAGE)); |
1094 | 376 | 398 | ||
1095 | 377 | stopProcess(); | 399 | stopProcess(); |
1096 | @@ -384,6 +406,10 @@ | |||
1097 | 384 | void UbuntuDeviceHelper::detectDeveloperTools() | 406 | void UbuntuDeviceHelper::detectDeveloperTools() |
1098 | 385 | { | 407 | { |
1099 | 386 | setProcessState(UbuntuDevice::DetectDeveloperTools); | 408 | setProcessState(UbuntuDevice::DetectDeveloperTools); |
1100 | 409 | |||
1101 | 410 | m_dev->m_hasDeveloperTools = UbuntuDevice::Unknown; | ||
1102 | 411 | emit featureDetected(); | ||
1103 | 412 | |||
1104 | 387 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DETECTDEVELOPERTOOLS)); | 413 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DETECTDEVELOPERTOOLS)); |
1105 | 388 | 414 | ||
1106 | 389 | stopProcess(); | 415 | stopProcess(); |
1107 | @@ -503,6 +529,9 @@ | |||
1108 | 503 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSWRITABLE)); | 529 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSWRITABLE)); |
1109 | 504 | stopProcess(); | 530 | stopProcess(); |
1110 | 505 | 531 | ||
1111 | 532 | m_dev->m_hasWriteableImage = UbuntuDevice::Unknown; | ||
1112 | 533 | emit featureDetected(); | ||
1113 | 534 | |||
1114 | 506 | startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSWRITABLE_SCRIPT) | 535 | startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSWRITABLE_SCRIPT) |
1115 | 507 | .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH) | 536 | .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH) |
1116 | 508 | .arg(m_dev->id().toSetting().toString())); | 537 | .arg(m_dev->id().toSetting().toString())); |
1117 | @@ -517,6 +546,9 @@ | |||
1118 | 517 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSREADONLY)); | 546 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSREADONLY)); |
1119 | 518 | stopProcess(); | 547 | stopProcess(); |
1120 | 519 | 548 | ||
1121 | 549 | m_dev->m_hasWriteableImage = UbuntuDevice::Unknown; | ||
1122 | 550 | emit featureDetected(); | ||
1123 | 551 | |||
1124 | 520 | startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSREADONLY_SCRIPT) | 552 | startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_MAKEFSREADONLY_SCRIPT) |
1125 | 521 | .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH) | 553 | .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH) |
1126 | 522 | .arg(m_dev->id().toSetting().toString())); | 554 | .arg(m_dev->id().toSetting().toString())); |
1127 | @@ -589,6 +621,9 @@ | |||
1128 | 589 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ENABLEPLATFORMDEVELOPMENT)); | 621 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ENABLEPLATFORMDEVELOPMENT)); |
1129 | 590 | stopProcess(); | 622 | stopProcess(); |
1130 | 591 | 623 | ||
1131 | 624 | m_dev->m_hasDeveloperTools = UbuntuDevice::Unknown; | ||
1132 | 625 | emit featureDetected(); | ||
1133 | 626 | |||
1134 | 592 | startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ENABLEPLATFORMDEVELOPMENT_SCRIPT) | 627 | startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ENABLEPLATFORMDEVELOPMENT_SCRIPT) |
1135 | 593 | .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH) | 628 | .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH) |
1136 | 594 | .arg(m_dev->id().toSetting().toString())); | 629 | .arg(m_dev->id().toSetting().toString())); |
1137 | @@ -604,6 +639,9 @@ | |||
1138 | 604 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DISABLEPLATFORMDEVELOPMENT)); | 639 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DISABLEPLATFORMDEVELOPMENT)); |
1139 | 605 | stopProcess(); | 640 | stopProcess(); |
1140 | 606 | 641 | ||
1141 | 642 | m_dev->m_hasDeveloperTools = UbuntuDevice::Unknown; | ||
1142 | 643 | emit featureDetected(); | ||
1143 | 644 | |||
1144 | 607 | startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DISABLEPLATFORMDEVELOPMENT_SCRIPT) | 645 | startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DISABLEPLATFORMDEVELOPMENT_SCRIPT) |
1145 | 608 | .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH) | 646 | .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH) |
1146 | 609 | .arg(m_dev->id().toSetting().toString())); | 647 | .arg(m_dev->id().toSetting().toString())); |
1147 | @@ -630,9 +668,13 @@ | |||
1148 | 630 | void UbuntuDeviceHelper::cloneNetwork() | 668 | void UbuntuDeviceHelper::cloneNetwork() |
1149 | 631 | { | 669 | { |
1150 | 632 | m_clonedNwCount++; | 670 | m_clonedNwCount++; |
1151 | 671 | |||
1152 | 633 | setProcessState(UbuntuDevice::CloneNetwork); | 672 | setProcessState(UbuntuDevice::CloneNetwork); |
1153 | 634 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_CLONENETWORK)); | 673 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_CLONENETWORK)); |
1154 | 635 | 674 | ||
1155 | 675 | m_dev->m_hasNetworkConnection = UbuntuDevice::Unknown; | ||
1156 | 676 | emit featureDetected(); | ||
1157 | 677 | |||
1158 | 636 | stopProcess(); | 678 | stopProcess(); |
1159 | 637 | startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_CLONENETWORK_SCRIPT) | 679 | startProcess(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_CLONENETWORK_SCRIPT) |
1160 | 638 | .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH) | 680 | .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH) |
1161 | @@ -709,7 +751,9 @@ | |||
1162 | 709 | : LinuxDevice(other) | 751 | : LinuxDevice(other) |
1163 | 710 | , m_helper(new UbuntuDeviceHelper(this)) | 752 | , m_helper(new UbuntuDeviceHelper(this)) |
1164 | 711 | , m_processState(NotStarted) | 753 | , m_processState(NotStarted) |
1166 | 712 | , m_deviceInfoString(other.deviceInfoString()) | 754 | , m_deviceInfo(other.m_deviceInfo) |
1167 | 755 | , m_modelInfo(other.m_modelInfo) | ||
1168 | 756 | , m_productInfo(other.m_productInfo) | ||
1169 | 713 | { | 757 | { |
1170 | 714 | setDeviceState(ProjectExplorer::IDevice::DeviceDisconnected); | 758 | setDeviceState(ProjectExplorer::IDevice::DeviceDisconnected); |
1171 | 715 | setupPrivateKey(); | 759 | setupPrivateKey(); |
1172 | @@ -772,6 +816,11 @@ | |||
1173 | 772 | return m_helper; | 816 | return m_helper; |
1174 | 773 | } | 817 | } |
1175 | 774 | 818 | ||
1176 | 819 | void UbuntuDevice::cloneNetwork() | ||
1177 | 820 | { | ||
1178 | 821 | m_helper->cloneNetwork(); | ||
1179 | 822 | } | ||
1180 | 823 | |||
1181 | 775 | /*! | 824 | /*! |
1182 | 776 | * \brief UbuntuDevice::openTerminal | 825 | * \brief UbuntuDevice::openTerminal |
1183 | 777 | * Opens a detached terminal, logged into the device | 826 | * Opens a detached terminal, logged into the device |
1184 | @@ -898,14 +947,48 @@ | |||
1185 | 898 | m_helper->removeDevTools(); | 947 | m_helper->removeDevTools(); |
1186 | 899 | } | 948 | } |
1187 | 900 | 949 | ||
1196 | 901 | void UbuntuDevice::setDeviceInfoString(const QString &info) | 950 | void UbuntuDevice::setDeviceInfoString(const QString &deviceInfo) |
1197 | 902 | { | 951 | { |
1198 | 903 | m_deviceInfoString = info; | 952 | m_productInfo = tr("unknown"); |
1199 | 904 | } | 953 | m_modelInfo = m_productInfo; |
1200 | 905 | 954 | m_deviceInfo = m_productInfo; | |
1201 | 906 | QString UbuntuDevice::deviceInfoString() const | 955 | |
1202 | 907 | { | 956 | QRegularExpression expr(QStringLiteral("product:\\s?(\\w+)")); |
1203 | 908 | return m_deviceInfoString; | 957 | QRegularExpressionMatch m = expr.match(deviceInfo); |
1204 | 958 | if(m.hasMatch()) | ||
1205 | 959 | m_productInfo = m.captured(1); | ||
1206 | 960 | |||
1207 | 961 | expr.setPattern(QStringLiteral("model:\\s?(\\w+)")); | ||
1208 | 962 | m = expr.match(deviceInfo); | ||
1209 | 963 | if(m.hasMatch()) | ||
1210 | 964 | m_modelInfo = m.captured(1); | ||
1211 | 965 | |||
1212 | 966 | expr.setPattern(QStringLiteral("device:\\s?(\\w+)")); | ||
1213 | 967 | m = expr.match(deviceInfo); | ||
1214 | 968 | if(m.hasMatch()) | ||
1215 | 969 | m_deviceInfo = m.captured(1); | ||
1216 | 970 | } | ||
1217 | 971 | |||
1218 | 972 | void UbuntuDevice::setDeviceInfo(const QString &productInfo, const QString &modelInfo, const QString &deviceInfo) | ||
1219 | 973 | { | ||
1220 | 974 | m_productInfo = productInfo; | ||
1221 | 975 | m_modelInfo = modelInfo; | ||
1222 | 976 | m_deviceInfo = deviceInfo; | ||
1223 | 977 | } | ||
1224 | 978 | |||
1225 | 979 | QString UbuntuDevice::modelInfo() const | ||
1226 | 980 | { | ||
1227 | 981 | return m_modelInfo; | ||
1228 | 982 | } | ||
1229 | 983 | |||
1230 | 984 | QString UbuntuDevice::deviceInfo() const | ||
1231 | 985 | { | ||
1232 | 986 | return m_deviceInfo; | ||
1233 | 987 | } | ||
1234 | 988 | |||
1235 | 989 | QString UbuntuDevice::productInfo() const | ||
1236 | 990 | { | ||
1237 | 991 | return m_productInfo; | ||
1238 | 909 | } | 992 | } |
1239 | 910 | 993 | ||
1240 | 911 | UbuntuDevice::FeatureState UbuntuDevice::hasNetworkConnection() const | 994 | UbuntuDevice::FeatureState UbuntuDevice::hasNetworkConnection() const |
1241 | @@ -968,14 +1051,15 @@ | |||
1242 | 968 | case RemoveDevTools: | 1051 | case RemoveDevTools: |
1243 | 969 | return tr("Removing development tools"); | 1052 | return tr("Removing development tools"); |
1244 | 970 | case Done: | 1053 | case Done: |
1246 | 971 | return tr("Finished"); | 1054 | return tr("Ready"); |
1247 | 972 | } | 1055 | } |
1248 | 973 | return QString(); | 1056 | return QString(); |
1249 | 974 | } | 1057 | } |
1250 | 975 | 1058 | ||
1251 | 976 | ProjectExplorer::IDeviceWidget *UbuntuDevice::createWidget() | 1059 | ProjectExplorer::IDeviceWidget *UbuntuDevice::createWidget() |
1252 | 977 | { | 1060 | { |
1254 | 978 | return new UbuntuDeviceConfigurationWidget(sharedFromThis()); | 1061 | return new RemoteLinux::GenericLinuxDeviceConfigurationWidget(sharedFromThis()); |
1255 | 1062 | //return new UbuntuDeviceConfigurationWidget(sharedFromThis()); | ||
1256 | 979 | } | 1063 | } |
1257 | 980 | 1064 | ||
1258 | 981 | QList<Core::Id> UbuntuDevice::actionIds() const | 1065 | QList<Core::Id> UbuntuDevice::actionIds() const |
1259 | @@ -996,8 +1080,27 @@ | |||
1260 | 996 | void UbuntuDevice::fromMap(const QVariantMap &map) | 1080 | void UbuntuDevice::fromMap(const QVariantMap &map) |
1261 | 997 | { | 1081 | { |
1262 | 998 | LinuxDevice::fromMap(map); | 1082 | LinuxDevice::fromMap(map); |
1263 | 1083 | |||
1264 | 1084 | //legacy setting, will be converted to the new settings on the next save | ||
1265 | 999 | if(map.contains(DEVICE_INFO_KEY)) | 1085 | if(map.contains(DEVICE_INFO_KEY)) |
1267 | 1000 | m_deviceInfoString = map[DEVICE_INFO_KEY].toString(); | 1086 | setDeviceInfoString(map[DEVICE_INFO_KEY].toString()); |
1268 | 1087 | else { | ||
1269 | 1088 | QString unknown = tr("unknown"); | ||
1270 | 1089 | if(map.contains(DEVICE_DEVICE_INFO_KEY)) | ||
1271 | 1090 | m_deviceInfo = map[DEVICE_DEVICE_INFO_KEY].toString(); | ||
1272 | 1091 | else | ||
1273 | 1092 | m_deviceInfo = unknown; | ||
1274 | 1093 | |||
1275 | 1094 | if(map.contains(DEVICE_MODEL_INFO_KEY)) | ||
1276 | 1095 | m_modelInfo = map[DEVICE_MODEL_INFO_KEY].toString(); | ||
1277 | 1096 | else | ||
1278 | 1097 | m_modelInfo = unknown; | ||
1279 | 1098 | |||
1280 | 1099 | if(map.contains(DEVICE_PRODUCT_INFO_KEY)) | ||
1281 | 1100 | m_productInfo = map[DEVICE_PRODUCT_INFO_KEY].toString(); | ||
1282 | 1101 | else | ||
1283 | 1102 | m_productInfo = unknown; | ||
1284 | 1103 | } | ||
1285 | 1001 | 1104 | ||
1286 | 1002 | setupPrivateKey(); | 1105 | setupPrivateKey(); |
1287 | 1003 | m_helper->init(); | 1106 | m_helper->init(); |
1288 | @@ -1006,7 +1109,9 @@ | |||
1289 | 1006 | QVariantMap UbuntuDevice::toMap() const | 1109 | QVariantMap UbuntuDevice::toMap() const |
1290 | 1007 | { | 1110 | { |
1291 | 1008 | QVariantMap map = LinuxDevice::toMap(); | 1111 | QVariantMap map = LinuxDevice::toMap(); |
1293 | 1009 | map.insert(DEVICE_INFO_KEY,m_deviceInfoString); | 1112 | map.insert(DEVICE_PRODUCT_INFO_KEY,m_productInfo); |
1294 | 1113 | map.insert(DEVICE_MODEL_INFO_KEY,m_modelInfo); | ||
1295 | 1114 | map.insert(DEVICE_DEVICE_INFO_KEY,m_deviceInfo); | ||
1296 | 1010 | return map; | 1115 | return map; |
1297 | 1011 | } | 1116 | } |
1298 | 1012 | 1117 | ||
1299 | 1013 | 1118 | ||
1300 | === modified file 'src/ubuntu/ubuntudevice.h' | |||
1301 | --- src/ubuntu/ubuntudevice.h 2014-04-10 15:59:28 +0000 | |||
1302 | +++ src/ubuntu/ubuntudevice.h 2014-04-27 13:29:17 +0000 | |||
1303 | @@ -36,7 +36,6 @@ | |||
1304 | 36 | { | 36 | { |
1305 | 37 | Q_OBJECT | 37 | Q_OBJECT |
1306 | 38 | friend class UbuntuDevice; | 38 | friend class UbuntuDevice; |
1307 | 39 | |||
1308 | 40 | public: | 39 | public: |
1309 | 41 | explicit UbuntuDeviceHelper(UbuntuDevice* dev); | 40 | explicit UbuntuDeviceHelper(UbuntuDevice* dev); |
1310 | 42 | ~UbuntuDeviceHelper(); | 41 | ~UbuntuDeviceHelper(); |
1311 | @@ -150,6 +149,7 @@ | |||
1312 | 150 | QString serialNumber () const; | 149 | QString serialNumber () const; |
1313 | 151 | UbuntuDeviceHelper *helper () const; | 150 | UbuntuDeviceHelper *helper () const; |
1314 | 152 | 151 | ||
1315 | 152 | void cloneNetwork (); | ||
1316 | 153 | void openTerminal (); | 153 | void openTerminal (); |
1317 | 154 | void cloneTimeConfig (); | 154 | void cloneTimeConfig (); |
1318 | 155 | void enablePortForward (); | 155 | void enablePortForward (); |
1319 | @@ -162,8 +162,11 @@ | |||
1320 | 162 | void setWriteableImageEnabled ( const bool enabled = true ); | 162 | void setWriteableImageEnabled ( const bool enabled = true ); |
1321 | 163 | void setDeveloperToolsInstalled ( const bool installed = true ); | 163 | void setDeveloperToolsInstalled ( const bool installed = true ); |
1322 | 164 | 164 | ||
1325 | 165 | void setDeviceInfoString (const QString &info); | 165 | void setDeviceInfoString (const QString &deviceInfo); |
1326 | 166 | QString deviceInfoString () const; | 166 | void setDeviceInfo (const QString &productInfo, const QString &modelInfo, const QString &deviceInfo); |
1327 | 167 | QString modelInfo() const; | ||
1328 | 168 | QString deviceInfo() const; | ||
1329 | 169 | QString productInfo() const; | ||
1330 | 167 | 170 | ||
1331 | 168 | FeatureState developerModeEnabled () const; | 171 | FeatureState developerModeEnabled () const; |
1332 | 169 | FeatureState hasNetworkConnection () const; | 172 | FeatureState hasNetworkConnection () const; |
1333 | @@ -198,7 +201,9 @@ | |||
1334 | 198 | FeatureState m_hasWriteableImage; | 201 | FeatureState m_hasWriteableImage; |
1335 | 199 | FeatureState m_hasDeveloperTools; | 202 | FeatureState m_hasDeveloperTools; |
1336 | 200 | ProcessState m_processState; | 203 | ProcessState m_processState; |
1338 | 201 | QString m_deviceInfoString; | 204 | QString m_modelInfo; |
1339 | 205 | QString m_deviceInfo; | ||
1340 | 206 | QString m_productInfo; | ||
1341 | 202 | Utils::PortList m_localForwardedPorts; | 207 | Utils::PortList m_localForwardedPorts; |
1342 | 203 | 208 | ||
1343 | 204 | private: | 209 | private: |
1344 | 205 | 210 | ||
1345 | === modified file 'src/ubuntu/ubuntudevicemode.cpp' | |||
1346 | --- src/ubuntu/ubuntudevicemode.cpp 2013-09-04 15:30:00 +0000 | |||
1347 | +++ src/ubuntu/ubuntudevicemode.cpp 2014-04-27 13:29:17 +0000 | |||
1348 | @@ -18,6 +18,8 @@ | |||
1349 | 18 | 18 | ||
1350 | 19 | #include "ubuntudevicemode.h" | 19 | #include "ubuntudevicemode.h" |
1351 | 20 | #include "ubuntuconstants.h" | 20 | #include "ubuntuconstants.h" |
1352 | 21 | #include "ubuntudevicesmodel.h" | ||
1353 | 22 | #include "ubuntuemulatormodel.h" | ||
1354 | 21 | 23 | ||
1355 | 22 | #include <coreplugin/modemanager.h> | 24 | #include <coreplugin/modemanager.h> |
1356 | 23 | #include <coreplugin/editormanager/editormanager.h> | 25 | #include <coreplugin/editormanager/editormanager.h> |
1357 | @@ -29,18 +31,30 @@ | |||
1358 | 29 | #include <utils/styledbar.h> | 31 | #include <utils/styledbar.h> |
1359 | 30 | #include <QVBoxLayout> | 32 | #include <QVBoxLayout> |
1360 | 31 | #include <QScrollArea> | 33 | #include <QScrollArea> |
1361 | 34 | #include <QQuickView> | ||
1362 | 35 | #include <QQmlContext> | ||
1363 | 36 | #include <QQmlEngine> | ||
1364 | 37 | #include <QDebug> | ||
1365 | 32 | 38 | ||
1366 | 33 | using namespace Ubuntu::Internal; | 39 | using namespace Ubuntu::Internal; |
1367 | 34 | 40 | ||
1368 | 41 | UbuntuDeviceMode *UbuntuDeviceMode::m_instance = 0; | ||
1369 | 42 | |||
1370 | 35 | UbuntuDeviceMode::UbuntuDeviceMode(QObject *parent) : | 43 | UbuntuDeviceMode::UbuntuDeviceMode(QObject *parent) : |
1371 | 36 | Core::IMode(parent) | 44 | Core::IMode(parent) |
1372 | 37 | { | 45 | { |
1373 | 46 | Q_ASSERT_X(m_instance == 0, Q_FUNC_INFO,"There can be only one instance of UbuntuDeviceMode"); | ||
1374 | 47 | m_instance = this; | ||
1375 | 48 | |||
1376 | 49 | m_qmlControl = new UbuntuQMLDeviceMode(this); | ||
1377 | 50 | |||
1378 | 38 | setDisplayName(tr(Ubuntu::Constants::UBUNTU_MODE_DEVICES_DISPLAYNAME)); | 51 | setDisplayName(tr(Ubuntu::Constants::UBUNTU_MODE_DEVICES_DISPLAYNAME)); |
1379 | 39 | setIcon(QIcon(QLatin1String(Ubuntu::Constants::UBUNTU_MODE_DEVICES_ICON))); | 52 | setIcon(QIcon(QLatin1String(Ubuntu::Constants::UBUNTU_MODE_DEVICES_ICON))); |
1380 | 40 | setPriority(Ubuntu::Constants::UBUNTU_MODE_DEVICES_PRIORITY); | 53 | setPriority(Ubuntu::Constants::UBUNTU_MODE_DEVICES_PRIORITY); |
1381 | 41 | setId(Ubuntu::Constants::UBUNTU_MODE_DEVICES); | 54 | setId(Ubuntu::Constants::UBUNTU_MODE_DEVICES); |
1382 | 42 | setObjectName(QLatin1String(Ubuntu::Constants::UBUNTU_MODE_DEVICES)); | 55 | setObjectName(QLatin1String(Ubuntu::Constants::UBUNTU_MODE_DEVICES)); |
1383 | 43 | 56 | ||
1384 | 57 | |||
1385 | 44 | m_modeWidget = new QWidget; | 58 | m_modeWidget = new QWidget; |
1386 | 45 | QVBoxLayout *layout = new QVBoxLayout; | 59 | QVBoxLayout *layout = new QVBoxLayout; |
1387 | 46 | layout->setMargin(0); | 60 | layout->setMargin(0); |
1388 | @@ -49,22 +63,90 @@ | |||
1389 | 49 | 63 | ||
1390 | 50 | Utils::StyledBar* styledBar = new Utils::StyledBar(m_modeWidget); | 64 | Utils::StyledBar* styledBar = new Utils::StyledBar(m_modeWidget); |
1391 | 51 | layout->addWidget(styledBar); | 65 | layout->addWidget(styledBar); |
1397 | 52 | QScrollArea *scrollArea = new QScrollArea(m_modeWidget); | 66 | |
1398 | 53 | scrollArea->setFrameShape(QFrame::NoFrame); | 67 | m_modeView = new QQuickView; |
1399 | 54 | layout->addWidget(scrollArea); | 68 | m_modeView->setResizeMode(QQuickView::SizeRootObjectToView); |
1400 | 55 | scrollArea->setWidget(&m_ubuntuDevicesWidget); | 69 | m_devicesModel = new UbuntuDevicesModel(m_modeView); |
1401 | 56 | scrollArea->setWidgetResizable(true); | 70 | m_emulatorModel = new UbuntuEmulatorModel(m_modeView); |
1402 | 71 | |||
1403 | 72 | connect(m_devicesModel,SIGNAL(stdOutMessage(QString)),m_qmlControl,SLOT(addText(QString))); | ||
1404 | 73 | connect(m_devicesModel,SIGNAL(stdErrMessage(QString)),m_qmlControl,SLOT(addErrorText(QString))); | ||
1405 | 74 | connect(m_emulatorModel,SIGNAL(logMessage(QString)),m_qmlControl,SLOT(addText(QString))); | ||
1406 | 75 | connect(m_emulatorModel,SIGNAL(stdOutMessage(QString)),m_qmlControl,SLOT(addText(QString))); | ||
1407 | 76 | connect(m_emulatorModel,SIGNAL(stdErrMessage(QString)),m_qmlControl,SLOT(addErrorText(QString))); | ||
1408 | 77 | |||
1409 | 78 | QWidget* container = QWidget::createWindowContainer(m_modeView); | ||
1410 | 79 | container->setMinimumWidth(860); | ||
1411 | 80 | container->setMinimumHeight(548); | ||
1412 | 81 | container->setFocusPolicy(Qt::TabFocus); | ||
1413 | 82 | layout->addWidget(container); | ||
1414 | 83 | |||
1415 | 84 | m_modeView->rootContext()->setContextProperty(QLatin1String("devicesModel") ,m_devicesModel); | ||
1416 | 85 | m_modeView->rootContext()->setContextProperty(QLatin1String("emulatorModel"),m_emulatorModel); | ||
1417 | 86 | m_modeView->rootContext()->setContextProperty(QLatin1String("deviceMode") ,m_qmlControl); | ||
1418 | 87 | m_modeView->rootContext()->setContextProperty(QLatin1String("resourceRoot") ,Constants::UBUNTU_DEVICESCREEN_ROOT); | ||
1419 | 88 | m_modeView->setSource(QUrl::fromLocalFile(Constants::UBUNTU_DEVICESCREEN_QML)); | ||
1420 | 57 | 89 | ||
1421 | 58 | connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)), SLOT(modeChanged(Core::IMode*))); | 90 | connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)), SLOT(modeChanged(Core::IMode*))); |
1422 | 59 | |||
1423 | 60 | setWidget(m_modeWidget); | 91 | setWidget(m_modeWidget); |
1424 | 61 | } | 92 | } |
1425 | 62 | 93 | ||
1428 | 63 | void UbuntuDeviceMode::modeChanged(Core::IMode *mode) { | 94 | UbuntuDevice::ConstPtr UbuntuDeviceMode::device() |
1429 | 64 | 95 | { | |
1430 | 96 | if(m_devicesModel->rowCount() <= 0) | ||
1431 | 97 | return UbuntuDevice::ConstPtr(); | ||
1432 | 98 | |||
1433 | 99 | if(!m_deviceIndex.isValid()) { | ||
1434 | 100 | m_deviceIndex = 0; //device 0 is always the first selected | ||
1435 | 101 | } | ||
1436 | 102 | return m_devicesModel->device(m_deviceIndex.toInt()); | ||
1437 | 103 | } | ||
1438 | 104 | |||
1439 | 105 | void UbuntuDeviceMode::deviceSelected(const QVariant index) | ||
1440 | 106 | { | ||
1441 | 107 | m_deviceIndex = index; | ||
1442 | 108 | emit updateDeviceActions (); | ||
1443 | 109 | } | ||
1444 | 110 | |||
1445 | 111 | void UbuntuDeviceMode::modeChanged(Core::IMode *mode) | ||
1446 | 112 | { | ||
1447 | 113 | Q_UNUSED(mode); | ||
1448 | 65 | } | 114 | } |
1449 | 66 | 115 | ||
1450 | 67 | void UbuntuDeviceMode::initialize() { | 116 | void UbuntuDeviceMode::initialize() { |
1451 | 68 | 117 | ||
1453 | 69 | 118 | } | |
1454 | 119 | |||
1455 | 120 | UbuntuDeviceMode *UbuntuDeviceMode::instance() | ||
1456 | 121 | { | ||
1457 | 122 | return m_instance; | ||
1458 | 123 | } | ||
1459 | 124 | |||
1460 | 125 | |||
1461 | 126 | UbuntuQMLDeviceMode::UbuntuQMLDeviceMode(UbuntuDeviceMode *parent) | ||
1462 | 127 | : QObject(parent), | ||
1463 | 128 | m_mode(parent) | ||
1464 | 129 | { | ||
1465 | 130 | |||
1466 | 131 | } | ||
1467 | 132 | |||
1468 | 133 | void UbuntuQMLDeviceMode::deviceSelected(const QVariant index) | ||
1469 | 134 | { | ||
1470 | 135 | m_mode->deviceSelected(index); | ||
1471 | 136 | } | ||
1472 | 137 | |||
1473 | 138 | void UbuntuQMLDeviceMode::addText(const QString &arg) | ||
1474 | 139 | { | ||
1475 | 140 | QString in = arg; | ||
1476 | 141 | in.replace(QStringLiteral("\n"),QStringLiteral("<br>")); | ||
1477 | 142 | emit appendText(in); | ||
1478 | 143 | } | ||
1479 | 144 | |||
1480 | 145 | void UbuntuQMLDeviceMode::addErrorText(const QString &error) | ||
1481 | 146 | { | ||
1482 | 147 | QString in = error; | ||
1483 | 148 | in.replace(QStringLiteral("\n"),QStringLiteral("<br>")); | ||
1484 | 149 | in.prepend(QStringLiteral("<font color=\"#FF0000\">")); | ||
1485 | 150 | in.append(QStringLiteral("</font>")); | ||
1486 | 151 | emit appendText(in); | ||
1487 | 70 | } | 152 | } |
1488 | 71 | 153 | ||
1489 | === modified file 'src/ubuntu/ubuntudevicemode.h' | |||
1490 | --- src/ubuntu/ubuntudevicemode.h 2013-09-04 15:30:00 +0000 | |||
1491 | +++ src/ubuntu/ubuntudevicemode.h 2014-04-27 13:29:17 +0000 | |||
1492 | @@ -19,12 +19,38 @@ | |||
1493 | 19 | #ifndef UBUNTUDEVICEMODE_H | 19 | #ifndef UBUNTUDEVICEMODE_H |
1494 | 20 | #define UBUNTUDEVICEMODE_H | 20 | #define UBUNTUDEVICEMODE_H |
1495 | 21 | 21 | ||
1496 | 22 | #include "ubuntudevice.h" | ||
1497 | 22 | #include <coreplugin/imode.h> | 23 | #include <coreplugin/imode.h> |
1499 | 23 | #include "ubuntudeviceswidget.h" | 24 | |
1500 | 25 | class QQuickView; | ||
1501 | 24 | 26 | ||
1502 | 25 | namespace Ubuntu { | 27 | namespace Ubuntu { |
1503 | 26 | namespace Internal { | 28 | namespace Internal { |
1504 | 27 | 29 | ||
1505 | 30 | class UbuntuDevicesModel; | ||
1506 | 31 | class UbuntuEmulatorModel; | ||
1507 | 32 | class UbuntuDeviceMode; | ||
1508 | 33 | |||
1509 | 34 | class UbuntuQMLDeviceMode : public QObject { | ||
1510 | 35 | Q_OBJECT | ||
1511 | 36 | |||
1512 | 37 | public: | ||
1513 | 38 | UbuntuQMLDeviceMode( UbuntuDeviceMode *parent ); | ||
1514 | 39 | |||
1515 | 40 | public slots: | ||
1516 | 41 | void deviceSelected ( const QVariant index ); | ||
1517 | 42 | void addText (const QString &arg); | ||
1518 | 43 | void addErrorText (const QString &error); | ||
1519 | 44 | |||
1520 | 45 | signals: | ||
1521 | 46 | void logChanged(const QString &arg); | ||
1522 | 47 | void appendText(const QString &newText); | ||
1523 | 48 | |||
1524 | 49 | private: | ||
1525 | 50 | UbuntuDeviceMode* m_mode; | ||
1526 | 51 | }; | ||
1527 | 52 | |||
1528 | 53 | |||
1529 | 28 | class UbuntuDeviceMode : public Core::IMode | 54 | class UbuntuDeviceMode : public Core::IMode |
1530 | 29 | { | 55 | { |
1531 | 30 | Q_OBJECT | 56 | Q_OBJECT |
1532 | @@ -33,12 +59,26 @@ | |||
1533 | 33 | UbuntuDeviceMode(QObject *parent = 0); | 59 | UbuntuDeviceMode(QObject *parent = 0); |
1534 | 34 | void initialize(); | 60 | void initialize(); |
1535 | 35 | 61 | ||
1536 | 62 | static UbuntuDeviceMode *instance(); | ||
1537 | 63 | UbuntuDevice::ConstPtr device(); | ||
1538 | 64 | |||
1539 | 65 | void deviceSelected ( const QVariant index ); | ||
1540 | 66 | |||
1541 | 67 | signals: | ||
1542 | 68 | void updateDeviceActions (); | ||
1543 | 69 | |||
1544 | 36 | protected slots: | 70 | protected slots: |
1545 | 37 | void modeChanged(Core::IMode*); | 71 | void modeChanged(Core::IMode*); |
1546 | 38 | 72 | ||
1547 | 39 | protected: | 73 | protected: |
1548 | 74 | static UbuntuDeviceMode *m_instance; | ||
1549 | 75 | UbuntuDevicesModel *m_devicesModel; | ||
1550 | 76 | UbuntuEmulatorModel *m_emulatorModel; | ||
1551 | 77 | UbuntuQMLDeviceMode *m_qmlControl; | ||
1552 | 78 | QQuickView *m_modeView; | ||
1553 | 40 | QWidget* m_modeWidget; | 79 | QWidget* m_modeWidget; |
1555 | 41 | UbuntuDevicesWidget m_ubuntuDevicesWidget; | 80 | QVariant m_deviceIndex; |
1556 | 81 | QString m_log; | ||
1557 | 42 | }; | 82 | }; |
1558 | 43 | 83 | ||
1559 | 44 | 84 | ||
1560 | 45 | 85 | ||
1561 | === added file 'src/ubuntu/ubuntudevicesmodel.cpp' | |||
1562 | --- src/ubuntu/ubuntudevicesmodel.cpp 1970-01-01 00:00:00 +0000 | |||
1563 | +++ src/ubuntu/ubuntudevicesmodel.cpp 2014-04-27 13:29:17 +0000 | |||
1564 | @@ -0,0 +1,734 @@ | |||
1565 | 1 | #include "ubuntudevicesmodel.h" | ||
1566 | 2 | #include "ubuntuconstants.h" | ||
1567 | 3 | #include "ubuntukitmanager.h" | ||
1568 | 4 | |||
1569 | 5 | #include <projectexplorer/devicesupport/devicemanager.h> | ||
1570 | 6 | #include <projectexplorer/kitmanager.h> | ||
1571 | 7 | #include <projectexplorer/kit.h> | ||
1572 | 8 | #include <projectexplorer/kitinformation.h> | ||
1573 | 9 | |||
1574 | 10 | #include <QCoreApplication> | ||
1575 | 11 | #include <QRegularExpression> | ||
1576 | 12 | #include <QRegularExpressionMatch> | ||
1577 | 13 | #include <QVariant> | ||
1578 | 14 | |||
1579 | 15 | namespace Ubuntu { | ||
1580 | 16 | namespace Internal { | ||
1581 | 17 | |||
1582 | 18 | UbuntuDevicesModel::UbuntuDevicesModel(QObject *parent) : | ||
1583 | 19 | QAbstractListModel(parent) | ||
1584 | 20 | { | ||
1585 | 21 | m_deviceNotifier = new UbuntuDeviceNotifier(this); | ||
1586 | 22 | connect(m_deviceNotifier,SIGNAL(deviceConnected(QString)),this,SLOT(deviceConnected(QString))); | ||
1587 | 23 | |||
1588 | 24 | m_adbProcess = new QProcess(this); | ||
1589 | 25 | connect(m_adbProcess,SIGNAL(finished(int)),this,SLOT(refreshFinished(int))); | ||
1590 | 26 | connect(m_adbProcess,SIGNAL(readyRead()),this,SLOT(adbReadyRead())); | ||
1591 | 27 | |||
1592 | 28 | |||
1593 | 29 | ProjectExplorer::KitManager* devMgr = static_cast<ProjectExplorer::KitManager*>(ProjectExplorer::KitManager::instance()); | ||
1594 | 30 | connect(devMgr,SIGNAL(kitsLoaded()),this,SLOT(refresh())); | ||
1595 | 31 | connect(ProjectExplorer::DeviceManager::instance(),SIGNAL(deviceListReplaced()),this,SLOT(readDevicesFromSettings())); | ||
1596 | 32 | } | ||
1597 | 33 | |||
1598 | 34 | bool UbuntuDevicesModel::set(int index, const QString &role, const QVariant &value) | ||
1599 | 35 | { | ||
1600 | 36 | if(index < 0 || index >= rowCount()) | ||
1601 | 37 | return false; | ||
1602 | 38 | |||
1603 | 39 | QModelIndex idx = createIndex(index,0); | ||
1604 | 40 | if(!roleNames().values().contains(role.toUtf8())) | ||
1605 | 41 | return false; | ||
1606 | 42 | |||
1607 | 43 | return setData(idx,value,roleNames().key(role.toUtf8())); | ||
1608 | 44 | } | ||
1609 | 45 | |||
1610 | 46 | int UbuntuDevicesModel::rowCount(const QModelIndex &parent) const | ||
1611 | 47 | { | ||
1612 | 48 | if(parent.isValid()) | ||
1613 | 49 | return 0; | ||
1614 | 50 | return m_knownDevices.size(); | ||
1615 | 51 | } | ||
1616 | 52 | |||
1617 | 53 | bool UbuntuDevicesModel::setData(const QModelIndex &index, const QVariant &value, int role) | ||
1618 | 54 | { | ||
1619 | 55 | qDebug()<<"Setting index "<<index<<" with data "<<value<<" to role "<<role; | ||
1620 | 56 | if(!index.isValid() | ||
1621 | 57 | || index.parent().isValid() | ||
1622 | 58 | || index.row() < 0 | ||
1623 | 59 | || index.row() > rowCount()) | ||
1624 | 60 | return false; | ||
1625 | 61 | |||
1626 | 62 | UbuntuDevice::Ptr dev = m_knownDevices[index.row()]->device(); | ||
1627 | 63 | |||
1628 | 64 | switch (role) { | ||
1629 | 65 | case Qt::DisplayRole: | ||
1630 | 66 | case Qt::EditRole: | ||
1631 | 67 | return false; | ||
1632 | 68 | case KitListRole: | ||
1633 | 69 | return false; | ||
1634 | 70 | case DeveloperModeRole: { | ||
1635 | 71 | if(!value.type() == QVariant::Bool) | ||
1636 | 72 | return false; | ||
1637 | 73 | |||
1638 | 74 | bool set = value.toBool(); | ||
1639 | 75 | UbuntuDevice::FeatureState newState = set ? UbuntuDevice::Available : UbuntuDevice::NotAvailable; | ||
1640 | 76 | UbuntuDevice::FeatureState oldState = dev->developerModeEnabled(); | ||
1641 | 77 | |||
1642 | 78 | if(oldState == UbuntuDevice::Unknown) | ||
1643 | 79 | return false; | ||
1644 | 80 | |||
1645 | 81 | if( oldState != newState ) | ||
1646 | 82 | dev->setDeveloperModeEnabled(set); | ||
1647 | 83 | return true; | ||
1648 | 84 | break; | ||
1649 | 85 | } | ||
1650 | 86 | case NetworkConnectionRole: { | ||
1651 | 87 | if(!value.type() == QVariant::Bool) | ||
1652 | 88 | return false; | ||
1653 | 89 | |||
1654 | 90 | bool set = value.toBool(); | ||
1655 | 91 | UbuntuDevice::FeatureState oldState = dev->hasNetworkConnection(); | ||
1656 | 92 | |||
1657 | 93 | if( oldState == UbuntuDevice::Unknown || oldState == UbuntuDevice::Available ) | ||
1658 | 94 | return false; | ||
1659 | 95 | |||
1660 | 96 | if(set) | ||
1661 | 97 | dev->cloneNetwork(); | ||
1662 | 98 | return true; | ||
1663 | 99 | |||
1664 | 100 | break; | ||
1665 | 101 | } | ||
1666 | 102 | case WriteableImageRole: { | ||
1667 | 103 | if(!value.type() == QVariant::Bool) | ||
1668 | 104 | return false; | ||
1669 | 105 | |||
1670 | 106 | bool set = value.toBool(); | ||
1671 | 107 | UbuntuDevice::FeatureState newState = set ? UbuntuDevice::Available : UbuntuDevice::NotAvailable; | ||
1672 | 108 | UbuntuDevice::FeatureState oldState = dev->hasWriteableImage(); | ||
1673 | 109 | |||
1674 | 110 | if(oldState == UbuntuDevice::Unknown) | ||
1675 | 111 | return false; | ||
1676 | 112 | |||
1677 | 113 | if( oldState != newState ) | ||
1678 | 114 | dev->setWriteableImageEnabled(set); | ||
1679 | 115 | return true; | ||
1680 | 116 | break; | ||
1681 | 117 | } | ||
1682 | 118 | case DeveloperToolsRole: { | ||
1683 | 119 | if(!value.type() == QVariant::Bool) | ||
1684 | 120 | return false; | ||
1685 | 121 | |||
1686 | 122 | bool set = value.toBool(); | ||
1687 | 123 | UbuntuDevice::FeatureState newState = set ? UbuntuDevice::Available : UbuntuDevice::NotAvailable; | ||
1688 | 124 | UbuntuDevice::FeatureState oldState = dev->hasDeveloperTools(); | ||
1689 | 125 | |||
1690 | 126 | if(oldState == UbuntuDevice::Unknown) | ||
1691 | 127 | return false; | ||
1692 | 128 | |||
1693 | 129 | if( oldState != newState ) | ||
1694 | 130 | dev->setDeveloperToolsInstalled(set); | ||
1695 | 131 | return true; | ||
1696 | 132 | break; | ||
1697 | 133 | } | ||
1698 | 134 | default: | ||
1699 | 135 | break; | ||
1700 | 136 | } | ||
1701 | 137 | |||
1702 | 138 | return false; | ||
1703 | 139 | } | ||
1704 | 140 | |||
1705 | 141 | QVariant UbuntuDevicesModel::data(const QModelIndex &index, int role) const | ||
1706 | 142 | { | ||
1707 | 143 | if(!index.isValid() | ||
1708 | 144 | || index.parent().isValid() | ||
1709 | 145 | || index.row() < 0 | ||
1710 | 146 | || index.row() > rowCount()) | ||
1711 | 147 | return QVariant(); | ||
1712 | 148 | |||
1713 | 149 | switch (role) { | ||
1714 | 150 | case Qt::DisplayRole: | ||
1715 | 151 | case Qt::EditRole: | ||
1716 | 152 | return m_knownDevices[index.row()]->device()->displayName(); | ||
1717 | 153 | case UniqueIdRole: | ||
1718 | 154 | return m_knownDevices[index.row()]->id().uniqueIdentifier(); | ||
1719 | 155 | case DetectionStateRole: | ||
1720 | 156 | return m_knownDevices[index.row()]->device()->detectionState(); | ||
1721 | 157 | case DetectionStateStringRole: | ||
1722 | 158 | return m_knownDevices[index.row()]->device()->detectionStateString(); | ||
1723 | 159 | case ConnectionStateRole: | ||
1724 | 160 | return m_knownDevices[index.row()]->device()->deviceState(); | ||
1725 | 161 | case ConnectionStateStringRole: | ||
1726 | 162 | return m_knownDevices[index.row()]->device()->deviceStateToString(); | ||
1727 | 163 | case KitListRole: | ||
1728 | 164 | return QVariant::fromValue(m_knownDevices[index.row()]->kits()); | ||
1729 | 165 | case DeveloperModeRole: | ||
1730 | 166 | return m_knownDevices[index.row()]->device()->developerModeEnabled(); | ||
1731 | 167 | case NetworkConnectionRole: | ||
1732 | 168 | return m_knownDevices[index.row()]->device()->hasNetworkConnection(); | ||
1733 | 169 | case WriteableImageRole: | ||
1734 | 170 | return m_knownDevices[index.row()]->device()->hasWriteableImage(); | ||
1735 | 171 | case DeveloperToolsRole: | ||
1736 | 172 | return m_knownDevices[index.row()]->device()->hasDeveloperTools(); | ||
1737 | 173 | case EmulatorRole: | ||
1738 | 174 | return false; | ||
1739 | 175 | case LogRole: | ||
1740 | 176 | return m_knownDevices[index.row()]->device()->helper()->log(); | ||
1741 | 177 | case SerialIdRole: | ||
1742 | 178 | return m_knownDevices[index.row()]->device()->id().toSetting(); | ||
1743 | 179 | case ModelInfoRole: | ||
1744 | 180 | return m_knownDevices[index.row()]->device()->modelInfo(); | ||
1745 | 181 | case DeviceInfoRole: | ||
1746 | 182 | return m_knownDevices[index.row()]->device()->deviceInfo(); | ||
1747 | 183 | case ProductInfoRole: | ||
1748 | 184 | return m_knownDevices[index.row()]->device()->productInfo(); | ||
1749 | 185 | default: | ||
1750 | 186 | break; | ||
1751 | 187 | } | ||
1752 | 188 | |||
1753 | 189 | return QVariant(); | ||
1754 | 190 | } | ||
1755 | 191 | |||
1756 | 192 | QHash<int, QByteArray> UbuntuDevicesModel::roleNames() const | ||
1757 | 193 | { | ||
1758 | 194 | QHash<int,QByteArray> roles = QAbstractListModel::roleNames(); | ||
1759 | 195 | roles.insert(UniqueIdRole,"deviceId"); | ||
1760 | 196 | roles.insert(DetectionStateRole,"detectionState"); | ||
1761 | 197 | roles.insert(DetectionStateStringRole,"detectionStateString"); | ||
1762 | 198 | roles.insert(ConnectionStateRole,"connectionState"); | ||
1763 | 199 | roles.insert(ConnectionStateStringRole,"connectionStateString"); | ||
1764 | 200 | roles.insert(KitListRole,"kits"); | ||
1765 | 201 | roles.insert(DeveloperModeRole,"developerModeEnabled"); | ||
1766 | 202 | roles.insert(NetworkConnectionRole,"hasNetworkConnection"); | ||
1767 | 203 | roles.insert(WriteableImageRole,"hasWriteableImage"); | ||
1768 | 204 | roles.insert(DeveloperToolsRole,"hasDeveloperTools"); | ||
1769 | 205 | roles.insert(EmulatorRole,"isEmulator"); | ||
1770 | 206 | roles.insert(LogRole,"deviceLog"); | ||
1771 | 207 | roles.insert(SerialIdRole,"serial"); | ||
1772 | 208 | roles.insert(ModelInfoRole,"modelInfo"); | ||
1773 | 209 | roles.insert(DeviceInfoRole,"deviceInfo"); | ||
1774 | 210 | roles.insert(ProductInfoRole,"productInfo"); | ||
1775 | 211 | return roles; | ||
1776 | 212 | } | ||
1777 | 213 | |||
1778 | 214 | Qt::ItemFlags UbuntuDevicesModel::flags(const QModelIndex &index) const | ||
1779 | 215 | { | ||
1780 | 216 | return QAbstractListModel::flags(index) | Qt::ItemIsEditable; | ||
1781 | 217 | } | ||
1782 | 218 | |||
1783 | 219 | void UbuntuDevicesModel::triggerCloneTimeConfig(const int devId) | ||
1784 | 220 | { | ||
1785 | 221 | int row = findDevice(devId); | ||
1786 | 222 | if(row < 0) | ||
1787 | 223 | return; | ||
1788 | 224 | m_knownDevices[row]->device()->cloneTimeConfig(); | ||
1789 | 225 | } | ||
1790 | 226 | |||
1791 | 227 | void UbuntuDevicesModel::triggerPortForwarding(const int devId) | ||
1792 | 228 | { | ||
1793 | 229 | int row = findDevice(devId); | ||
1794 | 230 | if(row < 0) | ||
1795 | 231 | return; | ||
1796 | 232 | m_knownDevices[row]->device()->enablePortForward(); | ||
1797 | 233 | } | ||
1798 | 234 | |||
1799 | 235 | void UbuntuDevicesModel::triggerSSHSetup(const int devId) | ||
1800 | 236 | { | ||
1801 | 237 | int row = findDevice(devId); | ||
1802 | 238 | if(row < 0) | ||
1803 | 239 | return; | ||
1804 | 240 | m_knownDevices[row]->device()->deployPublicKey(); | ||
1805 | 241 | } | ||
1806 | 242 | |||
1807 | 243 | void UbuntuDevicesModel::triggerSSHConnection(const int devId) | ||
1808 | 244 | { | ||
1809 | 245 | int row = findDevice(devId); | ||
1810 | 246 | if(row < 0) | ||
1811 | 247 | return; | ||
1812 | 248 | m_knownDevices[row]->device()->openTerminal(); | ||
1813 | 249 | } | ||
1814 | 250 | |||
1815 | 251 | void UbuntuDevicesModel::triggerReboot(const int devId) | ||
1816 | 252 | { | ||
1817 | 253 | int row = findDevice(devId); | ||
1818 | 254 | if(row < 0) | ||
1819 | 255 | return; | ||
1820 | 256 | m_knownDevices[row]->device()->reboot(); | ||
1821 | 257 | } | ||
1822 | 258 | |||
1823 | 259 | void UbuntuDevicesModel::triggerRebootBootloader(const int devId) | ||
1824 | 260 | { | ||
1825 | 261 | int row = findDevice(devId); | ||
1826 | 262 | if(row < 0) | ||
1827 | 263 | return; | ||
1828 | 264 | m_knownDevices[row]->device()->rebootToBootloader(); | ||
1829 | 265 | } | ||
1830 | 266 | |||
1831 | 267 | void UbuntuDevicesModel::triggerRebootRecovery(const int devId) | ||
1832 | 268 | { | ||
1833 | 269 | int row = findDevice(devId); | ||
1834 | 270 | if(row < 0) | ||
1835 | 271 | return; | ||
1836 | 272 | m_knownDevices[row]->device()->rebootToRecovery(); | ||
1837 | 273 | } | ||
1838 | 274 | |||
1839 | 275 | void UbuntuDevicesModel::triggerShutdown(const int devId) | ||
1840 | 276 | { | ||
1841 | 277 | int row = findDevice(devId); | ||
1842 | 278 | if(row < 0) | ||
1843 | 279 | return; | ||
1844 | 280 | m_knownDevices[row]->device()->shutdown(); | ||
1845 | 281 | } | ||
1846 | 282 | |||
1847 | 283 | void UbuntuDevicesModel::triggerKitAutocreate(const int devId) | ||
1848 | 284 | { | ||
1849 | 285 | int row = findDevice(devId); | ||
1850 | 286 | if(row < 0) | ||
1851 | 287 | return; | ||
1852 | 288 | UbuntuKitManager::autoCreateKit(m_knownDevices[row]->device()); | ||
1853 | 289 | } | ||
1854 | 290 | |||
1855 | 291 | void UbuntuDevicesModel::triggerKitRemove(const int devId, const QVariant &kitid) | ||
1856 | 292 | { | ||
1857 | 293 | int row = findDevice(devId); | ||
1858 | 294 | if(row < 0) | ||
1859 | 295 | return; | ||
1860 | 296 | |||
1861 | 297 | ProjectExplorer::Kit* k = ProjectExplorer::KitManager::find(Core::Id::fromSetting(kitid)); | ||
1862 | 298 | if(ProjectExplorer::DeviceKitInformation::deviceId(k) == Core::Id(devId)) { | ||
1863 | 299 | //completely delete the kit | ||
1864 | 300 | ProjectExplorer::KitManager::deregisterKit(k); | ||
1865 | 301 | } | ||
1866 | 302 | } | ||
1867 | 303 | |||
1868 | 304 | void UbuntuDevicesModel::refresh() | ||
1869 | 305 | { | ||
1870 | 306 | if( m_adbProcess->state() != QProcess::NotRunning ) { | ||
1871 | 307 | //make sure we use a clean QProcess | ||
1872 | 308 | m_adbProcess->disconnect(this); | ||
1873 | 309 | m_adbProcess->kill(); | ||
1874 | 310 | m_adbProcess->deleteLater(); | ||
1875 | 311 | |||
1876 | 312 | m_adbProcess = new QProcess(this); | ||
1877 | 313 | connect(m_adbProcess,SIGNAL(finished(int)),this,SLOT(refreshFinished(int))); | ||
1878 | 314 | connect(m_adbProcess,SIGNAL(readyRead()),this,SLOT(adbReadyRead())); | ||
1879 | 315 | } | ||
1880 | 316 | bool restartAdb = true; | ||
1881 | 317 | m_adbProcess->setWorkingDirectory(QCoreApplication::applicationDirPath()); | ||
1882 | 318 | QStringList args = QStringList() << (restartAdb ? QString::number(1) : QString::number(0)); | ||
1883 | 319 | m_adbProcess->start(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_DETECTDEVICES_SCRIPT) | ||
1884 | 320 | .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH),args); | ||
1885 | 321 | |||
1886 | 322 | clear(); | ||
1887 | 323 | } | ||
1888 | 324 | |||
1889 | 325 | void UbuntuDevicesModel::clear() | ||
1890 | 326 | { | ||
1891 | 327 | if(rowCount()) { | ||
1892 | 328 | beginRemoveRows(QModelIndex(),0,rowCount()-1); | ||
1893 | 329 | qDeleteAll(m_knownDevices.begin(),m_knownDevices.end()); | ||
1894 | 330 | m_knownDevices.clear(); | ||
1895 | 331 | endRemoveRows(); | ||
1896 | 332 | } | ||
1897 | 333 | } | ||
1898 | 334 | |||
1899 | 335 | int UbuntuDevicesModel::findDevice(int uniqueIdentifier) const | ||
1900 | 336 | { | ||
1901 | 337 | for ( int i = 0; i < m_knownDevices.size(); i++ ) { | ||
1902 | 338 | if(m_knownDevices[i]->id().uniqueIdentifier() == uniqueIdentifier) | ||
1903 | 339 | return i; | ||
1904 | 340 | } | ||
1905 | 341 | return -1; | ||
1906 | 342 | } | ||
1907 | 343 | |||
1908 | 344 | bool UbuntuDevicesModel::hasDevice(int uniqueIdentifier) const | ||
1909 | 345 | { | ||
1910 | 346 | return findDevice(uniqueIdentifier) >= 0; | ||
1911 | 347 | } | ||
1912 | 348 | |||
1913 | 349 | UbuntuDevice::ConstPtr UbuntuDevicesModel::device(const int index) | ||
1914 | 350 | { | ||
1915 | 351 | if(index < 0 || index >= rowCount()) | ||
1916 | 352 | return UbuntuDevice::ConstPtr(); | ||
1917 | 353 | return m_knownDevices[index]->device(); | ||
1918 | 354 | } | ||
1919 | 355 | |||
1920 | 356 | UbuntuDevicesItem *UbuntuDevicesModel::createItem(UbuntuDevice::Ptr dev) | ||
1921 | 357 | { | ||
1922 | 358 | UbuntuDevicesItem *devItem = new UbuntuDevicesItem(dev,this); | ||
1923 | 359 | connect(devItem,SIGNAL(kitsChanged()),this,SLOT(kitsChanged())); | ||
1924 | 360 | connect(devItem,SIGNAL(detectionStateChanged()),this,SLOT(detectionStateChanged())); | ||
1925 | 361 | connect(devItem,SIGNAL(featureDetected()),this,SLOT(featureDetected())); | ||
1926 | 362 | connect(devItem,SIGNAL(logUpdated()),this,SLOT(logUpdated())); | ||
1927 | 363 | return devItem; | ||
1928 | 364 | } | ||
1929 | 365 | |||
1930 | 366 | /*! | ||
1931 | 367 | * \brief UbuntuDevicesModel::indexFromHelper | ||
1932 | 368 | * Checks if the passed QObject is a DeviceHelper and returns the | ||
1933 | 369 | * row index of the related device | ||
1934 | 370 | */ | ||
1935 | 371 | int UbuntuDevicesModel::indexFromHelper(QObject *possibleHelper) | ||
1936 | 372 | { | ||
1937 | 373 | UbuntuDevicesItem* hlpr = qobject_cast<UbuntuDevicesItem*>(possibleHelper); | ||
1938 | 374 | if(!hlpr) return -1; | ||
1939 | 375 | return findDevice(hlpr->id().uniqueIdentifier()); | ||
1940 | 376 | } | ||
1941 | 377 | |||
1942 | 378 | void UbuntuDevicesModel::deviceChanged(QObject *possibleHelper, const QVector<int> &relatedRoles) | ||
1943 | 379 | { | ||
1944 | 380 | int idx = indexFromHelper(possibleHelper); | ||
1945 | 381 | if(idx < 0) | ||
1946 | 382 | return; | ||
1947 | 383 | QModelIndex changed = createIndex(idx,0); | ||
1948 | 384 | emit dataChanged(changed,changed,relatedRoles); | ||
1949 | 385 | } | ||
1950 | 386 | |||
1951 | 387 | /*! | ||
1952 | 388 | * \brief UbuntuDevicesModel::readDevicesFromSettings | ||
1953 | 389 | * read all known devices from the DeviceManager, this is triggered | ||
1954 | 390 | * automatically on startup | ||
1955 | 391 | */ | ||
1956 | 392 | void UbuntuDevicesModel::readDevicesFromSettings() | ||
1957 | 393 | { | ||
1958 | 394 | clear(); | ||
1959 | 395 | |||
1960 | 396 | QList<UbuntuDevicesItem*> devs; | ||
1961 | 397 | ProjectExplorer::DeviceManager* devMgr = ProjectExplorer::DeviceManager::instance(); | ||
1962 | 398 | for(int i = 0; i < devMgr->deviceCount(); i++) { | ||
1963 | 399 | ProjectExplorer::IDevice::ConstPtr dev = devMgr->deviceAt(i); | ||
1964 | 400 | if(dev && dev->type() == Core::Id(Constants::UBUNTU_DEVICE_TYPE_ID)) { | ||
1965 | 401 | |||
1966 | 402 | //ugly hack to get a mutable version of the device | ||
1967 | 403 | //no idea why its necessary to lock it up | ||
1968 | 404 | Ubuntu::Internal::UbuntuDevice* cPtr = qSharedPointerCast<const Ubuntu::Internal::UbuntuDevice>(dev)->helper()->device(); | ||
1969 | 405 | if(cPtr) | ||
1970 | 406 | devs.append(createItem(cPtr->sharedFromThis())); | ||
1971 | 407 | |||
1972 | 408 | } | ||
1973 | 409 | } | ||
1974 | 410 | |||
1975 | 411 | beginInsertRows(QModelIndex(),0,devs.count()-1); | ||
1976 | 412 | m_knownDevices = devs; | ||
1977 | 413 | endInsertRows(); | ||
1978 | 414 | |||
1979 | 415 | connect(devMgr,SIGNAL(deviceAdded(Core::Id)),this,SLOT(deviceAdded(Core::Id))); | ||
1980 | 416 | connect(devMgr,SIGNAL(deviceRemoved(Core::Id)),this,SLOT(deviceRemoved(Core::Id))); | ||
1981 | 417 | connect(devMgr,SIGNAL(deviceUpdated(Core::Id)),this,SLOT(deviceUpdated(Core::Id))); | ||
1982 | 418 | } | ||
1983 | 419 | |||
1984 | 420 | void UbuntuDevicesModel::detectionStateChanged() | ||
1985 | 421 | { | ||
1986 | 422 | //contains the possible changed roles when this slot is called | ||
1987 | 423 | static QVector<int> relatedRoles = QVector<int>() | ||
1988 | 424 | << DetectionStateRole << DetectionStateStringRole; | ||
1989 | 425 | |||
1990 | 426 | deviceChanged(sender(),relatedRoles); | ||
1991 | 427 | } | ||
1992 | 428 | |||
1993 | 429 | void UbuntuDevicesModel::featureDetected() | ||
1994 | 430 | { | ||
1995 | 431 | //contains the possible changed roles when this slot is called | ||
1996 | 432 | static QVector<int> relatedRoles = QVector<int>() | ||
1997 | 433 | << DeveloperModeRole << NetworkConnectionRole | ||
1998 | 434 | << WriteableImageRole << DeveloperToolsRole; | ||
1999 | 435 | |||
2000 | 436 | deviceChanged(sender(),relatedRoles); | ||
2001 | 437 | } | ||
2002 | 438 | |||
2003 | 439 | void UbuntuDevicesModel::logUpdated() | ||
2004 | 440 | { | ||
2005 | 441 | //contains the possible changed roles when this slot is called | ||
2006 | 442 | static QVector<int> relatedRoles = QVector<int>() | ||
2007 | 443 | << LogRole; | ||
2008 | 444 | |||
2009 | 445 | deviceChanged(sender(),relatedRoles); | ||
2010 | 446 | } | ||
2011 | 447 | |||
2012 | 448 | void UbuntuDevicesModel::kitsChanged() | ||
2013 | 449 | { | ||
2014 | 450 | //contains the possible changed roles when this slot is called | ||
2015 | 451 | static QVector<int> relatedRoles = QVector<int>() | ||
2016 | 452 | << KitListRole; | ||
2017 | 453 | |||
2018 | 454 | deviceChanged(sender(),relatedRoles); | ||
2019 | 455 | } | ||
2020 | 456 | |||
2021 | 457 | /*! | ||
2022 | 458 | * \brief UbuntuDevicesModel::deviceAdded | ||
2023 | 459 | * A device was added in the DeviceManager, check if know it and | ||
2024 | 460 | * if we should know it. If its a new Ubuntu device its added to | ||
2025 | 461 | * the known devices | ||
2026 | 462 | */ | ||
2027 | 463 | void UbuntuDevicesModel::deviceAdded(const Core::Id &id) | ||
2028 | 464 | { | ||
2029 | 465 | ProjectExplorer::IDevice::ConstPtr ptr = ProjectExplorer::DeviceManager::instance()->find(id); | ||
2030 | 466 | if(!ptr) | ||
2031 | 467 | return; | ||
2032 | 468 | |||
2033 | 469 | if(ptr->type() != Core::Id(Constants::UBUNTU_DEVICE_TYPE_ID)) | ||
2034 | 470 | return; | ||
2035 | 471 | |||
2036 | 472 | qDebug()<<"Device Manager reports device added: "<<id.toString(); | ||
2037 | 473 | if (hasDevice(id.uniqueIdentifier())) | ||
2038 | 474 | return; | ||
2039 | 475 | |||
2040 | 476 | Ubuntu::Internal::UbuntuDevice::ConstPtr ubuntuDev | ||
2041 | 477 | = qSharedPointerCast<const Ubuntu::Internal::UbuntuDevice>(ptr); | ||
2042 | 478 | |||
2043 | 479 | Ubuntu::Internal::UbuntuDeviceHelper* hlp = ubuntuDev->helper(); | ||
2044 | 480 | Ubuntu::Internal::UbuntuDevice* dev = hlp->device(); | ||
2045 | 481 | |||
2046 | 482 | beginInsertRows(QModelIndex(),rowCount(),rowCount()); | ||
2047 | 483 | m_knownDevices.append(createItem(dev->sharedFromThis())); | ||
2048 | 484 | endInsertRows(); | ||
2049 | 485 | } | ||
2050 | 486 | |||
2051 | 487 | /*! | ||
2052 | 488 | * \brief UbuntuDevicesWidget::deviceRemoved | ||
2053 | 489 | * A device was removed from the device manager, if its one of ours | ||
2054 | 490 | * we will also remove it | ||
2055 | 491 | */ | ||
2056 | 492 | void UbuntuDevicesModel::deviceRemoved(const Core::Id &id) | ||
2057 | 493 | { | ||
2058 | 494 | int index = findDevice(id.uniqueIdentifier()); | ||
2059 | 495 | if(index < 0) | ||
2060 | 496 | return; | ||
2061 | 497 | |||
2062 | 498 | qDebug()<<"Device Manager reports device removed: "<<id.toString(); | ||
2063 | 499 | beginRemoveRows(QModelIndex(),index,index); | ||
2064 | 500 | delete m_knownDevices.takeAt(index); | ||
2065 | 501 | endRemoveRows(); | ||
2066 | 502 | } | ||
2067 | 503 | |||
2068 | 504 | /*! | ||
2069 | 505 | * \brief UbuntuDevicesModel::deviceUpdated | ||
2070 | 506 | * called when a device state is changed between connected | ||
2071 | 507 | * and disconnected or device data was changed | ||
2072 | 508 | */ | ||
2073 | 509 | void UbuntuDevicesModel::deviceUpdated(const Core::Id &id) | ||
2074 | 510 | { | ||
2075 | 511 | //contains the possible changed roles when this slot is called | ||
2076 | 512 | static QVector<int> relatedRoles = QVector<int>() | ||
2077 | 513 | << Qt::DisplayRole << Qt::EditRole | ||
2078 | 514 | << ConnectionStateRole << ConnectionStateStringRole; | ||
2079 | 515 | |||
2080 | 516 | int index = findDevice(id.uniqueIdentifier()); | ||
2081 | 517 | if(index >= 0) { | ||
2082 | 518 | QModelIndex changed = createIndex(index,0); | ||
2083 | 519 | emit dataChanged(changed, changed,relatedRoles); | ||
2084 | 520 | } | ||
2085 | 521 | } | ||
2086 | 522 | |||
2087 | 523 | void UbuntuDevicesModel::deviceConnected(const QString &id) | ||
2088 | 524 | { | ||
2089 | 525 | int idx = findDevice(Core::Id::fromSetting(id).uniqueIdentifier()); | ||
2090 | 526 | if(idx >= 0) | ||
2091 | 527 | return; | ||
2092 | 528 | |||
2093 | 529 | refresh(); | ||
2094 | 530 | } | ||
2095 | 531 | |||
2096 | 532 | void UbuntuDevicesModel::refreshFinished(int exitCode) | ||
2097 | 533 | { | ||
2098 | 534 | readDevicesFromSettings(); | ||
2099 | 535 | foreach(UbuntuDevicesItem* item, m_knownDevices) | ||
2100 | 536 | item->device()->helper()->refresh(); | ||
2101 | 537 | |||
2102 | 538 | if(exitCode != 0) { | ||
2103 | 539 | return; | ||
2104 | 540 | } | ||
2105 | 541 | |||
2106 | 542 | //read all data from the process | ||
2107 | 543 | adbReadyRead(); | ||
2108 | 544 | |||
2109 | 545 | QStringList lines = m_adbReply.trimmed().split(QLatin1String(Constants::LINEFEED)); | ||
2110 | 546 | foreach(QString line, lines) { | ||
2111 | 547 | line = line.trimmed(); | ||
2112 | 548 | |||
2113 | 549 | if (line.isEmpty()) { | ||
2114 | 550 | continue; | ||
2115 | 551 | } | ||
2116 | 552 | |||
2117 | 553 | QRegularExpression exp(QLatin1String(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_ADB_REGEX)); | ||
2118 | 554 | QRegularExpressionMatch match = exp.match(line); | ||
2119 | 555 | |||
2120 | 556 | if(match.hasMatch()) { | ||
2121 | 557 | QStringList lineData = match.capturedTexts(); | ||
2122 | 558 | |||
2123 | 559 | //The first entry is always the full match | ||
2124 | 560 | //which means in our case its the complete string | ||
2125 | 561 | lineData.takeFirst(); | ||
2126 | 562 | |||
2127 | 563 | if (lineData.count() == 2) { | ||
2128 | 564 | QString sSerialNumber = lineData.takeFirst(); | ||
2129 | 565 | QString sDeviceInfo = lineData.takeFirst(); | ||
2130 | 566 | |||
2131 | 567 | //sometimes the adb server is not started when adb devices is | ||
2132 | 568 | //executed, we just skip those lines | ||
2133 | 569 | if(sSerialNumber == QLatin1String("*")) | ||
2134 | 570 | continue; | ||
2135 | 571 | |||
2136 | 572 | if(sSerialNumber.isEmpty() || sSerialNumber.startsWith(QLatin1String(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_ADB_NOACCESS))) { | ||
2137 | 573 | continue; | ||
2138 | 574 | } | ||
2139 | 575 | |||
2140 | 576 | registerNewDevice(sSerialNumber,sDeviceInfo); | ||
2141 | 577 | } | ||
2142 | 578 | } | ||
2143 | 579 | } | ||
2144 | 580 | } | ||
2145 | 581 | |||
2146 | 582 | void UbuntuDevicesModel::adbReadyRead() | ||
2147 | 583 | { | ||
2148 | 584 | QString stderr = QString::fromLocal8Bit(m_adbProcess->readAllStandardError()); | ||
2149 | 585 | QString stdout = QString::fromLocal8Bit(m_adbProcess->readAllStandardOutput()); | ||
2150 | 586 | |||
2151 | 587 | if(!stderr.trimmed().isEmpty()) { | ||
2152 | 588 | emit stdErrMessage(stderr); | ||
2153 | 589 | m_adbReply.append(stderr); | ||
2154 | 590 | } | ||
2155 | 591 | |||
2156 | 592 | if(!stdout.trimmed().isEmpty()) { | ||
2157 | 593 | emit stdOutMessage(stdout); | ||
2158 | 594 | m_adbReply.append(stdout); | ||
2159 | 595 | } | ||
2160 | 596 | qDebug()<<m_adbReply; | ||
2161 | 597 | } | ||
2162 | 598 | |||
2163 | 599 | /*! | ||
2164 | 600 | * \brief UbuntuDevicesModel::registerNewDevice | ||
2165 | 601 | * Registers a new device in the device manager if its not | ||
2166 | 602 | * already in the known devices map. | ||
2167 | 603 | * \note will not add it into model list, this | ||
2168 | 604 | * will happen automatically when the device is | ||
2169 | 605 | * registered in the device manager | ||
2170 | 606 | */ | ||
2171 | 607 | void UbuntuDevicesModel::registerNewDevice(const QString &serial, const QString &deviceInfo) | ||
2172 | 608 | { | ||
2173 | 609 | if(findDevice(Core::Id::fromSetting(serial).uniqueIdentifier()) >= 0) | ||
2174 | 610 | return; | ||
2175 | 611 | |||
2176 | 612 | bool isEmu = serial.startsWith(QLatin1String("emulator")); | ||
2177 | 613 | |||
2178 | 614 | Ubuntu::Internal::UbuntuDevice::Ptr dev = Ubuntu::Internal::UbuntuDevice::create( | ||
2179 | 615 | tr("Ubuntu Device") | ||
2180 | 616 | , serial | ||
2181 | 617 | , isEmu ? ProjectExplorer::IDevice::Emulator : ProjectExplorer::IDevice::Hardware | ||
2182 | 618 | , ProjectExplorer::IDevice::AutoDetected); | ||
2183 | 619 | |||
2184 | 620 | dev->setDeviceInfoString(deviceInfo); | ||
2185 | 621 | ProjectExplorer::DeviceManager::instance()->addDevice(dev); | ||
2186 | 622 | } | ||
2187 | 623 | |||
2188 | 624 | /*! | ||
2189 | 625 | * \class UbuntuDevicesItem | ||
2190 | 626 | * Represents a Device inside the UbuntuDevicesModel, | ||
2191 | 627 | * the item tracks changes in the device and notifies the model | ||
2192 | 628 | * accordingly | ||
2193 | 629 | */ | ||
2194 | 630 | UbuntuDevicesItem::UbuntuDevicesItem(UbuntuDevice::Ptr device, QObject* parent) : | ||
2195 | 631 | QObject(parent), | ||
2196 | 632 | m_device(device) | ||
2197 | 633 | { | ||
2198 | 634 | QList<ProjectExplorer::Kit*> allkits = ProjectExplorer::KitManager::kits(); | ||
2199 | 635 | foreach (ProjectExplorer::Kit* k, allkits) { | ||
2200 | 636 | if( ProjectExplorer::DeviceKitInformation::deviceId(k) == device->id() ) | ||
2201 | 637 | m_myKits.insert(k->id()); | ||
2202 | 638 | } | ||
2203 | 639 | |||
2204 | 640 | connect(ProjectExplorer::KitManager::instance(),SIGNAL(kitAdded(ProjectExplorer::Kit*)), | ||
2205 | 641 | this,SLOT(onKitAdded(ProjectExplorer::Kit*))); | ||
2206 | 642 | connect(ProjectExplorer::KitManager::instance(),SIGNAL(kitRemoved(ProjectExplorer::Kit*)), | ||
2207 | 643 | this,SLOT(onKitRemoved(ProjectExplorer::Kit*))); | ||
2208 | 644 | connect(ProjectExplorer::KitManager::instance(),SIGNAL(kitUpdated(ProjectExplorer::Kit*)), | ||
2209 | 645 | this,SLOT(onKitUpdated(ProjectExplorer::Kit*))); | ||
2210 | 646 | |||
2211 | 647 | connect(device->helper(),SIGNAL(detectionStateChanged()),this,SLOT(deviceStateChanged())); | ||
2212 | 648 | connect(device->helper(),SIGNAL(featureDetected()),this,SIGNAL(featureDetected())); | ||
2213 | 649 | connect(device->helper(),SIGNAL(message(QString)),this,SIGNAL(logUpdated())); | ||
2214 | 650 | } | ||
2215 | 651 | |||
2216 | 652 | /*! | ||
2217 | 653 | * \brief UbuntuDevicesItem::id | ||
2218 | 654 | * Returns the internal device ID | ||
2219 | 655 | */ | ||
2220 | 656 | Core::Id UbuntuDevicesItem::id() const | ||
2221 | 657 | { | ||
2222 | 658 | return m_device->id(); | ||
2223 | 659 | } | ||
2224 | 660 | |||
2225 | 661 | UbuntuDevice::Ptr UbuntuDevicesItem::device() const | ||
2226 | 662 | { | ||
2227 | 663 | return m_device; | ||
2228 | 664 | } | ||
2229 | 665 | |||
2230 | 666 | QVariantList UbuntuDevicesItem::kits() const | ||
2231 | 667 | { | ||
2232 | 668 | QVariantList kits; | ||
2233 | 669 | foreach (const Core::Id &id, m_myKits) { | ||
2234 | 670 | ProjectExplorer::Kit* k = ProjectExplorer::KitManager::find(id); | ||
2235 | 671 | if(!k) | ||
2236 | 672 | continue; | ||
2237 | 673 | |||
2238 | 674 | qDebug()<<"Adding "<<k->displayName(); | ||
2239 | 675 | |||
2240 | 676 | QVariantMap m; | ||
2241 | 677 | m.insert(QStringLiteral("displayName"),k->displayName()); | ||
2242 | 678 | m.insert(QStringLiteral("id"),k->id().toSetting()); | ||
2243 | 679 | kits.append(QVariant::fromValue(m)); | ||
2244 | 680 | } | ||
2245 | 681 | |||
2246 | 682 | return kits; | ||
2247 | 683 | } | ||
2248 | 684 | |||
2249 | 685 | /*! | ||
2250 | 686 | * \brief UbuntuDevicesItem::onKitAdded | ||
2251 | 687 | * Checks if the new Kit that just got added to the KitManager contains | ||
2252 | 688 | * the device, if it does the Kit is added to the internal Kit list | ||
2253 | 689 | */ | ||
2254 | 690 | void UbuntuDevicesItem::onKitAdded(ProjectExplorer::Kit *k) | ||
2255 | 691 | { | ||
2256 | 692 | if( ProjectExplorer::DeviceKitInformation::deviceId(k) == m_device->id() ) { | ||
2257 | 693 | if(!m_myKits.contains(k->id())){ | ||
2258 | 694 | m_myKits.insert(k->id()); | ||
2259 | 695 | emit kitsChanged(); | ||
2260 | 696 | } | ||
2261 | 697 | } | ||
2262 | 698 | } | ||
2263 | 699 | |||
2264 | 700 | /*! | ||
2265 | 701 | * \brief UbuntuDevicesItem::onKitRemoved | ||
2266 | 702 | * Checks if the removed Kit \a k is in the internal Kit list | ||
2267 | 703 | * and removes it | ||
2268 | 704 | */ | ||
2269 | 705 | void UbuntuDevicesItem::onKitRemoved(ProjectExplorer::Kit *k) | ||
2270 | 706 | { | ||
2271 | 707 | if(m_myKits.contains(k->id())) { | ||
2272 | 708 | m_myKits.remove(k->id()); | ||
2273 | 709 | emit kitsChanged(); | ||
2274 | 710 | } | ||
2275 | 711 | } | ||
2276 | 712 | |||
2277 | 713 | /*! | ||
2278 | 714 | * \brief UbuntuDevicesItem::onKitUpdated | ||
2279 | 715 | * Checks if the updated Kit now contains the internal device | ||
2280 | 716 | * or if it does NOT contain the device anymore | ||
2281 | 717 | */ | ||
2282 | 718 | void UbuntuDevicesItem::onKitUpdated(ProjectExplorer::Kit *k) | ||
2283 | 719 | { | ||
2284 | 720 | if( ProjectExplorer::DeviceKitInformation::deviceId(k) == m_device->id() ) { | ||
2285 | 721 | onKitAdded(k); | ||
2286 | 722 | } else { | ||
2287 | 723 | onKitRemoved(k); | ||
2288 | 724 | } | ||
2289 | 725 | } | ||
2290 | 726 | |||
2291 | 727 | void UbuntuDevicesItem::deviceStateChanged() | ||
2292 | 728 | { | ||
2293 | 729 | emit detectionStateChanged(); | ||
2294 | 730 | } | ||
2295 | 731 | |||
2296 | 732 | } | ||
2297 | 733 | } | ||
2298 | 734 | |||
2299 | 0 | 735 | ||
2300 | === added file 'src/ubuntu/ubuntudevicesmodel.h' | |||
2301 | --- src/ubuntu/ubuntudevicesmodel.h 1970-01-01 00:00:00 +0000 | |||
2302 | +++ src/ubuntu/ubuntudevicesmodel.h 2014-04-27 13:29:17 +0000 | |||
2303 | @@ -0,0 +1,169 @@ | |||
2304 | 1 | #ifndef UBUNTUDEVICESMODEL_H | ||
2305 | 2 | #define UBUNTUDEVICESMODEL_H | ||
2306 | 3 | |||
2307 | 4 | #include "ubuntudevice.h" | ||
2308 | 5 | #include "ubuntudevicenotifier.h" | ||
2309 | 6 | |||
2310 | 7 | #include <coreplugin/id.h> | ||
2311 | 8 | |||
2312 | 9 | #include <QAbstractListModel> | ||
2313 | 10 | #include <QList> | ||
2314 | 11 | |||
2315 | 12 | namespace ProjectExplorer { | ||
2316 | 13 | class Kit; | ||
2317 | 14 | } | ||
2318 | 15 | |||
2319 | 16 | namespace Ubuntu { | ||
2320 | 17 | namespace Internal { | ||
2321 | 18 | |||
2322 | 19 | class UbuntuDevicesItem; | ||
2323 | 20 | |||
2324 | 21 | class UbuntuDevicesModel : public QAbstractListModel | ||
2325 | 22 | { | ||
2326 | 23 | Q_OBJECT | ||
2327 | 24 | public: | ||
2328 | 25 | |||
2329 | 26 | enum Roles { | ||
2330 | 27 | ConnectionStateRole = Qt::UserRole, | ||
2331 | 28 | UniqueIdRole, | ||
2332 | 29 | ConnectionStateStringRole, | ||
2333 | 30 | DetectionStateRole, | ||
2334 | 31 | DetectionStateStringRole, | ||
2335 | 32 | KitListRole, | ||
2336 | 33 | DeveloperModeRole, | ||
2337 | 34 | NetworkConnectionRole, | ||
2338 | 35 | WriteableImageRole, | ||
2339 | 36 | DeveloperToolsRole, | ||
2340 | 37 | EmulatorRole, | ||
2341 | 38 | LogRole, | ||
2342 | 39 | SerialIdRole, | ||
2343 | 40 | ModelInfoRole, | ||
2344 | 41 | DeviceInfoRole, | ||
2345 | 42 | ProductInfoRole | ||
2346 | 43 | }; | ||
2347 | 44 | |||
2348 | 45 | explicit UbuntuDevicesModel(QObject *parent = 0); | ||
2349 | 46 | |||
2350 | 47 | Q_INVOKABLE bool set(int index, const QString &role, const QVariant &value); | ||
2351 | 48 | |||
2352 | 49 | int findDevice(int uniqueIdentifier) const; | ||
2353 | 50 | bool hasDevice (int uniqueIdentifier) const; | ||
2354 | 51 | UbuntuDevice::ConstPtr device ( const int index ); | ||
2355 | 52 | |||
2356 | 53 | // QAbstractItemModel interface | ||
2357 | 54 | virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; | ||
2358 | 55 | virtual bool setData(const QModelIndex &index, const QVariant &value, int role); | ||
2359 | 56 | virtual QVariant data(const QModelIndex &index, int role) const; | ||
2360 | 57 | virtual QHash<int, QByteArray> roleNames() const; | ||
2361 | 58 | virtual Qt::ItemFlags flags(const QModelIndex &index) const; | ||
2362 | 59 | signals: | ||
2363 | 60 | void logMessage (const QString &str); | ||
2364 | 61 | void stdOutMessage (const QString &str); | ||
2365 | 62 | void stdErrMessage (const QString &str); | ||
2366 | 63 | |||
2367 | 64 | public slots: | ||
2368 | 65 | void triggerCloneTimeConfig ( const int devId ); | ||
2369 | 66 | void triggerPortForwarding ( const int devId ); | ||
2370 | 67 | void triggerSSHSetup ( const int devId ); | ||
2371 | 68 | void triggerSSHConnection ( const int devId ); | ||
2372 | 69 | void triggerReboot ( const int devId ); | ||
2373 | 70 | void triggerRebootBootloader( const int devId ); | ||
2374 | 71 | void triggerRebootRecovery ( const int devId ); | ||
2375 | 72 | void triggerShutdown ( const int devId ); | ||
2376 | 73 | void triggerKitAutocreate ( const int devId ); | ||
2377 | 74 | void triggerKitRemove (const int devId, const QVariant &kitid ); | ||
2378 | 75 | void refresh (); | ||
2379 | 76 | |||
2380 | 77 | protected: | ||
2381 | 78 | void clear (); | ||
2382 | 79 | UbuntuDevicesItem *createItem (UbuntuDevice::Ptr dev); | ||
2383 | 80 | int indexFromHelper (QObject* possibleHelper); | ||
2384 | 81 | void deviceChanged(QObject* possibleHelper, const QVector<int> &relatedRoles); | ||
2385 | 82 | void registerNewDevice(const QString &serial, const QString &deviceInfo); | ||
2386 | 83 | |||
2387 | 84 | protected slots: | ||
2388 | 85 | void readDevicesFromSettings(); | ||
2389 | 86 | void detectionStateChanged (); | ||
2390 | 87 | void featureDetected (); | ||
2391 | 88 | void logUpdated (); | ||
2392 | 89 | void kitsChanged (); | ||
2393 | 90 | void deviceAdded(const Core::Id &id); | ||
2394 | 91 | void deviceRemoved(const Core::Id &id); | ||
2395 | 92 | void deviceUpdated(const Core::Id &id); | ||
2396 | 93 | void deviceConnected(const QString&id); | ||
2397 | 94 | void refreshFinished(int exitCode); | ||
2398 | 95 | void adbReadyRead(); | ||
2399 | 96 | |||
2400 | 97 | private: | ||
2401 | 98 | QList<UbuntuDevicesItem*> m_knownDevices; | ||
2402 | 99 | UbuntuDeviceNotifier *m_deviceNotifier; | ||
2403 | 100 | QProcess *m_adbProcess; | ||
2404 | 101 | QString m_adbReply; | ||
2405 | 102 | }; | ||
2406 | 103 | |||
2407 | 104 | /*! | ||
2408 | 105 | * \brief The UbuntuDeviceStates class | ||
2409 | 106 | * Provides enums for QML | ||
2410 | 107 | */ | ||
2411 | 108 | class UbuntuDeviceStates : public QObject | ||
2412 | 109 | { | ||
2413 | 110 | Q_OBJECT | ||
2414 | 111 | public: | ||
2415 | 112 | enum FeatureState { | ||
2416 | 113 | NotAvailable = UbuntuDevice::NotAvailable, | ||
2417 | 114 | Unknown = UbuntuDevice::Unknown, | ||
2418 | 115 | Available = UbuntuDevice::Available | ||
2419 | 116 | }; | ||
2420 | 117 | Q_ENUMS(FeatureState) | ||
2421 | 118 | |||
2422 | 119 | enum DeviceDetectionState { | ||
2423 | 120 | NotStarted = UbuntuDevice::NotStarted, | ||
2424 | 121 | Detecting, | ||
2425 | 122 | Done = UbuntuDevice::Done | ||
2426 | 123 | }; | ||
2427 | 124 | Q_ENUMS(DeviceDetectionState) | ||
2428 | 125 | |||
2429 | 126 | enum DeviceConnectionState { | ||
2430 | 127 | DeviceReadyToUse = ProjectExplorer::IDevice::DeviceReadyToUse, | ||
2431 | 128 | DeviceConnected = ProjectExplorer::IDevice::DeviceConnected, | ||
2432 | 129 | DeviceDisconnected = ProjectExplorer::IDevice::DeviceDisconnected, | ||
2433 | 130 | DeviceStateUnknown = ProjectExplorer::IDevice::DeviceStateUnknown | ||
2434 | 131 | }; | ||
2435 | 132 | Q_ENUMS(DeviceConnectionState) | ||
2436 | 133 | }; | ||
2437 | 134 | |||
2438 | 135 | class UbuntuDevicesItem : public QObject | ||
2439 | 136 | { | ||
2440 | 137 | Q_OBJECT | ||
2441 | 138 | public: | ||
2442 | 139 | UbuntuDevicesItem(Ubuntu::Internal::UbuntuDevice::Ptr device, QObject* parent = 0); | ||
2443 | 140 | |||
2444 | 141 | Core::Id id() const; | ||
2445 | 142 | UbuntuDevice::Ptr device() const; | ||
2446 | 143 | QVariantList kits() const; | ||
2447 | 144 | |||
2448 | 145 | signals: | ||
2449 | 146 | void kitsChanged (); | ||
2450 | 147 | void connectionChanged (); | ||
2451 | 148 | void detectionStateChanged (); | ||
2452 | 149 | void featureDetected (); | ||
2453 | 150 | void logUpdated(); | ||
2454 | 151 | |||
2455 | 152 | private slots: | ||
2456 | 153 | void onKitAdded(ProjectExplorer::Kit *k); | ||
2457 | 154 | void onKitRemoved(ProjectExplorer::Kit *k); | ||
2458 | 155 | void onKitUpdated(ProjectExplorer::Kit *k); | ||
2459 | 156 | void deviceStateChanged (); | ||
2460 | 157 | |||
2461 | 158 | |||
2462 | 159 | private: | ||
2463 | 160 | Ubuntu::Internal::UbuntuDevice::Ptr m_device; | ||
2464 | 161 | QSet<Core::Id> m_myKits; | ||
2465 | 162 | }; | ||
2466 | 163 | |||
2467 | 164 | } | ||
2468 | 165 | } | ||
2469 | 166 | |||
2470 | 167 | |||
2471 | 168 | |||
2472 | 169 | #endif // UBUNTUDEVICESMODEL_H | ||
2473 | 0 | 170 | ||
2474 | === added file 'src/ubuntu/ubuntuemulatormodel.cpp' | |||
2475 | --- src/ubuntu/ubuntuemulatormodel.cpp 1970-01-01 00:00:00 +0000 | |||
2476 | +++ src/ubuntu/ubuntuemulatormodel.cpp 2014-04-27 13:29:17 +0000 | |||
2477 | @@ -0,0 +1,408 @@ | |||
2478 | 1 | #include "ubuntuemulatormodel.h" | ||
2479 | 2 | #include "ubuntuconstants.h" | ||
2480 | 3 | |||
2481 | 4 | #include <utils/projectnamevalidatinglineedit.h> | ||
2482 | 5 | |||
2483 | 6 | #include <QMutableStringListIterator> | ||
2484 | 7 | #include <QCoreApplication> | ||
2485 | 8 | #include <QStandardPaths> | ||
2486 | 9 | #include <QDir> | ||
2487 | 10 | #include <QRegularExpression> | ||
2488 | 11 | #include <QRegularExpressionMatch> | ||
2489 | 12 | |||
2490 | 13 | namespace Ubuntu { | ||
2491 | 14 | namespace Internal { | ||
2492 | 15 | |||
2493 | 16 | /*! | ||
2494 | 17 | \brief UbuntuEmulatorModel | ||
2495 | 18 | Provides informations about all existing emulators | ||
2496 | 19 | \note This will be merged with the devices model when the | ||
2497 | 20 | emulator tool can query the serial number of not running | ||
2498 | 21 | emulators | ||
2499 | 22 | */ | ||
2500 | 23 | |||
2501 | 24 | UbuntuEmulatorModel::UbuntuEmulatorModel(QObject *parent) : | ||
2502 | 25 | QAbstractListModel(parent) , | ||
2503 | 26 | m_process(0), | ||
2504 | 27 | m_emulatorInstalled(false) , | ||
2505 | 28 | m_state(UbuntuEmulatorModel::Initial), | ||
2506 | 29 | m_cancellable(false) | ||
2507 | 30 | { | ||
2508 | 31 | m_process = new UbuntuProcess(this); | ||
2509 | 32 | connect(m_process,SIGNAL(message(QString)),this,SLOT(onMessage(QString))); | ||
2510 | 33 | connect(m_process,SIGNAL(finished(QString,int)),this,SLOT(processFinished(QString,int))); | ||
2511 | 34 | connect(m_process,SIGNAL(stdOut(QString)),this,SIGNAL(stdOutMessage(QString))); | ||
2512 | 35 | connect(m_process,SIGNAL(error(QString)),this,SIGNAL(stdErrMessage(QString))); | ||
2513 | 36 | |||
2514 | 37 | checkEmulatorInstalled(); | ||
2515 | 38 | } | ||
2516 | 39 | |||
2517 | 40 | bool UbuntuEmulatorModel::emulatorInstalled() const | ||
2518 | 41 | { | ||
2519 | 42 | return m_emulatorInstalled; | ||
2520 | 43 | } | ||
2521 | 44 | |||
2522 | 45 | void UbuntuEmulatorModel::setEmulatorInstalled(bool arg) | ||
2523 | 46 | { | ||
2524 | 47 | if (m_emulatorInstalled != arg) { | ||
2525 | 48 | m_emulatorInstalled = arg; | ||
2526 | 49 | emit emulatorInstalledChanged(arg); | ||
2527 | 50 | } | ||
2528 | 51 | } | ||
2529 | 52 | |||
2530 | 53 | bool UbuntuEmulatorModel::busy() const | ||
2531 | 54 | { | ||
2532 | 55 | return m_busy; | ||
2533 | 56 | } | ||
2534 | 57 | |||
2535 | 58 | void UbuntuEmulatorModel::setBusy(bool arg) | ||
2536 | 59 | { | ||
2537 | 60 | if (m_busy != arg) { | ||
2538 | 61 | m_busy = arg; | ||
2539 | 62 | emit busyChanged(arg); | ||
2540 | 63 | } | ||
2541 | 64 | } | ||
2542 | 65 | |||
2543 | 66 | QString UbuntuEmulatorModel::state() const | ||
2544 | 67 | { | ||
2545 | 68 | switch(m_state) { | ||
2546 | 69 | case CheckEmulator: { | ||
2547 | 70 | return tr("Checking if emulator tool is installed"); | ||
2548 | 71 | break; | ||
2549 | 72 | } | ||
2550 | 73 | case InstallEmulator: { | ||
2551 | 74 | return tr("Installing emulator tool"); | ||
2552 | 75 | break; | ||
2553 | 76 | } | ||
2554 | 77 | case CreateEmulatorImage: { | ||
2555 | 78 | return tr("Creating emulator image"); | ||
2556 | 79 | break; | ||
2557 | 80 | } | ||
2558 | 81 | case FindImages: { | ||
2559 | 82 | return tr("Searching for emulator images"); | ||
2560 | 83 | break; | ||
2561 | 84 | } | ||
2562 | 85 | default: | ||
2563 | 86 | return QString(); | ||
2564 | 87 | break; | ||
2565 | 88 | } | ||
2566 | 89 | } | ||
2567 | 90 | |||
2568 | 91 | void UbuntuEmulatorModel::setState(UbuntuEmulatorModel::State newState) | ||
2569 | 92 | { | ||
2570 | 93 | if(m_state != newState) { | ||
2571 | 94 | m_state = newState; | ||
2572 | 95 | if(m_state == UbuntuEmulatorModel::Initial || m_state == UbuntuEmulatorModel::Idle) | ||
2573 | 96 | setBusy(false); | ||
2574 | 97 | else | ||
2575 | 98 | setBusy(true); | ||
2576 | 99 | |||
2577 | 100 | emit stateChanged(state()); | ||
2578 | 101 | } | ||
2579 | 102 | } | ||
2580 | 103 | |||
2581 | 104 | bool UbuntuEmulatorModel::cancellable() const | ||
2582 | 105 | { | ||
2583 | 106 | return m_cancellable; | ||
2584 | 107 | } | ||
2585 | 108 | |||
2586 | 109 | void UbuntuEmulatorModel::setCancellable(bool arg) | ||
2587 | 110 | { | ||
2588 | 111 | if (m_cancellable != arg) { | ||
2589 | 112 | m_cancellable = arg; | ||
2590 | 113 | emit cancellableChanged(arg); | ||
2591 | 114 | } | ||
2592 | 115 | } | ||
2593 | 116 | |||
2594 | 117 | void UbuntuEmulatorModel::beginAction(const QString &msg) | ||
2595 | 118 | { | ||
2596 | 119 | emit logMessage(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ACTION_BEGIN).arg(msg)); | ||
2597 | 120 | } | ||
2598 | 121 | |||
2599 | 122 | void UbuntuEmulatorModel::endAction(const QString &msg) | ||
2600 | 123 | { | ||
2601 | 124 | emit logMessage(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_ACTION_END).arg(msg)); | ||
2602 | 125 | } | ||
2603 | 126 | |||
2604 | 127 | int UbuntuEmulatorModel::rowCount(const QModelIndex &parent) const | ||
2605 | 128 | { | ||
2606 | 129 | if(parent.isValid()) | ||
2607 | 130 | return 0; | ||
2608 | 131 | return m_data.size(); | ||
2609 | 132 | } | ||
2610 | 133 | |||
2611 | 134 | QVariant UbuntuEmulatorModel::data(const QModelIndex &index, int role) const | ||
2612 | 135 | { | ||
2613 | 136 | if(!index.isValid() | ||
2614 | 137 | || index.parent().isValid() | ||
2615 | 138 | || index.row() < 0 | ||
2616 | 139 | || index.row() > rowCount()) | ||
2617 | 140 | return QVariant(); | ||
2618 | 141 | |||
2619 | 142 | switch (role) { | ||
2620 | 143 | case Qt::DisplayRole: | ||
2621 | 144 | case Qt::EditRole: | ||
2622 | 145 | return m_data[index.row()].name; | ||
2623 | 146 | case UbuntuVersionRole: | ||
2624 | 147 | return m_data[index.row()].ubuntuVersion; | ||
2625 | 148 | case DeviceVersionRole: | ||
2626 | 149 | return m_data[index.row()].deviceVersion; | ||
2627 | 150 | case ImageVersionRole: | ||
2628 | 151 | return m_data[index.row()].imageVersion; | ||
2629 | 152 | default: | ||
2630 | 153 | break; | ||
2631 | 154 | } | ||
2632 | 155 | return QVariant(); | ||
2633 | 156 | } | ||
2634 | 157 | |||
2635 | 158 | QHash<int, QByteArray> UbuntuEmulatorModel::roleNames() const | ||
2636 | 159 | { | ||
2637 | 160 | QHash<int, QByteArray> rNames = QAbstractListModel::roleNames(); | ||
2638 | 161 | rNames.insert(UbuntuVersionRole,"ubuntuVersion"); | ||
2639 | 162 | rNames.insert(DeviceVersionRole,"deviceVersion"); | ||
2640 | 163 | rNames.insert(ImageVersionRole,"imageVersion"); | ||
2641 | 164 | return rNames; | ||
2642 | 165 | } | ||
2643 | 166 | |||
2644 | 167 | Qt::ItemFlags UbuntuEmulatorModel::flags(const QModelIndex &index) const | ||
2645 | 168 | { | ||
2646 | 169 | return QAbstractListModel::flags(index); | ||
2647 | 170 | } | ||
2648 | 171 | |||
2649 | 172 | void UbuntuEmulatorModel::clear() | ||
2650 | 173 | { | ||
2651 | 174 | if(rowCount()) { | ||
2652 | 175 | beginResetModel(); | ||
2653 | 176 | m_data.clear(); | ||
2654 | 177 | endResetModel(); | ||
2655 | 178 | } | ||
2656 | 179 | } | ||
2657 | 180 | |||
2658 | 181 | void UbuntuEmulatorModel::checkEmulatorInstalled() | ||
2659 | 182 | { | ||
2660 | 183 | setState(CheckEmulator); | ||
2661 | 184 | setCancellable(false); | ||
2662 | 185 | |||
2663 | 186 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_EMULATOR_INSTALLED)); | ||
2664 | 187 | m_process->stop(); | ||
2665 | 188 | QString sEmulatorPackageName = QLatin1String(Ubuntu::Constants::EMULATOR_PACKAGE_NAME); | ||
2666 | 189 | m_process->append(QStringList() | ||
2667 | 190 | << QString::fromLatin1(Constants::UBUNTUWIDGETS_LOCAL_PACKAGE_INSTALLED_SCRIPT).arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH).arg(sEmulatorPackageName) | ||
2668 | 191 | << QCoreApplication::applicationDirPath()); | ||
2669 | 192 | m_process->start(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_EMULATOR_INSTALLED)); | ||
2670 | 193 | |||
2671 | 194 | } | ||
2672 | 195 | |||
2673 | 196 | void UbuntuEmulatorModel::findEmulatorImages() | ||
2674 | 197 | { | ||
2675 | 198 | setState(FindImages); | ||
2676 | 199 | setCancellable(false); | ||
2677 | 200 | |||
2678 | 201 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_SEARCH_IMAGES)); | ||
2679 | 202 | m_process->stop(); | ||
2680 | 203 | m_process->append(QStringList() | ||
2681 | 204 | << QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_SEARCH_IMAGES_SCRIPT).arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH) | ||
2682 | 205 | << QCoreApplication::applicationDirPath()); | ||
2683 | 206 | m_process->start(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_SEARCH_IMAGES)); | ||
2684 | 207 | } | ||
2685 | 208 | |||
2686 | 209 | void UbuntuEmulatorModel::installEmulator() | ||
2687 | 210 | { | ||
2688 | 211 | if(m_emulatorInstalled) | ||
2689 | 212 | return; | ||
2690 | 213 | |||
2691 | 214 | setState(InstallEmulator); | ||
2692 | 215 | setCancellable(false); | ||
2693 | 216 | |||
2694 | 217 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_INSTALL_EMULATOR_PACKAGE)); | ||
2695 | 218 | QString sEmulatorPackageName = QLatin1String(Ubuntu::Constants::EMULATOR_PACKAGE_NAME); | ||
2696 | 219 | m_process->stop(); | ||
2697 | 220 | m_process->append(QStringList() | ||
2698 | 221 | << QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_INSTALL_EMULATOR_PACKAGE_SCRIPT).arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH).arg(sEmulatorPackageName) | ||
2699 | 222 | << QCoreApplication::applicationDirPath()); | ||
2700 | 223 | m_process->start(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_INSTALL_EMULATOR_PACKAGE)); | ||
2701 | 224 | } | ||
2702 | 225 | |||
2703 | 226 | void UbuntuEmulatorModel::createEmulatorImage(const QString &name) | ||
2704 | 227 | { | ||
2705 | 228 | setState(CreateEmulatorImage); | ||
2706 | 229 | setCancellable(true); | ||
2707 | 230 | |||
2708 | 231 | beginAction(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR)); | ||
2709 | 232 | m_process->stop(); | ||
2710 | 233 | QString strEmulatorName = name; | ||
2711 | 234 | QString strEmulatorPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); | ||
2712 | 235 | strEmulatorPath += QDir::separator(); | ||
2713 | 236 | strEmulatorPath += QLatin1String(Constants::DEFAULT_EMULATOR_PATH); | ||
2714 | 237 | strEmulatorPath += QDir::separator(); | ||
2715 | 238 | m_process->append(QStringList() | ||
2716 | 239 | << QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR_SCRIPT) | ||
2717 | 240 | .arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH).arg(strEmulatorPath).arg(strEmulatorName) | ||
2718 | 241 | << QCoreApplication::applicationDirPath()); | ||
2719 | 242 | m_process->start(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_CREATE_EMULATOR)); | ||
2720 | 243 | } | ||
2721 | 244 | |||
2722 | 245 | void UbuntuEmulatorModel::startEmulator(const QString &name) | ||
2723 | 246 | { | ||
2724 | 247 | QStringList args = QStringList() << name; | ||
2725 | 248 | QProcess::startDetached(QString::fromLatin1(Constants::UBUNTUDEVICESWIDGET_LOCAL_START_EMULATOR_SCRIPT).arg(Ubuntu::Constants::UBUNTU_SCRIPTPATH) | ||
2726 | 249 | ,args | ||
2727 | 250 | ,QCoreApplication::applicationDirPath()); | ||
2728 | 251 | } | ||
2729 | 252 | |||
2730 | 253 | QVariant UbuntuEmulatorModel::validateEmulatorName(const QString &name) | ||
2731 | 254 | { | ||
2732 | 255 | |||
2733 | 256 | QString error; | ||
2734 | 257 | bool result = Utils::ProjectNameValidatingLineEdit::validateProjectName(name,&error); | ||
2735 | 258 | |||
2736 | 259 | if(result) { | ||
2737 | 260 | foreach(const EmulatorItem &item, m_data){ | ||
2738 | 261 | if(item.name == name) { | ||
2739 | 262 | result = false; | ||
2740 | 263 | error = tr("Emulator name already exists"); | ||
2741 | 264 | } | ||
2742 | 265 | } | ||
2743 | 266 | } | ||
2744 | 267 | |||
2745 | 268 | QVariantMap m; | ||
2746 | 269 | m.insert(QStringLiteral("valid"),result); | ||
2747 | 270 | m.insert(QStringLiteral("error"),error); | ||
2748 | 271 | return QVariant::fromValue(m); | ||
2749 | 272 | } | ||
2750 | 273 | |||
2751 | 274 | void UbuntuEmulatorModel::cancel() | ||
2752 | 275 | { | ||
2753 | 276 | if (m_cancellable && m_state == CreateEmulatorImage) { | ||
2754 | 277 | m_process->stop(); | ||
2755 | 278 | } | ||
2756 | 279 | } | ||
2757 | 280 | |||
2758 | 281 | void UbuntuEmulatorModel::onMessage(const QString &msg) | ||
2759 | 282 | { | ||
2760 | 283 | if (msg.startsWith(QLatin1String(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_UNABLE_TO_FETCH))) { | ||
2761 | 284 | setEmulatorInstalled(false); | ||
2762 | 285 | } | ||
2763 | 286 | m_reply.append(msg); | ||
2764 | 287 | } | ||
2765 | 288 | |||
2766 | 289 | void UbuntuEmulatorModel::processFinished(const QString &, int) | ||
2767 | 290 | { | ||
2768 | 291 | State lastState = m_state; | ||
2769 | 292 | setCancellable(false); | ||
2770 | 293 | |||
2771 | 294 | setState(UbuntuEmulatorModel::Idle); | ||
2772 | 295 | switch(lastState) { | ||
2773 | 296 | case CheckEmulator: { | ||
2774 | 297 | QStringList lines = m_reply.trimmed().split(QLatin1String(Constants::LINEFEED)); | ||
2775 | 298 | foreach(QString line, lines) { | ||
2776 | 299 | line = line.trimmed(); | ||
2777 | 300 | if (line.isEmpty()) { | ||
2778 | 301 | continue; | ||
2779 | 302 | } | ||
2780 | 303 | if (line.startsWith(QLatin1String(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_LOCAL_NO_EMULATOR_INSTALLED))) { | ||
2781 | 304 | setEmulatorInstalled(false); | ||
2782 | 305 | } else { | ||
2783 | 306 | QStringList lineData = line.split(QLatin1String(Constants::SPACE)); | ||
2784 | 307 | QString sEmulatorPackageStatus = lineData.takeFirst(); | ||
2785 | 308 | //QString sEmulatorPackageName = lineData.takeFirst(); | ||
2786 | 309 | //QString sEmulatorPackageVersion = lineData.takeFirst(); | ||
2787 | 310 | if (sEmulatorPackageStatus.startsWith(QLatin1String(Constants::INSTALLED))) { | ||
2788 | 311 | setEmulatorInstalled(true); | ||
2789 | 312 | findEmulatorImages(); | ||
2790 | 313 | } | ||
2791 | 314 | } | ||
2792 | 315 | } | ||
2793 | 316 | break; | ||
2794 | 317 | } | ||
2795 | 318 | case InstallEmulator: { | ||
2796 | 319 | QStringList lines = m_reply.trimmed().split(QLatin1String(Constants::LINEFEED)); | ||
2797 | 320 | foreach(QString line, lines) { | ||
2798 | 321 | line = line.trimmed(); | ||
2799 | 322 | if (line.isEmpty()) { | ||
2800 | 323 | continue; | ||
2801 | 324 | } | ||
2802 | 325 | if (line.startsWith(QLatin1String(Constants::UBUNTUDEVICESWIDGET_ONFINISHED_LOCAL_NO_EMULATOR_INSTALLED))) { | ||
2803 | 326 | setEmulatorInstalled(false); | ||
2804 | 327 | break; | ||
2805 | 328 | } else { | ||
2806 | 329 | QStringList lineData = line.split(QLatin1String(Constants::SPACE)); | ||
2807 | 330 | QString sEmulatorPackageStatus = lineData.takeFirst(); | ||
2808 | 331 | //QString sEmulatorPackageName = lineData.takeFirst(); | ||
2809 | 332 | //QString sEmulatorPackageVersion = lineData.takeFirst(); | ||
2810 | 333 | if (sEmulatorPackageStatus.startsWith(QLatin1String(Constants::INSTALLED))) { | ||
2811 | 334 | setEmulatorInstalled(true); | ||
2812 | 335 | findEmulatorImages(); | ||
2813 | 336 | break; | ||
2814 | 337 | } | ||
2815 | 338 | } | ||
2816 | 339 | } | ||
2817 | 340 | break; | ||
2818 | 341 | } | ||
2819 | 342 | case CreateEmulatorImage: { | ||
2820 | 343 | findEmulatorImages(); | ||
2821 | 344 | break; | ||
2822 | 345 | } | ||
2823 | 346 | case FindImages: { | ||
2824 | 347 | QStringList lines = m_reply.trimmed().split(QLatin1String(Constants::LINEFEED)); | ||
2825 | 348 | clear(); | ||
2826 | 349 | |||
2827 | 350 | QList<EmulatorItem> items; | ||
2828 | 351 | |||
2829 | 352 | QMutableStringListIterator iter(lines); | ||
2830 | 353 | QRegularExpression regexName (QStringLiteral("^(\\w+)")); | ||
2831 | 354 | QRegularExpression regexUbuntu (QStringLiteral("ubuntu=([0-9]+)")); | ||
2832 | 355 | QRegularExpression regexDevice (QStringLiteral("device=([0-9]+)")); | ||
2833 | 356 | QRegularExpression regexVersion(QStringLiteral("version=([0-9]+)")); | ||
2834 | 357 | while (iter.hasNext()) { | ||
2835 | 358 | QString line = iter.next(); | ||
2836 | 359 | if(line.isEmpty()) { | ||
2837 | 360 | iter.remove(); | ||
2838 | 361 | continue; | ||
2839 | 362 | } | ||
2840 | 363 | |||
2841 | 364 | qDebug()<<"Handling emulator: "<<line; | ||
2842 | 365 | QRegularExpressionMatch mName = regexName.match(line); | ||
2843 | 366 | QRegularExpressionMatch mUbu = regexUbuntu.match(line); | ||
2844 | 367 | QRegularExpressionMatch mDev = regexDevice.match(line); | ||
2845 | 368 | QRegularExpressionMatch mVer = regexVersion.match(line); | ||
2846 | 369 | |||
2847 | 370 | if(!mName.hasMatch()) | ||
2848 | 371 | continue; | ||
2849 | 372 | |||
2850 | 373 | EmulatorItem item; | ||
2851 | 374 | item.name = mName.captured(1); | ||
2852 | 375 | |||
2853 | 376 | if(mUbu.hasMatch()) | ||
2854 | 377 | item.ubuntuVersion = mUbu.captured(1); | ||
2855 | 378 | else | ||
2856 | 379 | item.ubuntuVersion = tr("unknown"); | ||
2857 | 380 | |||
2858 | 381 | if(mDev.hasMatch()) | ||
2859 | 382 | item.deviceVersion = mDev.captured(1); | ||
2860 | 383 | else | ||
2861 | 384 | item.deviceVersion = tr("unknown"); | ||
2862 | 385 | |||
2863 | 386 | if(mVer.hasMatch()) | ||
2864 | 387 | item.imageVersion = mVer.captured(1); | ||
2865 | 388 | else | ||
2866 | 389 | item.imageVersion = tr("unknown"); | ||
2867 | 390 | |||
2868 | 391 | items.append(item); | ||
2869 | 392 | } | ||
2870 | 393 | |||
2871 | 394 | if(items.count()) { | ||
2872 | 395 | beginResetModel(); | ||
2873 | 396 | m_data = items; | ||
2874 | 397 | endResetModel(); | ||
2875 | 398 | } | ||
2876 | 399 | break; | ||
2877 | 400 | } | ||
2878 | 401 | default: | ||
2879 | 402 | break; | ||
2880 | 403 | } | ||
2881 | 404 | m_reply.clear(); | ||
2882 | 405 | } | ||
2883 | 406 | |||
2884 | 407 | } // namespace Internal | ||
2885 | 408 | } // namespace Ubuntu | ||
2886 | 0 | 409 | ||
2887 | === added file 'src/ubuntu/ubuntuemulatormodel.h' | |||
2888 | --- src/ubuntu/ubuntuemulatormodel.h 1970-01-01 00:00:00 +0000 | |||
2889 | +++ src/ubuntu/ubuntuemulatormodel.h 2014-04-27 13:29:17 +0000 | |||
2890 | @@ -0,0 +1,102 @@ | |||
2891 | 1 | #ifndef UBUNTU_INTERNAL_UBUNTUEMULATORMODEL_H | ||
2892 | 2 | #define UBUNTU_INTERNAL_UBUNTUEMULATORMODEL_H | ||
2893 | 3 | |||
2894 | 4 | #include "ubuntuprocess.h" | ||
2895 | 5 | #include <QAbstractListModel> | ||
2896 | 6 | |||
2897 | 7 | namespace Ubuntu { | ||
2898 | 8 | namespace Internal { | ||
2899 | 9 | |||
2900 | 10 | class UbuntuEmulatorModel : public QAbstractListModel | ||
2901 | 11 | { | ||
2902 | 12 | Q_OBJECT | ||
2903 | 13 | public: | ||
2904 | 14 | |||
2905 | 15 | enum State { | ||
2906 | 16 | Initial, | ||
2907 | 17 | CheckEmulator, | ||
2908 | 18 | InstallEmulator, | ||
2909 | 19 | CreateEmulatorImage, | ||
2910 | 20 | FindImages, | ||
2911 | 21 | Idle | ||
2912 | 22 | }; | ||
2913 | 23 | |||
2914 | 24 | enum Roles { | ||
2915 | 25 | UbuntuVersionRole = Qt::UserRole, | ||
2916 | 26 | DeviceVersionRole, | ||
2917 | 27 | ImageVersionRole | ||
2918 | 28 | }; | ||
2919 | 29 | |||
2920 | 30 | struct EmulatorItem { | ||
2921 | 31 | QString name; | ||
2922 | 32 | QString ubuntuVersion; | ||
2923 | 33 | QString deviceVersion; | ||
2924 | 34 | QString imageVersion; | ||
2925 | 35 | }; | ||
2926 | 36 | |||
2927 | 37 | Q_PROPERTY(bool emulatorInstalled READ emulatorInstalled WRITE setEmulatorInstalled NOTIFY emulatorInstalledChanged) | ||
2928 | 38 | Q_PROPERTY(bool busy READ busy NOTIFY busyChanged) | ||
2929 | 39 | Q_PROPERTY(bool cancellable READ cancellable NOTIFY cancellableChanged) | ||
2930 | 40 | Q_PROPERTY(QString state READ state NOTIFY stateChanged) | ||
2931 | 41 | |||
2932 | 42 | explicit UbuntuEmulatorModel(QObject *parent = 0); | ||
2933 | 43 | |||
2934 | 44 | void setEmulatorInstalled(bool arg); | ||
2935 | 45 | bool emulatorInstalled() const; | ||
2936 | 46 | |||
2937 | 47 | bool busy() const; | ||
2938 | 48 | QString state() const; | ||
2939 | 49 | bool cancellable() const; | ||
2940 | 50 | |||
2941 | 51 | // QAbstractItemModel interface | ||
2942 | 52 | virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; | ||
2943 | 53 | virtual QVariant data(const QModelIndex &index, int role) const; | ||
2944 | 54 | virtual QHash<int, QByteArray> roleNames() const; | ||
2945 | 55 | virtual Qt::ItemFlags flags(const QModelIndex &index) const; | ||
2946 | 56 | |||
2947 | 57 | protected: | ||
2948 | 58 | void clear(); | ||
2949 | 59 | void setBusy(bool arg); | ||
2950 | 60 | void setState(State newState); | ||
2951 | 61 | void beginAction (const QString &msg); | ||
2952 | 62 | void endAction (const QString &msg); | ||
2953 | 63 | void setCancellable(bool arg); | ||
2954 | 64 | |||
2955 | 65 | public slots: | ||
2956 | 66 | void checkEmulatorInstalled (); | ||
2957 | 67 | void findEmulatorImages (); | ||
2958 | 68 | void installEmulator (); | ||
2959 | 69 | void createEmulatorImage (const QString &name); | ||
2960 | 70 | void startEmulator (const QString &name); | ||
2961 | 71 | QVariant validateEmulatorName ( const QString &name); | ||
2962 | 72 | void cancel (); | ||
2963 | 73 | |||
2964 | 74 | protected slots: | ||
2965 | 75 | void onMessage (const QString &msg); | ||
2966 | 76 | void processFinished (const QString &, int); | ||
2967 | 77 | |||
2968 | 78 | signals: | ||
2969 | 79 | void emulatorInstalledChanged(bool arg); | ||
2970 | 80 | void busyChanged(bool arg); | ||
2971 | 81 | void stateChanged(const QString &arg); | ||
2972 | 82 | void logMessage (const QString &str); | ||
2973 | 83 | void stdOutMessage (const QString &str); | ||
2974 | 84 | void stdErrMessage (const QString &str); | ||
2975 | 85 | |||
2976 | 86 | void cancellableChanged(bool arg); | ||
2977 | 87 | |||
2978 | 88 | private: | ||
2979 | 89 | QString m_reply; | ||
2980 | 90 | UbuntuProcess *m_process; | ||
2981 | 91 | bool m_emulatorInstalled; | ||
2982 | 92 | State m_state; | ||
2983 | 93 | bool m_busy; | ||
2984 | 94 | |||
2985 | 95 | QList<EmulatorItem> m_data; | ||
2986 | 96 | bool m_cancellable; | ||
2987 | 97 | }; | ||
2988 | 98 | |||
2989 | 99 | } // namespace Internal | ||
2990 | 100 | } // namespace Ubuntu | ||
2991 | 101 | |||
2992 | 102 | #endif // UBUNTU_INTERNAL_UBUNTUEMULATORMODEL_H | ||
2993 | 0 | 103 | ||
2994 | === modified file 'src/ubuntu/ubuntukitmanager.cpp' | |||
2995 | --- src/ubuntu/ubuntukitmanager.cpp 2014-04-09 15:00:21 +0000 | |||
2996 | +++ src/ubuntu/ubuntukitmanager.cpp 2014-04-27 13:29:17 +0000 | |||
2997 | @@ -23,11 +23,24 @@ | |||
2998 | 23 | return ProjectExplorer::ToolChainKitInformation::toolChain(a) == ProjectExplorer::ToolChainKitInformation::ToolChainKitInformation::toolChain(b); | 23 | return ProjectExplorer::ToolChainKitInformation::toolChain(a) == ProjectExplorer::ToolChainKitInformation::ToolChainKitInformation::toolChain(b); |
2999 | 24 | } | 24 | } |
3000 | 25 | 25 | ||
3001 | 26 | static bool lessThanToolchain (const ClickToolChain* left, const ClickToolChain* right) | ||
3002 | 27 | { | ||
3003 | 28 | const UbuntuClickTool::Target &leftTarget = left->clickTarget(); | ||
3004 | 29 | const UbuntuClickTool::Target &rightTarget = right->clickTarget(); | ||
3005 | 30 | |||
3006 | 31 | if(leftTarget.majorVersion < rightTarget.majorVersion) | ||
3007 | 32 | return true; | ||
3008 | 33 | if(leftTarget.minorVersion < rightTarget.minorVersion) | ||
3009 | 34 | return true; | ||
3010 | 35 | |||
3011 | 36 | return false; | ||
3012 | 37 | } | ||
3013 | 38 | |||
3014 | 26 | UbuntuKitManager::UbuntuKitManager() | 39 | UbuntuKitManager::UbuntuKitManager() |
3015 | 27 | { | 40 | { |
3016 | 28 | } | 41 | } |
3017 | 29 | 42 | ||
3019 | 30 | void UbuntuKitManager::autoDetectKits() | 43 | QList<ClickToolChain *> UbuntuKitManager::clickToolChains() |
3020 | 31 | { | 44 | { |
3021 | 32 | QList<ClickToolChain *> toolchains; | 45 | QList<ClickToolChain *> toolchains; |
3022 | 33 | // having a empty toolchains list will remove all autodetected kits for android | 46 | // having a empty toolchains list will remove all autodetected kits for android |
3023 | @@ -41,6 +54,42 @@ | |||
3024 | 41 | toolchains << static_cast<ClickToolChain *>(tc); | 54 | toolchains << static_cast<ClickToolChain *>(tc); |
3025 | 42 | } | 55 | } |
3026 | 43 | } | 56 | } |
3027 | 57 | return toolchains; | ||
3028 | 58 | } | ||
3029 | 59 | |||
3030 | 60 | void UbuntuKitManager::autoCreateKit(UbuntuDevice::Ptr device) | ||
3031 | 61 | { | ||
3032 | 62 | QList<ClickToolChain*> toolchains = clickToolChains(); | ||
3033 | 63 | if(toolchains.size() == 0) { | ||
3034 | 64 | //create target | ||
3035 | 65 | return; | ||
3036 | 66 | } | ||
3037 | 67 | |||
3038 | 68 | qSort(toolchains.begin(),toolchains.end(),lessThanToolchain); | ||
3039 | 69 | |||
3040 | 70 | //right now we are going to use the last toolchain, because its the one | ||
3041 | 71 | //with the highest framework, this needs to be changed once we have x86 targets | ||
3042 | 72 | ClickToolChain* tc = toolchains.last(); | ||
3043 | 73 | ProjectExplorer::Kit* newKit = createKit(tc); | ||
3044 | 74 | if(newKit) { | ||
3045 | 75 | fixKit(newKit); | ||
3046 | 76 | |||
3047 | 77 | newKit->setDisplayName(tr("%1 (GCC %2-%3-%4)") | ||
3048 | 78 | .arg(device->displayName()) | ||
3049 | 79 | .arg(tc->clickTarget().architecture) | ||
3050 | 80 | .arg(tc->clickTarget().framework) | ||
3051 | 81 | .arg(tc->clickTarget().series)); | ||
3052 | 82 | |||
3053 | 83 | ProjectExplorer::DeviceKitInformation::setDevice(newKit,device); | ||
3054 | 84 | ProjectExplorer::KitManager::registerKit(newKit); | ||
3055 | 85 | } | ||
3056 | 86 | } | ||
3057 | 87 | |||
3058 | 88 | void UbuntuKitManager::autoDetectKits() | ||
3059 | 89 | { | ||
3060 | 90 | // having a empty toolchains list will remove all autodetected kits for android | ||
3061 | 91 | // exactly what we want in that case | ||
3062 | 92 | QList<ClickToolChain *> toolchains = clickToolChains(); | ||
3063 | 44 | 93 | ||
3064 | 45 | QList<ProjectExplorer::Kit *> existingKits; | 94 | QList<ProjectExplorer::Kit *> existingKits; |
3065 | 46 | foreach (ProjectExplorer::Kit *k, ProjectExplorer::KitManager::kits()) { | 95 | foreach (ProjectExplorer::Kit *k, ProjectExplorer::KitManager::kits()) { |
3066 | 47 | 96 | ||
3067 | === modified file 'src/ubuntu/ubuntukitmanager.h' | |||
3068 | --- src/ubuntu/ubuntukitmanager.h 2014-04-10 10:56:24 +0000 | |||
3069 | +++ src/ubuntu/ubuntukitmanager.h 2014-04-27 13:29:17 +0000 | |||
3070 | @@ -19,6 +19,7 @@ | |||
3071 | 19 | #define UBUNTU_INTERNAL_UBUNTUKITMANAGER_H | 19 | #define UBUNTU_INTERNAL_UBUNTUKITMANAGER_H |
3072 | 20 | 20 | ||
3073 | 21 | #include "clicktoolchain.h" | 21 | #include "clicktoolchain.h" |
3074 | 22 | #include "ubuntudevice.h" | ||
3075 | 22 | #include <projectexplorer/kit.h> | 23 | #include <projectexplorer/kit.h> |
3076 | 23 | 24 | ||
3077 | 24 | namespace Debugger{ | 25 | namespace Debugger{ |
3078 | @@ -34,10 +35,12 @@ | |||
3079 | 34 | public: | 35 | public: |
3080 | 35 | UbuntuKitManager(); | 36 | UbuntuKitManager(); |
3081 | 36 | 37 | ||
3082 | 38 | static void autoCreateKit ( UbuntuDevice::Ptr device ); | ||
3083 | 37 | static void autoDetectKits (); | 39 | static void autoDetectKits (); |
3084 | 38 | static ProjectExplorer::Kit *createKit (ClickToolChain* tc); | 40 | static ProjectExplorer::Kit *createKit (ClickToolChain* tc); |
3085 | 39 | static QVariant createOrFindDebugger(const Utils::FileName &path); | 41 | static QVariant createOrFindDebugger(const Utils::FileName &path); |
3086 | 40 | static void fixKit (ProjectExplorer::Kit* k); | 42 | static void fixKit (ProjectExplorer::Kit* k); |
3087 | 43 | static QList<ClickToolChain *> clickToolChains(); | ||
3088 | 41 | }; | 44 | }; |
3089 | 42 | 45 | ||
3090 | 43 | } // namespace Internal | 46 | } // namespace Internal |
3091 | 44 | 47 | ||
3092 | === modified file 'src/ubuntu/ubuntumenu.cpp' | |||
3093 | --- src/ubuntu/ubuntumenu.cpp 2014-04-15 07:51:40 +0000 | |||
3094 | +++ src/ubuntu/ubuntumenu.cpp 2014-04-27 13:29:17 +0000 | |||
3095 | @@ -19,7 +19,7 @@ | |||
3096 | 19 | #include "ubuntumenu.h" | 19 | #include "ubuntumenu.h" |
3097 | 20 | #include "ubuntushared.h" | 20 | #include "ubuntushared.h" |
3098 | 21 | #include "ubuntuconstants.h" | 21 | #include "ubuntuconstants.h" |
3100 | 22 | #include "ubuntudeviceswidget.h" | 22 | #include "ubuntudevicemode.h" |
3101 | 23 | #include "ubuntuproject.h" | 23 | #include "ubuntuproject.h" |
3102 | 24 | #include "ubuntuclicktool.h" | 24 | #include "ubuntuclicktool.h" |
3103 | 25 | #include "ubuntudevice.h" | 25 | #include "ubuntudevice.h" |
3104 | @@ -82,7 +82,7 @@ | |||
3105 | 82 | connect(&m_ubuntuProcess,SIGNAL(error(QString)),this,SLOT(onError(QString))); | 82 | connect(&m_ubuntuProcess,SIGNAL(error(QString)),this,SLOT(onError(QString))); |
3106 | 83 | 83 | ||
3107 | 84 | connect(ProjectExplorer::ProjectExplorerPlugin::instance(),SIGNAL(updateRunActions()),this,SLOT(slotUpdateActions())); | 84 | connect(ProjectExplorer::ProjectExplorerPlugin::instance(),SIGNAL(updateRunActions()),this,SLOT(slotUpdateActions())); |
3109 | 85 | connect(UbuntuDevicesWidget::instance(),SIGNAL(updateDeviceActions()),this,SLOT(slotUpdateActions())); | 85 | connect(UbuntuDeviceMode::instance(),SIGNAL(updateDeviceActions()),this,SLOT(slotUpdateActions())); |
3110 | 86 | } | 86 | } |
3111 | 87 | 87 | ||
3112 | 88 | 88 | ||
3113 | @@ -103,7 +103,7 @@ | |||
3114 | 103 | 103 | ||
3115 | 104 | //bool canRun = projectExplorerInstance->canRun(startupProject,ProjectExplorer::NormalRunMode); | 104 | //bool canRun = projectExplorerInstance->canRun(startupProject,ProjectExplorer::NormalRunMode); |
3116 | 105 | bool projectOpen = (startupProject!=NULL); | 105 | bool projectOpen = (startupProject!=NULL); |
3118 | 106 | bool deviceDetected = UbuntuDevicesWidget::instance()->deviceDetected(); | 106 | bool deviceDetected = !UbuntuDeviceMode::instance()->device().isNull(); |
3119 | 107 | 107 | ||
3120 | 108 | foreach(QAction* act, m_actions) { | 108 | foreach(QAction* act, m_actions) { |
3121 | 109 | bool requiresDevice = act->property(Constants::UBUNTU_MENUJSON_DEVICEREQUIRED).toBool(); | 109 | bool requiresDevice = act->property(Constants::UBUNTU_MENUJSON_DEVICEREQUIRED).toBool(); |
3122 | @@ -475,8 +475,13 @@ | |||
3123 | 475 | } | 475 | } |
3124 | 476 | } | 476 | } |
3125 | 477 | 477 | ||
3127 | 478 | UbuntuDevice::ConstPtr device = UbuntuDevicesWidget::instance()->device(); | 478 | UbuntuDevice::ConstPtr device = UbuntuDeviceMode::instance()->device(); |
3128 | 479 | if (device) { | 479 | if (device) { |
3129 | 480 | if( device->deviceState() != ProjectExplorer::IDevice::DeviceReadyToUse ) { | ||
3130 | 481 | QMessageBox::warning(0,tr("Device not ready"),tr("The currently selected device is not ready, please select another one on the devices mode")); | ||
3131 | 482 | return; | ||
3132 | 483 | } | ||
3133 | 484 | |||
3134 | 480 | command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_DEVICE_IP),device->sshParameters().host); | 485 | command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_DEVICE_IP),device->sshParameters().host); |
3135 | 481 | command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_DEVICE_USERNAME),device->sshParameters().userName); | 486 | command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_DEVICE_USERNAME),device->sshParameters().userName); |
3136 | 482 | command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_DEVICE_PORT),QString::number(device->sshParameters().port)); | 487 | command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_DEVICE_PORT),QString::number(device->sshParameters().port)); |
3137 | 483 | 488 | ||
3138 | === modified file 'src/ubuntu/ubuntuplugin.cpp' | |||
3139 | --- src/ubuntu/ubuntuplugin.cpp 2014-04-10 18:50:24 +0000 | |||
3140 | +++ src/ubuntu/ubuntuplugin.cpp 2014-04-27 13:29:17 +0000 | |||
3141 | @@ -31,6 +31,7 @@ | |||
3142 | 31 | #include "ubuntucmakebuildconfiguration.h" | 31 | #include "ubuntucmakebuildconfiguration.h" |
3143 | 32 | #include "ubunturemotedeployconfiguration.h" | 32 | #include "ubunturemotedeployconfiguration.h" |
3144 | 33 | #include "ubuntulocaldeployconfiguration.h" | 33 | #include "ubuntulocaldeployconfiguration.h" |
3145 | 34 | #include "ubuntudevicesmodel.h" | ||
3146 | 34 | #include "localportsmanager.h" | 35 | #include "localportsmanager.h" |
3147 | 35 | 36 | ||
3148 | 36 | #include <coreplugin/modemanager.h> | 37 | #include <coreplugin/modemanager.h> |
3149 | @@ -42,6 +43,7 @@ | |||
3150 | 42 | #include <QDebug> | 43 | #include <QDebug> |
3151 | 43 | #include <QFileInfo> | 44 | #include <QFileInfo> |
3152 | 44 | #include <QGuiApplication> | 45 | #include <QGuiApplication> |
3153 | 46 | #include <QtQml> | ||
3154 | 45 | 47 | ||
3155 | 46 | using namespace Ubuntu; | 48 | using namespace Ubuntu; |
3156 | 47 | using namespace Ubuntu::Internal; | 49 | using namespace Ubuntu::Internal; |
3157 | @@ -61,8 +63,9 @@ | |||
3158 | 61 | Q_UNUSED(arguments) | 63 | Q_UNUSED(arguments) |
3159 | 62 | Q_UNUSED(errorString) | 64 | Q_UNUSED(errorString) |
3160 | 63 | 65 | ||
3161 | 66 | qmlRegisterUncreatableType<UbuntuDeviceStates>("Ubuntu.DevicesModel",0,1,"States",QStringLiteral("Not instantiable")); | ||
3162 | 67 | |||
3163 | 64 | const QLatin1String mimetypesXml(Constants::UBUNTU_MIMETYPE_XML); | 68 | const QLatin1String mimetypesXml(Constants::UBUNTU_MIMETYPE_XML); |
3164 | 65 | |||
3165 | 66 | if (!Core::MimeDatabase::addMimeTypes(mimetypesXml, errorString)) | 69 | if (!Core::MimeDatabase::addMimeTypes(mimetypesXml, errorString)) |
3166 | 67 | return false; | 70 | return false; |
3167 | 68 | 71 | ||
3168 | 69 | 72 | ||
3169 | === modified file 'src/ubuntu/ubuntuprocess.cpp' | |||
3170 | --- src/ubuntu/ubuntuprocess.cpp 2014-03-06 09:43:48 +0000 | |||
3171 | +++ src/ubuntu/ubuntuprocess.cpp 2014-04-27 13:29:17 +0000 | |||
3172 | @@ -122,11 +122,8 @@ | |||
3173 | 122 | emit finished(m_currentProcess->program(), code); | 122 | emit finished(m_currentProcess->program(), code); |
3174 | 123 | return; | 123 | return; |
3175 | 124 | } | 124 | } |
3176 | 125 | QString errorMsg = QString::fromLocal8Bit(m_currentProcess->readAllStandardError()); | ||
3177 | 126 | if (errorMsg.trimmed().length()>0) emit error(errorMsg); | ||
3178 | 127 | QString msg = QString::fromLocal8Bit(m_currentProcess->readAllStandardOutput()); | ||
3179 | 128 | if (msg.trimmed().length()>0) emit message(msg); | ||
3180 | 129 | 125 | ||
3181 | 126 | processReadyRead(); | ||
3182 | 130 | emit finished(m_currentProcess->program(), code); | 127 | emit finished(m_currentProcess->program(), code); |
3183 | 131 | emit finished(m_currentProcess,m_currentProcess->program(),code); | 128 | emit finished(m_currentProcess,m_currentProcess->program(),code); |
3184 | 132 | processCmdQueue(); | 129 | processCmdQueue(); |
3185 | @@ -135,10 +132,12 @@ | |||
3186 | 135 | void UbuntuProcess::processReadyRead() { | 132 | void UbuntuProcess::processReadyRead() { |
3187 | 136 | QString stderr = QString::fromLocal8Bit(m_currentProcess->readAllStandardError()); | 133 | QString stderr = QString::fromLocal8Bit(m_currentProcess->readAllStandardError()); |
3188 | 137 | QString stdout = QString::fromLocal8Bit(m_currentProcess->readAllStandardOutput()); | 134 | QString stdout = QString::fromLocal8Bit(m_currentProcess->readAllStandardOutput()); |
3190 | 138 | if (!stderr.isEmpty()) { | 135 | if (!stderr.trimmed().isEmpty()) { |
3191 | 136 | emit error(stderr); | ||
3192 | 139 | emit message(stderr); | 137 | emit message(stderr); |
3193 | 140 | } | 138 | } |
3195 | 141 | if (!stdout.isEmpty()) { | 139 | if (!stdout.trimmed().isEmpty()) { |
3196 | 140 | emit stdOut(stdout); | ||
3197 | 142 | emit message(stdout); | 141 | emit message(stdout); |
3198 | 143 | } | 142 | } |
3199 | 144 | } | 143 | } |
3200 | 145 | 144 | ||
3201 | === modified file 'src/ubuntu/ubuntuprocess.h' | |||
3202 | --- src/ubuntu/ubuntuprocess.h 2014-03-06 09:43:48 +0000 | |||
3203 | +++ src/ubuntu/ubuntuprocess.h 2014-04-27 13:29:17 +0000 | |||
3204 | @@ -45,8 +45,9 @@ | |||
3205 | 45 | void start(QString taskTitle); | 45 | void start(QString taskTitle); |
3206 | 46 | 46 | ||
3207 | 47 | signals: | 47 | signals: |
3210 | 48 | void message(QString); | 48 | void message(const QString&); |
3211 | 49 | void error(QString); | 49 | void error (const QString&); |
3212 | 50 | void stdOut(const QString&); | ||
3213 | 50 | void finished(QString,int); | 51 | void finished(QString,int); |
3214 | 51 | void finished(const QProcess*,QString,int); | 52 | void finished(const QProcess*,QString,int); |
3215 | 52 | void started(QString); | 53 | void started(QString); |
3216 | 53 | 54 | ||
3217 | === modified file 'src/ubuntu/ubunturemoterunconfiguration.cpp' | |||
3218 | --- src/ubuntu/ubunturemoterunconfiguration.cpp 2014-04-10 11:04:55 +0000 | |||
3219 | +++ src/ubuntu/ubunturemoterunconfiguration.cpp 2014-04-27 13:29:17 +0000 | |||
3220 | @@ -95,6 +95,8 @@ | |||
3221 | 95 | env.appendOrSet(QLatin1String("QML2_IMPORT_PATH"), | 95 | env.appendOrSet(QLatin1String("QML2_IMPORT_PATH"), |
3222 | 96 | QString::fromLatin1("lib/%1").arg(clickTc->gnutriplet()), | 96 | QString::fromLatin1("lib/%1").arg(clickTc->gnutriplet()), |
3223 | 97 | QString::fromLatin1(":")); | 97 | QString::fromLatin1(":")); |
3224 | 98 | env.prependOrSetPath(QStringLiteral("lib/")+clickTc->gnutriplet()+QStringLiteral("/bin")); | ||
3225 | 99 | env.appendOrSetPath(QStringLiteral("$PATH")); | ||
3226 | 98 | } | 100 | } |
3227 | 99 | env.appendOrSet(QLatin1String("pkgdir"),workingDirectory()); | 101 | env.appendOrSet(QLatin1String("pkgdir"),workingDirectory()); |
3228 | 100 | env.appendOrSet(QLatin1String("APP_ID"),m_appId); | 102 | env.appendOrSet(QLatin1String("APP_ID"),m_appId); |
3229 | @@ -199,16 +201,24 @@ | |||
3230 | 199 | return false; | 201 | return false; |
3231 | 200 | } else { | 202 | } else { |
3232 | 201 | //looks like a application without a launcher | 203 | //looks like a application without a launcher |
3243 | 202 | m_localExecutable = target()->activeBuildConfiguration()->buildDirectory().toString() | 204 | CMakeProjectManager::CMakeProject* pro = static_cast<CMakeProjectManager::CMakeProject*> (target()->project()); |
3244 | 203 | + QDir::separator() | 205 | foreach(const CMakeProjectManager::CMakeBuildTarget &t, pro->buildTargets()) { |
3245 | 204 | + QLatin1String(Constants::UBUNTU_DEPLOY_DESTDIR) | 206 | if(t.library || t.executable.isEmpty()) |
3246 | 205 | + QDir::separator() | 207 | continue; |
3247 | 206 | + command; | 208 | |
3248 | 207 | 209 | QFileInfo execInfo(t.executable); | |
3249 | 208 | m_remoteExecutable = workingDirectory() | 210 | |
3250 | 209 | + QDir::separator() | 211 | if(execInfo.fileName() == commInfo.fileName()) |
3251 | 210 | + command; | 212 | m_localExecutable = t.executable; |
3252 | 211 | 213 | } | |
3253 | 214 | |||
3254 | 215 | if (m_localExecutable.isEmpty()) { | ||
3255 | 216 | if(errorMessage) | ||
3256 | 217 | *errorMessage = tr("Could not find %1 in the project targets").arg(command); | ||
3257 | 218 | return false; | ||
3258 | 219 | } | ||
3259 | 220 | |||
3260 | 221 | m_remoteExecutable = command; | ||
3261 | 212 | } | 222 | } |
3262 | 213 | 223 | ||
3263 | 214 | QFileInfo desk(m_desktopFile); | 224 | QFileInfo desk(m_desktopFile); |
3264 | 215 | 225 | ||
3265 | === modified file 'src/ubuntu/ubuntusettingsdeviceconnectivitywidget.cpp' | |||
3266 | --- src/ubuntu/ubuntusettingsdeviceconnectivitywidget.cpp 2014-04-10 12:29:54 +0000 | |||
3267 | +++ src/ubuntu/ubuntusettingsdeviceconnectivitywidget.cpp 2014-04-27 13:29:17 +0000 | |||
3268 | @@ -18,7 +18,6 @@ | |||
3269 | 18 | 18 | ||
3270 | 19 | #include "ubuntusettingsdeviceconnectivitywidget.h" | 19 | #include "ubuntusettingsdeviceconnectivitywidget.h" |
3271 | 20 | #include "ui_ubuntusettingsdeviceconnectivitywidget.h" | 20 | #include "ui_ubuntusettingsdeviceconnectivitywidget.h" |
3272 | 21 | #include "ubuntudeviceswidget.h" | ||
3273 | 22 | #include "ubuntuconstants.h" | 21 | #include "ubuntuconstants.h" |
3274 | 23 | 22 | ||
3275 | 24 | using namespace Ubuntu; | 23 | using namespace Ubuntu; |
PASSED: Continuous integration, rev:149 jenkins. qa.ubuntu. com/job/ qtcreator- plugin- ubuntu- ci/229/ jenkins. qa.ubuntu. com/job/ qtcreator- plugin- ubuntu- trusty- amd64-ci/ 160 jenkins. qa.ubuntu. com/job/ qtcreator- plugin- ubuntu- trusty- armhf-ci/ 160
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/qtcreator- plugin- ubuntu- ci/229/ rebuild
http://