on xenial help sign in
merged with trunk
commit032654ba4f6b7bee319549e6e4f7511637c85f40 authorNick Dedekind <nicholas.dedekind@gmail.com> dateMon 16 Sep 2013, 08:37 (13 years ago) parent8434489d1296e3
79 files changed+1490−624
Applications/Application.qml+1−1 Bottombar/Bottombar.qml+2−2 CMakeLists.txt+4 Components/ApplicationManagerWrapper.qml+89−42 Components/ApplicationScreenshot.qml+2−2 Components/ApplicationsModelStageFiltered.qml+49 Components/EdgeDemo.qml+26−20 Components/EdgeDemoOverlay.qml+1−1 Components/Stage.qml+1−1 Dash/Apps/RunningApplicationTile.qml+2−3 Dash/Apps/RunningApplicationsGrid.qml+4−4 Greeter/GreeterContent.qml+19−2 Launcher/Launcher.qml+4−4 Launcher/LauncherPanel.qml+3−3 Panel/Indicators/DefaultIndicatorWidget.qml+1−1 Panel/Indicators/MessagingIndicatorWidget.qml+1−1 Panel/Indicators/NetworkIndicatorWidget.qml+6−6 Panel/Indicators/SoundIndicatorWidget.qml+1−1 Shell.qml+30−26 SideStage/SideStage.qml+1−1 debian/changelog+88 debian/control+9−7 main.cpp+73−6 plugins/AccountsService/AccountsService.cpp+67−37 plugins/AccountsService/AccountsService.h+34−8 plugins/AccountsService/AccountsServiceDBusAdaptor.cpp+126 plugins/AccountsService/AccountsServiceDBusAdaptor.h+54 plugins/AccountsService/CMakeLists.txt+1 plugins/Unity/Indicators/Messaging/qml/MessageMenuItemFactory.qml+6−6 plugins/Unity/Indicators/qml/MenuItemFactory.qml+1−1 plugins/Unity/Indicators/rootactionstate.cpp+8−8 plugins/Unity/IndicatorsLegacy/Network/qml/AccessPoint.qml+2−2 plugins/Unity/Launcher/CMakeLists.txt+3−2 plugins/Unity/Launcher/backend/launcherbackend.cpp+10−5 plugins/Unity/Launcher/backend/launcherbackend.h+2−2 plugins/Unity/Launcher/launcheritem.cpp+1−7 plugins/Unity/Launcher/launcheritem.h+1−3 plugins/Unity/Launcher/launchermodel.cpp+94−46 plugins/Unity/Launcher/launchermodel.h+10−1 plugins/Utils/qsortfilterproxymodelqml.cpp+13−1 plugins/Utils/qsortfilterproxymodelqml.h+1 po/ca.po+32−32 run_on_device+2−1 tests/mocks/AccountsService/AccountsService.cpp+19−3 tests/mocks/AccountsService/AccountsService.h+22−3 tests/mocks/AccountsService/CMakeLists.txt+2 tests/mocks/Ubuntu/Application/CMakeLists.txt−29 tests/mocks/Ubuntu/Application/qmldir−3 tests/mocks/Ubuntu/CMakeLists.txt−1 tests/mocks/Ubuntu/Application/ApplicationImage.cpp → tests/mocks/Unity/Application/ApplicationImage.cpp tests/mocks/Ubuntu/Application/ApplicationImage.h → tests/mocks/Unity/Application/ApplicationImage.h tests/mocks/Ubuntu/Application/ApplicationInfo.cpp → tests/mocks/Unity/Application/ApplicationInfo.cpp+15−2 tests/mocks/Ubuntu/Application/ApplicationInfo.h → tests/mocks/Unity/Application/ApplicationInfo.h+12−18 tests/mocks/Ubuntu/Application/ApplicationListModel.cpp → tests/mocks/Unity/Application/ApplicationListModel.cpp tests/mocks/Ubuntu/Application/ApplicationListModel.h → tests/mocks/Unity/Application/ApplicationListModel.h tests/mocks/Ubuntu/Application/ApplicationManager.cpp → tests/mocks/Unity/Application/ApplicationManager.cpp+185−153 tests/mocks/Ubuntu/Application/ApplicationManager.h → tests/mocks/Unity/Application/ApplicationManager.h+26−26 tests/mocks/Unity/Application/CMakeLists.txt+37 tests/mocks/Ubuntu/Application/InputFilterArea.qml → tests/mocks/Unity/Application/InputFilterArea.qml tests/mocks/Unity/Application/OSKController.qml+20 tests/mocks/Ubuntu/Application/plugin.cpp → tests/mocks/Unity/Application/plugin.cpp+6−5 tests/mocks/Ubuntu/Application/plugin.h → tests/mocks/Unity/Application/plugin.h+1−1 tests/mocks/Unity/Application/qmldir+4 tests/mocks/Unity/CMakeLists.txt+1 tests/mocks/Unity/Launcher/CMakeLists.txt+1−1 tests/mocks/Unity/Launcher/MockLauncherModel.cpp+7−4 tests/mocks/Unity/Launcher/MockLauncherModel.h+3−1 tests/plugins/AccountsService/CMakeLists.txt+1 tests/plugins/AccountsService/client.cpp+19−7 tests/plugins/Unity/Launcher/CMakeLists.txt+15−3 tests/plugins/Unity/Launcher/click-icon.desktop+4 tests/plugins/Unity/Launcher/launcherbackendtest.cpp+25 tests/plugins/Unity/Launcher/launchermodeltest.cpp+88−18 tests/plugins/Unity/Launcher/rel-icon.desktop+1−1 tests/plugins/Unity/Launcher/rel-icon.svg tests/qmltests/Components/tst_Stage.qml+1−1 tests/qmltests/Dash/Apps/tst_RunningApplicationsGrid.qml+55−37 tests/qmltests/Launcher/tst_Launcher.qml+2−2 tests/qmltests/tst_Shell.qml+33−9
Applications/Application.qml+1−1
@@ -16,7 +16,7 @@
1616
1717import QtQuick 2.0
1818import "applications.js" as ApplicationsModel
19−import Ubuntu.Application 0.1
19+import Unity.Application 0.1
2020
2121/* This class is temporary. It is meant to be API compatible with qthybris' Application
2222 class.
Bottombar/Bottombar.qml+2−2
@@ -18,7 +18,7 @@ import QtQuick 2.0
1818import "../Components"
1919import "../Components/Math.js" as MathLocal
2020import Unity 0.1
21−import Ubuntu.Application 0.1
21+import Unity.Application 0.1
2222import Ubuntu.Gestures 0.1
2323
2424Item {
@@ -144,7 +144,7 @@ Item {
144144
145145 InputFilterArea {
146146 anchors.fill: parent
147− blockInput: hudButton.visible
147+ blockInput: (hudButton.opacity == 1)
148148 }
149149
150150 states: [
CMakeLists.txt+4
@@ -62,10 +62,13 @@ set(SHELL_PRIVATE_LIBDIR ${CMAKE_INSTALL_LIBDIR}/unity8)
6262
6363configure_file(paths.h.in ${CMAKE_CURRENT_BINARY_DIR}/paths.h @ONLY)
6464
65+pkg_check_modules(UNITY-MIR REQUIRED unity-mir)
66+
6567include_directories(
6668 ${CMAKE_CURRENT_BINARY_DIR}
6769 ${CMAKE_CURRENT_SOURCE_DIR}
6870 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
71+ ${UNITY-MIR_INCLUDE_DIRS}
6972 )
7073
7174set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
@@ -118,6 +121,7 @@ target_link_libraries(${SHELL_APP}
118121 ${Qt5Qml_LIBRARIES}
119122 ${Qt5Quick_LIBRARIES}
120123 ${XCB_LDFLAGS}
124+ ${CMAKE_DL_LIBS}
121125 )
122126
123127# install binaries
Components/ApplicationManagerWrapper.qml+89−42
@@ -15,15 +15,15 @@
1515 */
1616
1717import QtQuick 2.0
18−import Ubuntu.Application 0.1
18+import Unity.Application 0.1
1919
2020Item {
2121 id: applicationManager
2222
23− property var mainStageApplications: ApplicationManager.mainStageApplications
24− property var sideStageApplications: ApplicationManager.sideStageApplications
25− property var mainStageFocusedApplication: ApplicationManager.mainStageFocusedApplication
26− property var sideStageFocusedApplication: ApplicationManager.sideStageFocusedApplication
23+ property alias mainStageApplications: mainStageModel
24+ property alias sideStageApplications: sideStageModel
25+ property variant mainStageFocusedApplication: null
26+ property variant sideStageFocusedApplication: null
2727 property bool sideStageEnabled: true
2828 signal focusRequested(string desktopFile)
2929 property bool keyboardVisible: ApplicationManager.keyboardVisible
@@ -31,32 +31,76 @@ Item {
3131
3232 property bool fake: ApplicationManager.fake ? ApplicationManager.fake : false
3333
34− Component.onCompleted: {
35− // Start the watcher so that the ApplicationManager applications model can be populated.
36− ApplicationManager.startWatcher();
34+ ApplicationsModelStageFiltered {
35+ id: mainStageModel
36+ stage: ApplicationInfo.MainStage
37+ }
38+
39+ ApplicationsModelStageFiltered {
40+ id: sideStageModel
41+ stage: ApplicationInfo.SideStage
42+ }
43+
44+ Connections {
45+ target: ApplicationManager
46+ onFocusedApplicationIdChanged: {
47+ var app = ApplicationManager.findApplication(ApplicationManager.focusedApplicationId)
48+ if (!app) { //nothing at all focused, so clear all
49+ mainStageFocusedApplication = null;
50+ sideStageFocusedApplication = null;
51+ } else {
52+ if (app.stage == ApplicationInfo.MainStage) {
53+ mainStageFocusedApplication = app;
54+ // possible the side stage app being unfocused fired this signal, so check for it
55+ if (sideStageFocusedApplication && !sideStageFocusedApplication.focused)
56+ sideStageFocusedApplication = null;
57+ } else {
58+ sideStageFocusedApplication = app;
59+ // possible the main stage app being unfocused fired this signal, so check for it
60+ if (mainStageFocusedApplication && !mainStageFocusedApplication.focused)
61+ mainStageFocusedApplication = null;
62+ }
63+ }
64+ }
3765 }
3866
3967 function activateApplication(desktopFile, argument) {
40− var application;
41− application = getApplicationFromDesktopFile(desktopFile, ApplicationInfo.MainStage);
42− if (application == null) {
43− application = getApplicationFromDesktopFile(desktopFile, ApplicationInfo.SideStage);
68+ var appId;
69+
70+ // HACK: Applications identified sometimes with with appId, but mostly with desktopFile.
71+ // TODO: convert entire shell to use appId only.
72+ if (desktopFile.indexOf(".desktop") >= 0) {
73+ appId = desktopFileToAppId(desktopFile);
74+ } else {
75+ appId = desktopFile;
4476 }
45− if (application != null) {
77+
78+ var application = ApplicationManager.findApplication(appId);
79+ if (application !== null) {
4680 return application;
4781 }
4882
4983 var execFlags = sideStageEnabled ? ApplicationManager.NoFlag : ApplicationManager.ForceMainStage;
5084
5185 if (argument) {
52− return ApplicationManager.startProcess(desktopFile, execFlags, [argument]);
86+ return ApplicationManager.startApplication(appId, execFlags, [argument]);
5387 } else {
54− return ApplicationManager.startProcess(desktopFile, execFlags);
88+ return ApplicationManager.startApplication(appId, execFlags);
5589 }
5690 }
5791
58− function stopProcess(application) {
59− ApplicationManager.stopProcess(application)
92+ function stopApplication(application) {
93+ var appId;
94+
95+ // HACK: Applications identified sometimes with with appId, but mostly with desktopFile.
96+ // TODO: convert entire shell to use appId only.
97+ if (typeof application == "string") {
98+ appId = application;
99+ } else {
100+ appId = desktopFileToAppId(application.desktopFile);
101+ }
102+
103+ ApplicationManager.stopApplication(appId);
60104 }
61105
62106 function focusApplication(application) {
@@ -64,51 +108,54 @@ Item {
64108 return;
65109 }
66110
67− ApplicationManager.focusApplication(application.handle);
111+ ApplicationManager.focusApplication(application.appId);
68112 }
69113
70114 function unfocusCurrentApplication() {
71− ApplicationManager.unfocusCurrentApplication(ApplicationInfo.MainStage);
115+ ApplicationManager.unfocusCurrentApplication();
72116 }
73117
74118 function moveRunningApplicationStackPosition(from, to, stage) {
75− var applications;
119+ if (from == to || from < 0 || to < 0) return;
120+
76121 if (stage == ApplicationInfo.SideStage) {
77− applications = ApplicationManager.sideStageApplications;
122+ sideStageModel.move(from, to);
78123 } else {
79− applications = ApplicationManager.mainStageApplications;
124+ mainStageModel.move(from, to);
80125 }
81− // FIXME: applications.move(0, 0) crashes
82− if (from !== to && from >= 0 && to >= 0) applications.move(from, to);
83126 }
84127
85128 function getApplicationFromDesktopFile(desktopFile, stage) {
86− var foundSideStageApp, foundMainStageApp;
129+ var appId;
87130
88− foundMainStageApp = __find(desktopFile, ApplicationManager.mainStageApplications)
89− if (stage == ApplicationInfo.MainStage) {
90− return foundMainStageApp;
91− }
92− foundSideStageApp = __find(desktopFile, ApplicationManager.sideStageApplications)
93− if (stage == ApplicationInfo.SideStage) {
94− return foundSideStageApp;
131+ // HACK: Applications identified sometimes with with appId, but mostly with desktopFile.
132+ // TODO: convert entire shell to use appId only.
133+ if (desktopFile.indexOf(".desktop") >= 0) {
134+ appId = desktopFileToAppId(desktopFile);
135+ } else {
136+ appId = desktopFile;
95137 }
96138
97− // if stage not specified, return whichever app running on either stage
98− return (foundMainStageApp) ? foundMainStageApp : foundSideStageApp;
99−
139+ for (var i = 0, len = ApplicationManager.count; i < len; i++ ) {
140+ var app = ApplicationManager.get(i);
100141
101− function __find(desktopFile, applications) {
102− for (var i = 0; i < applications.count; i++ ) {
103− var application = applications.get(i);
104− if (application.desktopFile == desktopFile) {
105− return application;
106− }
142+ // if stage not specified, return whichever app running on either stage
143+ if (app.appId == appId && (stage == undefined || app.stage == stage)) {
144+ return app;
107145 }
108− return null;
109146 }
110147 }
111148
149+ function desktopFileToAppId(desktopFile) {
150+ var right = desktopFile.lastIndexOf(".desktop");
151+ var left = desktopFile.lastIndexOf("/");
152+ if (left == -1 || right == -1 || left == right) {
153+ console.log("ApplicationManagerWrapper: unable to extract appId from '" + desktopFile + "'");
154+ return "";
155+ }
156+ return desktopFile.substring(left+1, right);
157+ }
158+
112159 Connections {
113160 target: ApplicationManager
114161 onFocusRequested: {
Components/ApplicationScreenshot.qml+2−2
@@ -16,7 +16,7 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
19−import Ubuntu.Application 0.1
19+import Unity.Application 0.1
2020
2121Item {
2222 id: applicationScreenshot
@@ -56,6 +56,6 @@ Item {
5656 width: applicationScreenshot.application ? parent.width : 0
5757 height: applicationScreenshot.application ? parent.height : 0
5858 visible: applicationScreenshot.application != null && ready
59− source: applicationScreenshot.application
59+ source: ApplicationManager.findApplication((application) ? application.appId : "")
6060 }
6161}
Components/ApplicationsModelStageFiltered.qmlnew file+49
@@ -0,0 +1,49 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.0
18+import Utils 0.1
19+import Unity.Application 0.1
20+
21+SortFilterProxyModel {
22+ id: root
23+ property int stage
24+
25+ function get(index) {
26+ return model.get(mapRowToSource(index));
27+ }
28+
29+ function move(from, to) {
30+ var realFrom = mapRowToSource(from);
31+ if (realFrom == -1) {
32+ console.log("ERROR; invalid from=" + from + " index in move operation");
33+ return;
34+ }
35+ var realTo = mapRowToSource(to);
36+ if (realTo == -1) {
37+ // assuming wanting to move to end of list
38+ realTo = model.count - 1;
39+ }
40+
41+ if (realFrom == realTo) return;
42+ model.move(realFrom, realTo);
43+ }
44+
45+ model: ApplicationManager
46+ dynamicSortFilter: true
47+ filterRole: ApplicationManager.RoleStage
48+ filterRegExp: RegExp(stage)
49+}
Components/EdgeDemo.qml+26−20
@@ -43,15 +43,12 @@ Item {
4343 }
4444
4545 function hideEdgeDemoInShell() {
46− var user = LightDM.Users.data(greeter.currentIndex, LightDM.UserRoles.NameRole);
47− AccountsService.setUserProperty(user, "demo-edges", false);
48− d.showEdgeDemo = false;
46+ AccountsService.demoEdges = false;
4947 stopDemo();
5048 }
5149
5250 function hideEdgeDemoInGreeter() {
53− // TODO: AccountsService.setUserProperty("lightdm", "demo-edges", false);
54− d.showEdgeDemoInGreeter = false;
51+ // TODO: AccountsService.demoEdges = false as lightdm user
5552 }
5653
5754 function hideEdgeDemos() {
@@ -71,6 +68,24 @@ Item {
7168 if (d.finalEdgeDemo) d.finalEdgeDemo.destroy()
7269 }
7370
71+ function startDemo() {
72+ if (!d.overlay) {
73+ d.overlay = Qt.createComponent("EdgeDemoOverlay.qml")
74+ }
75+
76+ launcherEnabled = false;
77+ dashEnabled = false;
78+ panelEnabled = false;
79+ panelContentEnabled = false;
80+
81+ // Begin with either greeter or dash, depending on which is visible
82+ if (greeter && greeter.shown) {
83+ startRightEdgeDemo()
84+ } else {
85+ startTopEdgeDemo()
86+ }
87+ }
88+
7489 QtObject {
7590 id: d
7691 property Component overlay
@@ -79,22 +94,18 @@ Item {
7994 property QtObject bottomEdgeDemo
8095 property QtObject leftEdgeDemo
8196 property QtObject finalEdgeDemo
82− property bool showEdgeDemo: false
83− property bool showEdgeDemoInGreeter: d.showEdgeDemo // TODO: AccountsService.getUserProperty("lightdm", "demo-edges")
97+ property bool showEdgeDemo: AccountsService.demoEdges
98+ property bool showEdgeDemoInGreeter: AccountsService.demoEdges // TODO: AccountsService.demoEdges as lightdm user
8499
85− onShowEdgeDemoInGreeterChanged: {
86− if (!d.overlay && d.showEdgeDemoInGreeter) {
87− d.overlay = Qt.createComponent("EdgeDemoOverlay.qml")
88− startRightEdgeDemo()
100+ onShowEdgeDemoChanged: {
101+ stopDemo()
102+ if (d.showEdgeDemo) {
103+ startDemo()
89104 }
90105 }
91106 }
92107
93108 function startRightEdgeDemo() {
94− launcherEnabled = false;
95− demo.dashEnabled = false;
96− demo.panelEnabled = false;
97− demo.panelContentEnabled = false;
98109 if (demo.greeter) {
99110 d.rightEdgeDemo = d.overlay.createObject(demo.greeter, {
100111 "edge": "right",
@@ -123,11 +134,6 @@ Item {
123134
124135 onUnlocked: hide()
125136 onShownChanged: if (!greeter.shown) hide()
126−
127− onSelected: {
128− var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole)
129− d.showEdgeDemo = AccountsService.getUserProperty(user, "demo-edges")
130− }
131137 }
132138
133139 function startTopEdgeDemo() {
Components/EdgeDemoOverlay.qml+1−1
@@ -17,7 +17,7 @@
1717import Powerd 0.1
1818import QtQuick 2.0
1919import QtGraphicalEffects 1.0
20−import Ubuntu.Application 0.1
20+import Unity.Application 0.1
2121import Ubuntu.Components 0.1
2222
2323Showable {
Components/Stage.qml+1−1
@@ -15,7 +15,7 @@
1515 */
1616
1717import QtQuick 2.0
18−import Ubuntu.Application 0.1
18+import Unity.Application 0.1
1919import Ubuntu.Components 0.1
2020import Ubuntu.Gestures 0.1
2121
Dash/Apps/RunningApplicationTile.qml+2−3
@@ -16,7 +16,7 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
19−import Ubuntu.Application 0.1
19+import Unity.Application 0.1
2020import "../../Components/"
2121import "../../Components/ListItems"
2222
@@ -76,10 +76,9 @@ AbstractButton {
7676
7777 ApplicationImage {
7878 id: applicationImage
79− source: application
79+ source: ApplicationManager.findApplication((application) ? application.appId : "")
8080 width: shapedApplicationImage.width
8181 height: shapedApplicationImage.height
82− fillMode: ApplicationImage.PreserveAspectCrop
8382 }
8483
8584 UbuntuShape {
Dash/Apps/RunningApplicationsGrid.qml+4−4
@@ -52,22 +52,22 @@ ResponsiveFlowView {
5252
5353 RunningApplicationTile {
5454 id: runningAppTile
55− objectName: "runningAppTile " + model.application.name
55+ objectName: "runningAppTile " + model.name
5656 anchors {
5757 top: parent.top
5858 horizontalCenter: parent.horizontalCenter
5959 }
60− application: model.application
60+ application: model
6161 onRequestedActivationMode: { root.terminationModeEnabled = false }
6262 onRequestedTerminationMode: {
6363 if (canEnableTerminationMode)
6464 root.terminationModeEnabled = true
6565 }
6666 onRequestedApplicationTermination: {
67− shell.applicationManager.stopProcess(application)
67+ shell.applicationManager.stopApplication(model.appId)
6868 }
6969 onRequestedApplicationActivation: {
70− shell.activateApplication(application.desktopFile)
70+ shell.activateApplication(model.appId)
7171 }
7272
7373 terminationModeEnabled: root.terminationModeEnabled
Greeter/GreeterContent.qml+19−2
@@ -15,6 +15,7 @@
1515 */
1616
1717import QtQuick 2.0
18+import AccountsService 0.1
1819import Ubuntu.Components 0.1
1920import LightDM 0.1 as LightDM
2021import "../Components"
@@ -39,14 +40,30 @@ MouseArea {
3940 color: "black"
4041 }
4142
43+ property url backgroundValue: AccountsService.backgroundFile != undefined && AccountsService.backgroundFile.length > 0 ? AccountsService.backgroundFile : shell.defaultBackground
44+ onBackgroundValueChanged: wallpaper.source = backgroundValue
45+
4246 CrossFadeImage {
4347 id: wallpaper
44−
45− source: shell.background
4648 anchors.fill: parent
4749 fadeInFirst: false
4850 }
4951
52+ // See Shell.qml's backgroundSettings treatment for why we need a separate
53+ // Image, but it boils down to avoiding binding loop detection.
54+ Image {
55+ source: wallpaper.source
56+ height: 0
57+ width: 0
58+ sourceSize.height: 0
59+ sourceSize.width: 0
60+ onStatusChanged: {
61+ if (status == Image.Error && source != shell.defaultBackground) {
62+ wallpaper.source = shell.defaultBackground
63+ }
64+ }
65+ }
66+
5067 Rectangle {
5168 anchors.fill: parent
5269 color: "black"
Launcher/Launcher.qml+4−4
@@ -35,7 +35,7 @@ Item {
3535 readonly property bool shown: panel.x > -panel.width
3636
3737 // emitted when an application is selected
38− signal launcherApplicationSelected(string desktopFile)
38+ signal launcherApplicationSelected(string appId)
3939
4040 // emitted when the apps dash should be shown because of a swipe gesture
4141 signal dash()
@@ -159,7 +159,7 @@ Item {
159159
160160 onApplicationSelected: {
161161 root.state = ""
162− launcherApplicationSelected(desktopFile)
162+ launcherApplicationSelected(appId)
163163 }
164164 onDashItemSelected: {
165165 root.state = ""
@@ -192,12 +192,12 @@ Item {
192192
193193 direction: Direction.Rightwards
194194
195− enabled: root.available && root.state !== "visible"
195+ enabled: root.available
196196 width: root.dragAreaWidth
197197 height: root.height
198198
199199 onTouchXChanged: {
200− if (status !== DirectionalDragArea.Recognized)
200+ if (status !== DirectionalDragArea.Recognized || launcher.state == "visible")
201201 return;
202202
203203 // When the gesture finally gets recognized, the finger will likely be
Launcher/LauncherPanel.qml+3−3
@@ -34,7 +34,7 @@ Item {
3434 property bool preventHiding: moving || dndArea.draggedIndex >= 0 || dndArea.quickListPopover !== null || dndArea.pressed
3535 property int highlightIndex: -1
3636
37− signal applicationSelected(string desktopFile)
37+ signal applicationSelected(string appId)
3838 signal dashItemSelected(int index)
3939
4040 BorderImage {
@@ -300,7 +300,7 @@ Item {
300300 } else if (clickedItem.angle < -12) {
301301 launcherListView.flick(0, launcherListView.clickFlickSpeed);
302302 } else {
303− root.applicationSelected(LauncherModel.get(index).desktopFile);
303+ root.applicationSelected(LauncherModel.get(index).appId);
304304 }
305305 return;
306306 }
@@ -311,7 +311,7 @@ Item {
311311 } else if (clickedItem.angle < -30) {
312312 launcherListView.flick(0, launcherListView.clickFlickSpeed);
313313 } else {
314− root.applicationSelected(LauncherModel.get(index).desktopFile);
314+ root.applicationSelected(LauncherModel.get(index).appId);
315315 }
316316 }
317317
Panel/Indicators/DefaultIndicatorWidget.qml+1−1
@@ -75,7 +75,7 @@ Indicators.IndicatorWidget {
7575 }
7676
7777 label = action.state[Indicators.ActionState.Label];
78− iconSource = "image://gicon/" + action.state[Indicators.ActionState.IconSource];
78+ iconSource = "image://theme/" + action.state[Indicators.ActionState.IconSource];
7979 enabled = action.state[Indicators.ActionState.Visible];
8080 }
8181}
Panel/Indicators/MessagingIndicatorWidget.qml+1−1
@@ -21,5 +21,5 @@ import QtQuick 2.0
2121
2222DefaultIndicatorWidget {
2323 // default the icon so we have something to show when we don't have the bus.
24− iconSource: "image://gicon/indicator-messages"
24+ iconSource: "image://theme/indicator-messages"
2525}
Panel/Indicators/NetworkIndicatorWidget.qml+6−6
@@ -97,16 +97,16 @@ Indicators.IndicatorWidget {
9797 function get_icon_for_signal(con_state, value) {
9898 if (con_state >= Indicators.NetworkConnection.Activating && con_state <= Indicators.NetworkConnection.Deactivating) {
9999 if (value == 0) {
100− return "image://gicon/nm-signal-00";
100+ return "image://theme/nm-signal-00";
101101 } else if (value <= 25) {
102− return "image://gicon/nm-signal-25";
102+ return "image://theme/nm-signal-25";
103103 } else if (value <= 50) {
104− return "image://gicon/nm-signal-50";
104+ return "image://theme/nm-signal-50";
105105 } else if (value <= 75) {
106− return "image://gicon/nm-signal-75";
106+ return "image://theme/nm-signal-75";
107107 }
108− return "image://gicon/nm-signal-100";
108+ return "image://theme/nm-signal-100";
109109 }
110− return "image://gicon/wifi-none";
110+ return "image://theme/wifi-none";
111111 }
112112}
Panel/Indicators/SoundIndicatorWidget.qml+1−1
@@ -21,6 +21,6 @@ import QtQuick 2.0
2121
2222DefaultIndicatorWidget {
2323 // default the icon so we have something to show when we don't have the bus.
24− iconSource: "image://gicon/audio-volume-high"
24+ iconSource: "image://theme/audio-volume-high"
2525 enabled: true
2626}
Shell.qml+30−26
@@ -15,8 +15,9 @@
1515 */
1616
1717import QtQuick 2.0
18+import AccountsService 0.1
1819import GSettings 1.0
19−import Ubuntu.Application 0.1
20+import Unity.Application 0.1
2021import Ubuntu.Components 0.1
2122import Ubuntu.Gestures 0.1
2223import Unity.Launcher 0.1
@@ -64,6 +65,12 @@ FocusScope {
6465
6566 property var applicationManager: ApplicationManagerWrapper {}
6667
68+ Binding {
69+ target: LauncherModel
70+ property: "applicationManager"
71+ value: ApplicationManager
72+ }
73+
6774 Component.onCompleted: {
6875 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
6976
@@ -74,6 +81,9 @@ FocusScope {
7481 applicationManager.unfocusCurrentApplication();
7582 }
7683
84+ readonly property bool applicationFocused: !!applicationManager.mainStageFocusedApplication
85+ || !!applicationManager.sideStageFocusedApplication
86+
7787 readonly property bool fullscreenMode: {
7888 if (greeter.shown || lockscreen.shown) {
7989 return false;
@@ -95,15 +105,6 @@ FocusScope {
95105 greeter.hide();
96106 shell.activateApplication(desktopFile);
97107 }
98−
99− onMainStageFocusedApplicationChanged: {
100− var app = applicationManager.mainStageFocusedApplication
101− if (app != null) {
102− LauncherModel.applicationFocused(app.desktopFile);
103− } else {
104− LauncherModel.applicationFocused("");
105− }
106− }
107108 }
108109
109110 function activateApplication(desktopFile, argument) {
@@ -156,6 +157,10 @@ FocusScope {
156157 }
157158 }
158159
160+ OSKController {
161+ anchors.fill: parent // as needs to know the geometry of the shell
162+ }
163+
159164 VolumeControl {
160165 id: volumeControl
161166 }
@@ -254,7 +259,7 @@ FocusScope {
254259 property bool fullyShown: shown && x == 0 && parent.x == 0
255260 property bool fullyHidden: !shown && x == width
256261 available: !greeter.shown
257− hides: [launcher, panel.indicators]
262+ hides: [panel.indicators]
258263 shown: false
259264 opacity: 1.0
260265 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
@@ -478,6 +483,7 @@ FocusScope {
478483 onSelected: {
479484 // Update launcher items for new user
480485 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
486+ AccountsService.user = user;
481487 LauncherModel.setUser(user);
482488 }
483489
@@ -490,7 +496,8 @@ FocusScope {
490496
491497 InputFilterArea {
492498 anchors.fill: parent
493− blockInput: greeter.shown || lockscreen.shown
499+ blockInput: !applicationFocused || greeter.shown || lockscreen.shown || launcher.shown
500+ || panel.indicators.shown || hud.shown
494501 }
495502
496503 Connections {
@@ -502,10 +509,8 @@ FocusScope {
502509
503510 function setFocused(focused) {
504511 if (!focused) {
505− // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
506− // the stage was actually shown
507− if (mainStage.fullyShown) powerConnection.previousMainApp = applicationManager.mainStageFocusedApplication;
508− if (sideStage.fullyShown) powerConnection.previousSideApp = applicationManager.sideStageFocusedApplication;
512+ powerConnection.previousMainApp = applicationManager.mainStageFocusedApplication;
513+ powerConnection.previousSideApp = applicationManager.sideStageFocusedApplication;
509514 applicationManager.unfocusCurrentApplication();
510515 } else {
511516 if (powerConnection.previousMainApp) {
@@ -556,8 +561,13 @@ FocusScope {
556561 searchVisible: !greeter.shown && !lockscreen.shown
557562
558563 InputFilterArea {
559− anchors.fill: parent
560− blockInput: panel.indicators.shown
564+ anchors {
565+ top: parent.top
566+ left: parent.left
567+ right: parent.right
568+ }
569+ height: (panel.fullscreenMode) ? shell.edgeSize : panel.panelHeight
570+ blockInput: true
561571 }
562572 }
563573
@@ -577,11 +587,6 @@ FocusScope {
577587 onMainStageFocusedApplicationChanged: hud.hide()
578588 onSideStageFocusedApplicationChanged: hud.hide()
579589 }
580−
581− InputFilterArea {
582− anchors.fill: parent
583− blockInput: hud.shown
584− }
585590 }
586591
587592 Revealer {
@@ -604,8 +609,7 @@ FocusScope {
604609 theHud: hud
605610 anchors.fill: parent
606611 enabled: !panel.indicators.shown
607− applicationIsOnForeground: applicationManager.mainStageFocusedApplication
608− || applicationManager.sideStageFocusedApplication
612+ applicationIsOnForeground: applicationFocused
609613 }
610614
611615 InputFilterArea {
@@ -645,7 +649,7 @@ FocusScope {
645649 }
646650 onLauncherApplicationSelected:{
647651 greeter.hide()
648− shell.activateApplication(desktopFile)
652+ shell.activateApplication(appId)
649653 }
650654 onShownChanged: {
651655 if (shown) {
SideStage/SideStage.qml+1−1
@@ -15,7 +15,7 @@
1515 */
1616
1717import QtQuick 2.0
18−import Ubuntu.Application 0.1
18+import Unity.Application 0.1
1919import Ubuntu.Components 0.1
2020import "../Components"
2121
debian/changelog+88
@@ -1,3 +1,91 @@
1+unity8 (7.81.3+13.10.20130912-0ubuntu1) saucy; urgency=low
2+
3+ [ Michael Zanetti ]
4+ * add support for finding icons from click package apps in the
5+ launcher.
6+ * update to latest launcher API for better integration with the
7+ AppManager.
8+
9+ [ Ricardo Mendoza ]
10+ * Fixes problems related to image 20130912.0, amongst: * Fix autopilot
11+ tests by preventing blocking of input during HUD button animations,
12+ only when fully visible * Fix loading of unity-mir library, major
13+ version wasn't specified so unless the dev package was there it
14+ would fail.
15+
16+ [ Ubuntu daily release ]
17+ * Automatic snapshot from revision 316
18+
19+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Thu, 12 Sep 2013 13:47:59 +0000
20+
21+unity8 (7.81.3+13.10.20130911.1-0ubuntu1) saucy; urgency=low
22+
23+ [ Michael Terry ]
24+ * Switch from deprecated image://gicon/ to new image://theme/.
25+
26+ [ Gerry Boland ]
27+ * Add OSKController so shell can control OSK correctly on Mir.
28+ * Remove InputFilterArea for bottom edge swipes, as applications also
29+ listen for such swipes for Toolbar reveal.
30+
31+ [ Ricardo Mendoza ]
32+ * Select the backend to use dynamically on runtime according to the
33+ QPA selected by the system.
34+
35+ [ Ubuntu daily release ]
36+ * Automatic snapshot from revision 311
37+
38+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 11 Sep 2013 16:22:55 +0000
39+
40+unity8 (7.81.3+13.10.20130911-0ubuntu1) saucy; urgency=low
41+
42+ [ Michal Hruby ]
43+ * Hide all gicon strings from the shell and use the image://theme icon
44+ provider that was recently added to the SDK.
45+
46+ [ Gerry Boland ]
47+ * Convert to new ApplicationManager API.
48+
49+ [ Nick Dedekind ]
50+ * Updated access point design as per spec.
51+ * Indicator visibility based on connection with backend service.
52+
53+ [ Albert Astals ]
54+ * Dash: Make assignments bindings This way if the model changes the
55+ item value also changes.
56+
57+ [ Michael Zanetti ]
58+ * adds support for highlighting the currently focused application in
59+ the launcher, adds tests.
60+ * include ~/.local/share/applications in launcher's .desktop file
61+ search path.
62+ * shrink size of area for revealing the HUD button and make it
63+ disappear on release again. fixes 1219035. (LP: #1219035)
64+ * revert revision 304 as it makes the Shell crash.
65+
66+ [ Michael Terry ]
67+ * Allow testers to set custom password or pin in demo mode, rather
68+ than hardcoding them.
69+ * Have the greeter use AccountsService to determine its background.
70+ (LP: #1218402)
71+ * Listen to changes in the "show edge demo" AccountsService setting.
72+
73+ [ Daniel d'Andrada ]
74+ * Update fake/mock plugins so that "./run --fake" works well again -
75+ You can now see the thumbnails of the fake running applications once
76+ again. - You no longer get hundreds of warnings due to icons not
77+ found.
78+ * Reset apps scope when returning from app to dash (LP #1193419) If an
79+ app is on foreground and you perform a long left-edge swipe to
80+ minimize it, and therefore return to the dash, the dash should be in
81+ the Applications scope and showing the running/recents applications.
82+ (LP: #1193419)
83+
84+ [ Ubuntu daily release ]
85+ * Automatic snapshot from revision 306
86+
87+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 11 Sep 2013 00:54:31 +0000
88+
189unity8 (7.81.3+13.10.20130905.2-0ubuntu1) saucy; urgency=low
290
391 [ Michael Zanetti ]
debian/control+9−7
@@ -23,6 +23,7 @@ Build-Depends: cmake,
2323 libunity-api-dev (>= 7.80.3),
2424 libunity-core-6.0-dev (<< 7.80),
2525 libunity-dev (>= 7.0.12),
26+ libunity-mir-dev,
2627 libunity-scopes-json-def-phone,
2728 libupstart-dev,
2829 libusermetricsoutput1-dev,
@@ -54,7 +55,7 @@ Vcs-Browser: https://bazaar.launchpad.net/~unity-team/unity8/trunk
5455Package: indicators-client
5556Architecture: amd64 armhf i386
5657Depends: qmenumodel-qml (>= 0.2.7),
57− qtdeclarative5-ubuntu-ui-toolkit-plugin | qt-components-ubuntu,
58+ qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 0.1.46+13.10.20130829.1-0ubuntu1),
5859 unity8 (= ${binary:Version}),
5960 ${misc:Depends},
6061 ${shlibs:Depends},
@@ -65,13 +66,14 @@ Package: unity8
6566Architecture: any
6667Provides: indicator-renderer,
6768Depends: gsettings-desktop-schemas,
69+ libunity-mir1,
6870 qmenumodel-qml (>= 0.2.7),
6971 qtdeclarative5-dee-plugin,
7072 qtdeclarative5-gsettings1.0,
71− qtdeclarative5-ubuntu-ui-toolkit-plugin,
73+ qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 0.1.46+13.10.20130829.1-0ubuntu1),
7274 qtdeclarative5-unity-notifications-plugin | unity-notifications-impl,
7375 qtdeclarative5-xmllistmodel-plugin,
74− unity-launcher-impl-2,
76+ unity-launcher-impl-3,
7577 unity-notifications-impl-1,
7678 unity8-fake-env | qtubuntu-shell,
7779 unity8-private (= ${binary:Version}),
@@ -87,18 +89,18 @@ Description: Unity 8 shell
8789
8890Package: unity8-autopilot
8991Architecture: all
90−Depends: indicators-client (>= ${source:Version}),
92+Depends: gir1.2-glib-2.0,
93+ indicators-client (>= ${source:Version}),
9194 libautopilot-qt,
9295 libqt5test5,
9396 libqt5widgets5,
9497 python-evdev,
98+ python-gi,
9599 unity8 (>= ${source:Version}),
96100 unity8-fake-env (>= ${source:Version}),
97101 ${misc:Depends},
98102 ${python:Depends},
99103 ${shlibs:Depends},
100−Recommends: gir1.2-glib-2.0,
101− python-gi,
102104Description: Test package for Unity 8 shell
103105 Autopilot tests for the unity8 package
104106
@@ -120,7 +122,7 @@ Pre-Depends: ${misc:Pre-Depends},
120122Depends: ${misc:Depends},
121123 ${shlibs:Depends},
122124Provides: unity-launcher-impl,
123− unity-launcher-impl-2,
125+ unity-launcher-impl-3,
124126Description: Unity 8 private libs
125127 The Unity 8 shell is the primary user interface for Ubuntu devices.
126128 .
main.cpp+73−6
@@ -25,13 +25,17 @@
2525#include <QtQml/QQmlContext>
2626#include <qpa/qplatformnativeinterface.h>
2727#include <QLibrary>
28+#include <QDebug>
2829#include <libintl.h>
30+#include <dlfcn.h>
2931
3032// local
3133#include "paths.h"
3234#include "MouseTouchAdaptor.h"
3335#include "ApplicationArguments.h"
3436
37+#include <unity-mir/qmirserver.h>
38+
3539namespace {
3640
3741void prependImportPaths(QQmlEngine *engine, const QStringList &paths)
@@ -72,7 +76,7 @@ void resolveIconTheme() {
7276}
7377} // namespace {
7478
75−int main(int argc, char** argv)
79+int startShell(int argc, const char** argv, void* server)
7680{
7781 /* Workaround Qt platform integration plugin not advertising itself
7882 as having the following capabilities:
@@ -82,12 +86,29 @@ int main(int argc, char** argv)
8286 setenv("QML_FORCE_THREADED_RENDERER", "1", 1);
8387 setenv("QML_FIXED_ANIMATION_STEP", "1", 1);
8488
89+ const bool isUbuntuMirServer = qgetenv("QT_QPA_PLATFORM") == "ubuntumirserver";
90+
8591 QGuiApplication::setApplicationName("Unity 8");
86− QGuiApplication application(argc, argv);
92+ QGuiApplication *application;
93+ if (isUbuntuMirServer) {
94+ QLibrary unityMir("unity-mir", 1);
95+ unityMir.load();
96+
97+ typedef QGuiApplication* (*createServerApplication_t)(int&, const char **, void*);
98+ createServerApplication_t createQMirServerApplication = (createServerApplication_t) unityMir.resolve("createQMirServerApplication");
99+ if (!createQMirServerApplication) {
100+ qDebug() << "unable to resolve symbol: createQMirServerApplication";
101+ return 4;
102+ }
103+
104+ application = createQMirServerApplication(argc, argv, server);
105+ } else {
106+ application = new QGuiApplication(argc, (char**)argv);
107+ }
87108
88109 resolveIconTheme();
89110
90− QStringList args = application.arguments();
111+ QStringList args = application->arguments();
91112 ApplicationArguments qmlArgs(args);
92113
93114 // The testability driver is only loaded by QApplication but not by QGuiApplication.
@@ -124,7 +145,7 @@ int main(int argc, char** argv)
124145 if (args.contains(QLatin1String("-mousetouch"))) {
125146 mouseTouchAdaptor = new MouseTouchAdaptor;
126147 mouseTouchAdaptor->setTargetWindow(view);
127− application.installNativeEventFilter(mouseTouchAdaptor);
148+ application->installNativeEventFilter(mouseTouchAdaptor);
128149 }
129150
130151 QPlatformNativeInterface* nativeInterface = QGuiApplication::platformNativeInterface();
@@ -139,18 +160,64 @@ int main(int argc, char** argv)
139160 QUrl source("Shell.qml");
140161 prependImportPaths(view->engine(), ::overrideImportPaths());
141162 appendImportPaths(view->engine(), ::fallbackImportPaths());
163+
164+ QStringList importPath = view->engine()->importPathList().filter("qt5/imports");
165+ if (isUbuntuMirServer) {
166+ importPath.first().append("/Unity-Mir");
167+ view->engine()->addImportPath(importPath.first());
168+ }
169+
142170 view->setSource(source);
143171 view->setColor("transparent");
144172
145− if (qgetenv("QT_QPA_PLATFORM") == "ubuntu" || args.contains(QLatin1String("-fullscreen"))) {
173+ if (qgetenv("QT_QPA_PLATFORM") == "ubuntu" || isUbuntuMirServer || args.contains(QLatin1String("-fullscreen"))) {
146174 view->showFullScreen();
147175 } else {
148176 view->show();
149177 }
150178
151− int result = application.exec();
179+ int result = application->exec();
152180
153181 delete mouseTouchAdaptor;
182+ delete application;
154183
155184 return result;
156185}
186+
187+int main(int argc, const char *argv[])
188+{
189+ // For ubuntumirserver/ubuntumirclient
190+ if (qgetenv("QT_QPA_PLATFORM").startsWith("ubuntumir")) {
191+ setenv("QT_QPA_PLATFORM", "ubuntumirserver", 1);
192+
193+ // If we use unity-mir directly, we automatically link to the Mir-server
194+ // platform-api bindings, which result in unexpected behaviour when
195+ // running the non-Mir scenario.
196+ QLibrary unityMir("unity-mir", 1);
197+ unityMir.load();
198+ if (!unityMir.isLoaded()) {
199+ qDebug() << "Library unity-mir not found/loaded";
200+ return 1;
201+ }
202+
203+ typedef QMirServer* (*createServer_t)(int, const char **);
204+ createServer_t createQMirServer = (createServer_t) unityMir.resolve("createQMirServer");
205+ if (!createQMirServer) {
206+ qDebug() << "unable to resolve symbol: createQMirServer";
207+ return 2;
208+ }
209+
210+ QMirServer* mirServer = createQMirServer(argc, argv);
211+
212+ typedef int (*runWithClient_t)(QMirServer*, std::function<int(int, const char**, void*)>);
213+ runWithClient_t runWithClient = (runWithClient_t) unityMir.resolve("runQMirServerWithClient");
214+ if (!runWithClient) {
215+ qDebug() << "unable to resolve symbol: runWithClient";
216+ return 3;
217+ }
218+
219+ return runWithClient(mirServer, startShell);
220+ } else {
221+ return startShell(argc, argv, nullptr);
222+ }
223+}
plugins/AccountsService/AccountsService.cpp+67−37
@@ -17,58 +17,88 @@
1717 */
1818
1919#include "AccountsService.h"
20−#include <QDBusConnection>
21−#include <QDBusConnectionInterface>
22−#include <QDBusMessage>
23−#include <QDBusVariant>
20+#include "AccountsServiceDBusAdaptor.h"
21+
22+#include <QStringList>
2423
2524AccountsService::AccountsService(QObject* parent)
2625 : QObject(parent),
27− accounts_manager(NULL),
28− users()
26+ m_service(new AccountsServiceDBusAdaptor(this)),
27+ m_user(qgetenv("USER"))
2928{
30− auto connection = QDBusConnection::SM_BUSNAME();
31− auto interface = connection.interface();
32− interface->startService("org.freedesktop.Accounts");
33− accounts_manager = new QDBusInterface("org.freedesktop.Accounts",
34− "/org/freedesktop/Accounts",
35− "org.freedesktop.Accounts",
36− connection, this);
29+ connect(m_service, SIGNAL(propertiesChanged(const QString &, const QString &, const QStringList &)),
30+ this, SLOT(propertiesChanged(const QString &, const QString &, const QStringList &)));
31+ connect(m_service, SIGNAL(maybeChanged(const QString &)),
32+ this, SLOT(maybeChanged(const QString &)));
3733}
3834
39−QVariant AccountsService::getUserProperty(const QString &user, const QString &property)
35+QString AccountsService::getUser()
4036{
41− auto iface = getUserInterface(user);
42− if (iface != nullptr && iface->isValid()) {
43− auto answer = iface->call("Get", "com.canonical.unity.AccountsService", property);
44− if (answer.type() == QDBusMessage::ReplyMessage) {
45− return answer.arguments()[0].value<QDBusVariant>().variant();
46− }
37+ return m_user;
38+}
39+
40+void AccountsService::setUser(const QString &user)
41+{
42+ m_user = user;
43+ Q_EMIT userChanged();
44+
45+ updateDemoEdges();
46+ updateBackgroundFile();
47+}
48+
49+bool AccountsService::getDemoEdges()
50+{
51+ return m_demoEdges;
52+}
53+
54+void AccountsService::setDemoEdges(bool demoEdges)
55+{
56+ m_demoEdges = demoEdges;
57+ m_service->setUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges", demoEdges);
58+}
59+
60+QString AccountsService::getBackgroundFile()
61+{
62+ return m_backgroundFile;
63+}
64+
65+void AccountsService::updateDemoEdges()
66+{
67+ auto demoEdges = m_service->getUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges").toBool();
68+ if (m_demoEdges != demoEdges) {
69+ m_demoEdges = demoEdges;
70+ Q_EMIT demoEdgesChanged();
4771 }
48− return QVariant();
4972}
5073
51−void AccountsService::setUserProperty(const QString &user, const QString &property, const QVariant &value)
74+void AccountsService::updateBackgroundFile()
5275{
53− auto iface = getUserInterface(user);
54− if (iface != nullptr && iface->isValid()) {
55− // The value needs to be carefully wrapped
56− iface->call("Set", "com.canonical.unity.AccountsService", property, QVariant::fromValue(QDBusVariant(value)));
76+ auto backgroundFile = m_service->getUserProperty(m_user, "org.freedesktop.Accounts.User", "BackgroundFile").toString();
77+ if (m_backgroundFile != backgroundFile) {
78+ m_backgroundFile = backgroundFile;
79+ Q_EMIT backgroundFileChanged();
5780 }
5881}
5982
60−QDBusInterface *AccountsService::getUserInterface(const QString &user)
83+void AccountsService::propertiesChanged(const QString &user, const QString &interface, const QStringList &changed)
6184{
62− auto iface = users.value(user);
63− if (iface == nullptr && accounts_manager->isValid()) {
64− auto answer = accounts_manager->call("FindUserByName", user);
65− if (answer.type() == QDBusMessage::ReplyMessage) {
66− iface = new QDBusInterface("org.freedesktop.Accounts",
67− answer.arguments()[0].value<QDBusObjectPath>().path(),
68− "org.freedesktop.DBus.Properties",
69− accounts_manager->connection(), this);
70− users.insert(user, iface);
85+ if (m_user != user) {
86+ return;
87+ }
88+
89+ if (interface == "com.canonical.unity.AccountsService") {
90+ if (changed.contains("demo-edges")) {
91+ updateDemoEdges();
7192 }
7293 }
73− return iface;
94+}
95+
96+void AccountsService::maybeChanged(const QString &user)
97+{
98+ if (m_user != user) {
99+ return;
100+ }
101+
102+ // Standard properties might have changed
103+ updateBackgroundFile();
74104}
plugins/AccountsService/AccountsService.h+34−8
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2012,2013 Canonical, Ltd.
2+ * Copyright (C) 2013 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -19,26 +19,52 @@
1919#ifndef UNITY_ACCOUNTSSERVICE_H
2020#define UNITY_ACCOUNTSSERVICE_H
2121
22−#include <QDBusInterface>
23−#include <QMap>
2422#include <QObject>
2523#include <QString>
2624
25+class AccountsServiceDBusAdaptor;
26+
2727class AccountsService: public QObject
2828{
2929 Q_OBJECT
30+ Q_PROPERTY (QString user
31+ READ getUser
32+ WRITE setUser
33+ NOTIFY userChanged)
34+ Q_PROPERTY (bool demoEdges
35+ READ getDemoEdges
36+ WRITE setDemoEdges
37+ NOTIFY demoEdgesChanged)
38+ Q_PROPERTY (QString backgroundFile
39+ READ getBackgroundFile
40+ NOTIFY backgroundFileChanged)
3041
3142public:
3243 explicit AccountsService(QObject *parent = 0);
3344
34− Q_INVOKABLE QVariant getUserProperty(const QString &user, const QString &property);
35− Q_INVOKABLE void setUserProperty(const QString &user, const QString &property, const QVariant &value);
45+ QString getUser();
46+ void setUser(const QString &user);
47+ bool getDemoEdges();
48+ void setDemoEdges(bool demoEdges);
49+ QString getBackgroundFile();
50+
51+Q_SIGNALS:
52+ void userChanged();
53+ void demoEdgesChanged();
54+ void backgroundFileChanged();
55+
56+private Q_SLOTS:
57+ void propertiesChanged(const QString &user, const QString &interface, const QStringList &changed);
58+ void maybeChanged(const QString &user);
3659
3760private:
38− QDBusInterface *getUserInterface(const QString &user);
61+ void updateDemoEdges();
62+ void updateBackgroundFile();
3963
40− QDBusInterface *accounts_manager;
41− QMap<QString, QDBusInterface *> users;
64+ AccountsServiceDBusAdaptor *m_service;
65+ QString m_user;
66+ bool m_demoEdges;
67+ QString m_backgroundFile;
4268};
4369
4470#endif
plugins/AccountsService/AccountsServiceDBusAdaptor.cppnew file+126
@@ -0,0 +1,126 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Author: Michael Terry <michael.terry@canonical.com>
17+ */
18+
19+#include "AccountsServiceDBusAdaptor.h"
20+#include <QDBusConnection>
21+#include <QDBusConnectionInterface>
22+#include <QDBusMessage>
23+#include <QDBusVariant>
24+
25+AccountsServiceDBusAdaptor::AccountsServiceDBusAdaptor(QObject* parent)
26+ : QObject(parent),
27+ accounts_manager(NULL),
28+ users()
29+{
30+ auto connection = QDBusConnection::SM_BUSNAME();
31+ auto interface = connection.interface();
32+ interface->startService("org.freedesktop.Accounts");
33+ accounts_manager = new QDBusInterface("org.freedesktop.Accounts",
34+ "/org/freedesktop/Accounts",
35+ "org.freedesktop.Accounts",
36+ connection, this);
37+}
38+
39+QVariant AccountsServiceDBusAdaptor::getUserProperty(const QString &user, const QString &interface, const QString &property)
40+{
41+ auto iface = getUserInterface(user);
42+ if (iface != nullptr && iface->isValid()) {
43+ auto answer = iface->call("Get", interface, property);
44+ if (answer.type() == QDBusMessage::ReplyMessage) {
45+ return answer.arguments()[0].value<QDBusVariant>().variant();
46+ }
47+ }
48+ return QVariant();
49+}
50+
51+void AccountsServiceDBusAdaptor::setUserProperty(const QString &user, const QString &interface, const QString &property, const QVariant &value)
52+{
53+ auto iface = getUserInterface(user);
54+ if (iface != nullptr && iface->isValid()) {
55+ // The value needs to be carefully wrapped
56+ iface->call("Set", interface, property, QVariant::fromValue(QDBusVariant(value)));
57+ }
58+}
59+
60+void AccountsServiceDBusAdaptor::propertiesChangedSlot(const QString &interface, const QVariantMap &changed, const QStringList &invalid)
61+{
62+ // Merge changed and invalidated together
63+ QStringList combined;
64+ combined << invalid;
65+ combined << changed.keys();
66+ combined.removeDuplicates();
67+
68+ Q_EMIT propertiesChanged(getUserForPath(message().path()), interface, combined);
69+}
70+
71+void AccountsServiceDBusAdaptor::maybeChangedSlot()
72+{
73+ Q_EMIT maybeChanged(getUserForPath(message().path()));
74+}
75+
76+QString AccountsServiceDBusAdaptor::getUserForPath(const QString &path)
77+{
78+ QMap<QString, QDBusInterface *>::const_iterator i;
79+ for (i = users.constBegin(); i != users.constEnd(); ++i) {
80+ if (i.value()->path() == path) {
81+ return i.key();
82+ }
83+ }
84+ return QString();
85+}
86+
87+QDBusInterface *AccountsServiceDBusAdaptor::getUserInterface(const QString &user)
88+{
89+ auto iface = users.value(user);
90+ if (iface == nullptr && accounts_manager->isValid()) {
91+ auto answer = accounts_manager->call("FindUserByName", user);
92+ if (answer.type() == QDBusMessage::ReplyMessage) {
93+ auto path = answer.arguments()[0].value<QDBusObjectPath>().path();
94+
95+ iface = new QDBusInterface("org.freedesktop.Accounts",
96+ path,
97+ "org.freedesktop.DBus.Properties",
98+ accounts_manager->connection(), this);
99+
100+ // With its own pre-defined properties, AccountsService is oddly
101+ // close-lipped. It won't send out proper DBus.Properties notices,
102+ // but it does have one catch-all Changed() signal. So let's
103+ // listen to that.
104+ iface->connection().connect(
105+ iface->service(),
106+ path,
107+ "org.freedesktop.Accounts.User",
108+ "Changed",
109+ this,
110+ SLOT(maybeChangedSlot()));
111+
112+ // But custom properties do send out the right notifications, so
113+ // let's still listen there.
114+ iface->connection().connect(
115+ iface->service(),
116+ path,
117+ "org.freedesktop.DBus.Properties",
118+ "PropertiesChanged",
119+ this,
120+ SLOT(propertiesChangedSlot(QString, QVariantMap, QStringList)));
121+
122+ users.insert(user, iface);
123+ }
124+ }
125+ return iface;
126+}
plugins/AccountsService/AccountsServiceDBusAdaptor.hnew file+54
@@ -0,0 +1,54 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authors: Michael Terry <michael.terry@canonical.com>
17+ */
18+
19+#ifndef UNITY_ACCOUNTSSERVICEDBUSADAPTOR_H
20+#define UNITY_ACCOUNTSSERVICEDBUSADAPTOR_H
21+
22+#include <QDBusContext>
23+#include <QDBusInterface>
24+#include <QMap>
25+#include <QObject>
26+#include <QString>
27+
28+class AccountsServiceDBusAdaptor: public QObject, public QDBusContext
29+{
30+ Q_OBJECT
31+
32+public:
33+ explicit AccountsServiceDBusAdaptor(QObject *parent = 0);
34+
35+ Q_INVOKABLE QVariant getUserProperty(const QString &user, const QString &interface, const QString &property);
36+ Q_INVOKABLE void setUserProperty(const QString &user, const QString &interface, const QString &property, const QVariant &value);
37+
38+Q_SIGNALS:
39+ void propertiesChanged(const QString &user, const QString &interface, const QStringList &changed);
40+ void maybeChanged(const QString &user); // Standard properties might have changed
41+
42+private Q_SLOTS:
43+ void propertiesChangedSlot(const QString &interface, const QVariantMap &changed, const QStringList &invalid);
44+ void maybeChangedSlot();
45+
46+private:
47+ QDBusInterface *getUserInterface(const QString &user);
48+ QString getUserForPath(const QString &path);
49+
50+ QDBusInterface *accounts_manager;
51+ QMap<QString, QDBusInterface *> users;
52+};
53+
54+#endif
plugins/AccountsService/CMakeLists.txt+1
@@ -4,6 +4,7 @@ add_definitions(-DSM_BUSNAME=systemBus)
44
55add_library(AccountsService-qml MODULE
66 AccountsService.cpp
7+ AccountsServiceDBusAdaptor.cpp
78 plugin.cpp
89 )
910
plugins/Unity/Indicators/Messaging/qml/MessageMenuItemFactory.qml+6−6
@@ -68,8 +68,8 @@ Indicators.BaseMenuItem {
6868 time: menu ? Utils.formatDate(menu.ext.xCanonicalTime) : ""
6969 message: menu && menu.ext.xCanonicalText ? menu.ext.xCanonicalText : ""
7070 // icons
71− avatar: menu && menu.ext.xCanonicalIcon ? "image://gicon/" + encodeURI(menu.ext.xCanonicalIcon) : "qrc:/indicators/artwork/messaging/default_contact.png"
72− appIcon: menu && menu.ext.xCanonicalAppIcon ? "image://gicon/" + encodeURI(menu.ext.xCanonicalAppIcon) : ""
71+ avatar: menu && menu.ext.xCanonicalIcon ? "image://theme/" + encodeURI(menu.ext.xCanonicalIcon) : "qrc:/indicators/artwork/messaging/default_contact.png"
72+ appIcon: menu && menu.ext.xCanonicalAppIcon ? "image://theme/" + encodeURI(menu.ext.xCanonicalAppIcon) : ""
7373
7474 onActivateApp: {
7575 menuItem.model.activate(modelIndex, true);
@@ -94,8 +94,8 @@ Indicators.BaseMenuItem {
9494 message: menu && menu.ext.xCanonicalText ? menu.ext.xCanonicalText : ""
9595 replyButtonText: actionsDescription && actionsDescription[0].label ? actionsDescription[0].label : "Send"
9696 // icons
97− avatar: menu && menu.ext.xCanonicalIcon ? "image://gicon/" + encodeURI(menu.ext.xCanonicalIcon) : "qrc:/indicators/artwork/messaging/default_contact.png"
98− appIcon: menu && menu.ext.xCanonicalAppIcon ? "image://gicon/" + encodeURI(menu.ext.xCanonicalAppIcon) : ""
97+ avatar: menu && menu.ext.xCanonicalIcon ? "image://theme/" + encodeURI(menu.ext.xCanonicalIcon) : "qrc:/indicators/artwork/messaging/default_contact.png"
98+ appIcon: menu && menu.ext.xCanonicalAppIcon ? "image://theme/" + encodeURI(menu.ext.xCanonicalAppIcon) : ""
9999 // actions
100100 replyEnabled: replyAction.valid && replyAction.enabled
101101
@@ -132,8 +132,8 @@ Indicators.BaseMenuItem {
132132 replyButtonText: actionsDescription && actionsDescription[1].label ? actionsDescription[1].label : "Send"
133133 replyMessages: actionsDescription && actionsDescription[1]["parameter-hint"] ? actionsDescription[1]["parameter-hint"] : ""
134134 // icons
135− avatar: menu && menu.ext.xCanonicalIcon ? "image://gicon/" + encodeURI(menu.ext.xCanonicalIcon) : "qrc:/indicators/artwork/messaging/default_contact.png"
136− appIcon: menu && menu.ext.xCanonicalAppIcon ? "image://gicon/" + encodeURI(menu.ext.xCanonicalAppIcon) : ""
135+ avatar: menu && menu.ext.xCanonicalIcon ? "image://theme/" + encodeURI(menu.ext.xCanonicalIcon) : "qrc:/indicators/artwork/messaging/default_contact.png"
136+ appIcon: menu && menu.ext.xCanonicalAppIcon ? "image://theme/" + encodeURI(menu.ext.xCanonicalAppIcon) : ""
137137 // actions
138138 activateEnabled: activateAction.valid && activateAction.enabled
139139 replyEnabled: replyAction.valid && replyAction.enabled
plugins/Unity/Indicators/qml/MenuItemFactory.qml+1−1
@@ -217,7 +217,7 @@ Item {
217217
218218 title: menu && menu.label ? menu.label : ""
219219 count: menu && menu.actionState[0] ? menu.actionState[0] : "0"
220− appIcon: menu && (menu.ext.xCanonicalIcon.length > 0) ? "image://gicon/" + encodeURI(menu.ext.xCanonicalIcon) :
220+ appIcon: menu && (menu.ext.xCanonicalIcon.length > 0) ? "image://theme/" + encodeURI(menu.ext.xCanonicalIcon) :
221221 "qrc:/indicators/artwork/messaging/default_app.svg"
222222
223223 Component.onCompleted: {
plugins/Unity/Indicators/rootactionstate.cpp+8−8
@@ -148,15 +148,15 @@ static QString iconUri(GIcon *icon)
148148 QString uri;
149149
150150 if (G_IS_THEMED_ICON (icon)) {
151−
152151 const gchar* const* iconNames = g_themed_icon_get_names (G_THEMED_ICON (icon));
153− guint index = 0;
154− while(iconNames[index] != NULL) {
155− if (QIcon::hasThemeIcon(iconNames[index])) {
156− uri = QString("image://theme/%1").arg(iconNames[index]);
157− break;
158− }
159− index++;
152+
153+ QStringList iconNameList;
154+ for (uint index = 0; iconNames[index] != NULL; index++) {
155+ iconNameList << iconNames[index];
156+ }
157+
158+ if (!iconNameList.empty()) {
159+ uri = QString("image://theme/%1").arg(iconNameList.join(","));
160160 }
161161 }
162162 else if (G_IS_FILE_ICON (icon)) {
plugins/Unity/IndicatorsLegacy/Network/qml/AccessPoint.qml+2−2
@@ -47,10 +47,10 @@ Indicators.MenuItem {
4747 imageName += "-secure";
4848 }
4949
50− return "image://gicon/" + imageName;
50+ return "image://theme/" + imageName;
5151 }
5252
53− icon: menu && wifiApStrength ? getNetworkIcon(menu) : "image://gicon/wifi-none"
53+ icon: menu && wifiApStrength ? getNetworkIcon(menu) : "image://theme/wifi-none"
5454 iconFrame: false
5555 control: CheckBox {
5656 id: checkBoxActive
plugins/Unity/Launcher/CMakeLists.txt+3−2
@@ -1,5 +1,6 @@
11include(FindPkgConfig)
2−pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=2)
2+pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=3)
3+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=1)
34pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
45
56add_definitions(-DSM_BUSNAME=systemBus)
@@ -17,7 +18,7 @@ set(QMLLAUNCHERPLUGIN_SRC
1718 quicklistmodel.cpp
1819 common/quicklistentry.cpp
1920 backend/launcherbackend.cpp
20− ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsService.cpp
21+ ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsServiceDBusAdaptor.cpp
2122 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h
2223 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherModelInterface.h
2324 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/QuickListModelInterface.h
plugins/Unity/Launcher/backend/launcherbackend.cpp+10−5
@@ -18,7 +18,7 @@
1818 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1919 */
2020
21−#include "AccountsService.h"
21+#include "AccountsServiceDBusAdaptor.h"
2222#include "launcherbackend.h"
2323
2424#include <QDir>
@@ -43,7 +43,7 @@ LauncherBackend::LauncherBackend(bool useStorage, QObject *parent):
4343 m_accounts(nullptr)
4444{
4545 if (useStorage) {
46− m_accounts = new AccountsService(this);
46+ m_accounts = new AccountsServiceDBusAdaptor(this);
4747 }
4848 m_user = qgetenv("USER");
4949 syncFromAccounts();
@@ -214,7 +214,7 @@ void LauncherBackend::syncFromAccounts()
214214 m_storedApps.clear();
215215
216216 if (m_accounts && !m_user.isEmpty()) {
217− QVariant variant = m_accounts->getUserProperty(m_user, "launcher-items");
217+ QVariant variant = m_accounts->getUserProperty(m_user, "com.canonical.unity.AccountsService", "launcher-items");
218218 apps = qdbus_cast<QList<QVariantMap>>(variant.value<QDBusArgument>());
219219 defaults = isDefaultsItem(apps);
220220 }
@@ -257,7 +257,7 @@ void LauncherBackend::syncToAccounts()
257257 items << itemToVariant(appId);
258258 }
259259
260− m_accounts->setUserProperty(m_user, "launcher-items", QVariant::fromValue(items));
260+ m_accounts->setUserProperty(m_user, "com.canonical.unity.AccountsService", "launcher-items", QVariant::fromValue(items));
261261 }
262262}
263263
@@ -300,7 +300,12 @@ LauncherBackendItem* LauncherBackend::parseDesktopFile(const QString &desktopFil
300300 LauncherBackendItem* item = new LauncherBackendItem();
301301 item->desktopFile = desktopFile;
302302 item->displayName = settings.value("Desktop Entry/Name").toString();
303− item->icon = settings.value("Desktop Entry/Icon").toString();
303+
304+ if (settings.contains("Desktop Entry/Path")) {
305+ item->icon = settings.value("Desktop Entry/Path").toString() + "/" + settings.value("Desktop Entry/Icon").toString();
306+ } else {
307+ item->icon = settings.value("Desktop Entry/Icon").toString();
308+ }
304309 item->pinned = false;
305310 return item;
306311}
plugins/Unity/Launcher/backend/launcherbackend.h+2−2
@@ -25,7 +25,7 @@
2525#include <QSettings>
2626#include <QStringList>
2727
28−class AccountsService;
28+class AccountsServiceDBusAdaptor;
2929
3030/**
3131 * @brief An interface that provides all the data needed by the launcher.
@@ -156,7 +156,7 @@ private:
156156 QList<QString> m_storedApps;
157157 mutable QHash<QString, LauncherBackendItem*> m_itemCache;
158158
159− AccountsService *m_accounts;
159+ AccountsServiceDBusAdaptor *m_accounts;
160160 QString m_user;
161161};
162162
plugins/Unity/Launcher/launcheritem.cpp+1−7
@@ -20,10 +20,9 @@
2020#include "launcheritem.h"
2121#include "quicklistmodel.h"
2222
23−LauncherItem::LauncherItem(const QString &appId, const QString &desktopFile, const QString &name, const QString &icon, QObject *parent) :
23+LauncherItem::LauncherItem(const QString &appId, const QString &name, const QString &icon, QObject *parent) :
2424 LauncherItemInterface(parent),
2525 m_appId(appId),
26− m_desktopFile(desktopFile),
2726 m_name(name),
2827 m_icon(icon),
2928 m_pinned(false),
@@ -48,11 +47,6 @@ QString LauncherItem::appId() const
4847 return m_appId;
4948}
5049
51−QString LauncherItem::desktopFile() const
52−{
53− return m_desktopFile;
54−}
55−
5650QString LauncherItem::name() const
5751{
5852 return m_name;
plugins/Unity/Launcher/launcheritem.h+1−3
@@ -32,10 +32,9 @@ class LauncherItem: public LauncherItemInterface
3232{
3333 Q_OBJECT
3434public:
35− LauncherItem(const QString &appId, const QString &desktopFile, const QString &name, const QString &icon, QObject *parent = 0);
35+ LauncherItem(const QString &appId, const QString &name, const QString &icon, QObject *parent = 0);
3636
3737 QString appId() const;
38− QString desktopFile() const;
3938 QString name() const;
4039 QString icon() const;
4140
@@ -65,7 +64,6 @@ Q_SIGNALS:
6564
6665private:
6766 QString m_appId;
68− QString m_desktopFile;
6967 QString m_name;
7068 QString m_icon;
7169 bool m_pinned;
plugins/Unity/Launcher/launchermodel.cpp+94−46
@@ -21,16 +21,20 @@
2121#include "launcheritem.h"
2222#include "backend/launcherbackend.h"
2323
24+#include <unity/shell/application/ApplicationInfoInterface.h>
25+
26+using namespace unity::shell::application;
27+
2428LauncherModel::LauncherModel(QObject *parent):
2529 LauncherModelInterface(parent),
26− m_backend(new LauncherBackend(true, this))
30+ m_backend(new LauncherBackend(true, this)),
31+ m_appManager(0)
2732{
2833 connect(m_backend, SIGNAL(countChanged(QString,int)), SLOT(countChanged(QString,int)));
2934 connect(m_backend, SIGNAL(progressChanged(QString,int)), SLOT(progressChanged(QString,int)));
3035
3136 Q_FOREACH (const QString &entry, m_backend->storedApplications()) {
3237 LauncherItem *item = new LauncherItem(entry,
33− m_backend->desktopFile(entry),
3438 m_backend->displayName(entry),
3539 m_backend->icon(entry),
3640 this);
@@ -61,9 +65,7 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
6165 LauncherItem *item = m_list.at(index.row());
6266 switch(role) {
6367 case RoleAppId:
64− return item->desktopFile();
65− case RoleDesktopFile:
66− return item->desktopFile();
68+ return item->appId();
6769 case RoleName:
6870 return item->name();
6971 case RoleIcon:
@@ -137,7 +139,6 @@ void LauncherModel::pin(const QString &appId, int index)
137139 }
138140 beginInsertRows(QModelIndex(), index, index);
139141 LauncherItem *item = new LauncherItem(appId,
140− m_backend->desktopFile(appId),
141142 m_backend->displayName(appId),
142143 m_backend->icon(appId));
143144 item->setPinned(true);
@@ -193,45 +194,21 @@ void LauncherModel::setUser(const QString &username)
193194 m_backend->setUser(username);
194195}
195196
196−void LauncherModel::applicationFocused(const QString &appId)
197+ApplicationManagerInterface *LauncherModel::applicationManager() const
197198{
198− // Unfocus all apps
199− for(int i = 0; i < m_list.count(); ++i) {
200− LauncherItem *item = m_list.at(i);
201− if (item->focused()) {
202− item->setFocused(false);
203− Q_EMIT dataChanged(this->index(i), this->index(i), QVector<int>() << RoleFocused);
204− }
205− }
206−
207− if (appId.isEmpty()) {
208− return;
209− }
210−
211− // FIXME: drop this once we get real appIds from the AppManager
212− QString helper = appId.split('/').last();
213− if (helper.endsWith(".desktop")) {
214− helper.chop(8);
215− }
216−
217− int index = findApplication(helper);
218− if (index >= 0) {
219− m_list.at(index)->setFocused(true);
220− Q_EMIT dataChanged(this->index(index), this->index(index), QVector<int>() << RoleFocused);
221− } else {
222− // Add app to recent apps
223− QString desktopFile = m_backend->desktopFile(helper);
224− QString appName = m_backend->displayName(helper);
225− QString icon = m_backend->icon(helper);
226−
227− LauncherItem *item = new LauncherItem(helper, desktopFile, appName, icon);
228− item->setRecent(true);
229− item->setFocused(true);
230− beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
231− m_list.append(item);
232− endInsertRows();
199+ return m_appManager;
200+}
233201
234− // Clean up old recent apps
202+void LauncherModel::setApplicationManager(unity::shell::application::ApplicationManagerInterface *appManager)
203+{
204+ // Is there already another appmanager set?
205+ if (m_appManager) {
206+ // Disconnect any signals
207+ disconnect(this, SLOT(applicationAdded(QModelIndex,int)));
208+ disconnect(this, SLOT(applicationRemoved(QModelIndex,int)));
209+ disconnect(this, SLOT(focusedAppIdChanged()));
210+
211+ // remove any recent/running apps from the launcher
235212 QList<int> recentAppIndices;
236213 for (int i = 0; i < m_list.count(); ++i) {
237214 if (m_list.at(i)->recent()) {
@@ -239,22 +216,33 @@ void LauncherModel::applicationFocused(const QString &appId)
239216 }
240217 }
241218 int run = 0;
242− while (recentAppIndices.count() > 5) {
219+ while (recentAppIndices.count() > 0) {
243220 beginRemoveRows(QModelIndex(), recentAppIndices.first() - run, recentAppIndices.first() - run);
244221 m_list.takeAt(recentAppIndices.first() - run)->deleteLater();
245222 endRemoveRows();
246223 recentAppIndices.takeFirst();
247224 ++run;
248225 }
249− storeAppList();
226+ }
227+
228+ m_appManager = appManager;
229+ connect(m_appManager, SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(applicationAdded(QModelIndex,int)));
230+ connect(m_appManager, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), SLOT(applicationRemoved(QModelIndex,int)));
231+ connect(m_appManager, SIGNAL(focusedApplicationIdChanged()), SLOT(focusedAppIdChanged()));
232+
233+ Q_EMIT applicationManagerChanged();
234+
235+ for (int i = 0; i < appManager->count(); ++i) {
236+ applicationAdded(QModelIndex(), i);
250237 }
251238}
252239
240+
253241void LauncherModel::storeAppList()
254242{
255243 QStringList appIds;
256244 Q_FOREACH(LauncherItem *item, m_list) {
257− if (item->pinned() || item->recent()) {
245+ if (item->pinned()) {
258246 appIds << item->appId();
259247 }
260248 }
@@ -292,3 +280,63 @@ void LauncherModel::countChanged(const QString &appId, int count)
292280 Q_EMIT dataChanged(index(idx), index(idx), QVector<int>() << RoleCount);
293281 }
294282}
283+
284+void LauncherModel::applicationAdded(const QModelIndex &parent, int row)
285+{
286+ Q_UNUSED(parent);
287+
288+ ApplicationInfoInterface *app = m_appManager->get(row);
289+
290+ bool found = false;
291+ Q_FOREACH(LauncherItem *item, m_list) {
292+ if (app->appId() == item->appId()) {
293+ found = true;
294+ break;
295+ }
296+ }
297+ if (found) {
298+ // Shall we paint some running/recent app highlight? If yes, do it here.
299+ } else {
300+ LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString());
301+ item->setRecent(true);
302+ item->setFocused(app->focused());
303+
304+ beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
305+ m_list.append(item);
306+ endInsertRows();
307+ }
308+}
309+
310+void LauncherModel::applicationRemoved(const QModelIndex &parent, int row)
311+{
312+ Q_UNUSED(parent)
313+
314+ int appIndex = -1;
315+ for (int i = 0; i < m_list.count(); ++i) {
316+ if (m_list.at(i)->appId() == m_appManager->get(row)->appId()) {
317+ appIndex = i;
318+ break;
319+ }
320+ }
321+
322+ if (appIndex > -1 && !m_list.at(appIndex)->pinned()) {
323+ beginRemoveRows(QModelIndex(), appIndex, appIndex);
324+ m_list.takeAt(appIndex)->deleteLater();
325+ endRemoveRows();
326+ }
327+}
328+
329+void LauncherModel::focusedAppIdChanged()
330+{
331+ QString appId = m_appManager->focusedApplicationId();
332+ for (int i = 0; i < m_list.count(); ++i) {
333+ LauncherItem *item = m_list.at(i);
334+ if (!item->focused() && item->appId() == appId) {
335+ item->setFocused(true);
336+ Q_EMIT dataChanged(index(i), index(i), QVector<int>() << RoleFocused);
337+ } else if (item->focused() && item->appId() != appId) {
338+ item->setFocused(false);
339+ Q_EMIT dataChanged(index(i), index(i), QVector<int>() << RoleFocused);
340+ }
341+ }
342+}
plugins/Unity/Launcher/launchermodel.h+10−1
@@ -22,6 +22,7 @@
2222
2323// unity-api
2424#include <unity/shell/launcher/LauncherModelInterface.h>
25+#include <unity/shell/application/ApplicationManagerInterface.h>
2526
2627// Qt
2728#include <QAbstractListModel>
@@ -30,6 +31,7 @@ class LauncherItem;
3031class LauncherBackend;
3132
3233using namespace unity::shell::launcher;
34+using namespace unity::shell::application;
3335
3436class LauncherModel: public LauncherModelInterface
3537{
@@ -49,7 +51,9 @@ public:
4951 Q_INVOKABLE void requestRemove(const QString &appId);
5052 Q_INVOKABLE void quickListActionInvoked(const QString &appId, int actionIndex);
5153 Q_INVOKABLE void setUser(const QString &username);
52− Q_INVOKABLE void applicationFocused(const QString &appId);
54+
55+ unity::shell::application::ApplicationManagerInterface* applicationManager() const;
56+ void setApplicationManager(unity::shell::application::ApplicationManagerInterface *appManager);
5357
5458private:
5559 void storeAppList();
@@ -59,9 +63,14 @@ private Q_SLOTS:
5963 void progressChanged(const QString &appId, int progress);
6064 void countChanged(const QString &appId, int count);
6165
66+ void applicationAdded(const QModelIndex &parent, int row);
67+ void applicationRemoved(const QModelIndex &parent, int row);
68+ void focusedAppIdChanged();
69+
6270private:
6371 QList<LauncherItem*> m_list;
6472 LauncherBackend *m_backend;
73+ ApplicationManagerInterface *m_appManager;
6574};
6675
6776#endif // LAUNCHERMODEL_H
plugins/Utils/qsortfilterproxymodelqml.cpp+13−1
@@ -29,6 +29,17 @@ QSortFilterProxyModelQML::QSortFilterProxyModelQML(QObject *parent)
2929 connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), SIGNAL(countChanged()));
3030}
3131
32+/*
33+ * Enter row index of filtered/sorted model, returns row index of source model
34+ */
35+int QSortFilterProxyModelQML::mapRowToSource(int row)
36+{
37+ if (sourceModel() == NULL)
38+ return -1;
39+
40+ return QSortFilterProxyModel::mapToSource(index(row, 0)).row();
41+}
42+
3243QHash<int, QByteArray> QSortFilterProxyModelQML::roleNames() const
3344{
3445 return sourceModel() ? sourceModel()->roleNames() : QHash<int, QByteArray>();
@@ -51,6 +62,7 @@ QSortFilterProxyModelQML::setModel(QAbstractItemModel *itemModel)
5162 connect(itemModel, SIGNAL(modelReset()), SIGNAL(totalCountChanged()));
5263 connect(itemModel, SIGNAL(rowsInserted(QModelIndex,int,int)), SIGNAL(totalCountChanged()));
5364 connect(itemModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), SIGNAL(totalCountChanged()));
65+
5466 Q_EMIT totalCountChanged();
5567 Q_EMIT modelChanged();
5668 }
@@ -140,4 +152,4 @@ QSortFilterProxyModelQML::mapToSource(int row)
140152 } else {
141153 return -1;
142154 }
143−}
155+}
plugins/Utils/qsortfilterproxymodelqml.h+1
@@ -34,6 +34,7 @@ public:
3434 Q_INVOKABLE QVariant data(int row, int role);
3535 Q_INVOKABLE int count();
3636 Q_INVOKABLE int findFirst(int role, const QVariant& value) const;
37+ Q_INVOKABLE int mapRowToSource(int row);
3738 virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
3839
3940 /* getters */
po/ca.po+32−32
@@ -8,83 +8,83 @@ msgstr ""
88"Project-Id-Version: unity\n"
99"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
1010"POT-Creation-Date: 2013-08-27 13:36-0400\n"
11−"PO-Revision-Date: 2013-06-27 00:24+0000\n"
12−"Last-Translator: Michał Sawicz <michal.sawicz@canonical.com>\n"
11+"PO-Revision-Date: 2013-09-11 10:30+0000\n"
12+"Last-Translator: David Planella <david.planella@ubuntu.com>\n"
1313"Language-Team: Catalan <ca@li.org>\n"
1414"MIME-Version: 1.0\n"
1515"Content-Type: text/plain; charset=UTF-8\n"
1616"Content-Transfer-Encoding: 8bit\n"
1717"Plural-Forms: nplurals=2; plural=n != 1;\n"
18−"X-Launchpad-Export-Date: 2013-08-30 05:37+0000\n"
19−"X-Generator: Launchpad (build 16750)\n"
18+"X-Launchpad-Export-Date: 2013-09-12 08:06+0000\n"
19+"X-Generator: Launchpad (build 16761)\n"
2020
2121#: Applications/applications.js:23
2222msgid "Phone"
23−msgstr ""
23+msgstr "Telèfon"
2424
2525#: Applications/applications.js:29
2626msgid "Camera"
27−msgstr ""
27+msgstr "Càmera"
2828
2929#: Applications/applications.js:35
3030msgid "Gallery"
31−msgstr ""
31+msgstr "Galeria"
3232
3333#: Applications/applications.js:40
3434msgid "Facebook"
35−msgstr ""
35+msgstr "Facebook"
3636
3737#: Applications/applications.js:46
3838msgid "Browser"
39−msgstr ""
39+msgstr "Navegador"
4040
4141#: Applications/applications.js:51
4242msgid "Twitter"
43−msgstr ""
43+msgstr "Twitter"
4444
4545#: Applications/applications.js:57
4646msgid "GMail"
47−msgstr ""
47+msgstr "GMail"
4848
4949#: Applications/applications.js:62
5050msgid "Weather"
51−msgstr ""
51+msgstr "El temps"
5252
5353#: Applications/applications.js:68
5454msgid "Notepad"
55−msgstr ""
55+msgstr "Bloc de notes"
5656
5757#: Applications/applications.js:74
5858msgid "Calendar"
59−msgstr ""
59+msgstr "Calendari"
6060
6161#: Applications/applications.js:80
6262msgid "Media Player"
63−msgstr ""
63+msgstr "Reproductor multimèdia"
6464
6565#: Applications/applications.js:86
6666msgid "Evernote"
67−msgstr ""
67+msgstr "Evernote"
6868
6969#: Applications/applications.js:91
7070msgid "Map"
71−msgstr ""
71+msgstr "Mapa"
7272
7373#: Applications/applications.js:96
7474msgid "Pinterest"
75−msgstr ""
75+msgstr "Pinterest"
7676
7777#: Applications/applications.js:101
7878msgid "SoundCloud"
79−msgstr ""
79+msgstr "SoundCloud"
8080
8181#: Applications/applications.js:106
8282msgid "Wikipedia"
83−msgstr ""
83+msgstr "Viquipèdia"
8484
8585#: Applications/applications.js:111
8686msgid "YouTube"
87−msgstr ""
87+msgstr "YouTube"
8888
8989#: Components/EdgeDemoOverlay.qml:145
9090msgid "Skip intro"
@@ -92,7 +92,7 @@ msgstr ""
9292
9393#: Components/EdgeDemo.qml:98
9494msgid "Right edge"
95−msgstr ""
95+msgstr "Vora dreta"
9696
9797#: Components/EdgeDemo.qml:99
9898msgid "Try swiping from the right edge to unlock the phone"
@@ -100,7 +100,7 @@ msgstr ""
100100
101101#: Components/EdgeDemo.qml:135
102102msgid "Top edge"
103−msgstr ""
103+msgstr "Vora superior"
104104
105105#: Components/EdgeDemo.qml:136
106106msgid "Try swiping from the top edge to access the indicators"
@@ -116,7 +116,7 @@ msgstr ""
116116
117117#: Components/EdgeDemo.qml:189
118118msgid "Left edge"
119−msgstr ""
119+msgstr "Vora esquerra"
120120
121121#: Components/EdgeDemo.qml:190
122122msgid "Swipe from the left to reveal the launcher for quick access to apps"
@@ -124,7 +124,7 @@ msgstr ""
124124
125125#: Components/EdgeDemo.qml:217
126126msgid "Well done"
127−msgstr ""
127+msgstr "Enhorabona!"
128128
129129#: Components/EdgeDemo.qml:218
130130msgid "You have now mastered the edge gestures and can start using the phone"
@@ -138,7 +138,7 @@ msgstr "Cerques recents"
138138#: Dash/Apps/AppInfo.qml:73
139139#, qt-format
140140msgid "(%1)"
141−msgstr ""
141+msgstr "(%1)"
142142
143143#. TRANSLATORS: Number of persons who wrote reviews for this app
144144#: Dash/Apps/AppInfo.qml:85
@@ -158,7 +158,7 @@ msgstr ""
158158
159159#: Dash/Apps/AppReviews.qml:84
160160msgid "Review"
161−msgstr ""
161+msgstr "Ressenya"
162162
163163#: Dash/Apps/AppReviews.qml:118
164164msgid "Send"
@@ -166,15 +166,15 @@ msgstr ""
166166
167167#: Dash/Apps/AppReviews.qml:136
168168msgid "Comments:"
169−msgstr ""
169+msgstr "Comentaris:"
170170
171171#: Dash/DashMusic.qml:27 Dash/DashVideos.qml:28
172172msgid "Featured"
173−msgstr ""
173+msgstr "Destacats"
174174
175175#: Dash/DashMusic.qml:28 Dash/DashVideos.qml:29
176176msgid "Recent"
177−msgstr ""
177+msgstr "Recents"
178178
179179#: Dash/DashMusic.qml:29 Dash/DashVideos.qml:30
180180msgid "New Releases"
@@ -206,7 +206,7 @@ msgstr ""
206206
207207#: Dash/Video/VideoPreview.qml:176
208208msgid "Author:"
209−msgstr ""
209+msgstr "Autor:"
210210
211211#: Greeter/Lockscreen.qml:134
212212msgid "Emergency Call"
@@ -219,7 +219,7 @@ msgstr ""
219219
220220#: Greeter/PassphraseLockscreen.qml:59
221221msgid "Hello"
222−msgstr ""
222+msgstr "Hola"
223223
224224#: Hud/HudParametrizedActionsPage.qml:132
225225msgid "Confirm"
run_on_device+2−1
@@ -65,8 +65,9 @@ setup_adb_forwarding() {
6565}
6666
6767install_dependencies() {
68+ exec_with_adb rm /etc/init/ssh.override
69+ exec_with_adb service ssh start
6870 exec_with_adb apt-get update
69− exec_with_adb apt-get -y install openssh-server
7071 exec_with_ssh $SUDO apt-get -y install build-essential rsync bzr ccache gdb ninja-build devscripts equivs
7172}
7273
tests/mocks/AccountsService/AccountsService.cpp+19−3
@@ -23,11 +23,27 @@ AccountsService::AccountsService(QObject* parent)
2323{
2424}
2525
26−QVariant AccountsService::getUserProperty(const QString &, const QString &)
26+QString AccountsService::getUser()
2727{
28− return QVariant(false);
28+ return "testuser";
2929}
3030
31−void AccountsService::setUserProperty(const QString &, const QString &, const QVariant &)
31+void AccountsService::setUser(const QString &user)
3232{
33+ Q_UNUSED(user)
34+}
35+
36+bool AccountsService::getDemoEdges()
37+{
38+ return false;
39+}
40+
41+void AccountsService::setDemoEdges(bool demoEdges)
42+{
43+ Q_UNUSED(demoEdges)
44+}
45+
46+QString AccountsService::getBackgroundFile()
47+{
48+ return TOP_SRCDIR "/graphics/phone_background.jpg";
3349}
tests/mocks/AccountsService/AccountsService.h+22−3
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2012,2013 Canonical, Ltd.
2+ * Copyright (C) 2013 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -27,12 +27,31 @@
2727class AccountsService: public QObject
2828{
2929 Q_OBJECT
30+ Q_PROPERTY (QString user
31+ READ getUser
32+ WRITE setUser
33+ NOTIFY userChanged)
34+ Q_PROPERTY (bool demoEdges
35+ READ getDemoEdges
36+ WRITE setDemoEdges
37+ NOTIFY demoEdgesChanged)
38+ Q_PROPERTY (QString backgroundFile
39+ READ getBackgroundFile
40+ NOTIFY backgroundFileChanged)
3041
3142public:
3243 explicit AccountsService(QObject *parent = 0);
3344
34− Q_INVOKABLE QVariant getUserProperty(const QString &user, const QString &property);
35− Q_INVOKABLE void setUserProperty(const QString &user, const QString &property, const QVariant &value);
45+ QString getUser();
46+ void setUser(const QString &user);
47+ bool getDemoEdges();
48+ void setDemoEdges(bool demoEdges);
49+ QString getBackgroundFile();
50+
51+Q_SIGNALS:
52+ void userChanged();
53+ void demoEdgesChanged();
54+ void backgroundFileChanged();
3655};
3756
3857#endif
tests/mocks/AccountsService/CMakeLists.txt+2
@@ -1,3 +1,5 @@
1+add_definitions(-DTOP_SRCDIR="${CMAKE_SOURCE_DIR}")
2+
13add_library(MockAccountsService-qml MODULE
24 AccountsService.cpp
35 plugin.cpp
tests/mocks/Ubuntu/Application/CMakeLists.txtdeleted−29
@@ -1,29 +0,0 @@
1−set(FakeUbuntuApplicationQml_SOURCES
2− plugin.cpp
3− ApplicationInfo.cpp
4− ApplicationImage.cpp
5− ApplicationListModel.cpp
6− ApplicationManager.cpp
7−)
8−
9−add_library(FakeUbuntuApplicationQml MODULE ${FakeUbuntuApplicationQml_SOURCES})
10−
11−qt5_use_modules(FakeUbuntuApplicationQml Core Quick)
12−
13−# copy files into build directory for shadow builds
14−add_custom_target(UbuntuAppQmlDirFile ALL
15− COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/qmldir" ${CMAKE_CURRENT_BINARY_DIR}
16− DEPENDS qmldir
17−)
18−add_custom_target(InputFilterAreaQmlFile ALL
19− COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/InputFilterArea.qml" ${CMAKE_CURRENT_BINARY_DIR}
20− DEPENDS InputFilterArea.qml
21−)
22−
23−install(TARGETS FakeUbuntuApplicationQml
24− DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/mocks/Ubuntu/Application
25− )
26−
27−install(FILES qmldir InputFilterArea.qml
28− DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/mocks/Ubuntu/Application
29− )
tests/mocks/Ubuntu/Application/qmldirdeleted−3
@@ -1,3 +0,0 @@
1−module Ubuntu.Application
2−plugin FakeUbuntuApplicationQml
3−InputFilterArea 0.1 InputFilterArea.qml
tests/mocks/Ubuntu/CMakeLists.txt−1
@@ -1,2 +1 @@
1−add_subdirectory(Application)
21add_subdirectory(DownloadDaemonListener)
tests/mocks/Ubuntu/Application/ApplicationImage.cpp → tests/mocks/Unity/Application/ApplicationImage.cpprenamed

The content is the same.

tests/mocks/Ubuntu/Application/ApplicationImage.h → tests/mocks/Unity/Application/ApplicationImage.hrenamed

The content is the same.

tests/mocks/Ubuntu/Application/ApplicationInfo.cpp → tests/mocks/Unity/Application/ApplicationInfo.cpprenamed+15−2
@@ -21,11 +21,24 @@
2121#include <QQuickView>
2222#include <QQmlComponent>
2323
24+ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
25+ : ApplicationInfoInterface(appId, parent)
26+ ,m_appId(appId)
27+ ,m_stage(MainStage)
28+ ,m_state(Starting)
29+ ,m_focused(false)
30+ ,m_fullscreen(false)
31+ ,m_windowItem(0)
32+ ,m_windowComponent(0)
33+ ,m_parentItem(0)
34+{
35+}
36+
2437ApplicationInfo::ApplicationInfo(QObject *parent)
25− : QObject(parent)
26− ,m_handle(0)
38+ : ApplicationInfoInterface(QString(), parent)
2739 ,m_stage(MainStage)
2840 ,m_state(Starting)
41+ ,m_focused(false)
2942 ,m_fullscreen(false)
3043 ,m_windowItem(0)
3144 ,m_windowComponent(0)
tests/mocks/Ubuntu/Application/ApplicationInfo.h → tests/mocks/Unity/Application/ApplicationInfo.hrenamed+12−18
@@ -22,21 +22,18 @@
2222
2323class QQuickItem;
2424
25+// unity-api
26+#include <unity/shell/application/ApplicationInfoInterface.h>
27+
2528// A pretty dumb file. Just a container for properties.
2629// Implemented in C++ instead of QML just because of the enumerations
2730// See QTBUG-14861
28−class ApplicationInfo : public QObject {
31+
32+using namespace unity::shell::application;
33+
34+class ApplicationInfo : public ApplicationInfoInterface {
2935 Q_OBJECT
30− Q_ENUMS(Stage)
31− Q_ENUMS(State)
32− Q_PROPERTY(QString desktopFile READ desktopFile WRITE setDesktopFile NOTIFY desktopFileChanged)
33− Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
34− Q_PROPERTY(QString comment READ comment WRITE setComment NOTIFY commentChanged)
35− Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged)
36− Q_PROPERTY(QString exec READ exec WRITE setExec NOTIFY execChanged)
37− Q_PROPERTY(qint64 handle READ handle WRITE setHandle NOTIFY handleChanged)
38− Q_PROPERTY(Stage stage READ stage WRITE setStage NOTIFY stageChanged)
39− Q_PROPERTY(State state READ state WRITE setState NOTIFY stateChanged)
36+
4037 Q_PROPERTY(bool fullscreen READ fullscreen WRITE setFullscreen NOTIFY fullscreenChanged)
4138
4239 // Only exists in this fake implementation
@@ -48,10 +45,8 @@ class ApplicationInfo : public QObject {
4845 Q_PROPERTY(QString windowQml READ windowQml WRITE setWindowQml NOTIFY windowQmlChanged)
4946
5047 public:
51− enum Stage { MainStage, SideStage };
52− enum State { Starting, Running };
53−
5448 ApplicationInfo(QObject *parent = NULL);
49+ ApplicationInfo(const QString &appId, QObject *parent = NULL);
5550
5651 #define IMPLEMENT_PROPERTY(name, Name, type) \
5752 public: \
@@ -68,14 +63,13 @@ class ApplicationInfo : public QObject {
6863 private: \
6964 type m_##name;
7065
71− IMPLEMENT_PROPERTY(desktopFile, DesktopFile, QString)
66+ IMPLEMENT_PROPERTY(appId, AppId, QString)
7267 IMPLEMENT_PROPERTY(name, Name, QString)
7368 IMPLEMENT_PROPERTY(comment, Comment, QString)
74− IMPLEMENT_PROPERTY(icon, Icon, QString)
75− IMPLEMENT_PROPERTY(exec, Exec, QString)
76− IMPLEMENT_PROPERTY(handle, Handle, qint64)
69+ IMPLEMENT_PROPERTY(icon, Icon, QUrl)
7770 IMPLEMENT_PROPERTY(stage, Stage, Stage)
7871 IMPLEMENT_PROPERTY(state, State, State)
72+ IMPLEMENT_PROPERTY(focused, Focused, bool)
7973 IMPLEMENT_PROPERTY(fullscreen, Fullscreen, bool)
8074 IMPLEMENT_PROPERTY(imageQml, ImageQml, QString)
8175 IMPLEMENT_PROPERTY(windowQml, WindowQml, QString)
tests/mocks/Ubuntu/Application/ApplicationListModel.cpp → tests/mocks/Unity/Application/ApplicationListModel.cpprenamed

The content is the same.

tests/mocks/Ubuntu/Application/ApplicationListModel.h → tests/mocks/Unity/Application/ApplicationListModel.hrenamed

The content is the same.

tests/mocks/Ubuntu/Application/ApplicationManager.cpp → tests/mocks/Unity/Application/ApplicationManager.cpprenamed+185−153
@@ -16,7 +16,6 @@
1616
1717#include "ApplicationManager.h"
1818#include "ApplicationInfo.h"
19−#include "ApplicationListModel.h"
2019#include "paths.h"
2120
2221#include <QDir>
@@ -26,11 +25,7 @@
2625#include <QQmlComponent>
2726
2827ApplicationManager::ApplicationManager(QObject *parent)
29− : QObject(parent)
30− , m_mainStageApplications(new ApplicationListModel())
31− , m_sideStageApplications(new ApplicationListModel())
32− , m_mainStageFocusedApplication(0)
33− , m_sideStageFocusedApplication(0)
28+ : ApplicationManagerInterface(parent)
3429 , m_mainStageComponent(0)
3530 , m_mainStage(0)
3631 , m_sideStageComponent(0)
@@ -41,8 +36,84 @@ ApplicationManager::ApplicationManager(QObject *parent)
4136
4237ApplicationManager::~ApplicationManager()
4338{
44− delete m_mainStageApplications;
45− delete m_sideStageApplications;
39+}
40+
41+int ApplicationManager::rowCount(const QModelIndex& parent) const {
42+ return !parent.isValid() ? m_runningApplications.size() : 0;
43+}
44+
45+QVariant ApplicationManager::data(const QModelIndex& index, int role) const {
46+ if (index.row() < 0 || index.row() >= m_runningApplications.size())
47+ return QVariant();
48+
49+ auto app = m_runningApplications.at(index.row());
50+ switch(role) {
51+ case RoleAppId:
52+ return app->appId();
53+ case RoleName:
54+ return app->name();
55+ case RoleComment:
56+ return app->comment();
57+ case RoleIcon:
58+ return app->icon();
59+ case RoleStage:
60+ return app->stage();
61+ case RoleState:
62+ return app->state();
63+ case RoleFocused:
64+ return app->focused();
65+ default:
66+ return QVariant();
67+ }
68+}
69+
70+ApplicationInfo *ApplicationManager::get(int row) const {
71+ if (row < 0 || row >= m_runningApplications.size())
72+ return nullptr;
73+ return m_runningApplications.at(row);
74+}
75+
76+ApplicationInfo *ApplicationManager::findApplication(const QString &appId) const {
77+ for (ApplicationInfo *app : m_runningApplications) {
78+ if (app->appId() == appId) {
79+ return app;
80+ }
81+ }
82+ return nullptr;
83+}
84+
85+void ApplicationManager::add(ApplicationInfo *application) {
86+ if (!application)
87+ return;
88+
89+ beginInsertRows(QModelIndex(), m_runningApplications.size(), m_runningApplications.size());
90+ m_runningApplications.append(application);
91+ endInsertRows();
92+ Q_EMIT countChanged();
93+}
94+
95+void ApplicationManager::remove(ApplicationInfo *application) {
96+ int i = m_runningApplications.indexOf(application);
97+ if (i != -1) {
98+ beginRemoveRows(QModelIndex(), i, i);
99+ m_runningApplications.removeAt(i);
100+ endRemoveRows();
101+ Q_EMIT countChanged();
102+ }
103+}
104+
105+void ApplicationManager::move(int from, int to) {
106+ if (from == to) return;
107+
108+ if (from >= 0 && from < m_runningApplications.size() && to >= 0 && to < m_runningApplications.size()) {
109+ QModelIndex parent;
110+ /* When moving an item down, the destination index needs to be incremented
111+ * by one, as explained in the documentation:
112+ * http://qt-project.org/doc/qt-5.0/qtcore/qabstractitemmodel.html#beginMoveRows */
113+ beginMoveRows(parent, from, from, parent, to + (to > from ? 1 : 0));
114+ m_runningApplications.move(from, to);
115+ endMoveRows();
116+ }
46117}
47118
48119int ApplicationManager::keyboardHeight() const
@@ -70,36 +141,21 @@ ApplicationManager::FormFactorHint ApplicationManager::formFactorHint() const
70141 return PhoneFormFactor;
71142}
72143
73−ApplicationListModel* ApplicationManager::mainStageApplications() const
74−{
75− return m_mainStageApplications;
76−}
77−
78−ApplicationListModel* ApplicationManager::sideStageApplications() const
144+ApplicationInfo* ApplicationManager::startApplication(const QString &appId,
145+ const QStringList &arguments)
79146{
80− return m_sideStageApplications;
147+ return startApplication(appId, NoFlag, arguments);
81148}
82149
83−ApplicationInfo* ApplicationManager::mainStageFocusedApplication() const
84−{
85− return m_mainStageFocusedApplication;
86−}
87−
88−ApplicationInfo* ApplicationManager::sideStageFocusedApplication() const
89−{
90− return m_sideStageFocusedApplication;
91−}
92−
93−ApplicationInfo* ApplicationManager::startProcess(QString desktopFile,
150+ApplicationInfo* ApplicationManager::startApplication(const QString &appId,
94151 ExecFlags flags,
95− QStringList arguments)
152+ const QStringList &arguments)
96153{
97154 Q_UNUSED(arguments)
98155 ApplicationInfo *application = 0;
99156
100− for (int i = 0; i < m_availableApplications.count(); ++i) {
101− ApplicationInfo *availableApp = m_availableApplications[i];
102− if (availableApp->desktopFile() == desktopFile) {
157+ for (ApplicationInfo *availableApp : m_availableApplications) {
158+ if (availableApp->appId() == appId) {
103159 application = availableApp;
104160 break;
105161 }
@@ -109,86 +165,91 @@ ApplicationInfo* ApplicationManager::startProcess(QString desktopFile,
109165 return 0;
110166
111167 if (flags.testFlag(ApplicationManager::ForceMainStage)
112− || application->stage() == ApplicationInfo::MainStage) {
113− m_mainStageApplications->add(application);
114− } else {
115− m_sideStageApplications->add(application);
168+ && application->stage() == ApplicationInfo::SideStage) {
169+ application->setStage(ApplicationInfo::MainStage);
116170 }
171+ add(application);
117172
118173 return application;
119174}
120175
121−void ApplicationManager::stopProcess(ApplicationInfo* application)
176+bool ApplicationManager::stopApplication(const QString &appId)
122177{
123− if (m_mainStageApplications->contains(application)) {
124− m_mainStageApplications->remove(application);
178+ ApplicationInfo *application = findApplication(appId);
179+ if (application == nullptr)
180+ return false;
125181
126− if (m_mainStageFocusedApplication == application) {
127− m_mainStageFocusedApplication = 0;
128− Q_EMIT mainStageFocusedApplicationChanged();
129− }
130− } else if (m_sideStageApplications->contains(application)){
131− m_sideStageApplications->remove(application);
182+ remove(application);
183+ Q_EMIT focusedApplicationIdChanged();
184+ return true;
185+}
132186
133− if (m_sideStageFocusedApplication == application) {
134− m_sideStageFocusedApplication = 0;
135− Q_EMIT sideStageFocusedApplicationChanged();
187+QString ApplicationManager::focusedApplicationId() const {
188+ for (ApplicationInfo *app : m_runningApplications) {
189+ if (app->focused()) {
190+ return app->appId();
136191 }
137192 }
193+ return QString();
138194}
139195
140−void ApplicationManager::focusApplication(int handle)
196+bool ApplicationManager::focusApplication(const QString &appId)
141197{
142− for (int i = 0; i < m_mainStageApplications->m_applications.count(); ++i) {
143− ApplicationInfo *application = m_mainStageApplications->m_applications[i];
144− if (application->handle() == handle) {
145− if (m_mainStageFocusedApplication)
146− m_mainStageFocusedApplication->hideWindow();
147− m_mainStageFocusedApplication = application;
148− if (!m_mainStage)
149− createMainStage();
150− application->showWindow(m_mainStage);
151− m_mainStage->setZ(-1000);
152− if (m_sideStage)
153− m_sideStage->setZ(-2000);
154− Q_EMIT mainStageFocusedApplicationChanged();
155− return;
198+ ApplicationInfo *application = findApplication(appId);
199+ if (application == nullptr)
200+ return false;
201+
202+ if (application->stage() == ApplicationInfo::MainStage) {
203+ // unfocus currently focused mainstage app
204+ for (ApplicationInfo *app : m_runningApplications) {
205+ if (app->focused() && app->stage() == ApplicationInfo::MainStage) {
206+ app->setFocused(false);
207+ app->hideWindow();
208+ }
156209 }
157− }
158210
159− for (int i = 0; i < m_sideStageApplications->m_applications.count(); ++i) {
160− ApplicationInfo *application = m_sideStageApplications->m_applications[i];
161− if (application->handle() == handle) {
162− if (m_sideStageFocusedApplication)
163− m_sideStageFocusedApplication->hideWindow();
164− m_sideStageFocusedApplication = application;
165− if (!m_sideStage)
166− createSideStage();
167− application->showWindow(m_sideStage);
168− m_sideStage->setZ(-1000);
169− if (m_mainStage)
170− m_mainStage->setZ(-2000);
171− Q_EMIT sideStageFocusedApplicationChanged();
172− return;
211+ // focus this app
212+ application->setFocused(true);
213+ if (!m_mainStage)
214+ createMainStage();
215+ application->showWindow(m_mainStage);
216+ m_mainStage->setZ(-1000);
217+ if (m_sideStage)
218+ m_sideStage->setZ(-2000);
219+ } else if (application->stage() == ApplicationInfo::SideStage) {
220+ // unfocus currently focused sidestage app
221+ for (ApplicationInfo *app : m_runningApplications) {
222+ if (app->focused() && app->stage() == ApplicationInfo::SideStage) {
223+ app->setFocused(false);
224+ app->hideWindow();
225+ }
173226 }
227+
228+ // focus this app
229+ application->setFocused(true);
230+ if (!m_sideStage)
231+ createSideStage();
232+ application->showWindow(m_sideStage);
233+ m_sideStage->setZ(-1000);
234+ if (m_mainStage)
235+ m_mainStage->setZ(-2000);
174236 }
237+
238+ // move app to top of stack
239+ move(m_runningApplications.indexOf(application), 0);
240+ Q_EMIT focusedApplicationIdChanged();
241+ return true;
175242}
176243
177−void ApplicationManager::unfocusCurrentApplication(StageHint stageHint)
244+void ApplicationManager::unfocusCurrentApplication()
178245{
179− if (stageHint == SideStage) {
180− if (m_sideStageFocusedApplication) {
181− m_sideStageFocusedApplication->hideWindow();
182− m_sideStageFocusedApplication = 0;
183− Q_EMIT sideStageFocusedApplicationChanged();
184− }
185− } else {
186− if (m_mainStageFocusedApplication) {
187− m_mainStageFocusedApplication->hideWindow();
188− m_mainStageFocusedApplication = 0;
189− Q_EMIT mainStageFocusedApplicationChanged();
246+ for (ApplicationInfo *app : m_runningApplications) {
247+ if (app->focused()) {
248+ app->hideWindow();
249+ app->setFocused(false);
190250 }
191251 }
252+ Q_EMIT focusedApplicationIdChanged();
192253}
193254
194255void ApplicationManager::generateQmlStrings(ApplicationInfo *application)
@@ -213,7 +274,7 @@ void ApplicationManager::generateQmlStrings(ApplicationInfo *application)
213274 " fillMode: Image.PreserveAspectCrop\n"
214275 "}").arg(topMargin)
215276 .arg(shellAppDirectory())
216− .arg(application->icon());
277+ .arg(application->icon().toString());
217278 application->setWindowQml(windowQml);
218279
219280 QString imageQml = QString(
@@ -224,159 +285,130 @@ void ApplicationManager::generateQmlStrings(ApplicationInfo *application)
224285 " smooth: true\n"
225286 " fillMode: Image.PreserveAspectCrop\n"
226287 "}").arg(shellAppDirectory())
227− .arg(application->icon());
288+ .arg(application->icon().toString());
228289 application->setImageQml(imageQml);
229290}
230291
231292void ApplicationManager::buildListOfAvailableApplications()
232293{
233294 ApplicationInfo *application;
234− qint64 nextHandle = 1;
235295
236296 application = new ApplicationInfo(this);
237− application->setDesktopFile("/usr/share/applications/phone-app.desktop");
297+ application->setAppId("phone-app");
238298 application->setName("Phone");
239− application->setIcon("phone");
240− application->setExec("/usr/bin/phone-app");
299+ application->setIcon(QUrl("phone"));
241300 application->setStage(ApplicationInfo::SideStage);
242− application->setHandle(nextHandle++);
243301 generateQmlStrings(application);
244302 m_availableApplications.append(application);
245303
246304 application = new ApplicationInfo(this);
247− application->setDesktopFile("/usr/share/applications/camera-app.desktop");
305+ application->setAppId("camera-app");
248306 application->setName("Camera");
249− application->setIcon("camera");
307+ application->setIcon(QUrl("camera"));
250308 application->setFullscreen(true);
251− application->setExec("/usr/bin/camera-app --fullscreen");
252− application->setHandle(nextHandle++);
253309 generateQmlStrings(application);
254310 m_availableApplications.append(application);
255311
256312 application = new ApplicationInfo(this);
257− application->setDesktopFile("/usr/share/applications/gallery-app.desktop");
313+ application->setAppId("gallery-app");
258314 application->setName("Gallery");
259− application->setIcon("gallery");
260− application->setExec("/usr/bin/gallery-app");
261− application->setHandle(nextHandle++);
315+ application->setIcon(QUrl("gallery"));
262316 generateQmlStrings(application);
263317 m_availableApplications.append(application);
264318
265319 application = new ApplicationInfo(this);
266− application->setDesktopFile("/usr/share/applications/facebook-webapp.desktop");
320+ application->setAppId("facebook-webapp");
267321 application->setName("Facebook");
268− application->setIcon("facebook");
269− application->setExec("/usr/bin/webbrowser-app --chromeless http://m.facebook.com");
322+ application->setIcon(QUrl("facebook"));
270323 application->setStage(ApplicationInfo::SideStage);
271− application->setHandle(nextHandle++);
272324 generateQmlStrings(application);
273325 m_availableApplications.append(application);
274326
275327 application = new ApplicationInfo(this);
276− application->setDesktopFile("/usr/share/applications/webbrowser-app.desktop");
328+ application->setAppId("webbrowser-app");
277329 application->setName("Browser");
278− application->setIcon("browser");
279− application->setExec("/usr/bin/webbrowser-app");
280− application->setHandle(nextHandle++);
330+ application->setIcon(QUrl("browser"));
281331 generateQmlStrings(application);
282332 m_availableApplications.append(application);
283333
284334 application = new ApplicationInfo(this);
285− application->setDesktopFile("/usr/share/applications/twitter-webapp.desktop");
335+ application->setAppId("twitter-webapp");
286336 application->setName("Twitter");
287− application->setIcon("twitter");
288− application->setExec("/usr/bin/webbrowser-app --chromeless http://www.twitter.com");
337+ application->setIcon(QUrl("twitter"));
289338 application->setStage(ApplicationInfo::SideStage);
290− application->setHandle(nextHandle++);
291339 generateQmlStrings(application);
292340 m_availableApplications.append(application);
293341
294342 application = new ApplicationInfo(this);
295− application->setDesktopFile("/usr/share/applications/gmail-webapp.desktop");
343+ application->setAppId("gmail-webapp");
296344 application->setName("GMail");
297− application->setIcon("gmail");
298− application->setExec("/usr/bin/webbrowser-app --chromeless http://m.gmail.com");
299− application->setHandle(nextHandle++);
345+ application->setIcon(QUrl("gmail"));
300346 m_availableApplications.append(application);
301347
302348 application = new ApplicationInfo(this);
303− application->setDesktopFile("/usr/share/applications/ubuntu-weather-app.desktop");
349+ application->setAppId("ubuntu-weather-app");
304350 application->setName("Weather");
305− application->setIcon("weather");
306− application->setExec("/usr/bin/qmlscene /usr/share/ubuntu-weather-app/ubuntu-weather-app.qml");
351+ application->setIcon(QUrl("weather"));
307352 application->setStage(ApplicationInfo::SideStage);
308− application->setHandle(nextHandle++);
309353 generateQmlStrings(application);
310354 m_availableApplications.append(application);
311355
312356 application = new ApplicationInfo(this);
313− application->setDesktopFile("/usr/share/applications/notes-app.desktop");
357+ application->setAppId("notes-app");
314358 application->setName("Notepad");
315− application->setIcon("notepad");
316− application->setExec("/usr/bin/qmlscene /usr/share/notes-app/NotesApp.qml");
359+ application->setIcon(QUrl("notepad"));
317360 application->setStage(ApplicationInfo::SideStage);
318− application->setHandle(nextHandle++);
319361 m_availableApplications.append(application);
320362
321363 application = new ApplicationInfo(this);
322− application->setDesktopFile("/usr/share/applications/calendar-app.desktop");
364+ application->setAppId("calendar-app");
323365 application->setName("Calendar");
324− application->setIcon("calendar");
325− application->setExec("/usr/bin/qmlscene /usr/share/calendar-app/calendar.qml");
366+ application->setIcon(QUrl("calendar"));
326367 application->setStage(ApplicationInfo::SideStage);
327− application->setHandle(nextHandle++);
328368 m_availableApplications.append(application);
329369
330370 application = new ApplicationInfo(this);
331− application->setDesktopFile("/usr/share/applications/mediaplayer-app.desktop");
371+ application->setAppId("mediaplayer-app");
332372 application->setName("Media Player");
333− application->setIcon("mediaplayer-app");
373+ application->setIcon(QUrl("mediaplayer-app"));
334374 application->setFullscreen(true);
335− application->setExec("/usr/bin/mediaplayer-app");
336− application->setHandle(nextHandle++);
337375 m_availableApplications.append(application);
338376
339377 application = new ApplicationInfo(this);
340− application->setDesktopFile("/usr/share/applications/evernote.desktop");
378+ application->setAppId("evernote");
341379 application->setName("Evernote");
342− application->setIcon("evernote");
343− application->setHandle(nextHandle++);
380+ application->setIcon(QUrl("evernote"));
344381 m_availableApplications.append(application);
345382
346383 application = new ApplicationInfo(this);
347− application->setDesktopFile("/usr/share/applications/map.desktop");
384+ application->setAppId("map");
348385 application->setName("Map");
349− application->setIcon("map");
350− application->setHandle(nextHandle++);
386+ application->setIcon(QUrl("map"));
351387 generateQmlStrings(application);
352388 m_availableApplications.append(application);
353389
354390 application = new ApplicationInfo(this);
355− application->setDesktopFile("/usr/share/applications/pinterest.desktop");
391+ application->setAppId("pinterest");
356392 application->setName("Pinterest");
357− application->setIcon("pinterest");
358− application->setHandle(nextHandle++);
393+ application->setIcon(QUrl("pinterest"));
359394 m_availableApplications.append(application);
360395
361396 application = new ApplicationInfo(this);
362− application->setDesktopFile("/usr/share/applications/soundcloud.desktop");
397+ application->setAppId("soundcloud");
363398 application->setName("SoundCloud");
364− application->setIcon("soundcloud");
365− application->setHandle(nextHandle++);
399+ application->setIcon(QUrl("soundcloud"));
366400 m_availableApplications.append(application);
367401
368402 application = new ApplicationInfo(this);
369− application->setDesktopFile("/usr/share/applications/wikipedia.desktop");
403+ application->setAppId("wikipedia");
370404 application->setName("Wikipedia");
371− application->setIcon("wikipedia");
372− application->setHandle(nextHandle++);
405+ application->setIcon(QUrl("wikipedia"));
373406 m_availableApplications.append(application);
374407
375408 application = new ApplicationInfo(this);
376− application->setDesktopFile("/usr/share/applications/youtube.desktop");
409+ application->setAppId("youtube");
377410 application->setName("YouTube");
378− application->setIcon("youtube");
379− application->setHandle(nextHandle++);
411+ application->setIcon(QUrl("youtube"));
380412 m_availableApplications.append(application);
381413}
382414
tests/mocks/Ubuntu/Application/ApplicationManager.h → tests/mocks/Unity/Application/ApplicationManager.hrenamed+26−26
@@ -20,12 +20,15 @@
2020#include <QObject>
2121#include <QList>
2222#include <QStringList>
23−#include "ApplicationListModel.h"
2423#include "ApplicationInfo.h"
2524
25+// unity-api
26+#include <unity/shell/application/ApplicationManagerInterface.h>
27+
2628class QQuickItem;
29+using namespace unity::shell::application;
2730
28−class ApplicationManager : public QObject {
31+class ApplicationManager : public ApplicationManagerInterface {
2932 Q_OBJECT
3033 Q_ENUMS(Role)
3134 Q_ENUMS(StageHint)
@@ -39,12 +42,6 @@ class ApplicationManager : public QObject {
3942 Q_PROPERTY(int sideStageWidth READ sideStageWidth)
4043 Q_PROPERTY(StageHint stageHint READ stageHint)
4144 Q_PROPERTY(FormFactorHint formFactorHint READ formFactorHint)
42− Q_PROPERTY(ApplicationListModel* mainStageApplications READ mainStageApplications)
43− Q_PROPERTY(ApplicationListModel* sideStageApplications READ sideStageApplications)
44− Q_PROPERTY(ApplicationInfo* mainStageFocusedApplication READ mainStageFocusedApplication
45− NOTIFY mainStageFocusedApplicationChanged)
46− Q_PROPERTY(ApplicationInfo* sideStageFocusedApplication READ sideStageFocusedApplication
47− NOTIFY sideStageFocusedApplicationChanged)
4845
4946 Q_PROPERTY(bool fake READ fake CONSTANT)
5047
@@ -64,7 +61,8 @@ class ApplicationManager : public QObject {
6461 DesktopFormFactor, PhoneFormFactor, TabletFormFactor
6562 };
6663 enum FavoriteApplication {
67− CameraApplication, GalleryApplication, BrowserApplication, ShareApplication
64+ CameraApplication, GalleryApplication, BrowserApplication, ShareApplication,
65+ PhoneApplication, DialerApplication, MessagingApplication, AddressbookApplication
6866 };
6967 enum Flag {
7068 NoFlag = 0x0,
@@ -77,29 +75,34 @@ class ApplicationManager : public QObject {
7775 int sideStageWidth() const;
7876 StageHint stageHint() const;
7977 FormFactorHint formFactorHint() const;
80− ApplicationListModel* mainStageApplications() const;
81− ApplicationListModel* sideStageApplications() const;
82− ApplicationInfo* mainStageFocusedApplication() const;
83− ApplicationInfo* sideStageFocusedApplication() const;
8478
8579 bool fake() { return true; }
8680
87− Q_INVOKABLE void focusApplication(int handle);
88− Q_INVOKABLE void unfocusCurrentApplication(StageHint stageHint);
89− Q_INVOKABLE ApplicationInfo* startProcess(QString desktopFile,
90− ExecFlags flags,
91− QStringList arguments = QStringList());
92− Q_INVOKABLE void stopProcess(ApplicationInfo* application);
93− Q_INVOKABLE void startWatcher() {}
81+ // QAbstractItemModel methods.
82+ int rowCount(const QModelIndex& parent = QModelIndex()) const override;
83+ QVariant data(const QModelIndex& index, int role) const override;
84+ Q_INVOKABLE ApplicationInfo *get(int index) const override;
85+ Q_INVOKABLE ApplicationInfo *findApplication(const QString &appId) const override;
86+
87+ Q_INVOKABLE void move(int from, int to);
88+
89+ // Application control methods
90+ Q_INVOKABLE bool focusApplication(const QString &appId) override;
91+ Q_INVOKABLE void unfocusCurrentApplication() override;
92+ Q_INVOKABLE ApplicationInfo *startApplication(const QString &appId, const QStringList &arguments = QStringList()) override;
93+ Q_INVOKABLE ApplicationInfo *startApplication(const QString &appId, ExecFlags flags, const QStringList &arguments = QStringList());
94+ Q_INVOKABLE bool stopApplication(const QString &appId) override;
95+
96+ QString focusedApplicationId() const override;
9497
9598 Q_SIGNALS:
9699 void keyboardHeightChanged();
97100 void keyboardVisibleChanged();
98− void mainStageFocusedApplicationChanged();
99− void sideStageFocusedApplicationChanged();
100101 void focusRequested(FavoriteApplication favoriteApplication);
101102
102103 private:
104+ void add(ApplicationInfo *application);
105+ void remove(ApplicationInfo* application);
103106 void showApplicationWindow(ApplicationInfo *application);
104107 void buildListOfAvailableApplications();
105108 void generateQmlStrings(ApplicationInfo *application);
@@ -109,10 +112,7 @@ class ApplicationManager : public QObject {
109112 void createSideStage();
110113 int m_keyboardHeight;
111114 bool m_keyboardVisible;
112− ApplicationListModel* m_mainStageApplications;
113− ApplicationListModel* m_sideStageApplications;
114− ApplicationInfo* m_mainStageFocusedApplication;
115− ApplicationInfo* m_sideStageFocusedApplication;
115+ QList<ApplicationInfo*> m_runningApplications;
116116 QList<ApplicationInfo*> m_availableApplications;
117117 QQmlComponent *m_mainStageComponent;
118118 QQuickItem *m_mainStage;
tests/mocks/Unity/Application/CMakeLists.txtnew file+37
@@ -0,0 +1,37 @@
1+include(FindPkgConfig)
2+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application)
3+
4+set(FakeUnityApplicationQml_SOURCES
5+ plugin.cpp
6+ ApplicationInfo.cpp
7+ ApplicationImage.cpp
8+ ApplicationManager.cpp
9+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
10+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
11+)
12+
13+add_library(FakeUnityApplicationQml MODULE ${FakeUnityApplicationQml_SOURCES})
14+
15+qt5_use_modules(FakeUnityApplicationQml Core Quick)
16+
17+# copy files into build directory for shadow builds
18+add_custom_target(UnityAppQmlDirFile ALL
19+ COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/qmldir" ${CMAKE_CURRENT_BINARY_DIR}
20+ DEPENDS qmldir
21+)
22+add_custom_target(InputFilterAreaQmlFile ALL
23+ COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/InputFilterArea.qml" ${CMAKE_CURRENT_BINARY_DIR}
24+ DEPENDS InputFilterArea.qml
25+)
26+add_custom_target(OSKControllerQmlFile ALL
27+ COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/OSKController.qml" ${CMAKE_CURRENT_BINARY_DIR}
28+ DEPENDS OSKController.qml
29+)
30+
31+install(TARGETS FakeUnityApplicationQml
32+ DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/mocks/Unity/Application
33+ )
34+
35+install(FILES qmldir InputFilterArea.qml OSKController.qml
36+ DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/mocks/Unity/Application
37+ )
tests/mocks/Ubuntu/Application/InputFilterArea.qml → tests/mocks/Unity/Application/InputFilterArea.qmlrenamed

The content is the same.

tests/mocks/Unity/Application/OSKController.qmlnew file+20
@@ -0,0 +1,20 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.0;
18+
19+Item {
20+}
tests/mocks/Ubuntu/Application/plugin.cpp → tests/mocks/Unity/Application/plugin.cpprenamed+6−5
@@ -17,7 +17,6 @@
1717#include "plugin.h"
1818#include "ApplicationInfo.h"
1919#include "ApplicationImage.h"
20−#include "ApplicationListModel.h"
2120#include "ApplicationManager.h"
2221
2322#include <qqml.h>
@@ -28,11 +27,13 @@ static QObject* applicationManagerSingleton(QQmlEngine* engine, QJSEngine* scrip
2827 return new ApplicationManager();
2928}
3029
31−void FakeUbuntuApplicationQmlPlugin::registerTypes(const char *uri)
30+void FakeUnityApplicationQmlPlugin::registerTypes(const char *uri)
3231{
33− qmlRegisterSingletonType<ApplicationManager>(
34− uri, 0, 1, "ApplicationManager", applicationManagerSingleton);
32+ qmlRegisterUncreatableType<unity::shell::application::ApplicationManagerInterface>(uri, 0, 1, "ApplicationManagerInterface", "Abstract interface. Cannot be created in QML");
33+ qmlRegisterSingletonType<ApplicationManager>(uri, 0, 1, "ApplicationManager", applicationManagerSingleton);
34+
35+ qmlRegisterUncreatableType<unity::shell::application::ApplicationInfoInterface>(uri, 0, 1, "ApplicationInfoInterface", "Abstract interface. Cannot be created in QML");
3536 qmlRegisterType<ApplicationInfo>(uri, 0, 1, "ApplicationInfo");
37+
3638 qmlRegisterType<ApplicationImage>(uri, 0, 1, "ApplicationImage");
37− qmlRegisterType<ApplicationListModel>(uri, 0, 1, "ApplicationListModel");
3839}
tests/mocks/Ubuntu/Application/plugin.h → tests/mocks/Unity/Application/plugin.hrenamed+1−1
@@ -19,7 +19,7 @@
1919
2020#include <QQmlExtensionPlugin>
2121
22−class FakeUbuntuApplicationQmlPlugin : public QQmlExtensionPlugin
22+class FakeUnityApplicationQmlPlugin : public QQmlExtensionPlugin
2323{
2424 Q_OBJECT
2525 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
tests/mocks/Unity/Application/qmldirnew file+4
@@ -0,0 +1,4 @@
1+module Unity.Application
2+plugin FakeUnityApplicationQml
3+InputFilterArea 0.1 InputFilterArea.qml
4+OSKController 0.1 OSKController.qml
tests/mocks/Unity/CMakeLists.txt+1
@@ -1,3 +1,4 @@
1+add_subdirectory(Application)
12add_subdirectory(Indicators)
23
34pkg_search_module(DEE dee-1.0 REQUIRED)
tests/mocks/Unity/Launcher/CMakeLists.txt+1−1
@@ -1,5 +1,5 @@
11include(FindPkgConfig)
2−pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=2)
2+pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=3)
33
44add_definitions(-DTOP_SRCDIR="${CMAKE_SOURCE_DIR}")
55
tests/mocks/Unity/Launcher/MockLauncherModel.cpp+7−4
@@ -71,8 +71,6 @@ QVariant MockLauncherModel::data(const QModelIndex& index, int role) const
7171 LauncherItemInterface *item = m_list.at(index.row());
7272 switch(role)
7373 {
74− case RoleDesktopFile:
75− return item->desktopFile();
7674 case RoleName:
7775 return item->name();
7876 case RoleIcon:
@@ -185,7 +183,12 @@ void MockLauncherModel::setUser(const QString &username)
185183 // TODO: implement this...
186184}
187185
188−void MockLauncherModel::applicationFocused(const QString &appId)
186+void MockLauncherModel::setApplicationManager(unity::shell::application::ApplicationManagerInterface *applicationManager)
189187{
190− Q_UNUSED(appId)
188+ Q_UNUSED(applicationManager)
189+}
190+
191+unity::shell::application::ApplicationManagerInterface *MockLauncherModel::applicationManager() const
192+{
193+ return nullptr;
191194}
tests/mocks/Unity/Launcher/MockLauncherModel.h+3−1
@@ -44,7 +44,9 @@ public:
4444 Q_INVOKABLE void requestRemove(const QString &appId);
4545 Q_INVOKABLE void quickListActionInvoked(const QString &appId, int actionIndex);
4646 Q_INVOKABLE void setUser(const QString &username);
47− Q_INVOKABLE void applicationFocused(const QString &appId);
47+
48+ unity::shell::application::ApplicationManagerInterface *applicationManager() const;
49+ void setApplicationManager(unity::shell::application::ApplicationManagerInterface *applicationManager);
4850
4951Q_SIGNALS:
5052 void quickListTriggered(const QString &appId, int index);
tests/plugins/AccountsService/CMakeLists.txt+1
@@ -25,6 +25,7 @@ qt5_use_modules(mock-server Core DBus)
2525
2626add_executable(test-accountsservice
2727 ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsService.cpp
28+ ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsServiceDBusAdaptor.cpp
2829 client.cpp
2930 )
3031qt5_use_modules(test-accountsservice Core DBus Test)
tests/plugins/AccountsService/client.cpp+19−7
@@ -18,6 +18,7 @@
1818 */
1919
2020#include "AccountsService.h"
21+#include "AccountsServiceDBusAdaptor.h"
2122#include <QSignalSpy>
2223#include <QTest>
2324
@@ -30,17 +31,28 @@ private Q_SLOTS:
3031 void testInvalids()
3132 {
3233 // Test various invalid calls
33− AccountsService session;
34− QCOMPARE(session.getUserProperty("NOPE", "demo-edges"), QVariant());
35− QCOMPARE(session.getUserProperty("testuser", "NOPE"), QVariant());
34+ AccountsServiceDBusAdaptor session;
35+ QCOMPARE(session.getUserProperty("NOPE", "com.canonical.unity.AccountsService", "demo-edges"), QVariant());
36+ QCOMPARE(session.getUserProperty("testuser", "com.canonical.unity.AccountsService", "NOPE"), QVariant());
37+ }
38+
39+ void testGetSetServiceDBusAdaptor()
40+ {
41+ AccountsServiceDBusAdaptor session;
42+ session.setUserProperty("testuser", "com.canonical.unity.AccountsService", "demo-edges", QVariant(true));
43+ QCOMPARE(session.getUserProperty("testuser", "com.canonical.unity.AccountsService", "demo-edges"), QVariant(true));
44+ session.setUserProperty("testuser", "com.canonical.unity.AccountsService", "demo-edges", QVariant(false));
45+ QCOMPARE(session.getUserProperty("testuser", "com.canonical.unity.AccountsService", "demo-edges"), QVariant(false));
3646 }
3747
38− void testGetSet()
48+ void testGetSetService()
3949 {
4050 AccountsService session;
41− QCOMPARE(session.getUserProperty("testuser", "demo-edges"), QVariant(true));
42− session.setUserProperty("testuser", "demo-edges", QVariant(false));
43− QCOMPARE(session.getUserProperty("testuser", "demo-edges"), QVariant(false));
51+ session.setUser("testuser");
52+ session.setDemoEdges(true);
53+ QCOMPARE(session.getDemoEdges(), true);
54+ session.setDemoEdges(false);
55+ QCOMPARE(session.getDemoEdges(), false);
4456 }
4557};
4658
tests/plugins/Unity/Launcher/CMakeLists.txt+15−3
@@ -1,5 +1,6 @@
11pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
2−pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=2)
2+pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=3)
3+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=1)
34
45include_directories(
56 ${CMAKE_CURRENT_BINARY_DIR}
@@ -21,7 +22,7 @@ add_test(NAME launcherbackendtest COMMAND ${testBackendCommand})
2122add_custom_target(launcherbackendtest ${testBackendCommand})
2223add_executable(launcherbackendtestExec
2324 launcherbackendtest.cpp
24− ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsService.cpp
25+ ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsServiceDBusAdaptor.cpp
2526 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/backend/launcherbackend.cpp
2627 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/common/quicklistentry.cpp
2728 )
@@ -39,12 +40,14 @@ add_executable(launchermodeltestExec
3940 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/launchermodel.cpp
4041 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/launcheritem.cpp
4142 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/quicklistmodel.cpp
42− ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsService.cpp
43+ ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsServiceDBusAdaptor.cpp
4344 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/backend/launcherbackend.cpp
4445 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/common/quicklistentry.cpp
4546 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h
4647 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherModelInterface.h
4748 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/QuickListModelInterface.h
49+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
50+ ${LAUNCHER_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
4851 )
4952target_link_libraries(launchermodeltestExec ${GSETTINGS_QT_LDFLAGS} )
5053qt5_use_modules(launchermodeltestExec Test Core DBus)
@@ -57,3 +60,12 @@ foreach(DESKTOP_FILE ${DESKTOP_FILES})
5760 DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
5861 )
5962endforeach()
63+
64+# copy .svg files into build directory for shadow builds
65+file(GLOB DESKTOP_FILES *.svg)
66+
67+foreach(DESKTOP_FILE ${DESKTOP_FILES})
68+ file(COPY "${DESKTOP_FILE}"
69+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
70+ )
71+endforeach()
tests/plugins/Unity/Launcher/click-icon.desktopnew file+4
@@ -0,0 +1,4 @@
1+[Desktop Entry]
2+Name=Click Package Icon
3+Icon=click-icon.svg
4+Path=/path/to/some/click/app
tests/plugins/Unity/Launcher/launcherbackendtest.cpp+25
@@ -54,6 +54,31 @@ private Q_SLOTS:
5454 QCOMPARE(backend.isPinned("rel-icon"), true);
5555 QCOMPARE(backend.isPinned("no-name"), false); // doesn't exist anymore!
5656 }
57+
58+ void testIcon_data() {
59+ QTest::addColumn<QString>("appId");
60+ QTest::addColumn<QString>("expectedIcon");
61+
62+ // Needs to expand a relative icon to the absolute path
63+ QTest::newRow("relative icon path") << "rel-icon" << QDir::currentPath() + "/rel-icon.svg";
64+
65+ // In case an icon is not found on disk, it needs to fallback on image://theme/ for it
66+ QTest::newRow("fallback on theme") << "abs-icon" << "image://theme//path/to/icon.png";
67+
68+ // Click packages have a relative icon path but an absolute path as a separate entry
69+ // As we don't want to rely on a click app being installed for the test, accept it with the image://theme fallback
70+ QTest::newRow("click package icon") << "click-icon" << "image://theme//path/to/some/click/app/click-icon.svg";
71+ }
72+
73+ void testIcon() {
74+ QFETCH(QString, appId);
75+ QFETCH(QString, expectedIcon);
76+
77+ LauncherBackend backend(false);
78+ backend.setStoredApplications(QStringList() << appId);
79+
80+ QCOMPARE(backend.icon(appId), expectedIcon);
81+ }
5782};
5883
5984QTEST_GUILESS_MAIN(LauncherBackendTest)
tests/plugins/Unity/Launcher/launchermodeltest.cpp+88−18
@@ -19,38 +19,109 @@
1919
2020// unity-api
2121#include <unity/shell/launcher/LauncherModelInterface.h>
22+#include <unity/shell/application/ApplicationInfoInterface.h>
2223
2324#include "launcheritem.h"
2425#include "launchermodel.h"
2526
2627#include <QtTest>
2728
29+// This is a mock, specifically to test the LauncherModel
30+class MockApp: public unity::shell::application::ApplicationInfoInterface
31+{
32+ Q_OBJECT
33+public:
34+ MockApp(const QString &appId, QObject *parent = 0): ApplicationInfoInterface(appId, parent), m_appId(appId), m_focused(false) { }
35+ QString appId() const { return m_appId; }
36+ QString name() const { return "mock"; }
37+ QString comment() const { return "this is a mock"; }
38+ QUrl icon() const { return QUrl(); }
39+ ApplicationInfoInterface::Stage stage() const { return ApplicationInfoInterface::MainStage; }
40+ ApplicationInfoInterface::State state() const { return ApplicationInfoInterface::Running; }
41+ bool focused() const { return m_focused; }
42+
43+ // Methods used for mocking (not in the interface)
44+ void setFocused(bool focused) { m_focused = focused; Q_EMIT focusedChanged(focused); }
45+private:
46+ QString m_appId;
47+ bool m_focused;
48+};
49+
50+// This is a mock, specifically to test the LauncherModel
51+class MockAppManager: public unity::shell::application::ApplicationManagerInterface
52+{
53+ Q_OBJECT
54+public:
55+ MockAppManager(QObject *parent = 0): ApplicationManagerInterface(parent) {}
56+ int rowCount(const QModelIndex &) const { return m_list.count(); }
57+ QVariant data(const QModelIndex &, int ) const { return QVariant(); }
58+ QString focusedApplicationId() const {
59+ Q_FOREACH(MockApp *app, m_list) {
60+ if (app->focused()) return app->appId();
61+ }
62+ return QString();
63+ }
64+ unity::shell::application::ApplicationInfoInterface *get(int index) const { return m_list.at(index); }
65+ unity::shell::application::ApplicationInfoInterface *findApplication(const QString &) const { return nullptr; }
66+ unity::shell::application::ApplicationInfoInterface *startApplication(const QString &, const QStringList &) { return nullptr; }
67+ bool stopApplication(const QString &) { return false; }
68+ bool focusApplication(const QString &appId) {
69+ Q_FOREACH(MockApp* app, m_list) {
70+ app->setFocused(app->appId() == appId);
71+ }
72+ Q_EMIT focusedApplicationIdChanged();
73+ return true;
74+ }
75+
76+ void unfocusCurrentApplication() { }
77+
78+ void addApplication(MockApp *app) {
79+ beginInsertRows(QModelIndex(), count(), count());
80+ m_list.append(app);
81+ endInsertRows();
82+ }
83+ void removeApplication(int index) {
84+ beginRemoveRows(QModelIndex(), index, index);
85+ m_list.takeAt(index)->deleteLater();
86+ endRemoveRows();
87+ }
88+
89+private:
90+ QList<MockApp*> m_list;
91+};
92+
2893class LauncherModelTest : public QObject
2994{
3095 Q_OBJECT
3196
3297private:
3398 LauncherModel *launcherModel;
99+ MockAppManager *appManager;
34100
35101private Q_SLOTS:
36102
37103 void initTestCase() {
38104 launcherModel = new LauncherModel(this);
39105 QCOMPARE(launcherModel->rowCount(QModelIndex()), 0);
106+
107+ appManager = new MockAppManager(this);
108+ launcherModel->setApplicationManager(appManager);
40109 }
41110
111+ // Adding 2 apps to the mock appmanager. Both should appear in the launcher.
42112 void init() {
43− qDebug() << "init";
44− launcherModel->applicationFocused("abs-icon");
113+ appManager->addApplication(new MockApp("abs-icon"));
45114 QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
46115
47− launcherModel->applicationFocused("no-icon.desktop");
116+ appManager->addApplication(new MockApp("no-icon"));
48117 QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
49−
50− launcherModel->applicationFocused(QString());
51118 }
52119
120+ // Removing apps from appmanager and launcher as pinned ones would stick
53121 void cleanup() {
122+ while (appManager->count() > 0) {
123+ appManager->removeApplication(0);
124+ }
54125 while (launcherModel->rowCount(QModelIndex()) > 0) {
55126 launcherModel->requestRemove(launcherModel->get(0)->appId());
56127 }
@@ -118,27 +189,26 @@ private Q_SLOTS:
118189 QCOMPARE(launcherModel->get(0)->focused(), false);
119190 QCOMPARE(launcherModel->get(1)->focused(), false);
120191
121− launcherModel->applicationFocused("abs-icon");
192+ appManager->focusApplication("abs-icon");
122193 QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
123194 QCOMPARE(launcherModel->get(0)->focused(), true);
124195 QCOMPARE(launcherModel->get(1)->focused(), false);
125196
126− launcherModel->applicationFocused("no-icon");
197+ appManager->focusApplication("no-icon");
127198 QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
128199 QCOMPARE(launcherModel->get(0)->focused(), false);
129200 QCOMPARE(launcherModel->get(1)->focused(), true);
201+ }
130202
131− launcherModel->applicationFocused("rel-icon");
132− QCOMPARE(launcherModel->rowCount(QModelIndex()), 3);
133− QCOMPARE(launcherModel->get(0)->focused(), false);
134− QCOMPARE(launcherModel->get(1)->focused(), false);
135− QCOMPARE(launcherModel->get(2)->focused(), true);
136−
137− launcherModel->applicationFocused(QString());
138− QCOMPARE(launcherModel->rowCount(QModelIndex()), 3);
139− QCOMPARE(launcherModel->get(0)->focused(), false);
140− QCOMPARE(launcherModel->get(1)->focused(), false);
141− QCOMPARE(launcherModel->get(2)->focused(), false);
203+ void testClosingApps() {
204+ // At the start there are 2 items. Let's pin one.
205+ launcherModel->pin("abs-icon");
206+ while (appManager->count() > 0) {
207+ appManager->removeApplication(0);
208+ }
209+ // The pinned one needs to stay, the other needs to disappear
210+ QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
211+ QCOMPARE(launcherModel->get(0)->appId(), QLatin1String("abs-icon"));
142212 }
143213};
144214
tests/plugins/Unity/Launcher/rel-icon.desktop+1−1
@@ -1,3 +1,3 @@
11[Desktop Entry]
22Name=Relative Icon
3−Icon=rel-icon
3+Icon=rel-icon.svg
tests/plugins/Unity/Launcher/rel-icon.svgnew file

No changes to the content.

tests/qmltests/Components/tst_Stage.qml+1−1
@@ -18,7 +18,7 @@ import QtQuick 2.0
1818import QtTest 1.0
1919import ".."
2020import "../../../Components"
21−import Ubuntu.Application 0.1
21+import Unity.Application 0.1
2222import Ubuntu.Components 0.1
2323import Unity.Test 0.1 as UT
2424import "tst_Stage"
tests/qmltests/Dash/Apps/tst_RunningApplicationsGrid.qml+55−37
@@ -16,7 +16,6 @@
1616
1717import QtQuick 2.0
1818import QtTest 1.0
19−import Ubuntu.Application 0.1
2019import "../../../../Dash/Apps"
2120import Unity.Test 0.1 as UT
2221
@@ -29,8 +28,12 @@ Item {
2928
3029 property bool sideStageEnabled: false
3130
32− function stopProcess(application) {
33− fakeRunningAppsModel.remove(application)
31+ function stopApplication(appId) {
32+ for (var i=0, len=fakeRunningAppsModel.count; i<len; i++) {
33+ if (appId == fakeRunningAppsModel.get(i).appId) {
34+ fakeRunningAppsModel.remove(i)
35+ }
36+ }
3437 }
3538 }
3639
@@ -40,47 +43,62 @@ Item {
4043 property bool stageScreenshotsReady: false
4144 property var applicationManager: fakeApplicationManager
4245
43− function activateApplication(desktopFile) {
46+ function activateApplication(appId) {
4447 }
4548 }
4649
47− ApplicationListModel { id: fakeRunningAppsModel }
48−
49− ApplicationInfo {
50− id: phoneApp
51− name: "Phone"
52− icon: "phone-app"
53− exec: "/usr/bin/phone-app"
54− stage: ApplicationInfo.MainStage
55− desktopFile: "phone.desktop"
56− imageQml: "import QtQuick 2.0\n" +
57− "Rectangle { \n" +
58− " anchors.fill:parent \n" +
59− " color:'darkgreen' \n" +
60− " Text { anchors.centerIn: parent; text: 'PHONE' } \n" +
61− "}"
50+ ListModel {
51+ id: fakeRunningAppsModel
52+
53+ function contains(appId) {
54+ for (var i=0, len=fakeRunningAppsModel.count; i<len; i++) {
55+ if (appId == fakeRunningAppsModel.get(i).appId) {
56+ return true;
57+ }
58+ }
59+ return false;
60+ }
61+
62+ function rePopulate() {
63+ for (var i=0, len=availableAppsModel.count; i<len; i++) {
64+ fakeRunningAppsModel.append(availableAppsModel.get(i));
65+ }
66+ }
6267 }
6368
64− ApplicationInfo {
65− id: calendarApp
66− name: "Calendar"
67− icon: "calendar-app"
68− exec: "/usr/bin/calendar-app"
69− stage: ApplicationInfo.MainStage
70− desktopFile: "calendar.desktop"
71− imageQml: "import QtQuick 2.0\n" +
72− "Rectangle { \n" +
73− " anchors.fill:parent \n" +
74− " color:'darkblue' \n" +
75− " Text { anchors.centerIn: parent; text: 'CALENDAR'\n" +
76− " color:'white'} \n" +
77− "}"
69+ ListModel {
70+ id: availableAppsModel
71+ ListElement {
72+ name: "Phone"
73+ icon: "phone-app"
74+ exec: "/usr/bin/phone-app"
75+ appId: "phone"
76+ imageQml: "import QtQuick 2.0\n \
77+ Rectangle { \n \
78+ anchors.fill:parent \n \
79+ color:'darkgreen' \n \
80+ Text { anchors.centerIn: parent; text: 'PHONE' } \n \
81+ }"
82+ }
83+
84+ ListElement {
85+ name: "Calendar"
86+ icon: "calendar-app"
87+ exec: "/usr/bin/calendar-app"
88+ appId: "calendar"
89+ imageQml: "import QtQuick 2.0\n \
90+ Rectangle { \n \
91+ anchors.fill:parent \n \
92+ color:'darkblue' \n \
93+ Text { anchors.centerIn: parent; text: 'CALENDAR'\n \
94+ color:'white'} \n \
95+ }"
96+ }
7897 }
7998
8099 function resetRunningApplications() {
81100 fakeRunningAppsModel.clear()
82− fakeRunningAppsModel.add(phoneApp)
83− fakeRunningAppsModel.add(calendarApp)
101+ fakeRunningAppsModel.rePopulate()
84102 }
85103
86104 Component.onCompleted: {
@@ -185,11 +203,11 @@ Item {
185203 var calendarTile = findChild(runningApplicationsGrid, "runningAppTile Calendar")
186204 verify(calendarTile != undefined)
187205
188− verify(fakeRunningAppsModel.contains(calendarApp))
206+ verify(fakeRunningAppsModel.contains("calendar"))
189207
190208 mouseClick(calendarTile, calendarTile.width/2, calendarTile.height/2)
191209
192− verify(!fakeRunningAppsModel.contains(calendarApp))
210+ verify(!fakeRunningAppsModel.contains("calendar"))
193211
194212 // The tile for the Calendar app should eventually vanish since the
195213 // application has been terminated
tests/qmltests/Launcher/tst_Launcher.qml+2−2
@@ -38,7 +38,7 @@ Item {
3838 property string lastSelectedApplication
3939
4040 onLauncherApplicationSelected: {
41− lastSelectedApplication = desktopFile
41+ lastSelectedApplication = appId
4242 }
4343
4444 property int dashItemSelected_count: 0
@@ -131,7 +131,7 @@ Item {
131131 mouseClick(appIcon, appIcon.width/2, appIcon.height/2)
132132
133133 tryCompare(launcher, "lastSelectedApplication",
134− "/usr/share/applications/phone-app.desktop")
134+ "phone-app")
135135
136136 // Tapping on an application icon also dismisses the launcher
137137 revealer.waitUntilLauncherDisappears()
tests/qmltests/tst_Shell.qml+33−9
@@ -20,7 +20,7 @@
2020import QtQuick 2.0
2121import QtTest 1.0
2222import GSettings 1.0
23−import Ubuntu.Application 0.1
23+import Unity.Application 0.1
2424import Unity.Test 0.1 as UT
2525import Powerd 0.1
2626
@@ -66,16 +66,16 @@ Item {
6666 }
6767
6868 // kill all (fake) running apps
69− killApps(ApplicationManager.mainStageApplications);
70− killApps(ApplicationManager.sideStageApplications);
69+ killApps(ApplicationManager);
7170
7271 var dashHome = findChild(shell, "DashHome");
7372 swipeUntilScopeViewIsReached(dashHome);
7473 }
7574
7675 function killApps(apps) {
76+ if (!apps) return;
7777 while (apps.count > 0) {
78− ApplicationManager.stopProcess(apps.get(0));
78+ ApplicationManager.stopApplication(apps.get(0).appId);
7979 }
8080 }
8181
@@ -114,6 +114,26 @@ Item {
114114 checkRightEdgeDragWithNoRunningApps();
115115 }
116116
117+ function test_leftEdgeDrag_data() {
118+ return [
119+ {tag: "without launcher", revealLauncher: false},
120+ {tag: "with launcher", revealLauncher: true},
121+ ];
122+ }
123+
124+ function test_leftEdgeDrag(data) {
125+ dragLauncherIntoView();
126+ tapOnAppIconInLauncher();
127+ waitUntilApplicationWindowIsFullyVisible();
128+
129+ if (data.revealLauncher) {
130+ dragLauncherIntoView();
131+ }
132+
133+ swipeFromLeftEdge();
134+ waitUntilApplicationWindowIsFullyHidden();
135+ }
136+
117137 function test_suspend() {
118138 var greeter = findChild(shell, "greeter");
119139
@@ -122,8 +142,8 @@ Item {
122142 tapOnAppIconInLauncher();
123143 waitUntilApplicationWindowIsFullyVisible();
124144
125− var mainApp = ApplicationManager.mainStageFocusedApplication;
126− tryCompareFunction(function() { return mainApp != null; }, true);
145+ var mainApp = ApplicationManager.focusedApplicationId;
146+ tryCompareFunction(function() { return mainApp != ""; }, true);
127147
128148 // Try to suspend while proximity is engaged...
129149 Powerd.displayPowerStateChange(Powerd.Off, Powerd.UseProximity);
@@ -132,11 +152,11 @@ Item {
132152 // Now really suspend
133153 Powerd.displayPowerStateChange(Powerd.Off, 0);
134154 tryCompare(greeter, "showProgress", 1);
135− tryCompare(ApplicationManager, "mainStageFocusedApplication", null);
155+ tryCompare(ApplicationManager, "focusedApplicationId", "");
136156
137157 // And wake up
138158 Powerd.displayPowerStateChange(Powerd.On, 0);
139− tryCompare(ApplicationManager, "mainStageFocusedApplication", mainApp);
159+ tryCompare(ApplicationManager, "focusedApplicationId", mainApp);
140160 tryCompare(greeter, "showProgress", 1);
141161 }
142162
@@ -223,7 +243,11 @@ Item {
223243 function dragLauncherIntoView() {
224244 var launcherPanel = findChild(shell, "launcherPanel");
225245 verify(launcherPanel.x = - launcherPanel.width);
226− swipeFromLeftEdge();
246+
247+ var touchStartX = 2;
248+ var touchStartY = shell.height / 2;
249+ touchFlick(shell, touchStartX, touchStartY, launcherPanel.width + units.gu(1), touchStartY);
250+
227251 tryCompare(launcherPanel, "x", 0);
228252 }
229253