on xenial help sign in
Merge
commitda6049ecfc58cb63f76fbb28c6cf3b6aa196a9a6 authorAlbert Astals <albert.astals@canonical.com> dateMon 23 Sep 2013, 12:48 (13 years ago) parent9622e106fe2f9b
184 files changed+4218−1135
Applications/Application.qml+1−1 Bottombar/Bottombar.qml+5−3 CMakeLists.txt+4 Components/ApplicationManagerWrapper.qml+89−42 Components/ApplicationScreenshot.qml+2−2 Components/ApplicationsModelStageFiltered.qml+49 Components/EdgeDemo.qml+28−21 Components/EdgeDemoOverlay.qml+6−1 Components/IconUtil.js−42 Components/Stage.qml+1−1 Components/VolumeControl.qml+5−20 Dash/Apps/AppPreview.qml+1−2 Dash/Apps/ApplicationsFilterGrid.qml+1−2 Dash/Apps/RunningApplicationTile.qml+2−3 Dash/Apps/RunningApplicationsGrid.qml+4−4 Dash/DashBar.qml+2−3 Dash/Generic/GenericCarousel.qml+1−2 Dash/Generic/GenericFilterGrid.qml+1−2 Dash/Generic/GenericPreview.qml+1−2 Dash/GenericScopeView.qml+8−6 Dash/graphics/phone/home.png Dash/graphics/phone/music.png Dash/graphics/phone/videos.png Dash/graphics/tablet/apps.png Dash/graphics/tablet/home.png Dash/graphics/tablet/music.png Dash/graphics/tablet/people.png Dash/graphics/tablet/videos.png Greeter/Greeter.qml+2 Greeter/GreeterContent.qml+20−2 Greeter/Infographics.qml+1−2 Greeter/graphics/infographic_circle.png Greeter/graphics/infographic_circle_back.png Launcher/Launcher.qml+4−4 Launcher/LauncherDelegate.qml+20−9 Launcher/LauncherPanel.qml+12−5 Launcher/graphics/focused_app_arrow@30.png MouseTouchAdaptor.cpp+29−12 MouseTouchAdaptor.h+2−5 Panel/IndicatorItem.qml+2−3 Panel/IndicatorRow.qml+19−1 Panel/Indicators.qml+17−2 Panel/Indicators/DatetimeIndicatorWidget.qml+4−2 Panel/Indicators/DefaultIndicatorWidget.qml+3−6 Panel/Indicators/DefaultIndicatorWidget2.qml+43−16 Panel/Indicators/MessagingIndicatorWidget.qml+1−1 Panel/Indicators/NetworkIndicatorWidget.qml+10−7 Panel/Indicators/SoundIndicatorWidget.qml+2−1 Panel/MenuContent.qml+25−7 Shell.qml+52−27 SideStage/SideStage.qml+1−1 build+9 debian/changelog+207 debian/control+10−7 debian/unity8-private.install+1 main.cpp+76−9 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/CMakeLists.txt+1 plugins/SessionBroadcast/CMakeLists.txt+13 plugins/SessionBroadcast/SessionBroadcast.cpp+41 plugins/SessionBroadcast/SessionBroadcast.h+41 plugins/SessionBroadcast/plugin.cpp+35 plugins/SessionBroadcast/plugin.h+33 plugins/SessionBroadcast/qmldir+3 plugins/Unity/CMakeLists.txt+1 plugins/Unity/Indicators/CMakeLists.txt+9 plugins/Unity/Indicators/Network/qml/AccessPoint.qml+71−26 plugins/Unity/Indicators/indicator.cpp−2 plugins/Unity/Indicators/indicator.h−4 plugins/Unity/Indicators/indicators.h+1−1 plugins/Unity/Indicators/indicatorsmodel.cpp−3 plugins/Unity/Indicators/indicatorsmodel.h+2−1 plugins/Unity/Indicators/plugin.cpp+2 plugins/Unity/Indicators/qml/IndicatorBase.qml−5 plugins/Unity/Indicators/qml/IndicatorWidget.qml+1 plugins/Unity/Indicators/qml/MenuItemFactory.qml+6−21 plugins/Unity/Indicators/resources/artwork/network/secure.svg+71 plugins/Unity/Indicators/resources/indicators.qrc+5 plugins/Unity/Indicators/rootactionstate.cpp+52−22 plugins/Unity/Indicators/rootactionstate.h+9−6 plugins/Unity/Indicators/visibleindicatorsmodel.cpp+94 plugins/Unity/Indicators/visibleindicatorsmodel.h+56 plugins/Unity/IndicatorsLegacy/Messaging/qml/GroupedMessage.qml+1−1 plugins/Unity/IndicatorsLegacy/Messaging/qml/HeroMessage.qml+2−2 plugins/Unity/IndicatorsLegacy/Network/qml/AccessPoint.qml+2−2 plugins/Unity/IndicatorsLegacy/qml/IndicatorWidget.qml+2−2 plugins/Unity/Launcher/CMakeLists.txt+7−2 plugins/Unity/Launcher/backend/launcherbackend.cpp+192−100 plugins/Unity/Launcher/backend/launcherbackend.h+12−14 plugins/Unity/Launcher/launcheritem.cpp+15−7 plugins/Unity/Launcher/launcheritem.h+5−3 plugins/Unity/Launcher/launchermodel.cpp+126−10 plugins/Unity/Launcher/launchermodel.h+10 plugins/Unity/applicationpreview.cpp+5−1 plugins/Unity/categories.cpp−3 plugins/Unity/categories.h+1−2 plugins/Unity/categoryresults.cpp+5−2 plugins/Unity/categoryresults.h+1−1 plugins/Unity/iconutils.cpp+91 plugins/Unity/iconutils.h+27 plugins/Unity/preview.cpp+5−1 plugins/Unity/socialpreview.cpp+5−1 plugins/Utils/qsortfilterproxymodelqml.cpp+32 plugins/Utils/qsortfilterproxymodelqml.h+4 po/ca.po+32−32 po/es.po+24−22 po/is.po+256 po/sl.po+29−24 run_on_device+2−1 tests/autopilot/unity8/application_lifecycle/__init__.py+20 tests/autopilot/unity8/application_lifecycle/tests/__init__.py tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+136 tests/autopilot/unity8/shell/__init__.py+10 tests/autopilot/unity8/shell/tests/__init__.py+4−1 tests/autopilot/unity8/shell/tests/test_hud.py+7−2 tests/mocks/AccountsService/AccountsService.cpp+27−4 tests/mocks/AccountsService/AccountsService.h+27−3 tests/mocks/AccountsService/CMakeLists.txt+2 tests/mocks/LightDM/demo/GreeterPrivate.cpp+4−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+4 tests/mocks/Unity/Indicators/CMakeLists.txt+1 tests/mocks/Unity/Indicators/IndicatorsModel.qml+47−76 tests/mocks/Unity/Indicators/fakeplugin.cpp+2 tests/mocks/Unity/Indicators/qml/fake_menu_widget2.qml+2 tests/mocks/Unity/Launcher/CMakeLists.txt+1−1 tests/mocks/Unity/Launcher/MockLauncherItem.cpp+16 tests/mocks/Unity/Launcher/MockLauncherItem.h+4 tests/mocks/Unity/Launcher/MockLauncherModel.cpp+14−2 tests/mocks/Unity/Launcher/MockLauncherModel.h+3 tests/mocks/Unity/fake_applications_scope.cpp+68 tests/mocks/Unity/fake_applications_scope.h+33 tests/mocks/Unity/fake_categories.cpp+84−12 tests/mocks/Unity/fake_categories.h+7−3 tests/mocks/Unity/fake_preview.cpp+66 tests/mocks/Unity/fake_preview.h+62 tests/mocks/Unity/fake_scope.cpp+33−9 tests/mocks/Unity/fake_scope.h+15−1 tests/mocks/Unity/fake_scopes.cpp+4−1 tests/plugins/AccountsService/CMakeLists.txt+1 tests/plugins/AccountsService/client.cpp+19−7 tests/plugins/Unity/CMakeLists.txt+4 tests/plugins/Unity/Launcher/CMakeLists.txt+53−4 tests/plugins/Unity/Launcher/click-icon.desktop+4 tests/plugins/Unity/Launcher/click-icon.svg tests/plugins/Unity/Launcher/launcherbackendtest.cpp+41−42 tests/plugins/Unity/Launcher/launchermodeltest.cpp+275 tests/plugins/Unity/Launcher/rel-icon.desktop+1−1 tests/plugins/Unity/Launcher/rel-icon.svg tests/plugins/Unity/resultstest.cpp+104 tests/plugins/Unity/resultstest.h+35 tests/qmltests/CMakeLists.txt+1−1 tests/qmltests/Components/tst_Stage.qml+1−1 tests/qmltests/Dash/Apps/tst_RunningApplicationsGrid.qml+55−37 tests/qmltests/Dash/tst_DashContent.qml+1−1 tests/qmltests/Dash/tst_GenericScopeView.qml+3 tests/qmltests/Greeter/tst_Phone.qml+19−1 tests/qmltests/Launcher/tst_Launcher.qml+10−2 tests/qmltests/Panel/tst_IndicatorItem.qml+2−2 tests/qmltests/Panel/tst_Indicators.qml+30−11 tests/qmltests/Panel/tst_MenuContent.qml+9−2 tests/qmltests/Panel/tst_Panel.qml+3 tests/qmltests/tst_Shell.qml+33−9 tests/uqmlscene/main.cpp−2
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+5−3
@@ -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 {
@@ -107,7 +107,7 @@ Item {
107107 height: distanceThreshold
108108 anchors.bottom: parent.bottom
109109
110− distanceThreshold: units.gu(8)
110+ distanceThreshold: units.gu(1)
111111 enabled: !theHud.shown && bottombar.enabled && applicationIsOnForeground
112112 direction: Direction.Upwards
113113
@@ -119,6 +119,8 @@ Item {
119119 if (previousStatus == DirectionalDragArea.Recognized) {
120120 if (hudButton.mouseOver) {
121121 hudButton.clicked()
122+ } else {
123+ bottombar.state = "hidden"
122124 }
123125 }
124126 } else if (status === DirectionalDragArea.Undecided) {
@@ -142,7 +144,7 @@ Item {
142144
143145 InputFilterArea {
144146 anchors.fill: parent
145− blockInput: hudButton.visible
147+ blockInput: (hudButton.opacity == 1)
146148 }
147149
148150 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+28−21
@@ -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() {
@@ -218,8 +224,9 @@ Item {
218224 d.finalEdgeDemo = d.overlay.createObject(demo.underlay, {
219225 "edge": "none",
220226 "title": i18n.tr("Well done"),
221− "text": i18n.tr("You have now mastered the edge gestures and can start using the phone"),
227+ "text": i18n.tr("You have now mastered the edge gestures and can start using the phone<br><br>Tap anywhere to start"),
222228 "anchors.fill": demo.dash,
229+ "showSkip": false,
223230 });
224231 }
225232 if (d.finalEdgeDemo) {
Components/EdgeDemoOverlay.qml+6−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 {
@@ -43,6 +43,11 @@ Showable {
4343 */
4444 property alias skipText: skipLabel.text
4545
46+ /*
47+ * This is the visible status of the skip button.
48+ */
49+ property alias showSkip: skipLabel.visible
50+
4651 /*
4752 * Whether this demo is running currently.
4853 */
Components/IconUtil.jsdeleted−42
@@ -1,42 +0,0 @@
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−.pragma library
18−
19−// FIXME: a quick hack to get icons out of gicons and fallback to
20−// base icon for annotated icons. Doesn't correctly handle all icons.
21−// Proper global solution needed.
22−function from_gicon(name) {
23− var icon_name = name;
24− var annotated_re = /^. UnityProtocolAnnotatedIcon/;
25− if (annotated_re.test(name)) {
26− var base_icon_re = /'base-icon':.+?'(.+?)'/;
27− var base_icon = name.toString().match(base_icon_re);
28− icon_name = base_icon[1];
29− } else {
30− var themed_re = /^. GThemedIcon\s*([^\s]+)\s*/;
31− var themed = name.match(themed_re);
32− if (themed) {
33− return "image://gicon/" + themed[1];
34− }
35− }
36− var name_re = /^[a-z0-9\._-]+$/;
37− if (name_re.test(icon_name)) {
38− return "image://gicon/" + icon_name;
39− } else {
40− return icon_name;
41− }
42−}
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
Components/VolumeControl.qml+5−20
@@ -21,37 +21,22 @@ Item {
2121 id: root
2222 objectName: "volumeControl"
2323 visible: false
24− property int volume
2524
2625 QDBusActionGroup {
2726 id: actionGroup
2827 busType: 1
29− busName: "com.canonical.settings.sound"
30− objectPath: "/com/canonical/settings/sound"
28+ busName: "com.canonical.indicator.sound"
29+ objectPath: "/com/canonical/indicator/sound"
3130
32− property variant actionObject: action("volume")
33− property variant serverVolume: actionObject.valid ? actionObject.state: 0
34− }
35−
36− Binding {
37− target: root
38− property: "volume"
39− value: actionGroup.serverVolume * 100
40− }
41−
42− onVolumeChanged: {
43− if (actionGroup.serverVolume != volume) {
44− var targetVolume = Math.min(1, Math.max(0, volume / 100));
45− actionGroup.actionObject.updateState(targetVolume);
46− }
31+ property variant actionObject: action("scroll")
4732 }
4833
4934 function volumeUp() {
50− actionGroup.actionObject.updateState(Math.min(1, volume/100 + 0.10));
35+ actionGroup.actionObject.activate(1);
5136 }
5237
5338 function volumeDown() {
54− actionGroup.actionObject.updateState(Math.max(0, volume/100 - 0.10));
39+ actionGroup.actionObject.activate(-1);
5540 }
5641
5742 Component.onCompleted: actionGroup.start()
Dash/Apps/AppPreview.qml+1−2
@@ -20,7 +20,6 @@ import Ubuntu.Components.ListItems 0.1 as ListItem
2020import Ubuntu.DownloadDaemonListener 0.1
2121import ".."
2222import "../../Components"
23−import "../../Components/IconUtil.js" as IconUtil
2423
2524DashPreview {
2625 id: root
@@ -137,7 +136,7 @@ DashPreview {
137136 anchors { left: parent.left; right: parent.right }
138137
139138 appName: root.previewData.title
140− icon: IconUtil.from_gicon(root.previewData.appIcon)
139+ icon: root.previewData.appIcon
141140 rating: Math.round(root.previewData.rating * 10)
142141 reviews: root.previewData.numRatings
143142 rated: root.previewData.infoMap["rated"] ? root.previewData.infoMap["rated"].value : 0
Dash/Apps/ApplicationsFilterGrid.qml+1−2
@@ -17,7 +17,6 @@
1717import QtQuick 2.0
1818import "../../Components"
1919import "../../Applications"
20−import "../../Components/IconUtil.js" as IconUtil
2120
2221FilterGrid {
2322 id: filterGrid
@@ -50,7 +49,7 @@ FilterGrid {
5049 text: model.title ? model.title : application.name // FIXME: this is temporary
5150 imageWidth: units.gu(8)
5251 imageHeight: units.gu(7.5)
53− source: IconUtil.from_gicon(icon)
52+ source: icon
5453 onClicked: filterGrid.clicked(index, application.desktopFile);
5554 }
5655}
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
Dash/DashBar.qml+2−3
@@ -83,9 +83,8 @@ Item {
8383 }
8484
8585 delegate:
86− Item {
87− signal clicked()
88−
86+ // FIXME: Use Panel's integrated trigger() once that works again.
87+ MouseArea {
8988 width: itemSize
9089 height: dashBar.height
9190 anchors.top: parent.top
Dash/Generic/GenericCarousel.qml+1−2
@@ -17,7 +17,6 @@
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919import "../../Components"
20−import "../../Components/IconUtil.js" as IconUtil
2120
2221Carousel {
2322 id: genericCarousel
@@ -42,7 +41,7 @@ Carousel {
4241 image: Image {
4342 asynchronous: true
4443 sourceSize { width: item.width; height: item.height }
45− source: model ? IconUtil.from_gicon(model.icon) : ""
44+ source: model ? model.icon : ""
4645 }
4746 }
4847
Dash/Generic/GenericFilterGrid.qml+1−2
@@ -16,7 +16,6 @@
1616
1717import QtQuick 2.0
1818import "../../Components"
19−import "../../Components/IconUtil.js" as IconUtil
2019
2120FilterGrid {
2221 id: filtergrid
@@ -41,7 +40,7 @@ FilterGrid {
4140 imageWidth: filtergrid.iconWidth
4241 imageHeight: filtergrid.iconHeight
4342
44− source: IconUtil.from_gicon(model.icon)
43+ source: model.icon
4544
4645 fillMode: Image.PreserveAspectCrop
4746
Dash/Generic/GenericPreview.qml+1−2
@@ -18,7 +18,6 @@ import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919import "../../Components"
2020import "../../Components/ListItems" as ListItems
21−import "../../Components/IconUtil.js" as IconUtil
2221import ".."
2322
2423DashPreview {
@@ -27,7 +26,7 @@ DashPreview {
2726 title: previewData.title
2827 previewWidthRatio: 0.6
2928
30− property url url: IconUtil.from_gicon(previewData.image)
29+ property url url: previewData.image
3130
3231 header: UbuntuShape {
3332 id: urlLoader
Dash/GenericScopeView.qml+8−6
@@ -18,14 +18,14 @@ import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919import "../Components"
2020import "../Components/ListItems" as ListItems
21−import "../Components/IconUtil.js" as IconUtil
2221
2322ScopeView {
2423 id: scopeView
25− property alias previewShown: previewLoader.onScreen
24+ readonly property alias previewShown: previewLoader.onScreen
2625
2726 onIsCurrentChanged: {
2827 pageHeader.resetSearch();
28+ previewLoader.open = false;
2929 }
3030
3131 onMovementStarted: categoryView.showHeader()
@@ -74,12 +74,12 @@ ScopeView {
7474 onLoaded: {
7575 if (source.toString().indexOf("Apps/RunningApplicationsGrid.qml") != -1) {
7676 // TODO: the running apps grid doesn't support standard scope results model yet
77− item.firstModel = results.firstModel
78− item.secondModel = results.secondModel
77+ item.firstModel = Qt.binding(function() { return results.firstModel })
78+ item.secondModel = Qt.binding(function() { return results.secondModel })
7979 } else {
80− item.model = results
80+ item.model = Qt.binding(function() { return results })
8181 }
82− item.objectName = categoryId
82+ item.objectName = Qt.binding(function() { return categoryId })
8383 if (item.expandable) {
8484 var shouldFilter = index != categoryView.expandedIndex;
8585 if (shouldFilter != item.filter) {
@@ -180,6 +180,7 @@ ScopeView {
180180 case "grid": {
181181 switch (contentType) {
182182 case "video": return "Generic/GenericFilterGridPotrait.qml";
183+ case "music": return "Music/MusicFilterGrid.qml";
183184 default: return "Generic/GenericFilterGrid.qml";
184185 }
185186 }
@@ -247,6 +248,7 @@ ScopeView {
247248 }
248249
249250 Loader {
251+ objectName: "previewLoader"
250252 id: previewLoader
251253 property var previewData
252254 height: effect.bottomGapPx - effect.topGapPx
Dash/graphics/phone/home.pngdeleted

Binary file not shown.

Dash/graphics/phone/music.pngdeleted

Binary file not shown.

Dash/graphics/phone/videos.pngdeleted

Binary file not shown.

Dash/graphics/tablet/apps.pngdeleted

Binary file not shown.

Dash/graphics/tablet/home.pngdeleted

Binary file not shown.

Dash/graphics/tablet/music.pngdeleted

Binary file not shown.

Dash/graphics/tablet/people.pngdeleted

Binary file not shown.

Dash/graphics/tablet/videos.pngdeleted

Binary file not shown.

Greeter/Greeter.qml+2
@@ -26,6 +26,8 @@ Showable {
2626 enabled: shown
2727 created: greeterContentLoader.status == Loader.Ready && greeterContentLoader.item.ready
2828
29+ property url defaultBackground
30+
2931 // 1 when fully shown and 0 when fully hidden
3032 property real showProgress: MathLocal.clamp((width + x) / width, 0, 1)
3133
Greeter/GreeterContent.qml+20−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,31 @@ MouseArea {
3940 color: "black"
4041 }
4142
43+ property url backgroundValue: AccountsService.backgroundFile != undefined && AccountsService.backgroundFile.length > 0 ? AccountsService.backgroundFile : greeter.defaultBackground
44+ onBackgroundValueChanged: wallpaper.source = backgroundValue
45+
4246 CrossFadeImage {
4347 id: wallpaper
44−
45− source: shell.background
48+ objectName: "wallpaper"
4649 anchors.fill: parent
4750 fadeInFirst: false
4851 }
4952
53+ // See Shell.qml's backgroundSettings treatment for why we need a separate
54+ // Image, but it boils down to avoiding binding loop detection.
55+ Image {
56+ source: wallpaper.source
57+ height: 0
58+ width: 0
59+ sourceSize.height: 0
60+ sourceSize.width: 0
61+ onStatusChanged: {
62+ if (status == Image.Error && source != greeter.defaultBackground) {
63+ wallpaper.source = greeter.defaultBackground
64+ }
65+ }
66+ }
67+
5068 Rectangle {
5169 anchors.fill: parent
5270 color: "black"
Greeter/Infographics.qml+1−2
@@ -286,9 +286,8 @@ Item {
286286 objectName: "backgroundCircle"
287287
288288 anchors.fill: parent
289− opacity: 0.9
290289
291− source: "graphics/infographic_circle.png"
290+ source: "graphics/infographic_circle_back.png"
292291 }
293292
294293 Timer {
Greeter/graphics/infographic_circle.pngdeleted

Binary file not shown.

Greeter/graphics/infographic_circle_back.pngnew file

Binary file not shown.

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/LauncherDelegate.qml+20−9
@@ -24,6 +24,7 @@ Item {
2424 property int count: -1
2525 property int progress: -1
2626 property bool highlighted: false
27+ property bool itemFocused: false
2728 property real maxAngle: 0
2829 property bool inverted: false
2930
@@ -43,17 +44,18 @@ Item {
4344 onCountChanged: shaderEffectSource.scheduleUpdate();
4445 onProgressChanged: shaderEffectSource.scheduleUpdate();
4546 onHighlightedChanged: shaderEffectSource.scheduleUpdate();
47+ onItemFocusedChanged: shaderEffectSource.scheduleUpdate();
4648
4749 Item {
4850 id: iconItem
49− width: parent.itemWidth
50− height: parent.itemHeight
51+ width: parent.itemWidth + units.gu(1)
52+ height: parent.itemHeight + units.gu(1)
5153 anchors.centerIn: parent
5254
5355 UbuntuShape {
5456 id: iconShape
5557 anchors.fill: parent
56− anchors.margins: units.gu(0.5)
58+ anchors.margins: units.gu(1)
5759 radius: "medium"
5860
5961 image: Image {
@@ -78,7 +80,7 @@ Item {
7880 anchors {
7981 right: parent.right
8082 top: parent.top
81− margins: -units.dp(1)
83+ margins: units.dp(3)
8284 }
8385 width: Math.min(root.itemWidth, Math.max(units.gu(3), countLabel.implicitWidth + units.gu(2.5)))
8486 height: units.gu(3)
@@ -105,9 +107,9 @@ Item {
105107 left: iconItem.left
106108 right: iconItem.right
107109 bottom: iconItem.bottom
108− leftMargin: units.gu(0.5)
109− rightMargin: units.gu(0.5)
110− bottomMargin: units.gu(0.5)
110+ leftMargin: units.gu(1)
111+ rightMargin: units.gu(1)
112+ bottomMargin: units.gu(1)
111113 }
112114 height: units.gu(1.5)
113115 visible: root.progress > -1
@@ -136,14 +138,23 @@ Item {
136138 }
137139 }
138140 }
141+ Image {
142+ objectName: "focusedHighlight"
143+ anchors {
144+ right: parent.right
145+ verticalCenter: parent.verticalCenter
146+ }
147+ visible: root.itemFocused
148+ source: "graphics/focused_app_arrow.png"
149+ }
139150 }
140151
141152 ShaderEffect {
142153 id: transformEffect
143154 anchors.centerIn: parent
144155 anchors.verticalCenterOffset: root.offset
145− width: parent.itemWidth
146− height: parent.itemHeight
156+ width: iconItem.width
157+ height: iconItem.height
147158 property real itemOpacity: root.itemOpacity
148159 property real brightness: Math.max(-1, root.brightness)
149160 property real angle: root.angle
Launcher/LauncherPanel.qml+12−5
@@ -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 {
@@ -50,8 +50,6 @@ Item {
5050 id: mainColumn
5151 anchors {
5252 fill: parent
53− leftMargin: units.gu(0.5)
54− rightMargin: units.gu(0.5)
5553 }
5654
5755 MouseArea {
@@ -94,6 +92,8 @@ Item {
9492 fill: parent
9593 topMargin: -extensionSize + units.gu(0.5)
9694 bottomMargin: -extensionSize + units.gu(1)
95+ leftMargin: units.gu(0.5)
96+ rightMargin: units.gu(0.5)
9797 }
9898 topMargin: extensionSize
9999 bottomMargin: extensionSize
@@ -156,6 +156,7 @@ Item {
156156 iconName: model.icon
157157 count: model.count
158158 progress: model.progress
159+ itemFocused: model.focused
159160 inverted: root.inverted
160161 z: -Math.abs(offset)
161162 maxAngle: 55
@@ -299,7 +300,7 @@ Item {
299300 } else if (clickedItem.angle < -12) {
300301 launcherListView.flick(0, launcherListView.clickFlickSpeed);
301302 } else {
302− root.applicationSelected(LauncherModel.get(index).desktopFile);
303+ root.applicationSelected(LauncherModel.get(index).appId);
303304 }
304305 return;
305306 }
@@ -310,7 +311,7 @@ Item {
310311 } else if (clickedItem.angle < -30) {
311312 launcherListView.flick(0, launcherListView.clickFlickSpeed);
312313 } else {
313− root.applicationSelected(LauncherModel.get(index).desktopFile);
314+ root.applicationSelected(LauncherModel.get(index).appId);
314315 }
315316 }
316317
@@ -512,6 +513,12 @@ Item {
512513 objectName: "quickListEntry" + index
513514 text: (model.clickable ? "" : "<b>") + model.label + (model.clickable ? "" : "</b>")
514515 highlightWhenPressed: model.clickable
516+
517+ // FIXME: This is a workaround for the theme not being context sensitive. I.e. the
518+ // ListItems don't know that they are sitting in a themed Popover where the color
519+ // needs to be inverted.
520+ __foregroundColor: Theme.palette.selected.backgroundText
521+
515522 onClicked: {
516523 if (!model.clickable) {
517524 return;
Launcher/graphics/focused_app_arrow@30.pngnew file

Binary file not shown.

MouseTouchAdaptor.cpp+29−12
@@ -39,24 +39,16 @@ Qt::MouseButton translateMouseButton(xcb_button_t detail)
3939} // end of anonymous namespace
4040
4141MouseTouchAdaptor::MouseTouchAdaptor()
42− : m_targetWindow(0)
43− , m_leftButtonIsPressed(false)
42+ : m_leftButtonIsPressed(false)
4443{
4544 m_touchDevice = new QTouchDevice;
4645 m_touchDevice->setType(QTouchDevice::TouchScreen);
4746 QWindowSystemInterface::registerTouchDevice(m_touchDevice);
4847}
4948
50−void MouseTouchAdaptor::setTargetWindow(QWindow *window)
51−{
52− m_targetWindow = window;
53−}
54−
5549bool MouseTouchAdaptor::nativeEventFilter(const QByteArray & eventType,
5650 void * message, long * /*result*/)
5751{
58− Q_ASSERT(m_targetWindow);
59−
6052 if (eventType != "xcb_generic_event_t") {
6153 // wrong backend.
6254 qWarning("MouseTouchAdaptor: XCB backend not in use. Adaptor inoperative!");
@@ -91,7 +83,9 @@ bool MouseTouchAdaptor::handleButtonPress(xcb_button_press_event_t *pressEvent)
9183
9284 QPoint windowPos(pressEvent->event_x, pressEvent->event_y);
9385
94− QTouchEventSequence touchEvent = QTest::touchEvent(m_targetWindow, m_touchDevice,
86+ QWindow *targetWindow = findQWindowWithXWindowID(static_cast<WId>(pressEvent->event));
87+
88+ QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice,
9589 false /* autoCommit */);
9690 touchEvent.press(0 /* touchId */, windowPos);
9791 touchEvent.commit(false /* processEvents */);
@@ -110,7 +104,9 @@ bool MouseTouchAdaptor::handleButtonRelease(xcb_button_release_event_t *releaseE
110104
111105 QPoint windowPos(releaseEvent->event_x, releaseEvent->event_y);
112106
113− QTouchEventSequence touchEvent = QTest::touchEvent(m_targetWindow, m_touchDevice,
107+ QWindow *targetWindow = findQWindowWithXWindowID(static_cast<WId>(releaseEvent->event));
108+
109+ QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice,
114110 false /* autoCommit */);
115111 touchEvent.release(0 /* touchId */, windowPos);
116112 touchEvent.commit(false /* processEvents */);
@@ -127,10 +123,31 @@ bool MouseTouchAdaptor::handleMotionNotify(xcb_motion_notify_event_t *event)
127123
128124 QPoint windowPos(event->event_x, event->event_y);
129125
130− QTouchEventSequence touchEvent = QTest::touchEvent(m_targetWindow, m_touchDevice,
126+ QWindow *targetWindow = findQWindowWithXWindowID(static_cast<WId>(event->event));
127+
128+ QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice,
131129 false /* autoCommit */);
132130 touchEvent.move(0 /* touchId */, windowPos);
133131 touchEvent.commit(false /* processEvents */);
134132
135133 return true;
136134}
135+
136+QWindow *MouseTouchAdaptor::findQWindowWithXWindowID(WId windowId)
137+{
138+ QWindowList windowList = QGuiApplication::topLevelWindows();
139+ QWindow *foundWindow = nullptr;
140+
141+ int i = 0;
142+ while (!foundWindow && i < windowList.count()) {
143+ QWindow *window = windowList[i];
144+ if (window->winId() == windowId) {
145+ foundWindow = window;
146+ } else {
147+ ++i;
148+ }
149+ }
150+
151+ Q_ASSERT(foundWindow);
152+ return foundWindow;
153+}
MouseTouchAdaptor.h+2−5
@@ -20,11 +20,11 @@
2020#define MOUSE_TOUCH_ADAPTOR_H
2121
2222#include <QtCore/QAbstractNativeEventFilter>
23+#include <QWindow>
2324#include <xcb/xcb.h>
2425
2526class QMouseEvent;
2627class QTouchDevice;
27−class QWindow;
2828
2929// Transforms QMouseEvents into single-finger QTouchEvents.
3030class MouseTouchAdaptor : public QAbstractNativeEventFilter {
@@ -32,9 +32,6 @@ class MouseTouchAdaptor : public QAbstractNativeEventFilter {
3232public:
3333 MouseTouchAdaptor();
3434
35− // The window that will receive the generated QTouchEvents
36− void setTargetWindow(QWindow *window);
37−
3835 // Filters mouse events and posts the equivalent QTouchEvents.
3936 virtual bool nativeEventFilter(const QByteArray & eventType, void *message, long *result);
4037
@@ -43,8 +40,8 @@ private:
4340 bool handleButtonPress(xcb_button_press_event_t *pressEvent);
4441 bool handleButtonRelease(xcb_button_release_event_t *releaseEvent);
4542 bool handleMotionNotify(xcb_motion_notify_event_t *event);
43+ QWindow *findQWindowWithXWindowID(WId windowId);
4644
47− QWindow *m_targetWindow;
4845 QTouchDevice *m_touchDevice;
4946 bool m_leftButtonIsPressed;
5047};
Panel/IndicatorItem.qml+2−3
@@ -26,13 +26,12 @@ Item {
2626 property bool highlighted: false
2727 property bool dimmed: false
2828 property var indicatorProperties: undefined
29+ property bool indicatorVisible: loader.item ? loader.item.enabled : false
2930
3031 opacity: dimmed ? 0.4 : 1
3132 Behavior on opacity { StandardAnimation {} }
3233
33− // only visible when non-empty
34− visible: loader.item != undefined && loader.status == Loader.Ready ? loader.item.enabled : false
35− width: visible ? loader.item.width : 0
34+ width: loader.item ? loader.item.width : 0
3635
3736 Loader {
3837 id: loader
Panel/IndicatorRow.qml+19−1
@@ -16,6 +16,7 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
19+import Unity.Indicators 0.1 as Indicators
1920import "../Components"
2021
2122Item {
@@ -25,6 +26,7 @@ Item {
2526 readonly property int currentItemIndex: currentItem ? currentItem.ownIndex : -1
2627 property alias row: row
2728 property QtObject indicatorsModel: null
29+ property var visibleIndicators: defined
2830
2931 width: units.gu(40)
3032 height: units.gu(3)
@@ -55,7 +57,8 @@ Item {
5557 Item {
5658 id: itemWrapper
5759 height: indicatorRow.height
58− width: childrenRect.width
60+ width: indicatorItem.width
61+ visible: indicatorItem.indicatorVisible
5962
6063 property int ownIndex: index
6164 property alias highlighted: indicatorItem.highlighted
@@ -70,6 +73,21 @@ Item {
7073
7174 widgetSource: model.widgetSource
7275 indicatorProperties : model.indicatorProperties
76+
77+ Component.onCompleted: {
78+ if (visibleIndicators == undefined) {
79+ visibleIndicators = {}
80+ }
81+ indicatorRow.visibleIndicators[model.identifier] = indicatorVisible;
82+ indicatorRow.visibleIndicatorsChanged();
83+ }
84+ onIndicatorVisibleChanged: {
85+ if (visibleIndicators == undefined) {
86+ visibleIndicators = {}
87+ }
88+ indicatorRow.visibleIndicators[model.identifier] = indicatorVisible;
89+ indicatorRow.visibleIndicatorsChanged();
90+ }
7391 }
7492
7593 opacity: {
Panel/Indicators.qml+17−2
@@ -180,11 +180,19 @@ Showable {
180180 clip: !indicators.fullyOpened
181181 activeHeader: indicators.state == "hint" || indicators.state == "reveal"
182182 enabled: contentEnabled
183+ visibleIndicators: indicatorRow.visibleIndicators
183184
184185 Connections {
185− target: indicatorRow
186+ property bool enableIndexChangeSignal: true
187+
188+ target: enableIndexChangeSignal ? indicatorRow : null
186189 onCurrentItemIndexChanged: {
190+ var oldActive = enableIndexChangeSignal;
191+ enableIndexChangeSignal = false;
192+
187193 menuContent.setCurrentMenuIndex(indicatorRow.currentItemIndex);
194+
195+ enableIndexChangeSignal = oldActive;
188196 }
189197 }
190198
@@ -256,9 +264,16 @@ Showable {
256264 state: indicators.state
257265
258266 Connections {
259− target: menuContent
267+ property bool enableIndexChangeSignal: true
268+
269+ target: enableIndexChangeSignal ? menuContent : null
260270 onCurrentMenuIndexChanged: {
271+ var oldActive = enableIndexChangeSignal;
272+ enableIndexChangeSignal = false;
273+
261274 indicatorRow.setCurrentItem(menuContent.currentMenuIndex);
275+
276+ enableIndexChangeSignal = oldActive;
262277 }
263278 }
264279 }
Panel/Indicators/DatetimeIndicatorWidget.qml+4−2
@@ -25,6 +25,7 @@ Indicators.IndicatorWidget {
2525 id: indicatorWidget
2626
2727 width: timeLabel.width + units.gu(1)
28+ rootMenuType: "com.canonical.indicator.root.time"
2829
2930 property alias label: timeLabel.text
3031
@@ -52,14 +53,15 @@ Indicators.IndicatorWidget {
5253
5354 onActionStateChanged: {
5455 if (action == undefined || !action.valid) {
56+ enabled = false;
5557 return;
5658 }
5759
5860 if (action.state == undefined) {
59− visible = false;
61+ enabled = false;
6062 return;
6163 }
6264
63− indicatorWidget.visible = action.state[3];
65+ enabled = action.state[3];
6466 }
6567}
Panel/Indicators/DefaultIndicatorWidget.qml+3−6
@@ -24,7 +24,8 @@ import Unity.IndicatorsLegacy 0.1 as Indicators
2424Indicators.IndicatorWidget {
2525 id: indicatorWidget
2626
27− width: itemRow.width + units.gu(1)
27+ enabled:true
28+ width: itemRow.width + units.gu(0.5)
2829
2930 property alias label: itemLabel.text
3031 property alias iconSource: itemImage.source
@@ -67,14 +68,10 @@ Indicators.IndicatorWidget {
6768 }
6869
6970 if (action.state == undefined) {
70− label = "";
71− iconSource = "";
72− enabled = false;
7371 return;
7472 }
7573
7674 label = action.state[Indicators.ActionState.Label];
77− iconSource = "image://gicon/" + action.state[Indicators.ActionState.IconSource];
78− enabled = action.state[Indicators.ActionState.Visible];
75+ iconSource = "image://theme/" + action.state[Indicators.ActionState.IconSource];
7976 }
8077}
Panel/Indicators/DefaultIndicatorWidget2.qml+43−16
@@ -24,10 +24,11 @@ import Unity.Indicators 0.1 as Indicators
2424Indicators.IndicatorWidget {
2525 id: indicatorWidget
2626
27− width: itemRow.width + units.gu(1)
27+ width: itemRow.width + units.gu(0.5)
2828
29− property alias label: itemLabel.text
30− property alias iconSource: itemImage.source
29+ property alias leftLabel: itemLeftLabel.text
30+ property alias rightLabel: itemRightLabel.text
31+ property var icons: undefined
3132
3233 Row {
3334 id: itemRow
@@ -39,19 +40,43 @@ Indicators.IndicatorWidget {
3940 }
4041 spacing: units.gu(0.5)
4142
42− // FIXME : Should us Ubuntu.Icon . results in low res images
43− Image {
44− id: itemImage
45− objectName: "itemImage"
46− visible: source != ""
47− height: indicatorWidget.iconSize
48− width: indicatorWidget.iconSize
43+ Label {
44+ id: itemLeftLabel
45+ objectName: "leftLabel"
46+ color: Theme.palette.selected.backgroundText
47+ opacity: 0.8
48+ font.family: "Ubuntu"
49+ fontSize: "medium"
4950 anchors.verticalCenter: parent.verticalCenter
51+ visible: text != ""
52+ }
53+
54+ Row {
55+ width: childrenRect.width
56+ anchors {
57+ top: parent.top
58+ bottom: parent.bottom
59+ }
60+ spacing: units.gu(0.5)
61+
62+ Repeater {
63+ model: indicatorWidget.icons
64+
65+ Image {
66+ id: itemImage
67+ objectName: "itemImage"
68+ visible: source != ""
69+ source: modelData
70+ height: indicatorWidget.iconSize
71+ width: indicatorWidget.iconSize
72+ anchors.verticalCenter: parent.verticalCenter
73+ }
74+ }
5075 }
5176
5277 Label {
53− id: itemLabel
54− objectName: "itemLabel"
78+ id: itemRightLabel
79+ objectName: "rightLabel"
5580 color: Theme.palette.selected.backgroundText
5681 opacity: 0.8
5782 font.family: "Ubuntu"
@@ -63,14 +88,16 @@ Indicators.IndicatorWidget {
6388
6489 onActionStateChanged: {
6590 if (actionState == undefined) {
66− label = "";
67− iconSource = "";
91+ leftLabel = "";
92+ rightLabel = "";
93+ icons = undefined;
6894 enabled = false;
6995 return;
7096 }
7197
72− label = actionState.label;
73− iconSource = actionState.icon;
98+ leftLabel = actionState.leftLabel ? actionState.leftLabel : "";
99+ rightLabel = actionState.rightLabel ? actionState.rightLabel : "";
100+ icons = actionState.icons;
74101 enabled = actionState.visible;
75102 }
76103}
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+10−7
@@ -24,7 +24,7 @@ import Unity.IndicatorsLegacy 0.1 as Indicators
2424Indicators.IndicatorWidget {
2525 id: indicatorWidget
2626
27− width: networkIcon.width + units.gu(1)
27+ width: networkIcon.width + units.gu(0.5)
2828
2929 property int signalStrength: 0
3030 property int connectionState: Indicators.NetworkConnection.Initial
@@ -43,14 +43,17 @@ Indicators.IndicatorWidget {
4343
4444 onActionStateChanged: {
4545 if (action == undefined || !action.valid) {
46+ enabled = false;
4647 return;
4748 }
4849
4950 if (action.state == undefined) {
51+ enabled = false;
5052 connectionState = 0;
5153 return;
5254 }
5355
56+ enabled = true;
5457 connectionState = action.state[Indicators.NetworkActionState.Connection];
5558 if (connectionState == Indicators.NetworkConnection.Activated) {
5659 signalStrength = action.state[Indicators.NetworkActionState.SignalStrength];
@@ -94,16 +97,16 @@ Indicators.IndicatorWidget {
9497 function get_icon_for_signal(con_state, value) {
9598 if (con_state >= Indicators.NetworkConnection.Activating && con_state <= Indicators.NetworkConnection.Deactivating) {
9699 if (value == 0) {
97− return "image://gicon/nm-signal-00";
100+ return "image://theme/nm-signal-00";
98101 } else if (value <= 25) {
99− return "image://gicon/nm-signal-25";
102+ return "image://theme/nm-signal-25";
100103 } else if (value <= 50) {
101− return "image://gicon/nm-signal-50";
104+ return "image://theme/nm-signal-50";
102105 } else if (value <= 75) {
103− return "image://gicon/nm-signal-75";
106+ return "image://theme/nm-signal-75";
104107 }
105− return "image://gicon/nm-signal-100";
108+ return "image://theme/nm-signal-100";
106109 }
107− return "image://gicon/wifi-none";
110+ return "image://theme/wifi-none";
108111 }
109112}
Panel/Indicators/SoundIndicatorWidget.qml+2−1
@@ -21,5 +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"
25+ enabled: true
2526}
Panel/MenuContent.qml+25−7
@@ -17,6 +17,7 @@
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919import Unity.Indicators 0.1 as Indicators
20+import Utils 0.1
2021import "../Components"
2122
2223// FIXME : We dont want to use MainView.
@@ -27,20 +28,23 @@ MainView {
2728
2829 property QtObject indicatorsModel: null
2930 property bool __contentActive: false
30− readonly property int currentMenuIndex : tabs.selectedTabIndex
31+ readonly property int currentMenuIndex : filteredIndicators.mapToSource(tabs.selectedTabIndex)
3132 backgroundColor: "#221e1c" // FIXME not in palette yet
3233 property int contentReleaseInterval: 20000
3334 property bool activeHeader: false
35+ property alias visibleIndicators: visibleIndicatorsModel.visible
3436
3537 width: units.gu(40)
3638 height: units.gu(42)
3739
3840 function setCurrentMenuIndex(index) {
39− if (currentMenuIndex !== index) {
40− if (currentMenuIndex == -1) {
41+ var filteredIndex = filteredIndicators.mapFromSource(index)
42+
43+ if (tabs.selectedTabIndex !== filteredIndex) {
44+ if (tabs.selectedTabIndex == -1) {
4145 tabs.tabBar.animate = false;
4246 }
43− tabs.selectedTabIndex = index;
47+ tabs.selectedTabIndex = filteredIndex;
4448 tabs.tabBar.animate = true;
4549 }
4650 }
@@ -61,6 +65,20 @@ MainView {
6165 tabs.tabBar.alwaysSelectionMode = activeHeader;
6266 }
6367
68+ SortFilterProxyModel {
69+ id: filteredIndicators
70+ model: visibleIndicatorsModel
71+ dynamicSortFilter: true
72+
73+ filterRole: Indicators.IndicatorsModelRole.IsVisible
74+ filterRegExp: RegExp("^true$")
75+ }
76+
77+ Indicators.VisibleIndicatorsModel {
78+ id: visibleIndicatorsModel
79+ model: indicatorsModel
80+ }
81+
6482 Tabs {
6583 id: tabs
6684 objectName: "tabs"
@@ -69,8 +87,8 @@ MainView {
6987
7088 Repeater {
7189 id: repeater
72− model: indicatorsModel
73− objectName: "menus"
90+ model: filteredIndicators
91+ objectName: "tabsRepeater"
7492
7593 // FIXME: This is needed because tabs dont handle repeaters well.
7694 // Due to the child ordering happening after child insertion.
@@ -114,7 +132,7 @@ MainView {
114132 item[pName] = indicatorProperties[pName]
115133 }
116134 }
117− if (contentActive && menus.visible) {
135+ if (contentActive && tabs.visible) {
118136 item.start()
119137 }
120138 }
Shell.qml+52−27
@@ -15,13 +15,15 @@
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
2324import LightDM 0.1 as LightDM
2425import Powerd 0.1
26+import SessionBroadcast 0.1
2527import "Dash"
2628import "Greeter"
2729import "Launcher"
@@ -64,6 +66,12 @@ FocusScope {
6466
6567 property var applicationManager: ApplicationManagerWrapper {}
6668
69+ Binding {
70+ target: LauncherModel
71+ property: "applicationManager"
72+ value: ApplicationManager
73+ }
74+
6775 Component.onCompleted: {
6876 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
6977
@@ -74,6 +82,11 @@ FocusScope {
7482 applicationManager.unfocusCurrentApplication();
7583 }
7684
85+ readonly property bool applicationFocused: !!applicationManager.mainStageFocusedApplication
86+ || !!applicationManager.sideStageFocusedApplication
87+ // Used for autopilot testing.
88+ readonly property string currentFocusedAppId: ApplicationManager.focusedApplicationId
89+
7790 readonly property bool fullscreenMode: {
7891 if (greeter.shown || lockscreen.shown) {
7992 return false;
@@ -147,6 +160,10 @@ FocusScope {
147160 }
148161 }
149162
163+ OSKController {
164+ anchors.fill: parent // as needs to know the geometry of the shell
165+ }
166+
150167 VolumeControl {
151168 id: volumeControl
152169 }
@@ -245,7 +262,7 @@ FocusScope {
245262 property bool fullyShown: shown && x == 0 && parent.x == 0
246263 property bool fullyHidden: !shown && x == width
247264 available: !greeter.shown
248− hides: [launcher, panel.indicators]
265+ hides: [panel.indicators]
249266 shown: false
250267 opacity: 1.0
251268 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
@@ -446,6 +463,8 @@ FocusScope {
446463 hides: [launcher, panel.indicators, hud]
447464 shown: true
448465
466+ defaultBackground: shell.background
467+
449468 y: panel.panelHeight
450469 width: parent.width
451470 height: parent.height - panel.panelHeight
@@ -469,6 +488,7 @@ FocusScope {
469488 onSelected: {
470489 // Update launcher items for new user
471490 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
491+ AccountsService.user = user;
472492 LauncherModel.setUser(user);
473493 }
474494
@@ -481,7 +501,8 @@ FocusScope {
481501
482502 InputFilterArea {
483503 anchors.fill: parent
484− blockInput: greeter.shown || lockscreen.shown
504+ blockInput: !applicationFocused || greeter.shown || lockscreen.shown || launcher.shown
505+ || panel.indicators.shown || hud.shown
485506 }
486507
487508 Connections {
@@ -493,10 +514,8 @@ FocusScope {
493514
494515 function setFocused(focused) {
495516 if (!focused) {
496− // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
497− // the stage was actually shown
498− if (mainStage.fullyShown) powerConnection.previousMainApp = applicationManager.mainStageFocusedApplication;
499− if (sideStage.fullyShown) powerConnection.previousSideApp = applicationManager.sideStageFocusedApplication;
517+ powerConnection.previousMainApp = applicationManager.mainStageFocusedApplication;
518+ powerConnection.previousSideApp = applicationManager.sideStageFocusedApplication;
500519 applicationManager.unfocusCurrentApplication();
501520 } else {
502521 if (powerConnection.previousMainApp) {
@@ -529,6 +548,17 @@ FocusScope {
529548 }
530549 }
531550
551+ function showHome() {
552+ greeter.hide()
553+ // Animate if moving between application and dash
554+ if (!stages.shown) {
555+ dash.setCurrentScope("home.scope", true, false)
556+ } else {
557+ dash.setCurrentScope("home.scope", false, false)
558+ }
559+ stages.hide()
560+ }
561+
532562 Item {
533563 id: overlay
534564
@@ -547,8 +577,13 @@ FocusScope {
547577 searchVisible: !greeter.shown && !lockscreen.shown
548578
549579 InputFilterArea {
550− anchors.fill: parent
551− blockInput: panel.indicators.shown
580+ anchors {
581+ top: parent.top
582+ left: parent.left
583+ right: parent.right
584+ }
585+ height: (panel.fullscreenMode) ? shell.edgeSize : panel.panelHeight
586+ blockInput: true
552587 }
553588 }
554589
@@ -568,11 +603,6 @@ FocusScope {
568603 onMainStageFocusedApplicationChanged: hud.hide()
569604 onSideStageFocusedApplicationChanged: hud.hide()
570605 }
571−
572− InputFilterArea {
573− anchors.fill: parent
574− blockInput: hud.shown
575− }
576606 }
577607
578608 Revealer {
@@ -595,8 +625,7 @@ FocusScope {
595625 theHud: hud
596626 anchors.fill: parent
597627 enabled: !panel.indicators.shown
598− applicationIsOnForeground: applicationManager.mainStageFocusedApplication
599− || applicationManager.sideStageFocusedApplication
628+ applicationIsOnForeground: applicationFocused
600629 }
601630
602631 InputFilterArea {
@@ -617,16 +646,7 @@ FocusScope {
617646 width: parent.width
618647 dragAreaWidth: shell.edgeSize
619648 available: (!greeter.shown || greeter.narrowMode) && edgeDemo.launcherEnabled
620− onDashItemSelected: {
621− greeter.hide()
622− // Animate if moving between application and dash
623− if (!stages.shown) {
624− dash.setCurrentScope("home.scope", true, false)
625− } else {
626− dash.setCurrentScope("home.scope", false, false)
627− }
628− stages.hide();
629− }
649+ onDashItemSelected: showHome()
630650 onDash: {
631651 if (stages.shown) {
632652 dash.setCurrentScope("applications.scope", true, false)
@@ -636,7 +656,7 @@ FocusScope {
636656 }
637657 onLauncherApplicationSelected:{
638658 greeter.hide()
639− shell.activateApplication(desktopFile)
659+ shell.activateApplication(appId)
640660 }
641661 onShownChanged: {
642662 if (shown) {
@@ -734,4 +754,9 @@ FocusScope {
734754 indicators: panel.indicators
735755 underlay: underlay
736756 }
757+
758+ Connections {
759+ target: SessionBroadcast
760+ onShowHome: showHome()
761+ }
737762}
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
build+9
@@ -57,6 +57,15 @@ mk_build_deps() {
5757 [ ! -f unity8-build-deps*deb -o $CODE_DIR/debian/control -nt unity8-build-deps*deb ] && mk-build-deps --install --root-cmd sudo $CODE_DIR/debian/control
5858}
5959
60+if [ -f "/usr/bin/ccache" ] ; then
61+ if [ "x$CC" = "x" ]; then
62+ export CC='ccache gcc'
63+ fi
64+ if [ "x$CXX" = "x" ] ; then
65+ export CXX='ccache g++'
66+ fi
67+fi
68+
6069if [ -f "/usr/bin/ninja" ] ; then
6170 GENERATOR="-G Ninja"
6271 # Ninja does not need -j, it parallelizes automatically.
debian/changelog+207
@@ -1,3 +1,210 @@
1+unity8 (7.81.3+13.10.20130919.3-0ubuntu1) saucy; urgency=low
2+
3+ [ Michal Hruby ]
4+ * Add support for music grid renderer to GenericScopeView.
5+
6+ [ Nick Dedekind ]
7+ * Fixed the removal of messaging widget due to incompatible action
8+ state. (LP: #1225017)
9+
10+ [ Christopher Lee ]
11+ * Addition of initial autopilot tests for the application lifecycle.
12+
13+ [ Lars Uebernickel ]
14+ * VolumeControl: use action of the new indicator indicator-sound
15+ recently gained an action to increase and decrease the volume. This
16+ patch makes use of that to get rid of a bus round trip (to get the
17+ current volume) and a race (when the volume gets set between
18+ fetching the current volume and setting the new volume). (LP:
19+ #1219057)
20+
21+ [ Michael Terry ]
22+ * When AccountsService.backgroundFile is unset/invalid, have the
23+ greeter fall back to whatever the shell background is.
24+ * Add a tiny SessionBroadcast plugin that listens to unity-greeter-
25+ session-broadcast for the ShowHome signal.
26+
27+ [ Daniel d'Andrada ]
28+ * Remove obsolete, unused graphics.
29+ * Make MouseTouchAdaptor work with multiple QWindows.
30+
31+ [ Michael Zanetti ]
32+ * change how icons are searched a) try to find it the Icon as is b)
33+ prepend with Path if a Path variable is given c) fall back to the
34+ image://theme/ with just the icon name . (LP: #1225186)
35+ * fix an issue with removing a running app from the launcher and
36+ always store pinning to the config.
37+ * collapse any open preview when programmatically switching current
38+ dash index. (LP: #1221137)
39+
40+ [ Ubuntu daily release ]
41+ * Automatic snapshot from revision 333
42+
43+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Thu, 19 Sep 2013 15:15:07 +0000
44+
45+unity8 (7.81.3+13.10.20130916-0ubuntu1) saucy; urgency=low
46+
47+ [ Michael Zanetti ]
48+ * allow left edge gesture to minimize apps even when launcher is
49+ already visible.
50+ * Don't hide the launcher on changes in the stages.
51+ * ssh is now installed per default, but it's set to manual in the
52+ ssh.override.
53+
54+ [ Ubuntu daily release ]
55+ * Automatic snapshot from revision 320
56+
57+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Mon, 16 Sep 2013 11:49:28 +0000
58+
59+unity8 (7.81.3+13.10.20130912-0ubuntu1) saucy; urgency=low
60+
61+ [ Michael Zanetti ]
62+ * add support for finding icons from click package apps in the
63+ launcher.
64+ * update to latest launcher API for better integration with the
65+ AppManager.
66+
67+ [ Ricardo Mendoza ]
68+ * Fixes problems related to image 20130912.0, amongst: * Fix autopilot
69+ tests by preventing blocking of input during HUD button animations,
70+ only when fully visible * Fix loading of unity-mir library, major
71+ version wasn't specified so unless the dev package was there it
72+ would fail.
73+
74+ [ Ubuntu daily release ]
75+ * Automatic snapshot from revision 316
76+
77+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Thu, 12 Sep 2013 13:47:59 +0000
78+
79+unity8 (7.81.3+13.10.20130911.1-0ubuntu1) saucy; urgency=low
80+
81+ [ Michael Terry ]
82+ * Switch from deprecated image://gicon/ to new image://theme/.
83+
84+ [ Gerry Boland ]
85+ * Add OSKController so shell can control OSK correctly on Mir.
86+ * Remove InputFilterArea for bottom edge swipes, as applications also
87+ listen for such swipes for Toolbar reveal.
88+
89+ [ Ricardo Mendoza ]
90+ * Select the backend to use dynamically on runtime according to the
91+ QPA selected by the system.
92+
93+ [ Ubuntu daily release ]
94+ * Automatic snapshot from revision 311
95+
96+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 11 Sep 2013 16:22:55 +0000
97+
98+unity8 (7.81.3+13.10.20130911-0ubuntu1) saucy; urgency=low
99+
100+ [ Michal Hruby ]
101+ * Hide all gicon strings from the shell and use the image://theme icon
102+ provider that was recently added to the SDK.
103+
104+ [ Gerry Boland ]
105+ * Convert to new ApplicationManager API.
106+
107+ [ Nick Dedekind ]
108+ * Updated access point design as per spec.
109+ * Indicator visibility based on connection with backend service.
110+
111+ [ Albert Astals ]
112+ * Dash: Make assignments bindings This way if the model changes the
113+ item value also changes.
114+
115+ [ Michael Zanetti ]
116+ * adds support for highlighting the currently focused application in
117+ the launcher, adds tests.
118+ * include ~/.local/share/applications in launcher's .desktop file
119+ search path.
120+ * shrink size of area for revealing the HUD button and make it
121+ disappear on release again. fixes 1219035. (LP: #1219035)
122+ * revert revision 304 as it makes the Shell crash.
123+
124+ [ Michael Terry ]
125+ * Allow testers to set custom password or pin in demo mode, rather
126+ than hardcoding them.
127+ * Have the greeter use AccountsService to determine its background.
128+ (LP: #1218402)
129+ * Listen to changes in the "show edge demo" AccountsService setting.
130+
131+ [ Daniel d'Andrada ]
132+ * Update fake/mock plugins so that "./run --fake" works well again -
133+ You can now see the thumbnails of the fake running applications once
134+ again. - You no longer get hundreds of warnings due to icons not
135+ found.
136+ * Reset apps scope when returning from app to dash (LP #1193419) If an
137+ app is on foreground and you perform a long left-edge swipe to
138+ minimize it, and therefore return to the dash, the dash should be in
139+ the Applications scope and showing the running/recents applications.
140+ (LP: #1193419)
141+
142+ [ Ubuntu daily release ]
143+ * Automatic snapshot from revision 306
144+
145+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 11 Sep 2013 00:54:31 +0000
146+
147+unity8 (7.81.3+13.10.20130905.2-0ubuntu1) saucy; urgency=low
148+
149+ [ Michael Zanetti ]
150+ * Integrate Launcher with AppManager.
151+
152+ [ Nick Dedekind ]
153+ * Removed FIXME from slider int->double conversion.
154+
155+ [ Ubuntu daily release ]
156+ * Automatic snapshot from revision 291
157+
158+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Thu, 05 Sep 2013 10:48:02 +0000
159+
160+unity8 (7.81.3+13.10.20130904.1-0ubuntu1) saucy; urgency=low
161+
162+ [ Nicolas d'Offay ]
163+ * Switched infographic background at design's request.
164+
165+ [ Ubuntu daily release ]
166+ * Automatic snapshot from revision 287
167+
168+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 04 Sep 2013 07:34:57 +0000
169+
170+unity8 (7.81.3+13.10.20130904-0ubuntu1) saucy; urgency=low
171+
172+ [ mhall119 ]
173+ * Add a little bit of text to the last step of the tour telling the
174+ user how to end it and get to their phone.
175+
176+ [ Jussi Pakkanen ]
177+ * Use CCache if it is installed.
178+
179+ [ Nick Dedekind ]
180+ * Multiple icon/label support for indicators.
181+
182+ [ Albert Astals ]
183+ * Remove unneeded role.
184+
185+ [ Lars Uebernickel ]
186+ * Fall back to "ubuntu-mobile" icon theme if $UBUNTU_ICON_THEME is
187+ unset.
188+
189+ [ Michael Zanetti ]
190+ * Use MouseAreas in DashBar to enable clicking again.
191+ * load launcher default config from existing dconf key.
192+
193+ [ Ubuntu daily release ]
194+ * Automatic snapshot from revision 285
195+
196+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 04 Sep 2013 03:02:57 +0000
197+
198+unity8 (7.81.3+13.10.20130903.1-0ubuntu1) saucy; urgency=low
199+
200+ [ Michael Zanetti ]
201+ * workaround quicklist text color.
202+
203+ [ Ubuntu daily release ]
204+ * Automatic snapshot from revision 277
205+
206+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Tue, 03 Sep 2013 06:09:36 +0000
207+
1208unity8 (7.81.3+13.10.20130830-0ubuntu1) saucy; urgency=low
2209
3210 [ Pawel Stolowski ]
debian/control+10−7
@@ -9,6 +9,7 @@ Build-Depends: cmake,
99 libgl1-mesa-dev[!armhf] | libgl-dev[!armhf],
1010 libgl1-mesa-dri,
1111 libgles2-mesa-dev[armhf],
12+ libgsettings-qt-dev,
1213 libhud-client2-dev,
1314 libjson-perl,
1415 libnih-dbus-dev,
@@ -22,6 +23,7 @@ Build-Depends: cmake,
2223 libunity-api-dev (>= 7.80.3),
2324 libunity-core-6.0-dev (<< 7.80),
2425 libunity-dev (>= 7.0.12),
26+ libunity-mir-dev,
2527 libunity-scopes-json-def-phone,
2628 libupstart-dev,
2729 libusermetricsoutput1-dev,
@@ -53,7 +55,7 @@ Vcs-Browser: https://bazaar.launchpad.net/~unity-team/unity8/trunk
5355Package: indicators-client
5456Architecture: amd64 armhf i386
5557Depends: qmenumodel-qml (>= 0.2.7),
56− qtdeclarative5-ubuntu-ui-toolkit-plugin | qt-components-ubuntu,
58+ qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 0.1.46+13.10.20130829.1-0ubuntu1),
5759 unity8 (= ${binary:Version}),
5860 ${misc:Depends},
5961 ${shlibs:Depends},
@@ -64,13 +66,14 @@ Package: unity8
6466Architecture: any
6567Provides: indicator-renderer,
6668Depends: gsettings-desktop-schemas,
69+ libunity-mir1,
6770 qmenumodel-qml (>= 0.2.7),
6871 qtdeclarative5-dee-plugin,
6972 qtdeclarative5-gsettings1.0,
70− qtdeclarative5-ubuntu-ui-toolkit-plugin,
73+ qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 0.1.46+13.10.20130829.1-0ubuntu1),
7174 qtdeclarative5-unity-notifications-plugin | unity-notifications-impl,
7275 qtdeclarative5-xmllistmodel-plugin,
73− unity-launcher-impl-2,
76+ unity-launcher-impl-3,
7477 unity-notifications-impl-1,
7578 unity8-fake-env | qtubuntu-shell,
7679 unity8-private (= ${binary:Version}),
@@ -86,18 +89,18 @@ Description: Unity 8 shell
8689
8790Package: unity8-autopilot
8891Architecture: all
89−Depends: indicators-client (>= ${source:Version}),
92+Depends: gir1.2-glib-2.0,
93+ indicators-client (>= ${source:Version}),
9094 libautopilot-qt,
9195 libqt5test5,
9296 libqt5widgets5,
9397 python-evdev,
98+ python-gi,
9499 unity8 (>= ${source:Version}),
95100 unity8-fake-env (>= ${source:Version}),
96101 ${misc:Depends},
97102 ${python:Depends},
98103 ${shlibs:Depends},
99−Recommends: gir1.2-glib-2.0,
100− python-gi,
101104Description: Test package for Unity 8 shell
102105 Autopilot tests for the unity8 package
103106
@@ -119,7 +122,7 @@ Pre-Depends: ${misc:Pre-Depends},
119122Depends: ${misc:Depends},
120123 ${shlibs:Depends},
121124Provides: unity-launcher-impl,
122− unity-launcher-impl-2,
125+ unity-launcher-impl-3,
123126Description: Unity 8 private libs
124127 The Unity 8 shell is the primary user interface for Ubuntu devices.
125128 .
debian/unity8-private.install+1
@@ -3,6 +3,7 @@ usr/lib/*/unity8/qml/HudClient
33usr/lib/*/unity8/qml/LightDM
44usr/lib/*/unity8/qml/ListViewWithPageHeader
55usr/lib/*/unity8/qml/Powerd
6+usr/lib/*/unity8/qml/SessionBroadcast
67usr/lib/*/unity8/qml/Ubuntu
78usr/lib/*/unity8/qml/Unity
89usr/lib/*/unity8/qml/Utils
main.cpp+76−9
@@ -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)
@@ -65,13 +69,14 @@ void appendImportPaths(QQmlEngine *engine, const QStringList &paths)
6569
6670void resolveIconTheme() {
6771 const char *ubuntuIconTheme = getenv("UBUNTU_ICON_THEME");
68− if (ubuntuIconTheme != NULL) {
69− QIcon::setThemeName(ubuntuIconTheme);
72+ if (ubuntuIconTheme == NULL) {
73+ ubuntuIconTheme = "ubuntu-mobile";
7074 }
75+ QIcon::setThemeName(ubuntuIconTheme);
7176}
7277} // namespace {
7378
74−int main(int argc, char** argv)
79+int startShell(int argc, const char** argv, void* server)
7580{
7681 /* Workaround Qt platform integration plugin not advertising itself
7782 as having the following capabilities:
@@ -81,12 +86,29 @@ int main(int argc, char** argv)
8186 setenv("QML_FORCE_THREADED_RENDERER", "1", 1);
8287 setenv("QML_FIXED_ANIMATION_STEP", "1", 1);
8388
89+ const bool isUbuntuMirServer = qgetenv("QT_QPA_PLATFORM") == "ubuntumirserver";
90+
8491 QGuiApplication::setApplicationName("Unity 8");
85− 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+ }
86108
87109 resolveIconTheme();
88110
89− QStringList args = application.arguments();
111+ QStringList args = application->arguments();
90112 ApplicationArguments qmlArgs(args);
91113
92114 // The testability driver is only loaded by QApplication but not by QGuiApplication.
@@ -122,8 +144,7 @@ int main(int argc, char** argv)
122144 MouseTouchAdaptor *mouseTouchAdaptor = 0;
123145 if (args.contains(QLatin1String("-mousetouch"))) {
124146 mouseTouchAdaptor = new MouseTouchAdaptor;
125− mouseTouchAdaptor->setTargetWindow(view);
126− application.installNativeEventFilter(mouseTouchAdaptor);
147+ application->installNativeEventFilter(mouseTouchAdaptor);
127148 }
128149
129150 QPlatformNativeInterface* nativeInterface = QGuiApplication::platformNativeInterface();
@@ -138,18 +159,64 @@ int main(int argc, char** argv)
138159 QUrl source("Shell.qml");
139160 prependImportPaths(view->engine(), ::overrideImportPaths());
140161 appendImportPaths(view->engine(), ::fallbackImportPaths());
162+
163+ QStringList importPath = view->engine()->importPathList().filter("qt5/imports");
164+ if (isUbuntuMirServer) {
165+ importPath.first().append("/Unity-Mir");
166+ view->engine()->addImportPath(importPath.first());
167+ }
168+
141169 view->setSource(source);
142170 view->setColor("transparent");
143171
144− if (qgetenv("QT_QPA_PLATFORM") == "ubuntu" || args.contains(QLatin1String("-fullscreen"))) {
172+ if (qgetenv("QT_QPA_PLATFORM") == "ubuntu" || isUbuntuMirServer || args.contains(QLatin1String("-fullscreen"))) {
145173 view->showFullScreen();
146174 } else {
147175 view->show();
148176 }
149177
150− int result = application.exec();
178+ int result = application->exec();
151179
152180 delete mouseTouchAdaptor;
181+ delete application;
153182
154183 return result;
155184}
185+
186+int main(int argc, const char *argv[])
187+{
188+ // For ubuntumirserver/ubuntumirclient
189+ if (qgetenv("QT_QPA_PLATFORM").startsWith("ubuntumir")) {
190+ setenv("QT_QPA_PLATFORM", "ubuntumirserver", 1);
191+
192+ // If we use unity-mir directly, we automatically link to the Mir-server
193+ // platform-api bindings, which result in unexpected behaviour when
194+ // running the non-Mir scenario.
195+ QLibrary unityMir("unity-mir", 1);
196+ unityMir.load();
197+ if (!unityMir.isLoaded()) {
198+ qDebug() << "Library unity-mir not found/loaded";
199+ return 1;
200+ }
201+
202+ typedef QMirServer* (*createServer_t)(int, const char **);
203+ createServer_t createQMirServer = (createServer_t) unityMir.resolve("createQMirServer");
204+ if (!createQMirServer) {
205+ qDebug() << "unable to resolve symbol: createQMirServer";
206+ return 2;
207+ }
208+
209+ QMirServer* mirServer = createQMirServer(argc, argv);
210+
211+ typedef int (*runWithClient_t)(QMirServer*, std::function<int(int, const char**, void*)>);
212+ runWithClient_t runWithClient = (runWithClient_t) unityMir.resolve("runQMirServerWithClient");
213+ if (!runWithClient) {
214+ qDebug() << "unable to resolve symbol: runWithClient";
215+ return 3;
216+ }
217+
218+ return runWithClient(mirServer, startShell);
219+ } else {
220+ return startShell(argc, argv, nullptr);
221+ }
222+}
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/CMakeLists.txt+1
@@ -3,6 +3,7 @@ add_subdirectory(HudClient)
33add_subdirectory(LightDM)
44add_subdirectory(ListViewWithPageHeader)
55add_subdirectory(Powerd)
6+add_subdirectory(SessionBroadcast)
67add_subdirectory(Ubuntu)
78add_subdirectory(Unity)
89add_subdirectory(Utils)
plugins/SessionBroadcast/CMakeLists.txtnew file+13
@@ -0,0 +1,13 @@
1+include(Plugins)
2+
3+add_definitions(-DSM_BUSNAME=systemBus)
4+
5+add_library(SessionBroadcast-qml MODULE
6+ SessionBroadcast.cpp
7+ plugin.cpp
8+ )
9+
10+qt5_use_modules(SessionBroadcast-qml DBus Qml)
11+
12+export_qmlfiles(SessionBroadcast SessionBroadcast)
13+export_qmlplugin(SessionBroadcast 0.1 SessionBroadcast TARGETS SessionBroadcast-qml)
plugins/SessionBroadcast/SessionBroadcast.cppnew file+41
@@ -0,0 +1,41 @@
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 "SessionBroadcast.h"
20+#include <QDBusConnection>
21+
22+SessionBroadcast::SessionBroadcast(QObject* parent)
23+ : QObject(parent)
24+{
25+ auto connection = QDBusConnection::SM_BUSNAME();
26+
27+ connection.connect("com.canonical.Unity.Greeter.Broadcast",
28+ "/com/canonical/Unity/Greeter/Broadcast",
29+ "com.canonical.Unity.Greeter.Broadcast",
30+ "ShowHome",
31+ this,
32+ SLOT(onShowHome(const QString &)));
33+}
34+
35+void SessionBroadcast::onShowHome(const QString &username)
36+{
37+ // Only listen to requests meant for us
38+ if (username == qgetenv("USER")) {
39+ Q_EMIT showHome();
40+ }
41+}
plugins/SessionBroadcast/SessionBroadcast.hnew file+41
@@ -0,0 +1,41 @@
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_SESSIONBROADCAST_H
20+#define UNITY_SESSIONBROADCAST_H
21+
22+#include <QObject>
23+#include <QString>
24+
25+class QDBusInterface;
26+
27+class SessionBroadcast: public QObject
28+{
29+ Q_OBJECT
30+
31+public:
32+ explicit SessionBroadcast(QObject *parent = 0);
33+
34+Q_SIGNALS:
35+ void showHome();
36+
37+private Q_SLOTS:
38+ void onShowHome(const QString &username);
39+};
40+
41+#endif
plugins/SessionBroadcast/plugin.cppnew file+35
@@ -0,0 +1,35 @@
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+#include "plugin.h"
20+#include "SessionBroadcast.h"
21+
22+#include <QtQml>
23+
24+static QObject *broadcast_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
25+{
26+ Q_UNUSED(engine)
27+ Q_UNUSED(scriptEngine)
28+ return new SessionBroadcast();
29+}
30+
31+void SessionBroadcastPlugin::registerTypes(const char *uri)
32+{
33+ Q_ASSERT(uri == QLatin1String("SessionBroadcast"));
34+ qmlRegisterSingletonType<SessionBroadcast>(uri, 0, 1, "SessionBroadcast", broadcast_provider);
35+}
plugins/SessionBroadcast/plugin.hnew file+33
@@ -0,0 +1,33 @@
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_SESSIONBROADCAST_PLUGIN_H
20+#define UNITY_SESSIONBROADCAST_PLUGIN_H
21+
22+#include <QQmlExtensionPlugin>
23+
24+class SessionBroadcastPlugin : public QQmlExtensionPlugin
25+{
26+ Q_OBJECT
27+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
28+
29+public:
30+ void registerTypes(const char *uri);
31+};
32+
33+#endif
plugins/SessionBroadcast/qmldirnew file+3
@@ -0,0 +1,3 @@
1+module SessionBroadcast
2+plugin SessionBroadcast-qml
3+typeinfo plugin.qmltypes
plugins/Unity/CMakeLists.txt+1
@@ -47,6 +47,7 @@ set(QMLPLUGIN_SRC
4747 signalslist.cpp
4848 socialpreview.cpp
4949 socialpreviewcomment.cpp
50+ iconutils.cpp
5051 variantutils.cpp
5152)
5253
plugins/Unity/Indicators/CMakeLists.txt+9
@@ -34,11 +34,20 @@ set(IndicatorsQML_SOURCES
3434 rootactionstate.cpp
3535 unitymenumodelcache.cpp
3636 unitymenumodelstack.cpp
37+ visibleindicatorsmodel.cpp
3738)
3839add_definitions(-DUNITYINDICATORS_LIBRARY)
3940
41+set(IndicatorsQML_RESOURCES
42+ resources/indicators.qrc
43+)
44+
45+qt5_add_resources(IndicatorsQML_RESOURCES_RCC
46+ ${IndicatorsQML_RESOURCES}
47+)
4048
4149add_library(IndicatorsQml SHARED
50+ ${IndicatorsQML_RESOURCES_RCC}
4251 ${IndicatorsQML_SOURCES}
4352)
4453
plugins/Unity/Indicators/Network/qml/AccessPoint.qml+71−26
@@ -22,13 +22,15 @@ import Ubuntu.Components 0.1
2222import Ubuntu.Components.ListItems 0.1 as ListItem
2323import Unity.Indicators 0.1 as Indicators
2424
25−Indicators.FramedMenuItem {
26− id: accessPoint
25+Indicators.BaseMenuItem {
26+ id: menuItem
27+ implicitHeight: units.gu(5.5)
2728
2829 property bool checked: false
2930 property bool secure: false
3031 property bool adHoc: false
3132 property int signalStrength: 0
33+ property alias text: label.text
3234
3335 signal activate()
3436
@@ -37,36 +39,79 @@ Indicators.FramedMenuItem {
3739 checkBoxActive.checked = checked;
3840 }
3941
40− icon: {
41− var imageName = "nm-signal-100"
42−
43− if (adHoc) {
44− imageName = "nm-adhoc";
45− } else if (signalStrength == 0) {
46− imageName = "nm-signal-00";
47− } else if (signalStrength <= 25) {
48− imageName = "nm-signal-25";
49− } else if (signalStrength <= 50) {
50− imageName = "nm-signal-50";
51− } else if (signalStrength <= 75) {
52− imageName = "nm-signal-75";
42+ onClicked: {
43+ checkBoxActive.clicked();
44+ }
45+
46+ CheckBox {
47+ id: checkBoxActive
48+ height: units.gu(3)
49+ width: units.gu(3)
50+
51+ anchors {
52+ left: parent.left
53+ leftMargin: menuItem.__contentsMargins
54+ verticalCenter: parent.verticalCenter
5355 }
5456
55− if (secure) {
56− imageName += "-secure";
57+ onClicked: {
58+ menuItem.activate();
5759 }
58− return "image://gicon/" + imageName;
5960 }
6061
61− iconFrame: false
62− control: CheckBox {
63− id: checkBoxActive
64− height: units.gu(4)
65− width: units.gu(4)
66− anchors.centerIn: parent
62+ Image {
63+ id: iconSignal
6764
68− onClicked: {
69− accessPoint.activate();
65+ width: height
66+ height: Math.min(units.gu(5), parent.height - units.gu(1))
67+ anchors {
68+ left: checkBoxActive.right
69+ leftMargin: units.gu(1)
70+ verticalCenter: parent.verticalCenter
71+ }
72+
73+ source: {
74+ var imageName = "nm-signal-100"
75+
76+ if (adHoc) {
77+ imageName = "nm-adhoc";
78+ } else if (signalStrength == 0) {
79+ imageName = "nm-signal-00";
80+ } else if (signalStrength <= 25) {
81+ imageName = "nm-signal-25";
82+ } else if (signalStrength <= 50) {
83+ imageName = "nm-signal-50";
84+ } else if (signalStrength <= 75) {
85+ imageName = "nm-signal-75";
86+ }
87+ return "image://theme/" + imageName;
88+ }
89+ }
90+
91+ Label {
92+ id: label
93+ anchors {
94+ left: iconSignal.right
95+ leftMargin: units.gu(1)
96+ verticalCenter: parent.verticalCenter
97+ right: iconSecure.visible ? iconSecure.left : parent.right
98+ rightMargin: menuItem.__contentsMargins
99+ }
100+ elide: Text.ElideRight
101+ opacity: label.enabled ? 1.0 : 0.5
102+ }
103+
104+ Image {
105+ id: iconSecure
106+ visible: secure
107+ source: "qrc:/indicators/artwork/network/secure.svg"
108+
109+ width: height
110+ height: Math.min(units.gu(4), parent.height - units.gu(1))
111+ anchors {
112+ right: parent.right
113+ rightMargin: units.gu(1)
114+ verticalCenter: parent.verticalCenter
70115 }
71116 }
72117}
plugins/Unity/Indicators/indicator.cpp−2
@@ -51,7 +51,6 @@ void Indicator::init(const QString& busName, const QSettings& settings)
5151 }
5252 }
5353
54−
5554 QVariantMap properties;
5655 properties.clear();
5756 properties.insert("busType", 1);
@@ -87,7 +86,6 @@ void Indicator::setPosition(int position)
8786 }
8887}
8988
90−
9189QVariant Indicator::indicatorProperties() const
9290{
9391 return m_properties;
plugins/Unity/Indicators/indicator.h−4
@@ -29,10 +29,6 @@
2929class UNITYINDICATORS_EXPORT Indicator : public QObject
3030{
3131 Q_OBJECT
32− Q_PROPERTY(QString identifier READ identifier NOTIFY identifierChanged)
33− Q_PROPERTY(int position READ position NOTIFY positionChanged)
34− Q_PROPERTY(QVariant indicatorProperties READ indicatorProperties NOTIFY indicatorPropertiesChanged)
35−
3632public:
3733 typedef QSharedPointer<Indicator> Ptr;
3834
plugins/Unity/Indicators/indicators.h+1−1
@@ -79,7 +79,7 @@ public:
7979 WidgetSource,
8080 PageSource,
8181 IndicatorProperties,
82− IsValid
82+ IsVisible
8383 };
8484
8585 IndicatorsModelRole(QObject*parent=0):QObject(parent) {}
plugins/Unity/Indicators/indicatorsmodel.cpp−3
@@ -206,7 +206,6 @@ QHash<int, QByteArray> IndicatorsModel::roleNames() const
206206 roles[IndicatorsModelRole::WidgetSource] = "widgetSource";
207207 roles[IndicatorsModelRole::PageSource] = "pageSource";
208208 roles[IndicatorsModelRole::IndicatorProperties] = "indicatorProperties";
209− roles[IndicatorsModelRole::IsValid] = "isValid";
210209 }
211210 return roles;
212211}
@@ -269,8 +268,6 @@ QVariant IndicatorsModel::data(const QModelIndex &index, int role) const
269268 return QVariant(indicator->indicatorProperties());
270269 }
271270 break;
272− case IndicatorsModelRole::IsValid:
273− return (indicator ? true : false);
274271 case IndicatorsModelRole::Title:
275272 case IndicatorsModelRole::Description:
276273 case IndicatorsModelRole::WidgetSource:
plugins/Unity/Indicators/indicatorsmodel.h+2−1
@@ -44,7 +44,7 @@ public:
4444 Q_INVOKABLE void load();
4545 Q_INVOKABLE void unload();
4646
47− Q_INVOKABLE QVariant data(int row, int role = Qt::DisplayRole) const;
47+ Q_INVOKABLE QVariant data(int row, int role) const;
4848
4949 /* QAbstractItemModel */
5050 QHash<int, QByteArray> roleNames() const;
@@ -56,6 +56,7 @@ public:
5656 void setIndicatorData(const QVariant& data);
5757 QVariant indicatorData() const;
5858
59+
5960Q_SIGNALS:
6061 void countChanged();
6162 void indicatorDataChanged(const QVariant& data);
plugins/Unity/Indicators/plugin.cpp+2
@@ -32,6 +32,7 @@
3232#include "rootactionstate.h"
3333#include "unitymenumodelcache.h"
3434#include "unitymenumodelstack.h"
35+#include "visibleindicatorsmodel.h"
3536
3637static QObject* menuModelCacheSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
3738 Q_UNUSED(engine);
@@ -47,6 +48,7 @@ void Indicators2Plugin::registerTypes(const char *uri)
4748 qmlRegisterType<UnityMenuModelStack>(uri, 0, 1, "UnityMenuModelStack");
4849 qmlRegisterType<RootActionState>(uri, 0, 1, "RootActionState");
4950 qmlRegisterType<ModelPrinter>(uri, 0, 1, "ModelPrinter");
51+ qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");
5052
5153 qmlRegisterSingletonType<UnityMenuModelCache>(uri, 0, 1, "UnityMenuModelCache", menuModelCacheSingleton);
5254
plugins/Unity/Indicators/qml/IndicatorBase.qml−5
@@ -24,8 +24,6 @@ import Unity.Indicators 0.1 as Indicators
2424Item {
2525 id: indicatorItem
2626
27− // FIXME : should be disabled until bus available when we have desktop indicators
28− // for now, disable when we dont habe the correct profile.
2927 enabled: menuObjectPaths.hasOwnProperty(device)
3028
3129 //const
@@ -39,9 +37,6 @@ Item {
3937
4038 property string deviceMenuObjectPath: menuObjectPaths.hasOwnProperty(device) ? menuObjectPaths[device] : ""
4139
42− signal actionGroupUpdated()
43− signal modelUpdated()
44−
4540 property alias menuModel: cachedModel.model
4641
4742 CachedUnityMenuModel {
plugins/Unity/Indicators/qml/IndicatorWidget.qml+1
@@ -24,6 +24,7 @@ IndicatorBase {
2424 id: indicatorWidget
2525
2626 active: true
27+ enabled: false
2728 property int iconSize: height - units.gu(0.5)
2829
2930 property var actionState: Indicators.RootActionState {
plugins/Unity/Indicators/qml/MenuItemFactory.qml+6−21
@@ -73,23 +73,8 @@ Item {
7373 'max-icon': 'icon'});
7474 }
7575
76− // FIXME: The interval should be [0.0 - 1.0]. Unfortunately, when
77− // reaching the boundaries (0.0 or 1.0), the value is converted
78− // to an integer when automatically wrapped in a variant when
79− // passed to QStateAction::updateState(…). The server chokes on
80− // those values, complaining that they’re not of the right type…
8176 onChangeState: {
82− if (value == Math.round(value)) {
83− if (value >= maximumValue) {
84− model.changeState(modelIndex, maximumValue - 0.000001);
85− } else if (value <= minimumValue) {
86− model.changeState(modelIndex, minimumValue + 0.000001);
87− } else {
88− model.changeState(modelIndex, value * 1.000001);
89− }
90− } else {
91− model.changeState(modelIndex, value);
92− }
77+ model.changeState(modelIndex, value);
9378 }
9479 }
9580 }
@@ -174,17 +159,17 @@ Item {
174159 id: accessPoint;
175160 ICNetwork.AccessPoint {
176161 property QtObject menu: null
177−// property var strenthAction: QMenuModel.UnityMenuAction {
178−// model: menuFactory.model ? menuFactory.model : null
179−// name: menu ? menu.ext.xCanonicalWifiApStrengthAction : ""
180−// }
162+ property var strengthAction: QMenuModel.UnityMenuAction {
163+ model: menuFactory.model ? menuFactory.model : null
164+ name: menu ? menu.ext.xCanonicalWifiApStrengthAction : ""
165+ }
181166
182167 text: menu && menu.label ? menu.label : ""
183168 icon: menu ? menu.icon : ""
184169 secure: menu ? menu.ext.xCanonicalWifiApIsSecure : false
185170 adHoc: menu ? menu.ext.xCanonicalWifiApIsAdhoc : false
186171 checked: menu ? menu.isToggled : false
187−// signalStrength: strenthAction.valid ? strenthAction.state : 0
172+ signalStrength: strengthAction.valid ? strengthAction.state : 0
188173 enabled: menu ? menu.sensitive : false
189174
190175 Component.onCompleted: {
plugins/Unity/Indicators/resources/artwork/network/secure.svgnew file+71
@@ -0,0 +1,71 @@
1+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+<!-- Created with Inkscape (http://www.inkscape.org/) -->
3+
4+<svg
5+ xmlns:dc="http://purl.org/dc/elements/1.1/"
6+ xmlns:cc="http://creativecommons.org/ns#"
7+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
8+ xmlns:svg="http://www.w3.org/2000/svg"
9+ xmlns="http://www.w3.org/2000/svg"
10+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
11+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
12+ width="64"
13+ height="64"
14+ id="svg2986"
15+ version="1.1"
16+ inkscape:version="0.48.4 r9939"
17+ sodipodi:docname="secure.svg">
18+ <defs
19+ id="defs2988" />
20+ <sodipodi:namedview
21+ id="base"
22+ pagecolor="#ffffff"
23+ bordercolor="#666666"
24+ borderopacity="1.0"
25+ inkscape:pageopacity="0.0"
26+ inkscape:pageshadow="2"
27+ inkscape:zoom="7.9180415"
28+ inkscape:cx="7.5048745"
29+ inkscape:cy="29.401628"
30+ inkscape:current-layer="layer1"
31+ showgrid="true"
32+ inkscape:grid-bbox="true"
33+ inkscape:document-units="px"
34+ inkscape:snap-grids="false"
35+ inkscape:window-width="1549"
36+ inkscape:window-height="876"
37+ inkscape:window-x="51"
38+ inkscape:window-y="24"
39+ inkscape:window-maximized="1">
40+ <inkscape:grid
41+ type="xygrid"
42+ id="grid3012"
43+ empspacing="5"
44+ visible="true"
45+ enabled="true"
46+ snapvisiblegridlinesonly="true" />
47+ </sodipodi:namedview>
48+ <metadata
49+ id="metadata2991">
50+ <rdf:RDF>
51+ <cc:Work
52+ rdf:about="">
53+ <dc:format>image/svg+xml</dc:format>
54+ <dc:type
55+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
56+ <dc:title />
57+ </cc:Work>
58+ </rdf:RDF>
59+ </metadata>
60+ <g
61+ id="layer1"
62+ inkscape:label="Layer 1"
63+ inkscape:groupmode="layer"
64+ transform="translate(0,32)">
65+ <path
66+ inkscape:connector-curvature="0"
67+ d="M 29.999999,-18 C 25.568001,-18 22,-14.432 22,-10 v 6 h -2 c -1.107999,0 -2,0.892 -2,2 v 18 c 0,1.108 0.892001,2 2,2 h 24 c 1.108,0 2,-0.892 2,-2 V -2 c 0,-1.108 -0.892,-2 -2,-2 h -2 v -6 c 0,-4.432 -3.568001,-8 -8.000001,-8 h -4 z m 0,4 h 4 c 2.216,0 4,1.784 4,4 v 6 H 26.000001 v -6 c 0,-2.216 1.784,-4 3.999998,-4 z"
68+ style="fill:#dfdbd2;fill-rule:evenodd"
69+ id="path8" />
70+ </g>
71+</svg>
plugins/Unity/Indicators/resources/indicators.qrcnew file+5
@@ -0,0 +1,5 @@
1+<RCC>
2+ <qresource prefix="/indicators">
3+ <file>artwork/network/secure.svg</file>
4+ </qresource>
5+</RCC>
plugins/Unity/Indicators/rootactionstate.cpp+52−22
@@ -108,25 +108,32 @@ bool RootActionState::isValid() const
108108 return m_menu && m_menu->rowCount() > 0;
109109}
110110
111−QString RootActionState::label() const
111+QString RootActionState::leftLabel() const
112112{
113113 if (!isValid()) return QString();
114114
115− return m_cachedState.value("label", QVariant::fromValue(QString())).toString();
115+ return m_cachedState.value("pre-label", QVariant::fromValue(QString())).toString();
116116}
117117
118−QString RootActionState::icon() const
118+QString RootActionState::rightLabel() const
119119{
120120 if (!isValid()) return QString();
121121
122− return m_cachedState.value("icon", QVariant::fromValue(QString())).toString();
122+ return m_cachedState.value("label", QVariant::fromValue(QString())).toString();
123+}
124+
125+QStringList RootActionState::icons() const
126+{
127+ if (!isValid()) return QStringList();
128+
129+ return m_cachedState.value("icons", QVariant::fromValue(QStringList())).toStringList();
123130}
124131
125132QString RootActionState::accessibleName() const
126133{
127134 if (!isValid()) return QString();
128135
129− return m_cachedState.value("accessible-name", QVariant::fromValue(QString())).toString();
136+ return m_cachedState.value("accessible-desc", QVariant::fromValue(QString())).toString();
130137}
131138
132139bool RootActionState::isVisible() const
@@ -141,15 +148,15 @@ static QString iconUri(GIcon *icon)
141148 QString uri;
142149
143150 if (G_IS_THEMED_ICON (icon)) {
144−
145151 const gchar* const* iconNames = g_themed_icon_get_names (G_THEMED_ICON (icon));
146− guint index = 0;
147− while(iconNames[index] != NULL) {
148− if (QIcon::hasThemeIcon(iconNames[index])) {
149− uri = QString("image://theme/%1").arg(iconNames[index]);
150− break;
151− }
152− 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(","));
153160 }
154161 }
155162 else if (G_IS_FILE_ICON (icon)) {
@@ -198,16 +205,39 @@ QVariant RootActionState::toQVariant(GVariant* state) const
198205 while (g_variant_iter_loop (&iter, "{sv}", &key, &vvalue))
199206 {
200207 QString str = QString::fromUtf8(key);
201− if (str == "icon") {
208+ if (str == "icon" && !qmap.contains("icons")) {
209+ QStringList icons;
210+
202211 // FIXME - should be sending a url.
203− GIcon *icon = g_icon_deserialize (vvalue);
204− if (icon) {
205− qmap.insert(str, iconUri(icon));
206− g_object_unref (icon);
212+ GIcon *gicon = g_icon_deserialize (vvalue);
213+ if (gicon) {
214+ icons << iconUri(gicon);
215+ g_object_unref (gicon);
207216 }
208− else {
209− qmap.insert(str, QVariant(""));
217+ qmap.insert("icons", icons);
218+
219+ } else if (str == "icons") {
220+
221+ QStringList icons;
222+
223+ if (g_variant_type_is_array(g_variant_get_type(vvalue))) {
224+
225+
226+ for (int i = 0, iMax = g_variant_n_children(vvalue); i < iMax; i++) {
227+ GVariant *child = g_variant_get_child_value(vvalue, i);
228+
229+ // FIXME - should be sending a url.
230+ GIcon *gicon = g_icon_deserialize (child);
231+ if (gicon) {
232+ icons << iconUri(gicon);
233+ g_object_unref (gicon);
234+ }
235+ g_variant_unref(child);
236+ }
210237 }
238+ // will overwrite icon.
239+ qmap.insert("icons", icons);
240+
211241 } else {
212242 qmap.insert(str, ActionStateParser::toQVariant(vvalue));
213243 }
@@ -230,12 +260,12 @@ QVariant RootActionState::toQVariant(GVariant* state) const
230260 &visible);
231261
232262 qmap["label"] = label ? QString::fromUtf8(label) : "";
233− qmap["accessible-name"] = accessible_name ? QString::fromUtf8(accessible_name) : "";
263+ qmap["accessible-desc"] = accessible_name ? QString::fromUtf8(accessible_name) : "";
234264 qmap["visible"] = visible;
235265
236266 gicon = g_icon_new_for_string (icon, NULL);
237267 if (gicon) {
238− qmap["icon"] = iconUri(gicon);
268+ qmap["icons"] = QStringList() << iconUri(gicon);
239269 g_object_unref (gicon);
240270 }
241271
plugins/Unity/Indicators/rootactionstate.h+9−6
@@ -32,8 +32,9 @@ class UNITYINDICATORS_EXPORT RootActionState : public ActionStateParser
3232 Q_PROPERTY(UnityMenuModel* menu READ menu WRITE setMenu NOTIFY menuChanged)
3333
3434 Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
35− Q_PROPERTY(QString label READ label NOTIFY labelChanged)
36− Q_PROPERTY(QString icon READ icon NOTIFY iconChanged)
35+ Q_PROPERTY(QString leftLabel READ leftLabel NOTIFY leftLabelChanged)
36+ Q_PROPERTY(QString rightLabel READ rightLabel NOTIFY rightLabelChanged)
37+ Q_PROPERTY(QStringList icons READ icons NOTIFY iconsChanged)
3738 Q_PROPERTY(QString accessibleName READ accessibleName NOTIFY accessibleNameChanged)
3839 Q_PROPERTY(bool visible READ isVisible NOTIFY visibleChanged)
3940public:
@@ -47,8 +48,9 @@ public:
4748 void setIndex(int index);
4849
4950 bool isValid() const;
50− QString label() const;
51− QString icon() const;
51+ QString leftLabel() const;
52+ QString rightLabel() const;
53+ QStringList icons() const;
5254 QString accessibleName() const;
5355 bool isVisible() const;
5456
@@ -62,8 +64,9 @@ Q_SIGNALS:
6264 void indexChanged();
6365
6466 void validChanged();
65− void labelChanged();
66− void iconChanged();
67+ void leftLabelChanged();
68+ void rightLabelChanged();
69+ void iconsChanged();
6770 void accessibleNameChanged();
6871 void visibleChanged();
6972
plugins/Unity/Indicators/visibleindicatorsmodel.cppnew file+94
@@ -0,0 +1,94 @@
1+/*
2+ * Copyright (C) 2012, 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+// self
18+#include "visibleindicatorsmodel.h"
19+#include "indicators.h"
20+
21+VisibleIndicatorsModel::VisibleIndicatorsModel(QObject *parent)
22+ : QIdentityProxyModel(parent),
23+ m_inserting(false)
24+{
25+ QObject::connect(this, SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(onBeginRowInserted(QModelIndex, int, int)));
26+ QObject::connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(onRowInserted(QModelIndex, int, int)));
27+}
28+
29+QHash<int, QByteArray> VisibleIndicatorsModel::roleNames() const
30+{
31+ static QHash<int, QByteArray> roles;
32+ if (roles.isEmpty())
33+ {
34+ roles[IndicatorsModelRole::Identifier] = "identifier";
35+ roles[IndicatorsModelRole::Position] = "position";
36+ roles[IndicatorsModelRole::Title] = "title";
37+ roles[IndicatorsModelRole::Description] = "description";
38+ roles[IndicatorsModelRole::WidgetSource] = "widgetSource";
39+ roles[IndicatorsModelRole::PageSource] = "pageSource";
40+ roles[IndicatorsModelRole::IndicatorProperties] = "indicatorProperties";
41+ roles[IndicatorsModelRole::IsVisible] = "isVisible";
42+ }
43+ return roles;
44+}
45+
46+void VisibleIndicatorsModel::setSourceModel(QAbstractItemModel *model)
47+{
48+ if (sourceModel() != model) {
49+ QIdentityProxyModel::setSourceModel(model);
50+ Q_EMIT modelChanged();
51+ }
52+}
53+
54+QVariantMap VisibleIndicatorsModel::visible() const
55+{
56+ return m_visible;
57+}
58+
59+void VisibleIndicatorsModel::onBeginRowInserted(const QModelIndex&, int, int)
60+{
61+ m_inserting = true;
62+}
63+
64+void VisibleIndicatorsModel::onRowInserted(const QModelIndex&, int, int)
65+{
66+ m_inserting = false;
67+}
68+
69+void VisibleIndicatorsModel::setVisible(const QVariantMap& visible)
70+{
71+ if (m_visible != visible) {
72+ m_visible = visible;
73+ Q_EMIT visibleChanged();
74+
75+ // need to tell the view that the visible data has changed.
76+ if (!m_inserting && rowCount() > 0) {
77+ Q_EMIT dataChanged(index(0, 0), index(rowCount() - 1, 0), QVector<int>() << IndicatorsModelRole::IsVisible);
78+ }
79+ }
80+}
81+
82+QVariant VisibleIndicatorsModel::data(const QModelIndex &index, int role) const
83+{
84+ if (role != IndicatorsModelRole::IsVisible) {
85+ return QIdentityProxyModel::data(index, role);
86+ }
87+
88+ if (!index.isValid()) {
89+ return false;
90+ }
91+
92+ QString ident = QIdentityProxyModel::data(index, IndicatorsModelRole::Identifier).toString();
93+ return m_visible.value(ident, false).toBool();
94+}
plugins/Unity/Indicators/visibleindicatorsmodel.hnew file+56
@@ -0,0 +1,56 @@
1+/*
2+ * Copyright (C) 2012, 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:
17+ * Nick Dedekind <nick.dedekind@canonical.com>
18+ */
19+
20+#ifndef VISIBLEINDICATORSMODEL_H
21+#define VISIBLEINDICATORSMODEL_H
22+
23+#include <QIdentityProxyModel>
24+
25+class VisibleIndicatorsModel : public QIdentityProxyModel
26+{
27+ Q_OBJECT
28+
29+ Q_PROPERTY(QAbstractItemModel* model READ sourceModel WRITE setSourceModel NOTIFY modelChanged)
30+ Q_PROPERTY(QVariantMap visible READ visible WRITE setVisible NOTIFY visibleChanged)
31+
32+public:
33+ explicit VisibleIndicatorsModel(QObject *parent = 0);
34+
35+ virtual void setSourceModel(QAbstractItemModel *model);
36+ virtual QHash<int, QByteArray> roleNames() const;
37+ virtual QVariant data(const QModelIndex &index, int role) const;
38+
39+ QVariantMap visible() const;
40+ void setVisible(const QVariantMap& visible);
41+
42+public Q_SLOTS:
43+ void onBeginRowInserted(const QModelIndex&, int start, int end);
44+ void onRowInserted(const QModelIndex&, int start, int end);
45+
46+Q_SIGNALS:
47+ void totalCountChanged();
48+ void modelChanged();
49+ void visibleChanged();
50+
51+private:
52+ QVariantMap m_visible;
53+ bool m_inserting;
54+};
55+
56+#endif // VISIBLEINDICATORSMODEL_H
plugins/Unity/IndicatorsLegacy/Messaging/qml/GroupedMessage.qml+1−1
@@ -44,7 +44,7 @@ Indicators.BasicMenuItem {
4444 height: units.gu(6)
4545 width: units.gu(6)
4646 image: Image {
47− source: menu && (menu.extra.canonical_icon.length > 0) ? "image://gicon/" + encodeURI(menu.extra.canonical_icon) : "qrc:/indicators/artwork/messaging/default_app.svg"
47+ source: menu && (menu.extra.canonical_icon.length > 0) ? "image://theme/" + encodeURI(menu.extra.canonical_icon) : "qrc:/indicators/artwork/messaging/default_app.svg"
4848 fillMode: Image.PreserveAspectFit
4949 }
5050 }
plugins/Unity/IndicatorsLegacy/Messaging/qml/HeroMessage.qml+2−2
@@ -48,8 +48,8 @@ Indicators.BasicMenuItem {
4848 anchors.left: parent.left
4949 anchors.right: parent.right
5050
51− avatar: menu && (menu.extra.canonical_icon.length > 0) ? "image://gicon/" + encodeURI(menu.extra.canonical_icon) : "qrc:/indicators/artwork/messaging/default_contact.png"
52− icon: menu && (menu.extra.canonical_app_icon.length > 0) ? "image://gicon/" + encodeURI(menu.extra.canonical_app_icon) : ""
51+ avatar: menu && (menu.extra.canonical_icon.length > 0) ? "image://theme/" + encodeURI(menu.extra.canonical_icon) : "qrc:/indicators/artwork/messaging/default_contact.png"
52+ icon: menu && (menu.extra.canonical_app_icon.length > 0) ? "image://theme/" + encodeURI(menu.extra.canonical_app_icon) : ""
5353 appIcon: icon
5454
5555 state: heroMessage.state
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/IndicatorsLegacy/qml/IndicatorWidget.qml+2−2
@@ -23,7 +23,7 @@ import Unity.IndicatorsLegacy 0.1 as Indicators
2323IndicatorBase {
2424 id: indicatorWidget
2525
26−// enabled: false // FIXME : should be disabled until bus available when we have desktop indicators
26+ enabled: false
2727 property var action: undefined
2828 property bool started: (busType != 0) && (busName != "") && (deviceMenuObjectPath != "")
2929 property int iconSize: height - units.gu(0.5)
@@ -40,7 +40,6 @@ IndicatorBase {
4040 actionGroup.stop();
4141 }
4242 }
43− onActionChanged: actionStateChanged()
4443 onActionGroupUpdated: update_state()
4544 onModelUpdated: update_state()
4645
@@ -57,6 +56,7 @@ IndicatorBase {
5756
5857 if (extra.canonical_type === rootMenuType) {
5958 action = actionGroup.action(proxyModel.data(0, Indicators.FlatMenuProxyModelRole.Action));
59+ actionStateChanged();
6060 }
6161 }
6262
plugins/Unity/Launcher/CMakeLists.txt+7−2
@@ -1,11 +1,14 @@
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)
4+pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
35
46add_definitions(-DSM_BUSNAME=systemBus)
57
68include_directories(
79 ${CMAKE_CURRENT_SOURCE_DIR}
810 ${CMAKE_SOURCE_DIR}/plugins/AccountsService
11+ ${GSETTINGS_QT_INCLUDE_DIRS}
912)
1013
1114set(QMLLAUNCHERPLUGIN_SRC
@@ -15,7 +18,7 @@ set(QMLLAUNCHERPLUGIN_SRC
1518 quicklistmodel.cpp
1619 common/quicklistentry.cpp
1720 backend/launcherbackend.cpp
18− ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsService.cpp
21+ ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsServiceDBusAdaptor.cpp
1922 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h
2023 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherModelInterface.h
2124 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/QuickListModelInterface.h
@@ -25,6 +28,8 @@ add_library(UnityLauncher-qml MODULE
2528 ${QMLLAUNCHERPLUGIN_SRC}
2629 )
2730
31+target_link_libraries(UnityLauncher-qml ${GSETTINGS_QT_LDFLAGS})
32+
2833qt5_use_modules(UnityLauncher-qml DBus Qml)
2934
3035# export the qmldir and qmltypes files
plugins/Unity/Launcher/backend/launcherbackend.cpp+192−100
@@ -18,88 +18,117 @@
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>
2525#include <QDBusArgument>
2626#include <QFileInfo>
27+#include <QGSettings>
28+#include <QDebug>
29+
30+class LauncherBackendItem
31+{
32+public:
33+ LauncherBackendItem(): pinned(false) {}
34+
35+ QString desktopFile;
36+ QString displayName;
37+ QString icon;
38+ bool pinned;
39+};
2740
2841LauncherBackend::LauncherBackend(bool useStorage, QObject *parent):
2942 QObject(parent),
3043 m_accounts(nullptr)
3144{
3245 if (useStorage) {
33− m_accounts = new AccountsService(this);
46+ m_accounts = new AccountsServiceDBusAdaptor(this);
3447 }
35− setUser(qgetenv("USER"));
48+ m_user = qgetenv("USER");
49+ syncFromAccounts();
3650}
3751
3852LauncherBackend::~LauncherBackend()
3953{
40− clearItems();
41−}
54+ m_storedApps.clear();
4255
43−void LauncherBackend::clearItems()
44−{
45− for (LauncherBackendItem &app: m_storedApps) {
46− delete app.settings;
56+ Q_FOREACH(LauncherBackendItem *item, m_itemCache) {
57+ delete item;
4758 }
48− m_storedApps.clear();
59+ m_itemCache.clear();
4960}
5061
5162QStringList LauncherBackend::storedApplications() const
5263{
53− auto files = QStringList();
54− for (const LauncherBackendItem &app: m_storedApps) {
55− files << app.settings->fileName();
56− }
57− return files;
64+ return m_storedApps;
5865}
5966
6067void LauncherBackend::setStoredApplications(const QStringList &appIds)
6168{
62− // Record all existing pinned apps, so we can notice them in new list
63− auto pinnedItems = QStringList();
64− for (LauncherBackendItem &app: m_storedApps) {
65− if (app.pinned) {
66− pinnedItems.append(app.settings->fileName());
69+ if (appIds.count() < m_storedApps.count()) {
70+ Q_FOREACH(const QString &appId, m_storedApps) {
71+ if (!appIds.contains(appId)) {
72+ delete m_itemCache.take(appId);
73+ }
6774 }
6875 }
69−
70− clearItems();
71−
72− for (const QString &appId: appIds) {
73− loadApp(makeAppDetails(appId, pinnedItems.contains(desktopFile(appId))));
76+ m_storedApps = appIds;
77+ Q_FOREACH(const QString &appId, appIds) {
78+ if (!m_itemCache.contains(appId)) {
79+ QString df = findDesktopFile(appId);
80+ if (!df.isEmpty()) {
81+ LauncherBackendItem *item = parseDesktopFile(df);
82+ m_itemCache.insert(appId, item);
83+ } else {
84+ // Cannot find any data for that app... ignoring it.
85+ qWarning() << "cannot find desktop file for" << appId << ". discarding app.";
86+ m_storedApps.removeAll(appId);
87+ }
88+ }
7489 }
75−
7690 syncToAccounts();
7791}
7892
7993QString LauncherBackend::desktopFile(const QString &appId) const
8094{
81− QFileInfo fileInfo(QDir("/usr/share/applications"), appId);
82− return fileInfo.absoluteFilePath();
95+ LauncherBackendItem *item = m_itemCache.value(appId);
96+ if (item) {
97+ return item->desktopFile;
98+ }
99+
100+ return findDesktopFile(appId);
83101}
84102
85103QString LauncherBackend::displayName(const QString &appId) const
86104{
87− auto desktopFile = parseDesktopFile(appId);
88− auto displayName = desktopFile->value("Desktop Entry/Name").toString();
89− delete desktopFile;
90− return displayName;
105+ LauncherBackendItem *item = m_itemCache.value(appId);
106+ if (item) {
107+ return item->displayName;
108+ }
109+
110+ QString df = findDesktopFile(appId);
111+ if (!df.isEmpty()) {
112+ LauncherBackendItem *item = parseDesktopFile(df);
113+ m_itemCache.insert(appId, item);
114+ return item->displayName;
115+ }
116+
117+ return QString();
91118}
92119
93120QString LauncherBackend::icon(const QString &appId) const
94121{
95− auto desktopFile = parseDesktopFile(appId);
96− auto iconName = desktopFile->value("Desktop Entry/Icon").toString();
97− delete desktopFile;
98−
99− if (!iconName.isEmpty()) {
100− QFileInfo iconFileInfo(iconName);
101− if (iconFileInfo.isRelative()) {
102− iconName = "image://gicon/" + iconName;
122+ QString iconName;
123+ LauncherBackendItem *item = m_itemCache.value(appId);
124+ if (item) {
125+ iconName = item->icon;
126+ } else {
127+ QString df = findDesktopFile(appId);
128+ if (!df.isEmpty()) {
129+ LauncherBackendItem *item = parseDesktopFile(df);
130+ m_itemCache.insert(appId, item);
131+ iconName = item->icon;
103132 }
104133 }
105134
@@ -108,19 +137,26 @@ QString LauncherBackend::icon(const QString &appId) const
108137
109138bool LauncherBackend::isPinned(const QString &appId) const
110139{
111− auto index = findItem(appId);
112− if (index < 0) {
113− return false;
114− } else {
115− return m_storedApps[index].pinned;
140+ LauncherBackendItem *item = m_itemCache.value(appId);
141+ if (item) {
142+ return item->pinned;
116143 }
144+ return false;
117145}
118146
119147void LauncherBackend::setPinned(const QString &appId, bool pinned)
120148{
121− auto index = findItem(appId);
122− if (index >= 0 && !m_storedApps[index].pinned) {
123− m_storedApps[index].pinned = pinned;
149+ if (!m_storedApps.contains(appId)) {
150+ return;
151+ }
152+
153+ LauncherBackendItem *item = m_itemCache.value(appId);
154+ if (!item) {
155+ item = new LauncherBackendItem();
156+ m_itemCache.insert(appId, item);
157+ }
158+ if (item->pinned != pinned) {
159+ item->pinned = pinned;
124160 syncToAccounts();
125161 }
126162}
@@ -153,8 +189,10 @@ int LauncherBackend::count(const QString &appId) const
153189
154190void LauncherBackend::setUser(const QString &username)
155191{
156− m_user = username;
157− syncFromAccounts();
192+ if (qgetenv("USER") == "lightdm" && m_user != username) {
193+ m_user = username;
194+ syncFromAccounts();
195+ }
158196}
159197
160198void LauncherBackend::triggerQuickListAction(const QString &appId, const QString &quickListId)
@@ -169,75 +207,140 @@ void LauncherBackend::syncFromAccounts()
169207 QList<QVariantMap> apps;
170208 bool defaults = true;
171209
172− clearItems();
210+ m_storedApps.clear();
173211
174− if (m_user != "" && m_accounts != nullptr) {
175− auto variant = m_accounts->getUserProperty(m_user, "launcher-items");
212+ if (m_accounts && !m_user.isEmpty()) {
213+ QVariant variant = m_accounts->getUserProperty(m_user, "com.canonical.unity.AccountsService", "launcher-items");
176214 apps = qdbus_cast<QList<QVariantMap>>(variant.value<QDBusArgument>());
177215 defaults = isDefaultsItem(apps);
178216 }
179217
180− // TODO: load default pinned ones from default config, instead of hardcoding here...
181− if (defaults) {
182− apps <<
183− makeAppDetails("dialer-app.desktop", true) <<
184− makeAppDetails("messaging-app.desktop", true) <<
185− makeAppDetails("address-book-app.desktop", true) <<
186− makeAppDetails("camera-app.desktop", true) <<
187− makeAppDetails("gallery-app.desktop", true) <<
188− makeAppDetails("facebook-webapp.desktop", true) <<
189− makeAppDetails("webbrowser-app.desktop", true) <<
190− makeAppDetails("twitter-webapp.desktop", true) <<
191− makeAppDetails("gmail-webapp.desktop", true) <<
192− makeAppDetails("ubuntu-weather-app.desktop", true) <<
193− makeAppDetails("notes-app.desktop", true) <<
194− makeAppDetails("calendar-app.desktop", true);
195− }
196−
197− for (const QVariant &app: apps) {
198− loadApp(app.toMap());
218+ if (m_accounts && defaults) { // Checking accounts as it'll be null when !useStorage
219+ QGSettings gSettings("com.canonical.Unity.Launcher", "/com/canonical/unity/launcher/");
220+ Q_FOREACH(const QString &entry, gSettings.get("favorites").toStringList()) {
221+ if (entry.startsWith("application://")) {
222+ QString appId = entry;
223+ // Transform "application://foobar.desktop" to "foobar"
224+ appId.remove("application://");
225+ if (appId.endsWith(".desktop")) {
226+ appId.chop(8);
227+ }
228+ QString df = findDesktopFile(appId);
229+
230+ if (!df.isEmpty()) {
231+ m_storedApps << appId;
232+
233+ if (!m_itemCache.contains(appId)) {
234+ m_itemCache.insert(appId, parseDesktopFile(df));
235+ }
236+ m_itemCache.value(appId)->pinned = true;
237+ }
238+ }
239+ }
240+ } else {
241+ for (const QVariant &app: apps) {
242+ loadFromVariant(app.toMap());
243+ }
199244 }
200245}
201246
202247void LauncherBackend::syncToAccounts()
203248{
204− if (m_user != "" && m_accounts != nullptr) {
249+ if (m_accounts && !m_user.isEmpty()) {
205250 QList<QVariantMap> items;
206251
207− for (LauncherBackendItem &app: m_storedApps) {
208− items << makeAppDetails(app.settings->fileName(), app.pinned);
252+ Q_FOREACH(const QString &appId, m_storedApps) {
253+ items << itemToVariant(appId);
209254 }
210255
211− m_accounts->setUserProperty(m_user, "launcher-items", QVariant::fromValue(items));
256+ m_accounts->setUserProperty(m_user, "com.canonical.unity.AccountsService", "launcher-items", QVariant::fromValue(items));
212257 }
213258}
214259
215−QSettings *LauncherBackend::parseDesktopFile(const QString &appId) const
260+QString LauncherBackend::findDesktopFile(const QString &appId) const
216261{
217− auto fullAppId = desktopFile(appId);
218− return new QSettings(fullAppId, QSettings::IniFormat);
262+ int dashPos = -1;
263+ QString helper = appId;
264+
265+ QStringList searchDirs;
266+ searchDirs << QDir::homePath() + "/.local/share/applications";
267+ searchDirs << "/usr/share/applications";
268+
269+#ifdef LAUNCHER_TESTING
270+ searchDirs << "";
271+#endif
272+
273+ do {
274+ if (dashPos != -1) {
275+ helper = helper.replace(dashPos, 1, '/');
276+ }
277+
278+ Q_FOREACH(const QString &searchDir, searchDirs) {
279+ QFileInfo fileInfo(QDir(searchDir), helper + ".desktop");
280+ if (fileInfo.exists()) {
281+ return fileInfo.absoluteFilePath();
282+ }
283+ }
284+
285+ dashPos = helper.indexOf("-");
286+ } while (dashPos != -1);
287+
288+ return QString();
219289}
220290
221−void LauncherBackend::loadApp(const QVariantMap &details)
291+LauncherBackendItem* LauncherBackend::parseDesktopFile(const QString &desktopFile) const
222292{
223− auto appId = details.value("id").toString();
224− auto isPinned = details.value("is-pinned").toBool();
293+ QSettings settings(desktopFile, QSettings::IniFormat);
294+
295+ LauncherBackendItem* item = new LauncherBackendItem();
296+ item->desktopFile = desktopFile;
297+ item->displayName = settings.value("Desktop Entry/Name").toString();
298+
299+ QString iconString = settings.value("Desktop Entry/Icon").toString();
300+ QString pathString = settings.value("Desktop Entry/Path").toString();
301+ if (QFileInfo(iconString).exists()) {
302+ item->icon = QFileInfo(iconString).absoluteFilePath();
303+ } else if (QFileInfo(pathString + '/' + iconString).exists()) {
304+ item->icon = pathString + '/' + iconString;
305+ } else {
306+ item->icon = "image://theme/" + iconString;
307+ }
308+ item->pinned = false;
309+ return item;
310+}
225311
226− if (appId.isEmpty()) {
312+void LauncherBackend::loadFromVariant(const QVariantMap &details)
313+{
314+ if (!details.contains("id")) {
227315 return;
228316 }
317+ QString appId = details.value("id").toString();
318+
319+ LauncherBackendItem *item = m_itemCache.value(appId);
320+ if (item) {
321+ delete item;
322+ }
323+
324+ item = new LauncherBackendItem();
325+
326+ item->desktopFile = details.value("desktopFile").toString();
327+ item->displayName = details.value("name").toString();
328+ item->icon = details.value("icon").toString();
329+ item->pinned = details.value("is-pinned").toBool();
229330
230− LauncherBackendItem item;
231− item.settings = parseDesktopFile(appId);
232− item.pinned = isPinned;
233− m_storedApps.append(item);
331+ m_itemCache.insert(appId, item);
332+ m_storedApps.append(appId);
234333}
235334
236−QVariantMap LauncherBackend::makeAppDetails(const QString &appId, bool pinned) const
335+QVariantMap LauncherBackend::itemToVariant(const QString &appId) const
237336{
337+ LauncherBackendItem *item = m_itemCache.value(appId);
238338 QVariantMap details;
239339 details.insert("id", appId);
240− details.insert("is-pinned", pinned);
340+ details.insert("name", item->displayName);
341+ details.insert("icon", item->icon);
342+ details.insert("desktopFile", item->desktopFile);
343+ details.insert("is-pinned", item->pinned);
241344 return details;
242345}
243346
@@ -248,14 +351,3 @@ bool LauncherBackend::isDefaultsItem(const QList<QVariantMap> &apps) const
248351 // list of one item with the 'defaults' field set to true.
249352 return (apps.size() == 1 && apps[0].value("defaults").toBool());
250353}
251−
252−int LauncherBackend::findItem(const QString &appId) const
253−{
254− auto fullAppId = desktopFile(appId);
255− for (int i = 0; i < m_storedApps.size(); ++i) {
256− if (m_storedApps[i].settings->fileName() == fullAppId) {
257− return i;
258− }
259− }
260− return -1;
261−}
plugins/Unity/Launcher/backend/launcherbackend.h+12−14
@@ -25,12 +25,14 @@
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.
3232 */
3333
34+class LauncherBackendItem;
35+
3436class LauncherBackend : public QObject
3537{
3638 Q_OBJECT
@@ -141,24 +143,20 @@ Q_SIGNALS:
141143 void countChanged(const QString &appId, int count);
142144
143145private:
144− QSettings *parseDesktopFile(const QString &appId) const;
145− QVariantMap makeAppDetails(const QString &appId, bool pinned) const;
146− void loadApp(const QVariantMap &details);
147− int findItem(const QString &appId) const;
146+ QString findDesktopFile(const QString &appId) const;
147+ LauncherBackendItem* parseDesktopFile(const QString &desktopFile) const;
148+
149+ QVariantMap itemToVariant(const QString &appId) const;
150+ void loadFromVariant(const QVariantMap &details);
151+
148152 bool isDefaultsItem(const QList<QVariantMap> &apps) const;
149153 void syncFromAccounts();
150154 void syncToAccounts();
151− void clearItems();
152155
153− class LauncherBackendItem
154− {
155− public:
156− QSettings *settings;
157− bool pinned;
158− };
156+ QList<QString> m_storedApps;
157+ mutable QHash<QString, LauncherBackendItem*> m_itemCache;
159158
160− QList<LauncherBackendItem> m_storedApps;
161− AccountsService *m_accounts;
159+ AccountsServiceDBusAdaptor *m_accounts;
162160 QString m_user;
163161};
164162
plugins/Unity/Launcher/launcheritem.cpp+15−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),
@@ -31,6 +30,7 @@ LauncherItem::LauncherItem(const QString &appId, const QString &desktopFile, con
3130 m_recent(false),
3231 m_progress(-1),
3332 m_count(0),
33+ m_focused(false),
3434 m_quickList(new QuickListModel(this))
3535{
3636 QuickListEntry nameAction;
@@ -47,11 +47,6 @@ QString LauncherItem::appId() const
4747 return m_appId;
4848}
4949
50−QString LauncherItem::desktopFile() const
51−{
52− return m_desktopFile;
53−}
54−
5550QString LauncherItem::name() const
5651{
5752 return m_name;
@@ -131,6 +126,19 @@ void LauncherItem::setCount(int count)
131126 }
132127}
133128
129+bool LauncherItem::focused() const
130+{
131+ return m_focused;
132+}
133+
134+void LauncherItem::setFocused(bool focused)
135+{
136+ if (m_focused != focused) {
137+ m_focused = focused;
138+ Q_EMIT focusedChanged(focused);
139+ }
140+}
141+
134142unity::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
135143{
136144 return m_quickList;
plugins/Unity/Launcher/launcheritem.h+5−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
@@ -54,6 +53,9 @@ public:
5453 int count() const;
5554 void setCount(int count);
5655
56+ bool focused() const;
57+ void setFocused(bool focused);
58+
5759 unity::shell::launcher::QuickListModelInterface *quickList() const;
5860
5961Q_SIGNALS:
@@ -62,7 +64,6 @@ Q_SIGNALS:
6264
6365private:
6466 QString m_appId;
65− QString m_desktopFile;
6667 QString m_name;
6768 QString m_icon;
6869 bool m_pinned;
@@ -70,6 +71,7 @@ private:
7071 bool m_recent;
7172 int m_progress;
7273 int m_count;
74+ bool m_focused;
7375 QuickListModel *m_quickList;
7476};
7577
plugins/Unity/Launcher/launchermodel.cpp+126−10
@@ -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:
@@ -74,6 +76,8 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
7476 return item->count();
7577 case RoleProgress:
7678 return item->progress();
79+ case RoleFocused:
80+ return item->focused();
7781 }
7882
7983 return QVariant();
@@ -111,9 +115,11 @@ void LauncherModel::move(int oldIndex, int newIndex)
111115 m_list.move(oldIndex, newIndex);
112116 endMoveRows();
113117
114− storeAppList();
115−
116− pin(m_list.at(newIndex)->appId());
118+ if (!m_list.at(newIndex)->pinned()) {
119+ pin(m_list.at(newIndex)->appId());
120+ } else {
121+ storeAppList();
122+ }
117123}
118124
119125void LauncherModel::pin(const QString &appId, int index)
@@ -135,7 +141,6 @@ void LauncherModel::pin(const QString &appId, int index)
135141 }
136142 beginInsertRows(QModelIndex(), index, index);
137143 LauncherItem *item = new LauncherItem(appId,
138− m_backend->desktopFile(appId),
139144 m_backend->displayName(appId),
140145 m_backend->icon(appId));
141146 item->setPinned(true);
@@ -143,6 +148,8 @@ void LauncherModel::pin(const QString &appId, int index)
143148 m_list.insert(index, item);
144149 endInsertRows();
145150 }
151+
152+ storeAppList();
146153}
147154
148155void LauncherModel::requestRemove(const QString &appId)
@@ -152,6 +159,11 @@ void LauncherModel::requestRemove(const QString &appId)
152159 return;
153160 }
154161
162+ if (m_appManager->findApplication(appId)) {
163+ m_list.at(index)->setPinned(false);
164+ return;
165+ }
166+
155167 beginRemoveRows(QModelIndex(), index, index);
156168 m_list.takeAt(index)->deleteLater();
157169 endRemoveRows();
@@ -191,11 +203,55 @@ void LauncherModel::setUser(const QString &username)
191203 m_backend->setUser(username);
192204}
193205
206+ApplicationManagerInterface *LauncherModel::applicationManager() const
207+{
208+ return m_appManager;
209+}
210+
211+void LauncherModel::setApplicationManager(unity::shell::application::ApplicationManagerInterface *appManager)
212+{
213+ // Is there already another appmanager set?
214+ if (m_appManager) {
215+ // Disconnect any signals
216+ disconnect(this, SLOT(applicationAdded(QModelIndex,int)));
217+ disconnect(this, SLOT(applicationRemoved(QModelIndex,int)));
218+ disconnect(this, SLOT(focusedAppIdChanged()));
219+
220+ // remove any recent/running apps from the launcher
221+ QList<int> recentAppIndices;
222+ for (int i = 0; i < m_list.count(); ++i) {
223+ if (m_list.at(i)->recent()) {
224+ recentAppIndices << i;
225+ }
226+ }
227+ int run = 0;
228+ while (recentAppIndices.count() > 0) {
229+ beginRemoveRows(QModelIndex(), recentAppIndices.first() - run, recentAppIndices.first() - run);
230+ m_list.takeAt(recentAppIndices.first() - run)->deleteLater();
231+ endRemoveRows();
232+ recentAppIndices.takeFirst();
233+ ++run;
234+ }
235+ }
236+
237+ m_appManager = appManager;
238+ connect(m_appManager, SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(applicationAdded(QModelIndex,int)));
239+ connect(m_appManager, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), SLOT(applicationRemoved(QModelIndex,int)));
240+ connect(m_appManager, SIGNAL(focusedApplicationIdChanged()), SLOT(focusedAppIdChanged()));
241+
242+ Q_EMIT applicationManagerChanged();
243+
244+ for (int i = 0; i < appManager->count(); ++i) {
245+ applicationAdded(QModelIndex(), i);
246+ }
247+}
248+
249+
194250void LauncherModel::storeAppList()
195251{
196252 QStringList appIds;
197253 Q_FOREACH(LauncherItem *item, m_list) {
198− if (item->pinned() || item->recent()) {
254+ if (item->pinned()) {
199255 appIds << item->appId();
200256 }
201257 }
@@ -233,3 +289,63 @@ void LauncherModel::countChanged(const QString &appId, int count)
233289 Q_EMIT dataChanged(index(idx), index(idx), QVector<int>() << RoleCount);
234290 }
235291}
292+
293+void LauncherModel::applicationAdded(const QModelIndex &parent, int row)
294+{
295+ Q_UNUSED(parent);
296+
297+ ApplicationInfoInterface *app = m_appManager->get(row);
298+
299+ bool found = false;
300+ Q_FOREACH(LauncherItem *item, m_list) {
301+ if (app->appId() == item->appId()) {
302+ found = true;
303+ break;
304+ }
305+ }
306+ if (found) {
307+ // Shall we paint some running/recent app highlight? If yes, do it here.
308+ } else {
309+ LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString());
310+ item->setRecent(true);
311+ item->setFocused(app->focused());
312+
313+ beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
314+ m_list.append(item);
315+ endInsertRows();
316+ }
317+}
318+
319+void LauncherModel::applicationRemoved(const QModelIndex &parent, int row)
320+{
321+ Q_UNUSED(parent)
322+
323+ int appIndex = -1;
324+ for (int i = 0; i < m_list.count(); ++i) {
325+ if (m_list.at(i)->appId() == m_appManager->get(row)->appId()) {
326+ appIndex = i;
327+ break;
328+ }
329+ }
330+
331+ if (appIndex > -1 && !m_list.at(appIndex)->pinned()) {
332+ beginRemoveRows(QModelIndex(), appIndex, appIndex);
333+ m_list.takeAt(appIndex)->deleteLater();
334+ endRemoveRows();
335+ }
336+}
337+
338+void LauncherModel::focusedAppIdChanged()
339+{
340+ QString appId = m_appManager->focusedApplicationId();
341+ for (int i = 0; i < m_list.count(); ++i) {
342+ LauncherItem *item = m_list.at(i);
343+ if (!item->focused() && item->appId() == appId) {
344+ item->setFocused(true);
345+ Q_EMIT dataChanged(index(i), index(i), QVector<int>() << RoleFocused);
346+ } else if (item->focused() && item->appId() != appId) {
347+ item->setFocused(false);
348+ Q_EMIT dataChanged(index(i), index(i), QVector<int>() << RoleFocused);
349+ }
350+ }
351+}
plugins/Unity/Launcher/launchermodel.h+10
@@ -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{
@@ -50,6 +52,9 @@ public:
5052 Q_INVOKABLE void quickListActionInvoked(const QString &appId, int actionIndex);
5153 Q_INVOKABLE void setUser(const QString &username);
5254
55+ unity::shell::application::ApplicationManagerInterface* applicationManager() const;
56+ void setApplicationManager(unity::shell::application::ApplicationManagerInterface *appManager);
57+
5358private:
5459 void storeAppList();
5560 int findApplication(const QString &appId);
@@ -58,9 +63,14 @@ private Q_SLOTS:
5863 void progressChanged(const QString &appId, int progress);
5964 void countChanged(const QString &appId, int count);
6065
66+ void applicationAdded(const QModelIndex &parent, int row);
67+ void applicationRemoved(const QModelIndex &parent, int row);
68+ void focusedAppIdChanged();
69+
6170private:
6271 QList<LauncherItem*> m_list;
6372 LauncherBackend *m_backend;
73+ ApplicationManagerInterface *m_appManager;
6474};
6575
6676#endif // LAUNCHERMODEL_H
plugins/Unity/applicationpreview.cpp+5−1
@@ -19,6 +19,7 @@
1919
2020// local
2121#include "applicationpreview.h"
22+#include "iconutils.h"
2223
2324#include <QDebug>
2425
@@ -61,7 +62,10 @@ QString ApplicationPreview::license() const
6162QString ApplicationPreview::appIcon() const
6263{
6364 if (m_unityAppPreview) {
64− return QString::fromUtf8(g_icon_to_string(m_unityAppPreview->app_icon()));
65+ auto giconString = g_icon_to_string(m_unityAppPreview->app_icon());
66+ QString result(gIconToDeclarativeImageProviderString(QString::fromUtf8(giconString)));
67+ g_free(giconString);
68+ return result;
6569 } else {
6670 qWarning() << "Preview not set";
6771 }
plugins/Unity/categories.cpp−3
@@ -43,7 +43,6 @@ Categories::Categories(QObject* parent)
4343 m_roles[Categories::RoleHints] = "hints";
4444 m_roles[Categories::RoleResults] = "results";
4545 m_roles[Categories::RoleCount] = "count";
46− m_roles[Categories::RoleCategoryIndex] = "categoryIndex";
4746
4847 // TODO This should not be needed but accumulatting the count changes
4948 // makes the visualization more stable and also makes crashes on fast
@@ -222,8 +221,6 @@ Categories::data(const QModelIndex& index, int role) const
222221 return QVariant::fromValue(m_overriddenCategories[id]->rowCount());
223222 }
224223 return QVariant::fromValue(getResults(index.row())->rowCount());
225− case RoleCategoryIndex:
226− return QVariant::fromValue(index.row());
227224 default:
228225 return QVariant();
229226 }
plugins/Unity/categories.h+1−2
@@ -50,8 +50,7 @@ public:
5050 RoleProgressSource,
5151 RoleHints,
5252 RoleResults,
53− RoleCount,
54− RoleCategoryIndex
53+ RoleCount
5554 };
5655
5756 Q_INVOKABLE void overrideResults(const QString& categoryId, QAbstractItemModel* model);
plugins/Unity/categoryresults.cpp+5−2
@@ -19,6 +19,7 @@
1919
2020// self
2121#include "categoryresults.h"
22+#include "iconutils.h"
2223
2324// TODO: use something from libunity once it's public
2425enum ResultsColumn {
@@ -76,8 +77,10 @@ CategoryResults::data(const QModelIndex& index, int role) const
7677 switch (role) {
7778 case RoleUri:
7879 return DeeListModel::data(index, ResultsColumn::URI);
79− case RoleIconHint:
80− return DeeListModel::data(index, ResultsColumn::ICON_HINT);
80+ case RoleIconHint: {
81+ QString giconString(DeeListModel::data(index, ResultsColumn::ICON_HINT).toString());
82+ return QVariant::fromValue(gIconToDeclarativeImageProviderString(giconString));
83+ }
8184 case RoleCategory:
8285 return DeeListModel::data(index, ResultsColumn::CATEGORY);
8386 case RoleMimetype:
plugins/Unity/categoryresults.h+1−1
@@ -24,7 +24,7 @@
2424// dee-qt
2525#include "deelistmodel.h"
2626
27−class CategoryResults : public DeeListModel
27+class Q_DECL_EXPORT CategoryResults : public DeeListModel
2828{
2929 Q_OBJECT
3030
plugins/Unity/iconutils.cppnew file+91
@@ -0,0 +1,91 @@
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:
17+ * Michal Hruby <michal.hruby@canonical.com>
18+ */
19+
20+#include <QStringList>
21+#include <QUrl>
22+
23+#include <gio/gio.h>
24+#include "iconutils.h"
25+
26+#define BASE_THEME_ICON_URI "image://theme/"
27+
28+QString gIconToDeclarativeImageProviderString(QString const &giconString)
29+{
30+ if (giconString.isEmpty()) return giconString;
31+
32+ if (giconString.startsWith('/') || giconString.startsWith(QLatin1String("http")) ||
33+ giconString.startsWith(QLatin1String("file:"))) {
34+ return giconString;
35+ }
36+
37+ if (!giconString.startsWith(QLatin1String(". "))) {
38+ // must be a themed icon
39+ QString themedIcon(BASE_THEME_ICON_URI);
40+ themedIcon.append(giconString);
41+ return themedIcon;
42+ }
43+
44+ // special case annotated icon
45+ if (giconString.startsWith(QLatin1String(". UnityProtocolAnnotatedIcon "))) {
46+ QString annotatedIcon;
47+ QString serializedData(QUrl::fromPercentEncoding(giconString.mid(29).toUtf8()));
48+ GVariant *variant = g_variant_parse(G_VARIANT_TYPE_VARDICT, serializedData.toUtf8().constData(), NULL, NULL, NULL);
49+ gchar *baseUri;
50+ if (variant != NULL && g_variant_lookup(variant, "base-icon", "&s", &baseUri)) {
51+ annotatedIcon = gIconToDeclarativeImageProviderString(QString(baseUri));
52+ // FIXME: enclose in image://annotated/... once unity supports that
53+ }
54+ if (variant != NULL) g_variant_unref(variant);
55+
56+ return annotatedIcon;
57+ }
58+
59+ // handle real gicon strings
60+ QString result;
61+ GError *error = NULL;
62+ GIcon *icon = g_icon_new_for_string(giconString.toLocal8Bit().constData(), &error);
63+ if (error != NULL || icon == NULL) {
64+ qWarning("Unable to deserialize icon: %s", giconString.toLocal8Bit().constData());
65+ g_clear_error(&error);
66+ return result;
67+ }
68+
69+ if (G_IS_THEMED_ICON(icon)) {
70+ QString themedIcon(BASE_THEME_ICON_URI);
71+ QStringList list;
72+ const char* const *iconNames = g_themed_icon_get_names(G_THEMED_ICON(icon));
73+ if (iconNames != NULL) {
74+ for (const char * const *iter = iconNames; *iter != NULL; ++iter) {
75+ list << QLatin1String(*iter);
76+ }
77+ }
78+ themedIcon.append(list.join(QString(",")));
79+ result = themedIcon;
80+ } else if (G_IS_FILE_ICON(icon)) {
81+ GFile *file = g_file_icon_get_file(G_FILE_ICON(icon));
82+ gchar *uri = g_file_get_uri(file);
83+ QString iconUri(uri);
84+ g_free(uri);
85+ result = iconUri;
86+ }
87+
88+ g_object_unref(icon);
89+
90+ return result;
91+}
plugins/Unity/iconutils.hnew file+27
@@ -0,0 +1,27 @@
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:
17+ * Michal Hruby <michal.hruby@canonical.com>
18+ */
19+
20+#ifndef ICONUTILS_H
21+#define ICONUTILS_H
22+
23+#include <QString>
24+
25+QString gIconToDeclarativeImageProviderString(QString const &giconString);
26+
27+#endif
plugins/Unity/preview.cpp+5−1
@@ -26,6 +26,7 @@
2626#include "moviepreview.h"
2727#include "musicpreview.h"
2828#include "socialpreview.h"
29+#include "iconutils.h"
2930#include "variantutils.h"
3031
3132// Qt
@@ -102,7 +103,10 @@ QVariantMap Preview::infoHintsHash() const
102103QString Preview::image() const
103104{
104105 if (m_unityPreview) {
105− return QString::fromUtf8(g_icon_to_string(m_unityPreview->image()));
106+ auto giconString = g_icon_to_string(m_unityPreview->image());
107+ QString result(gIconToDeclarativeImageProviderString(QString::fromUtf8(giconString)));
108+ g_free(giconString);
109+ return result;
106110 } else {
107111 qWarning() << "Preview not set";
108112 }
plugins/Unity/socialpreview.cpp+5−1
@@ -19,6 +19,7 @@
1919
2020#include "socialpreview.h"
2121#include "socialpreviewcomment.h"
22+#include "iconutils.h"
2223
2324#include <QDebug>
2425
@@ -51,7 +52,10 @@ QString SocialPreview::content() const
5152QString SocialPreview::avatar() const
5253{
5354 if (m_unitySocialPreview) {
54− return QString::fromUtf8(g_icon_to_string(m_unitySocialPreview->avatar()));
55+ auto giconString = g_icon_to_string(m_unitySocialPreview->avatar());
56+ QString result(gIconToDeclarativeImageProviderString(QString::fromUtf8(giconString)));
57+ g_free(giconString);
58+ return result;
5559 } else {
5660 qWarning() << "Preview not set";
5761 }
plugins/Utils/qsortfilterproxymodelqml.cpp+32
@@ -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 }
@@ -121,3 +133,23 @@ QSortFilterProxyModelQML::findFirst(int role, const QVariant& value) const
121133 return -1;
122134 }
123135}
136+
137+int
138+QSortFilterProxyModelQML::mapFromSource(int row)
139+{
140+ if (sourceModel() != NULL) {
141+ return QSortFilterProxyModel::mapFromSource(sourceModel()->index(row, 0)).row();
142+ } else {
143+ return -1;
144+ }
145+}
146+
147+int
148+QSortFilterProxyModelQML::mapToSource(int row)
149+{
150+ if (sourceModel() != NULL) {
151+ return QSortFilterProxyModel::mapToSource(index(row, 0)).row();
152+ } else {
153+ return -1;
154+ }
155+}
plugins/Utils/qsortfilterproxymodelqml.h+4
@@ -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 */
@@ -45,6 +46,9 @@ public:
4546 void setModel(QAbstractItemModel *model);
4647 void setInvertMatch(bool invertMatch);
4748
49+ Q_INVOKABLE int mapFromSource(int row);
50+ Q_INVOKABLE int mapToSource(int row);
51+
4852Q_SIGNALS:
4953 void totalCountChanged();
5054 void countChanged();
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"
po/es.po+24−22
@@ -8,15 +8,15 @@ 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-07-08 07:25+0000\n"
11+"PO-Revision-Date: 2013-09-04 22:12+0000\n"
1212"Last-Translator: Adolfo Jayme Barrientos <fitoschido@gmail.com>\n"
1313"Language-Team: Spanish <es@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-05 05:35+0000\n"
19+"X-Generator: Launchpad (build 16758)\n"
2020
2121#: Applications/applications.js:23
2222msgid "Phone"
@@ -88,47 +88,49 @@ msgstr "YouTube"
8888
8989#: Components/EdgeDemoOverlay.qml:145
9090msgid "Skip intro"
91−msgstr ""
91+msgstr "Omitir la introducción"
9292
9393#: Components/EdgeDemo.qml:98
9494msgid "Right edge"
95−msgstr ""
95+msgstr "Borde derecho"
9696
9797#: Components/EdgeDemo.qml:99
9898msgid "Try swiping from the right edge to unlock the phone"
99−msgstr ""
99+msgstr "Deslice el dedo desde el borde derecho para desbloquear el teléfono"
100100
101101#: Components/EdgeDemo.qml:135
102102msgid "Top edge"
103−msgstr ""
103+msgstr "Borde superior"
104104
105105#: Components/EdgeDemo.qml:136
106106msgid "Try swiping from the top edge to access the indicators"
107−msgstr ""
107+msgstr "Deslice el dedo desde el borde superior para acceder a los menús"
108108
109109#: Components/EdgeDemo.qml:161
110110msgid "Close"
111−msgstr ""
111+msgstr "Cerrar"
112112
113113#: Components/EdgeDemo.qml:162
114114msgid "Swipe up again to close the settings screen"
115−msgstr ""
115+msgstr "Deslice hacia arriba para cerrar la pantalla de configuración"
116116
117117#: Components/EdgeDemo.qml:189
118118msgid "Left edge"
119−msgstr ""
119+msgstr "Borde izquierdo"
120120
121121#: Components/EdgeDemo.qml:190
122122msgid "Swipe from the left to reveal the launcher for quick access to apps"
123123msgstr ""
124+"Deslice el dedo desde la izquierda para mostrar el lanzador y acceder "
125+"rápidamente a las aplicaciones"
124126
125127#: Components/EdgeDemo.qml:217
126128msgid "Well done"
127−msgstr ""
129+msgstr "Bien hecho"
128130
129131#: Components/EdgeDemo.qml:218
130132msgid "You have now mastered the edge gestures and can start using the phone"
131−msgstr ""
133+msgstr "Ahora domina el uso de gestos de los bordes. Puede usar el teléfono"
132134
133135#: Components/PageHeader.qml:298
134136msgid "Recent searches"
@@ -138,35 +140,35 @@ msgstr "Búsquedas recientes"
138140#: Dash/Apps/AppInfo.qml:73
139141#, qt-format
140142msgid "(%1)"
141−msgstr ""
143+msgstr "(%1)"
142144
143145#. TRANSLATORS: Number of persons who wrote reviews for this app
144146#: Dash/Apps/AppInfo.qml:85
145147#, qt-format
146148msgid "%1 review"
147149msgid_plural "%1 reviews"
148−msgstr[0] ""
149−msgstr[1] ""
150+msgstr[0] "%1 reseña"
151+msgstr[1] "%1 reseñas"
150152
151153#: Dash/Apps/AppPreview.qml:175
152154msgid "Rate this"
153−msgstr ""
155+msgstr "Valorar esto"
154156
155157#: Dash/Apps/AppReviews.qml:72
156158msgid "Add a review"
157−msgstr ""
159+msgstr "Añadir una reseña"
158160
159161#: Dash/Apps/AppReviews.qml:84
160162msgid "Review"
161−msgstr ""
163+msgstr "Reseñar"
162164
163165#: Dash/Apps/AppReviews.qml:118
164166msgid "Send"
165−msgstr ""
167+msgstr "Enviar"
166168
167169#: Dash/Apps/AppReviews.qml:136
168170msgid "Comments:"
169−msgstr ""
171+msgstr "Comentarios:"
170172
171173#: Dash/DashMusic.qml:27 Dash/DashVideos.qml:28
172174msgid "Featured"
@@ -210,7 +212,7 @@ msgstr "Autor:"
210212
211213#: Greeter/Lockscreen.qml:134
212214msgid "Emergency Call"
213−msgstr ""
215+msgstr "Llamada de emergencia"
214216
215217#: Greeter/PassphraseLockscreen.qml:59
216218#, qt-format
po/is.ponew file+256
@@ -0,0 +1,256 @@
1+# Icelandic translation for unity8
2+# Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013
3+# This file is distributed under the same license as the unity8 package.
4+# FIRST AUTHOR <EMAIL@ADDRESS>, 2013.
5+#
6+msgid ""
7+msgstr ""
8+"Project-Id-Version: unity8\n"
9+"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
10+"POT-Creation-Date: 2013-08-27 13:36-0400\n"
11+"PO-Revision-Date: 2013-09-18 16:22+0000\n"
12+"Last-Translator: Andri Thorlacius <Unknown>\n"
13+"Language-Team: Icelandic <is@li.org>\n"
14+"MIME-Version: 1.0\n"
15+"Content-Type: text/plain; charset=UTF-8\n"
16+"Content-Transfer-Encoding: 8bit\n"
17+"Plural-Forms: nplurals=2; plural=n != 1;\n"
18+"X-Launchpad-Export-Date: 2013-09-19 05:14+0000\n"
19+"X-Generator: Launchpad (build 16765)\n"
20+
21+#: Applications/applications.js:23
22+msgid "Phone"
23+msgstr "Sími"
24+
25+#: Applications/applications.js:29
26+msgid "Camera"
27+msgstr "Myndavél"
28+
29+#: Applications/applications.js:35
30+msgid "Gallery"
31+msgstr "Myndasafn"
32+
33+#: Applications/applications.js:40
34+msgid "Facebook"
35+msgstr "Facebook"
36+
37+#: Applications/applications.js:46
38+msgid "Browser"
39+msgstr "Vafri"
40+
41+#: Applications/applications.js:51
42+msgid "Twitter"
43+msgstr "Twitter"
44+
45+#: Applications/applications.js:57
46+msgid "GMail"
47+msgstr "GMail"
48+
49+#: Applications/applications.js:62
50+msgid "Weather"
51+msgstr "Veður"
52+
53+#: Applications/applications.js:68
54+msgid "Notepad"
55+msgstr "Skrifblokk"
56+
57+#: Applications/applications.js:74
58+msgid "Calendar"
59+msgstr "Dagatal"
60+
61+#: Applications/applications.js:80
62+msgid "Media Player"
63+msgstr "Margmiðlunarspilari"
64+
65+#: Applications/applications.js:86
66+msgid "Evernote"
67+msgstr "Evernote"
68+
69+#: Applications/applications.js:91
70+msgid "Map"
71+msgstr "Kort"
72+
73+#: Applications/applications.js:96
74+msgid "Pinterest"
75+msgstr "Pinterest"
76+
77+#: Applications/applications.js:101
78+msgid "SoundCloud"
79+msgstr "SoundCloud"
80+
81+#: Applications/applications.js:106
82+msgid "Wikipedia"
83+msgstr "Wikipedia"
84+
85+#: Applications/applications.js:111
86+msgid "YouTube"
87+msgstr "YouTube"
88+
89+#: Components/EdgeDemoOverlay.qml:145
90+msgid "Skip intro"
91+msgstr "Hoppa yfir kynningu"
92+
93+#: Components/EdgeDemo.qml:98
94+msgid "Right edge"
95+msgstr "Hægri brún"
96+
97+#: Components/EdgeDemo.qml:99
98+msgid "Try swiping from the right edge to unlock the phone"
99+msgstr ""
100+"Prufaðu að renna puttanum frá hægri brúninni til að aflæsa símanum þínum."
101+
102+#: Components/EdgeDemo.qml:135
103+msgid "Top edge"
104+msgstr "Efri brún"
105+
106+#: Components/EdgeDemo.qml:136
107+msgid "Try swiping from the top edge to access the indicators"
108+msgstr ""
109+
110+#: Components/EdgeDemo.qml:161
111+msgid "Close"
112+msgstr "Loka"
113+
114+#: Components/EdgeDemo.qml:162
115+msgid "Swipe up again to close the settings screen"
116+msgstr ""
117+
118+#: Components/EdgeDemo.qml:189
119+msgid "Left edge"
120+msgstr "Vinstri brún"
121+
122+#: Components/EdgeDemo.qml:190
123+msgid "Swipe from the left to reveal the launcher for quick access to apps"
124+msgstr ""
125+
126+#: Components/EdgeDemo.qml:217
127+msgid "Well done"
128+msgstr "Vel gert"
129+
130+#: Components/EdgeDemo.qml:218
131+msgid "You have now mastered the edge gestures and can start using the phone"
132+msgstr ""
133+
134+#: Components/PageHeader.qml:298
135+msgid "Recent searches"
136+msgstr "Nýlegar leitir"
137+
138+#. TRANSLATORS: Number of persons who rated this app
139+#: Dash/Apps/AppInfo.qml:73
140+#, qt-format
141+msgid "(%1)"
142+msgstr "(%1)"
143+
144+#. TRANSLATORS: Number of persons who wrote reviews for this app
145+#: Dash/Apps/AppInfo.qml:85
146+#, qt-format
147+msgid "%1 review"
148+msgid_plural "%1 reviews"
149+msgstr[0] "%1 ummæli"
150+msgstr[1] "%1 ummæli"
151+
152+#: Dash/Apps/AppPreview.qml:175
153+msgid "Rate this"
154+msgstr "Gefa þessu einkunn"
155+
156+#: Dash/Apps/AppReviews.qml:72
157+msgid "Add a review"
158+msgstr "Gefa umsögn"
159+
160+#: Dash/Apps/AppReviews.qml:84
161+msgid "Review"
162+msgstr "Umsögn"
163+
164+#: Dash/Apps/AppReviews.qml:118
165+msgid "Send"
166+msgstr "Senda"
167+
168+#: Dash/Apps/AppReviews.qml:136
169+msgid "Comments:"
170+msgstr "Athugasemdir:"
171+
172+#: Dash/DashMusic.qml:27 Dash/DashVideos.qml:28
173+msgid "Featured"
174+msgstr "Efst á baugi"
175+
176+#: Dash/DashMusic.qml:28 Dash/DashVideos.qml:29
177+msgid "Recent"
178+msgstr "Nýlegt"
179+
180+#: Dash/DashMusic.qml:29 Dash/DashVideos.qml:30
181+msgid "New Releases"
182+msgstr "Nýjar Útgáfur"
183+
184+#: Dash/DashMusic.qml:30
185+msgid "Top Charting"
186+msgstr "Topp Listi"
187+
188+#: Dash/DashMusic.qml:91
189+msgid "Music"
190+msgstr "Tónlist"
191+
192+#: Dash/DashVideos.qml:31
193+msgid "Popular Online"
194+msgstr "Vinsælt á Netinu"
195+
196+#: Dash/DashVideos.qml:146
197+msgid "Videos"
198+msgstr "Myndbönd"
199+
200+#: Dash/Video/VideoPreview.qml:130
201+msgid "Directed by:"
202+msgstr "Leikstýrt af:"
203+
204+#: Dash/Video/VideoPreview.qml:153
205+msgid "Starring:"
206+msgstr "Meðal leikara eru:"
207+
208+#: Dash/Video/VideoPreview.qml:176
209+msgid "Author:"
210+msgstr "Höfundur:"
211+
212+#: Greeter/Lockscreen.qml:134
213+msgid "Emergency Call"
214+msgstr "Neyðarsímtal"
215+
216+#: Greeter/PassphraseLockscreen.qml:59
217+#, qt-format
218+msgid "Hello %1"
219+msgstr "Hæ %1"
220+
221+#: Greeter/PassphraseLockscreen.qml:59
222+msgid "Hello"
223+msgstr "Hæ"
224+
225+#: Hud/HudParametrizedActionsPage.qml:132
226+msgid "Confirm"
227+msgstr "Staðfesta"
228+
229+#: Hud/Hud.qml:61 Hud/Hud.qml:99 Hud/Hud.qml:372
230+msgid "Type or say a command"
231+msgstr "Skrifaðu eða segðu eitthvað"
232+
233+#: Hud/Hud.qml:84
234+msgid "Loading. Please Wait..."
235+msgstr "Hleð. Vinsamlegast Bíðið..."
236+
237+#: Hud/Hud.qml:89
238+msgid "Speak Now..."
239+msgstr "Talaðu Núna..."
240+
241+#: Hud/Hud.qml:94
242+msgid "Speaking..."
243+msgstr "Tala..."
244+
245+#: Panel/SearchIndicator.qml:27
246+msgid "Search"
247+msgstr "Leita"
248+
249+#: plugins/Unity/scope.cpp:317
250+msgid "Sorry, there is nothing that matches your search."
251+msgstr "Því miður, það var ekkert sem passaði við leitarorðið þitt."
252+
253+#: Shell.qml:429
254+#, qt-format
255+msgid "Please enter %1"
256+msgstr ""
po/sl.po+29−24
@@ -8,7 +8,7 @@ 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-07-02 12:59+0000\n"
11+"PO-Revision-Date: 2013-09-19 19:48+0000\n"
1212"Last-Translator: Damir Jerovšek <Unknown>\n"
1313"Language-Team: Slovenian <sl@li.org>\n"
1414"MIME-Version: 1.0\n"
@@ -16,8 +16,8 @@ msgstr ""
1616"Content-Transfer-Encoding: 8bit\n"
1717"Plural-Forms: nplurals=4; plural=(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || "
1818"n%100==4 ? 3 : 0);\n"
19−"X-Launchpad-Export-Date: 2013-08-30 05:37+0000\n"
20−"X-Generator: Launchpad (build 16750)\n"
19+"X-Launchpad-Export-Date: 2013-09-20 06:21+0000\n"
20+"X-Generator: Launchpad (build 16765)\n"
2121
2222#: Applications/applications.js:23
2323msgid "Phone"
@@ -25,7 +25,7 @@ msgstr "Telefon"
2525
2626#: Applications/applications.js:29
2727msgid "Camera"
28−msgstr ""
28+msgstr "Fotoaparat"
2929
3030#: Applications/applications.js:35
3131msgid "Gallery"
@@ -89,47 +89,50 @@ msgstr "YouTube"
8989
9090#: Components/EdgeDemoOverlay.qml:145
9191msgid "Skip intro"
92−msgstr ""
92+msgstr "Preskoči uvod"
9393
9494#: Components/EdgeDemo.qml:98
9595msgid "Right edge"
96−msgstr ""
96+msgstr "Desni rob"
9797
9898#: Components/EdgeDemo.qml:99
9999msgid "Try swiping from the right edge to unlock the phone"
100−msgstr ""
100+msgstr "Poskusite povleči od desnega roba za odklep telefona"
101101
102102#: Components/EdgeDemo.qml:135
103103msgid "Top edge"
104−msgstr ""
104+msgstr "Zgornji rob"
105105
106106#: Components/EdgeDemo.qml:136
107107msgid "Try swiping from the top edge to access the indicators"
108−msgstr ""
108+msgstr "Poskusite povleči od zgornjega roba za dostop do kazalnikov"
109109
110110#: Components/EdgeDemo.qml:161
111111msgid "Close"
112−msgstr ""
112+msgstr "Zapri"
113113
114114#: Components/EdgeDemo.qml:162
115115msgid "Swipe up again to close the settings screen"
116−msgstr ""
116+msgstr "Povlecite ponovno navzgor za zaprtje zaslona z nastavitvami"
117117
118118#: Components/EdgeDemo.qml:189
119119msgid "Left edge"
120−msgstr ""
120+msgstr "Levi rob"
121121
122122#: Components/EdgeDemo.qml:190
123123msgid "Swipe from the left to reveal the launcher for quick access to apps"
124124msgstr ""
125+"Poskusite povleči od leve za razkritje zaganjalnika za hiter dostop do "
126+"programov"
125127
126128#: Components/EdgeDemo.qml:217
127129msgid "Well done"
128−msgstr ""
130+msgstr "Odlično"
129131
130132#: Components/EdgeDemo.qml:218
131133msgid "You have now mastered the edge gestures and can start using the phone"
132134msgstr ""
135+"Zdaj, ko ste osvojili kretnje z robovi, lahko začnete uporabljati telefon"
133136
134137#: Components/PageHeader.qml:298
135138msgid "Recent searches"
@@ -139,35 +142,37 @@ msgstr "Nedavna iskanja"
139142#: Dash/Apps/AppInfo.qml:73
140143#, qt-format
141144msgid "(%1)"
142−msgstr ""
145+msgstr "(%1)"
143146
144147#. TRANSLATORS: Number of persons who wrote reviews for this app
145148#: Dash/Apps/AppInfo.qml:85
146149#, qt-format
147150msgid "%1 review"
148151msgid_plural "%1 reviews"
149−msgstr[0] ""
150−msgstr[1] ""
152+msgstr[0] "%1 ocen"
153+msgstr[1] "%1 ocena"
154+msgstr[2] "%1 oceni"
155+msgstr[3] "%1 ocene"
151156
152157#: Dash/Apps/AppPreview.qml:175
153158msgid "Rate this"
154−msgstr ""
159+msgstr "Ocenite"
155160
156161#: Dash/Apps/AppReviews.qml:72
157162msgid "Add a review"
158−msgstr ""
163+msgstr "Dodaj oceno"
159164
160165#: Dash/Apps/AppReviews.qml:84
161166msgid "Review"
162−msgstr ""
167+msgstr "Ocena"
163168
164169#: Dash/Apps/AppReviews.qml:118
165170msgid "Send"
166−msgstr ""
171+msgstr "Pošlji"
167172
168173#: Dash/Apps/AppReviews.qml:136
169174msgid "Comments:"
170−msgstr ""
175+msgstr "Opombe:"
171176
172177#: Dash/DashMusic.qml:27 Dash/DashVideos.qml:28
173178msgid "Featured"
@@ -211,7 +216,7 @@ msgstr ""
211216
212217#: Greeter/Lockscreen.qml:134
213218msgid "Emergency Call"
214−msgstr ""
219+msgstr "Klic v sili"
215220
216221#: Greeter/PassphraseLockscreen.qml:59
217222#, qt-format
@@ -220,7 +225,7 @@ msgstr "Pozdravljeni, %1"
220225
221226#: Greeter/PassphraseLockscreen.qml:59
222227msgid "Hello"
223−msgstr ""
228+msgstr "Pozdravljeni"
224229
225230#: Hud/HudParametrizedActionsPage.qml:132
226231msgid "Confirm"
@@ -253,4 +258,4 @@ msgstr "Nič se ne ujema z vašim iskalnim nizom."
253258#: Shell.qml:429
254259#, qt-format
255260msgid "Please enter %1"
256−msgstr ""
261+msgstr "Vnesite %1"
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/autopilot/unity8/application_lifecycle/__init__.pynew file+20
@@ -0,0 +1,20 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2013 Canonical
5+#
6+# This program is free software: you can redistribute it and/or modify
7+# it under the terms of the GNU General Public License as published by
8+# the Free Software Foundation, either version 3 of the License, or
9+# (at your option) any later version.
10+#
11+# This program is distributed in the hope that it will be useful,
12+# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+# GNU General Public License for more details.
15+#
16+# You should have received a copy of the GNU General Public License
17+# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+#
19+
20+"""Tests for the application lifecycle base package."""
tests/autopilot/unity8/application_lifecycle/tests/__init__.pynew file

No changes to the content.

tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.pynew file+136
@@ -0,0 +1,136 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2013 Canonical
5+#
6+# This program is free software: you can redistribute it and/or modify
7+# it under the terms of the GNU General Public License as published by
8+# the Free Software Foundation, either version 3 of the License, or
9+# (at your option) any later version.
10+#
11+# This program is distributed in the hope that it will be useful,
12+# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+# GNU General Public License for more details.
15+#
16+# You should have received a copy of the GNU General Public License
17+# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+#
19+
20+"""Tests for the application lifecycle."""
21+
22+from __future__ import absolute_import
23+
24+from unity8.shell import disable_qml_mocking
25+from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
26+
27+from autopilot.matchers import Eventually
28+from autopilot.platform import model
29+from testtools.matchers import Equals, NotEquals
30+
31+import logging
32+
33+logger = logging.getLogger(__name__)
34+
35+
36+class ApplicationLifecycleTests(UnityTestCase):
37+
38+ scenarios = _get_device_emulation_scenarios()
39+
40+ def setUp(self):
41+ super(ApplicationLifecycleTests, self).setUp()
42+ if model() == "Desktop":
43+ self.skipTest("Test cannot be run on the desktop.")
44+
45+ def swipe_screen_from_right(self):
46+ qml_view = self.main_window.get_qml_view()
47+ width = qml_view.width
48+ height = qml_view.height
49+ start_x = width
50+ start_y = int(height/2)
51+ end_x = int(width/2)
52+ end_y = start_y
53+
54+ logger.info("Swiping screen from the right edge")
55+ self.touch.drag(start_x, start_y, end_x, end_y)
56+
57+ def _get_current_focused_app_id(self):
58+ return self._proxy.select_single("Shell").currentFocusedAppId
59+
60+ def _launch_app(self, app_name):
61+ """Launches the application *app_name*
62+
63+ Assumes that the desktop file resides at:
64+ /usr/share/applications/{app_name}.desktop
65+
66+ """
67+ desktop_file = "--desktop_file_hint="\
68+ "/usr/share/applications/{app_name}.desktop".format(
69+ app_name=app_name
70+ )
71+ return self.launch_test_application(
72+ app_name,
73+ desktop_file,
74+ "--stage_hint=main_stage",
75+ app_type='qt'
76+ )
77+
78+ @disable_qml_mocking
79+ def test_can_launch_application(self):
80+ """Must be able to launch an application."""
81+ self.launch_unity()
82+ self.main_window.get_greeter().swipe()
83+
84+ app = self._launch_app("messaging-app")
85+
86+ self.assertThat(app, NotEquals(None))
87+ self.assertThat(
88+ self._get_current_focused_app_id(),
89+ Eventually(Equals("messaging-app"))
90+ )
91+
92+ @disable_qml_mocking
93+ def test_can_launch_multiple_applications(self):
94+ """A second application launched must be focused."""
95+ self.launch_unity()
96+ self.main_window.get_greeter().swipe()
97+
98+ self._launch_app("messaging-app")
99+ self.assertThat(
100+ self._get_current_focused_app_id(),
101+ Eventually(Equals("messaging-app"))
102+ )
103+
104+ self._launch_app("address-book-app")
105+ self.assertThat(
106+ self._get_current_focused_app_id(),
107+ Eventually(Equals("address-book-app"))
108+ )
109+
110+ @disable_qml_mocking
111+ def test_app_moves_from_unfocused_to_focused(self):
112+ """An application that is in the unfocused state must be able to be
113+ brought back to the focused state.
114+
115+ """
116+ self.launch_unity()
117+ self.main_window.get_greeter().swipe()
118+
119+ self._launch_app("messaging-app")
120+ self.assertThat(
121+ self._get_current_focused_app_id(),
122+ Eventually(Equals("messaging-app"))
123+ )
124+
125+ self._launch_app("address-book-app")
126+ self.assertThat(
127+ self._get_current_focused_app_id(),
128+ Eventually(Equals("address-book-app"))
129+ )
130+
131+ self.swipe_screen_from_right()
132+
133+ self.assertThat(
134+ self._get_current_focused_app_id(),
135+ Eventually(Equals("messaging-app"))
136+ )
tests/autopilot/unity8/shell/__init__.py+10
@@ -36,3 +36,13 @@ def with_lightdm_mock(mock_type):
3636 return fn(*args, **kwargs)
3737 return wrapper
3838 return with_lightdm_mock_internal
39+
40+
41+def disable_qml_mocking(fn):
42+ """Simple decorator that disables the QML mocks from being loaded."""
43+ @wraps(fn)
44+ def wrapper(*args, **kwargs):
45+ tests_self = args[0]
46+ tests_self._qml_mock_enabled = False
47+ return fn(*args, **kwargs)
48+ return wrapper
tests/autopilot/unity8/shell/tests/__init__.py+4−1
@@ -86,6 +86,7 @@ class UnityTestCase(AutopilotTestCase):
8686
8787 self._proxy = None
8888 self._lightdm_mock_type = None
89+ self._qml_mock_enabled = True
8990 self.touch = Touch.create()
9091 self._setup_display_details()
9192
@@ -160,7 +161,9 @@ class UnityTestCase(AutopilotTestCase):
160161
161162 if self._lightdm_mock_type is None:
162163 self.patch_lightdm_mock()
163− self._setup_extra_mock_environment_patch()
164+
165+ if self._qml_mock_enabled:
166+ self._setup_extra_mock_environment_patch()
164167
165168 app_proxy = self.launch_test_application(
166169 binary_path,
tests/autopilot/unity8/shell/tests/test_hud.py+7−2
@@ -34,6 +34,8 @@ class TestHud(UnityTestCase):
3434
3535 def test_show_hud_button_appears(self):
3636 """Swiping up while an app is active must show the 'show hud' button.
37+ The button must disappear not opening the HUD when releasing the
38+ mouse again somewhere on the screen except on the button itself.
3739
3840 """
3941 self.launch_unity()
@@ -49,9 +51,12 @@ class TestHud(UnityTestCase):
4951 hud_show_button
5052 )
5153 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
52− self.addCleanup(self.touch.release)
53− self.touch._finger_move(swipe_coords.end_x, swipe_coords.end_y)
54+ self.addCleanup(self._maybe_release_finger)
55+ self.touch._finger_move(swipe_coords.end_x, swipe_coords.end_y + hud_show_button.height);
5456 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
57+ self.touch.release();
58+ self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
59+ self.assertThat(hud.shown, Equals(False))
5560
5661 def test_show_hud_appears(self):
5762 """Releasing the touch on the 'show hud' button must display the hud.
tests/mocks/AccountsService/AccountsService.cpp+27−4
@@ -19,15 +19,38 @@
1919#include "AccountsService.h"
2020
2121AccountsService::AccountsService(QObject* parent)
22− : QObject(parent)
22+ : QObject(parent),
23+ m_backgroundFile(TOP_SRCDIR "/graphics/phone_background.jpg")
2324{
2425}
2526
26−QVariant AccountsService::getUserProperty(const QString &, const QString &)
27+QString AccountsService::getUser()
2728{
28− return QVariant(false);
29+ return "testuser";
2930}
3031
31−void AccountsService::setUserProperty(const QString &, const QString &, const QVariant &)
32+void AccountsService::setUser(const QString &user)
3233{
34+ Q_UNUSED(user)
35+}
36+
37+bool AccountsService::getDemoEdges()
38+{
39+ return false;
40+}
41+
42+void AccountsService::setDemoEdges(bool demoEdges)
43+{
44+ Q_UNUSED(demoEdges)
45+}
46+
47+QString AccountsService::getBackgroundFile()
48+{
49+ return m_backgroundFile;
50+}
51+
52+void AccountsService::setBackgroundFile(const QString &backgroundFile)
53+{
54+ m_backgroundFile = backgroundFile;
55+ backgroundFileChanged();
3356}
tests/mocks/AccountsService/AccountsService.h+27−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,36 @@
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+ WRITE setBackgroundFile // only available in mock
41+ NOTIFY backgroundFileChanged)
3042
3143public:
3244 explicit AccountsService(QObject *parent = 0);
3345
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);
46+ QString getUser();
47+ void setUser(const QString &user);
48+ bool getDemoEdges();
49+ void setDemoEdges(bool demoEdges);
50+ QString getBackgroundFile();
51+ void setBackgroundFile(const QString &backgroundFile);
52+
53+Q_SIGNALS:
54+ void userChanged();
55+ void demoEdgesChanged();
56+ void backgroundFileChanged();
57+
58+private:
59+ QString m_backgroundFile;
3660};
3761
3862#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/LightDM/demo/GreeterPrivate.cpp+4−2
@@ -55,11 +55,13 @@ void GreeterPrivate::handleRespond(const QString &response)
5555 QSettings settings(QDir::homePath() + "/.unity8-greeter-demo", QSettings::NativeFormat);
5656 QVariant password = settings.value("password", "none");
5757
58+ QString passwordValue;
5859 if (password == "pin") {
59− authenticated = (response == "1234");
60+ passwordValue = settings.value("passwordValue", "1234").toString();
6061 } else {
61− authenticated = (response == "password");
62+ passwordValue = settings.value("passwordValue", "password").toString();
6263 }
64+ authenticated = (response == passwordValue);
6365 Q_EMIT q->authenticationComplete();
6466}
6567
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+4
@@ -1,3 +1,4 @@
1+add_subdirectory(Application)
12add_subdirectory(Indicators)
23
34pkg_search_module(DEE dee-1.0 REQUIRED)
@@ -17,6 +18,9 @@ add_definitions(-DQT_NO_KEYWORDS)
1718
1819set(UnityQML_SOURCES
1920 ${CMAKE_SOURCE_DIR}/plugins/Unity/categoryresults.cpp
21+ ${CMAKE_SOURCE_DIR}/plugins/Unity/iconutils.cpp
22+ fake_applications_scope.cpp
23+ fake_preview.cpp
2024 fake_scope.cpp
2125 fake_scopes.cpp
2226 fake_categories.cpp
tests/mocks/Unity/Indicators/CMakeLists.txt+1
@@ -13,6 +13,7 @@ set(IndicatorsFakeQml_SOURCES
1313 fakeplugin.cpp
1414 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/indicators.h
1515 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/menucontentactivator.cpp
16+ ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/visibleindicatorsmodel.cpp
1617)
1718
1819set(IndicatorsFakeQml_RESOURCES
tests/mocks/Unity/Indicators/IndicatorsModel.qml+47−76
@@ -23,82 +23,53 @@ ListModel {
2323
2424 function load() {}
2525
26− ListElement {
27− identifier: "indicator-fake1";
28− priority: 0
29− title: "Menu1";
30− description: "";
31− widgetSource: "qrc:/tests/indciators/qml/fake_menu_widget1.qml";
32− pageSource: "qrc:/tests/indciators/qml/fake_menu_page1.qml";
33− indicatorProperties: "";
34− isValid: "";
35− }
36− ListElement {
37− identifier: "indicator-fake2";
38− priority: 1
39− title: "Menu2";
40− description: "";
41− widgetSource: "qrc:/tests/indciators/qml/fake_menu_widget2.qml";
42− pageSource: "qrc:/tests/indciators/qml/fake_menu_page2.qml";
43− indicatorProperties: "";
44− isValid: "";
45− }
46− ListElement {
47− identifier: "indicator-fake3";
48− priority: 2
49− title: "Menu3";
50− description: "";
51− widgetSource: "qrc:/tests/indciators/qml/fake_menu_widget3.qml";
52− pageSource: "qrc:/tests/indciators/qml/fake_menu_page3.qml";
53− indicatorProperties: "";
54− isValid: "";
55− }
56− ListElement {
57− identifier: "indicator-fake4";
58− priority: 3
59− title: "Menu4";
60− description: "";
61− widgetSource: "qrc:/tests/indciators/qml/fake_menu_widget4.qml";
62− pageSource: "qrc:/tests/indciators/qml/fake_menu_page4.qml";
63− indicatorProperties: "";
64− isValid: "";
65− }
66− ListElement {
67− identifier: "indicator-fake5";
68− priority: 4
69− title: "Menu5";
70− description: "";
71− widgetSource: "qrc:/tests/indciators/qml/fake_menu_widget5.qml";
72− pageSource: "qrc:/tests/indciators/qml/fake_menu_page5.qml";
73− indicatorProperties: "";
74− isValid: "";
75− }
26+ // Need to do this dynamically.
27+ // Apparently ListModels dont order roles visually when using ListElement
28+ // which throws off the filter for non-visible indicators.
29+ Component.onCompleted: {
30+ append({ "identifier": "indicator-fake1",
31+ "priority": 0,
32+ "title": "Menu1",
33+ "description": "",
34+ "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget1.qml",
35+ "pageSource": "qrc:/tests/indciators/qml/fake_menu_page1.qml",
36+ "indicatorProperties": ""
37+ });
7638
77− function data(row, role) {
78− if (role == Indicators.IndicatorsModelRole.Identifier) {
79− return get(row).identifier;
80− }
81− else if (role == Indicators.IndicatorsModelRole.Priority) {
82− return get(row).priority
83− }
84− else if (role == Indicators.IndicatorsModelRole.Title) {
85− return get(row).title
86− }
87− else if (role == Indicators.IndicatorsModelRole.Description) {
88− return get(row).description
89− }
90− else if (role == Indicators.IndicatorsModelRole.WidgetSource) {
91− return get(row).widgetSource
92− }
93− else if (role == Indicators.IndicatorsModelRole.PageSource) {
94− return get(row).pageSource
95− }
96− else if (role == Indicators.IndicatorsModelRole.IndicatorProperties) {
97− return get(row).indicatorProperties
98− }
99− else if (role == Indicators.IndicatorsModelRole.IsValid) {
100− return get(row).isValid
101− }
102− }
39+ append({ "identifier": "indicator-fake2",
40+ "priority": 1,
41+ "title": "Menu2",
42+ "description": "",
43+ "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget2.qml",
44+ "pageSource": "qrc:/tests/indciators/qml/fake_menu_page2.qml",
45+ "indicatorProperties": ""
46+ });
47+
48+ append({ "identifier": "indicator-fake3",
49+ "priority": 2,
50+ "title": "Menu3",
51+ "description": "",
52+ "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget3.qml",
53+ "pageSource": "qrc:/tests/indciators/qml/fake_menu_page3.qml",
54+ "indicatorProperties": ""
55+ });
10356
57+ append({ "identifier": "indicator-fake4",
58+ "priority": 3,
59+ "title": "Menu4",
60+ "description": "",
61+ "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget4.qml",
62+ "pageSource": "qrc:/tests/indciators/qml/fake_menu_page4.qml",
63+ "indicatorProperties": ""
64+ });
65+
66+ append({ "identifier": "indicator-fake5",
67+ "priority": 4,
68+ "title": "Menu5",
69+ "description": "",
70+ "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget5.qml",
71+ "pageSource": "qrc:/tests/indciators/qml/fake_menu_page5.qml",
72+ "indicatorProperties": ""
73+ });
74+ }
10475}
tests/mocks/Unity/Indicators/fakeplugin.cpp+2
@@ -25,12 +25,14 @@
2525// local
2626#include "indicators.h"
2727#include "menucontentactivator.h"
28+#include "visibleindicatorsmodel.h"
2829
2930void IndicatorsFakePlugin::registerTypes(const char * uri)
3031{
3132 Q_INIT_RESOURCE(indicators_fake);
3233
3334 qmlRegisterType<MenuContentActivator>(uri, 0, 1, "MenuContentActivator");
35+ qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");
3436
3537 qmlRegisterUncreatableType<MenuContentState>(uri, 0, 1, "MenuContentState", "Can't create MenuContentState class");
3638 qmlRegisterUncreatableType<ActionState>(uri, 0, 1, "ActionState", "Can't create ActionState class");
tests/mocks/Unity/Indicators/qml/fake_menu_widget2.qml+2
@@ -20,4 +20,6 @@ Rectangle {
2020 width: 40
2121 height: 40
2222 color : "yellow"
23+
24+ enabled: false
2325}
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/MockLauncherItem.cpp+16
@@ -33,6 +33,7 @@ MockLauncherItem::MockLauncherItem(const QString &appId, const QString& desktopF
3333 m_recent(false),
3434 m_progress(-1),
3535 m_count(0),
36+ m_focused(false),
3637 m_quickList(new MockQuickListModel(this))
3738{
3839
@@ -128,6 +129,21 @@ void MockLauncherItem::setCount(int count)
128129 }
129130}
130131
132+bool MockLauncherItem::focused() const
133+{
134+ return m_focused;
135+}
136+
137+void MockLauncherItem::setFocused(bool focused)
138+{
139+ if (m_focused != focused)
140+ {
141+ m_focused = focused;
142+ Q_EMIT focusedChanged(focused);
143+ }
144+}
145+
146+
131147unity::shell::launcher::QuickListModelInterface *MockLauncherItem::quickList() const
132148{
133149 return m_quickList;
tests/mocks/Unity/Launcher/MockLauncherItem.h+4
@@ -52,6 +52,9 @@ public:
5252 int count() const;
5353 void setCount(int count);
5454
55+ bool focused() const;
56+ void setFocused(bool focused);
57+
5558 unity::shell::launcher::QuickListModelInterface *quickList() const;
5659
5760private:
@@ -64,6 +67,7 @@ private:
6467 bool m_recent;
6568 int m_progress;
6669 int m_count;
70+ bool m_focused;
6771 MockQuickListModel *m_quickList;
6872};
6973
tests/mocks/Unity/Launcher/MockLauncherModel.cpp+14−2
@@ -25,6 +25,7 @@ MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(pa
2525 MockLauncherItem *item = new MockLauncherItem("phone-app", "/usr/share/applications/phone-app.desktop", "Phone", "phone-app", this);
2626 item->setProgress(0);
2727 m_list.append(item);
28+ item->setFocused(true);
2829 item = new MockLauncherItem("camera-app", "/usr/share/applications/camera-app.desktop", "Camera", "camera", this);
2930 item->setProgress(10);
3031 m_list.append(item);
@@ -49,6 +50,7 @@ MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(pa
4950 item = new MockLauncherItem("notes-app", "/usr/share/applications/notes-app.desktop", "Notepad", "notepad", this);
5051 item->setProgress(50);
5152 item->setCount(5);
53+ item->setFocused(true);
5254 m_list.append(item);
5355 item = new MockLauncherItem("calendar-app", "/usr/share/applications/calendar-app.desktop","Calendar", "calendar", this);
5456 m_list.append(item);
@@ -69,8 +71,6 @@ QVariant MockLauncherModel::data(const QModelIndex& index, int role) const
6971 LauncherItemInterface *item = m_list.at(index.row());
7072 switch(role)
7173 {
72− case RoleDesktopFile:
73− return item->desktopFile();
7474 case RoleName:
7575 return item->name();
7676 case RoleIcon:
@@ -85,6 +85,8 @@ QVariant MockLauncherModel::data(const QModelIndex& index, int role) const
8585 return item->progress();
8686 case RoleCount:
8787 return item->count();
88+ case RoleFocused:
89+ return item->focused();
8890 }
8991
9092 return QVariant();
@@ -180,3 +182,13 @@ void MockLauncherModel::setUser(const QString &username)
180182 Q_UNUSED(username)
181183 // TODO: implement this...
182184}
185+
186+void MockLauncherModel::setApplicationManager(unity::shell::application::ApplicationManagerInterface *applicationManager)
187+{
188+ Q_UNUSED(applicationManager)
189+}
190+
191+unity::shell::application::ApplicationManagerInterface *MockLauncherModel::applicationManager() const
192+{
193+ return nullptr;
194+}
tests/mocks/Unity/Launcher/MockLauncherModel.h+3
@@ -45,6 +45,9 @@ public:
4545 Q_INVOKABLE void quickListActionInvoked(const QString &appId, int actionIndex);
4646 Q_INVOKABLE void setUser(const QString &username);
4747
48+ unity::shell::application::ApplicationManagerInterface *applicationManager() const;
49+ void setApplicationManager(unity::shell::application::ApplicationManagerInterface *applicationManager);
50+
4851Q_SIGNALS:
4952 void quickListTriggered(const QString &appId, int index);
5053
tests/mocks/Unity/fake_applications_scope.cppnew file+68
@@ -0,0 +1,68 @@
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+#include "fake_applications_scope.h"
18+
19+static const gchar * categories_model_schema[] = {
20+ "s", //ID
21+ "s", // DISPLAY_NAME
22+ "s", // ICON_HINT
23+ "s", // RENDERER_NAME
24+ "a{sv}" // HINTS
25+};
26+
27+ApplicationsScope::ApplicationsScope(bool visible, QObject* parent)
28+ : Scope(parent)
29+{
30+ m_id = "applications.scope";
31+ m_name = "Applications";
32+ m_visible = visible;
33+ m_categories->setModel(createCategoriesModel());
34+}
35+
36+DeeModel* ApplicationsScope::createCategoriesModel()
37+{
38+ DeeModel* category_model = dee_sequence_model_new();
39+ dee_model_set_schema_full(category_model, categories_model_schema, G_N_ELEMENTS(categories_model_schema));
40+ GVariant* hints = g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), NULL, 0);
41+
42+ GVariant* children[1];
43+ children[0] = g_variant_new_dict_entry(g_variant_new_string("content-type"),
44+ g_variant_new_variant(g_variant_new_string("apps")));
45+ GVariant* recentHints = g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), children, 1);
46+ dee_model_append(category_model,
47+ "recent",
48+ "Recent",
49+ "gtk-apply",
50+ "special",
51+ recentHints);
52+
53+ dee_model_append(category_model,
54+ "installed",
55+ "Installed",
56+ "gtk-apply",
57+ "grid",
58+ hints);
59+
60+ dee_model_append(category_model,
61+ "suggested",
62+ "Suggested",
63+ "gtk-apply",
64+ "grid",
65+ hints);
66+
67+ return category_model;
68+}
tests/mocks/Unity/fake_applications_scope.hnew file+33
@@ -0,0 +1,33 @@
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+#ifndef FAKE_APPLICATIONS_SCOPE_H
18+#define FAKE_APPLICATIONS_SCOPE_H
19+
20+#include "fake_scope.h"
21+
22+class ApplicationsScope : public Scope
23+{
24+ Q_OBJECT
25+
26+public:
27+ ApplicationsScope(bool visible, QObject* parent = 0);
28+
29+private:
30+ DeeModel* createCategoriesModel();
31+};
32+
33+#endif // FAKE_APPLICATIONS_SCOPE_H
tests/mocks/Unity/fake_categories.cpp+84−12
@@ -24,11 +24,20 @@
2424
2525#define CATEGORY_COLUMN 2
2626
27+// TODO: use something from libunity once it's public
28+enum CategoryColumn {
29+ ID,
30+ DISPLAY_NAME,
31+ ICON_HINT,
32+ RENDERER_NAME,
33+ HINTS
34+};
35+
2736Categories::Categories(QObject* parent)
2837 : DeeListModel(parent)
2938{
3039 // FIXME: need to clean up unused filters on countChanged
31− m_roles[Categories::RoleId] = "id";
40+ m_roles[Categories::RoleCategoryId] = "categoryId";
3241 m_roles[Categories::RoleName] = "name";
3342 m_roles[Categories::RoleIcon] = "icon";
3443 m_roles[Categories::RoleRenderer] = "renderer";
@@ -36,7 +45,6 @@ Categories::Categories(QObject* parent)
3645 m_roles[Categories::RoleHints] = "hints";
3746 m_roles[Categories::RoleResults] = "results";
3847 m_roles[Categories::RoleCount] = "count";
39− m_roles[Categories::RoleCategoryIndex] = "categoryIndex";
4048
4149 // TODO This should not be needed but accumulatting the count changes
4250 // makes the visualization more stable and also makes crashes on fast
@@ -74,6 +82,25 @@ Categories::onCountChanged()
7482 }
7583}
7684
85+void Categories::onRowCountChanged()
86+{
87+ QAbstractItemModel* model = qobject_cast<QAbstractItemModel*>(sender());
88+ // find the corresponding category index
89+ for (auto iter = m_overriddenCategories.begin(); iter != m_overriddenCategories.end(); ++iter) {
90+ if (iter.value() == model) {
91+ for (int i = 0; i < rowCount(); i++) {
92+ auto id = data(index(i), RoleCategoryId).toString();
93+ if (id != iter.key()) continue;
94+ QVector<int> roles;
95+ roles.append(RoleCount);
96+ QModelIndex changedIndex = index(i);
97+ Q_EMIT dataChanged(changedIndex, changedIndex, roles);
98+ break;
99+ }
100+ }
101+ }
102+}
103+
77104void
78105Categories::onEmitCountChanged()
79106{
@@ -93,6 +120,41 @@ Categories::roleNames() const
93120 return m_roles;
94121}
95122
123+void Categories::onOverrideModelDestroyed()
124+{
125+ QObject* model = sender();
126+ auto iter = m_overriddenCategories.begin();
127+ while (iter != m_overriddenCategories.end()) {
128+ if (iter.value() == model) {
129+ iter = m_overriddenCategories.erase(iter);
130+ continue;
131+ }
132+ ++iter;
133+ }
134+}
135+
136+void Categories::overrideResults(const QString& categoryId, QAbstractItemModel* model)
137+{
138+ m_overriddenCategories[categoryId] = model;
139+ // watch the model
140+ connect(model, &QObject::destroyed, this, &Categories::onOverrideModelDestroyed);
141+ connect(model, &QAbstractItemModel::rowsInserted, this, &Categories::onRowCountChanged);
142+ connect(model, &QAbstractItemModel::rowsRemoved, this, &Categories::onRowCountChanged);
143+ connect(model, &QAbstractItemModel::modelReset, this, &Categories::onRowCountChanged);
144+
145+ // emit the dataChanged signal if the category is already in the model
146+ for (int i = 0; i < rowCount(); i++) {
147+ auto id = data(index(i), RoleCategoryId).toString();
148+ if (id != categoryId) continue;
149+ QVector<int> roles;
150+ roles.append(RoleCount);
151+ roles.append(RoleResults);
152+ QModelIndex changedIndex = index(i);
153+ Q_EMIT dataChanged(changedIndex, changedIndex, roles);
154+ break;
155+ }
156+}
157+
96158void Categories::setResultModel(DeeModel* model)
97159{
98160 // FIXME: should ref it
@@ -154,27 +216,37 @@ Categories::data(const QModelIndex& index, int role) const
154216 }
155217
156218 switch (role) {
157− case RoleId:
158− return DeeListModel::data(index, 0); //ID
219+ case RoleCategoryId:
220+ return DeeListModel::data(index, CategoryColumn::ID);
159221 case RoleName:
160− return DeeListModel::data(index, 1); //DISPLAY_NAME
222+ return DeeListModel::data(index, CategoryColumn::DISPLAY_NAME);
161223 case RoleIcon:
162− return DeeListModel::data(index, 2); //ICON_HINT
224+ return DeeListModel::data(index, CategoryColumn::ICON_HINT);
163225 case RoleRenderer:
164− return DeeListModel::data(index, 3); //RENDERER_NAME
226+ return DeeListModel::data(index, CategoryColumn::RENDERER_NAME);
165227 case RoleContentType:
166228 {
167− auto hints = DeeListModel::data(index, 4).toHash();
168− return hints.contains("content-type") ? hints["content-type"] : QVariant(QString("default"));
229+ auto hints = DeeListModel::data(index, CategoryColumn::HINTS).toHash();
230+ return hints.contains("content-type") ? hints["content-type"] : QVariant(QString("default"));
169231 }
170232 case RoleHints:
171− return DeeListModel::data(index, 4); //HINTS
233+ return DeeListModel::data(index, CategoryColumn::HINTS);
172234 case RoleResults:
235+ if (m_overriddenCategories.size() > 0)
236+ {
237+ auto id = DeeListModel::data(index, CategoryColumn::ID).toString();
238+ if (m_overriddenCategories.find(id) != m_overriddenCategories.end())
239+ return QVariant::fromValue(m_overriddenCategories[id]);
240+ }
173241 return QVariant::fromValue(getFilter(index.row()));
174242 case RoleCount:
243+ if (m_overriddenCategories.size() > 0)
244+ {
245+ auto id = DeeListModel::data(index, CategoryColumn::ID).toString();
246+ if (m_overriddenCategories.find(id) != m_overriddenCategories.end())
247+ return QVariant::fromValue(m_overriddenCategories[id]->rowCount());
248+ }
175249 return QVariant::fromValue(getFilter(index.row())->rowCount());
176− case RoleCategoryIndex:
177− return QVariant::fromValue(index.row());
178250 default:
179251 return QVariant();
180252 }
tests/mocks/Unity/fake_categories.h+7−3
@@ -34,17 +34,18 @@ class Categories : public DeeListModel
3434public:
3535 Categories(QObject* parent = 0);
3636 enum Roles {
37− RoleId,
37+ RoleCategoryId,
3838 RoleName,
3939 RoleIcon,
4040 RoleRenderer,
4141 RoleContentType,
4242 RoleHints,
4343 RoleResults,
44− RoleCount,
45− RoleCategoryIndex
44+ RoleCount
4645 };
4746
47+ Q_INVOKABLE void overrideResults(const QString& categoryId, QAbstractItemModel* model);
48+
4849 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
4950
5051 QHash<int, QByteArray> roleNames() const;
@@ -54,7 +55,9 @@ public:
5455
5556private Q_SLOTS:
5657 void onCountChanged();
58+ void onRowCountChanged();
5759 void onEmitCountChanged();
60+ void onOverrideModelDestroyed();
5861
5962private:
6063 DeeModel* getResultsForCategory(unsigned index) const;
@@ -64,6 +67,7 @@ private:
6467 QTimer m_timer;
6568 QSet<DeeListModel*> m_timerFilters;
6669 QHash<int, QByteArray> m_roles;
70+ QMap<QString, QAbstractItemModel*> m_overriddenCategories;
6771 mutable QMap<int, DeeListModel*> m_filters;
6872};
6973
tests/mocks/Unity/fake_preview.cppnew file+66
@@ -0,0 +1,66 @@
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+#include "fake_preview.h"
18+
19+QString Preview::rendererName() const
20+{
21+ return "foo";
22+}
23+
24+QString Preview::title() const
25+{
26+ return "Title";
27+}
28+
29+QString Preview::subtitle() const
30+{
31+ return "Subtitle";
32+}
33+
34+QString Preview::description() const
35+{
36+ return "Description";
37+}
38+
39+QVariant Preview::actions()
40+{
41+ return QVariant();
42+}
43+
44+QVariant Preview::infoHints()
45+{
46+ return QVariant();
47+}
48+
49+QVariantMap Preview::infoHintsHash() const
50+{
51+ return QVariantMap();
52+}
53+
54+QString Preview::image() const
55+{
56+ return "";
57+}
58+
59+QString Preview::imageSourceUri() const
60+{
61+ return "";
62+}
63+
64+void Preview::execute(const QString& actionId, const QHash<QString, QVariant>& hints)
65+{
66+}
tests/mocks/Unity/fake_preview.hnew file+62
@@ -0,0 +1,62 @@
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+#ifndef FAKE_PREVIEW_H
18+#define FAKE_PREVIEW_H
19+
20+// Qt
21+#include <QObject>
22+#include <QString>
23+#include <QMetaType>
24+#include <QList>
25+#include <QVariantMap>
26+
27+class Q_DECL_EXPORT Preview : public QObject
28+{
29+ Q_OBJECT
30+
31+ Q_PROPERTY(QString rendererName READ rendererName NOTIFY previewChanged)
32+ Q_PROPERTY(QString title READ title NOTIFY previewChanged)
33+ Q_PROPERTY(QString subtitle READ subtitle NOTIFY previewChanged)
34+ Q_PROPERTY(QString description READ description NOTIFY previewChanged)
35+ Q_PROPERTY(QVariant actions READ actions NOTIFY previewChanged)
36+ Q_PROPERTY(QVariant infoHints READ infoHints NOTIFY previewChanged)
37+ Q_PROPERTY(QVariantMap infoMap READ infoHintsHash NOTIFY previewChanged)
38+ Q_PROPERTY(QString image READ image NOTIFY previewChanged)
39+ Q_PROPERTY(QString imageSourceUri READ imageSourceUri NOTIFY previewChanged)
40+
41+public:
42+ explicit Preview(QObject *parent = 0);
43+
44+ QString rendererName() const;
45+ QString title() const;
46+ QString subtitle() const;
47+ QString description() const;
48+ QVariant actions();
49+ QVariant infoHints();
50+ QVariantMap infoHintsHash() const;
51+ QString image() const;
52+ QString imageSourceUri() const;
53+
54+ Q_INVOKABLE void execute(const QString& actionId, const QHash<QString, QVariant>& hints);
55+
56+Q_SIGNALS:
57+ void previewChanged();
58+};
59+
60+Q_DECLARE_METATYPE(Preview *)
61+
62+#endif // FAKE_PREVIEW_H
tests/mocks/Unity/fake_scope.cpp+33−9
@@ -20,6 +20,8 @@
2020#include <dee.h>
2121#include "paths.h"
2222
23+#include "fake_preview.h"
24+
2325static DeeModel* create_categories_model(unsigned category_count);
2426static DeeModel* create_results_model(unsigned category_count, unsigned result_count);
2527
@@ -127,6 +129,36 @@ void Scope::setNoResultsHint(const QString& str) {
127129 }
128130}
129131
132+void Scope::activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
133+ const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
134+ const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata)
135+{
136+ Q_UNUSED(uri);
137+ Q_UNUSED(icon_hint);
138+ Q_UNUSED(category);
139+ Q_UNUSED(result_type);
140+ Q_UNUSED(mimetype);
141+ Q_UNUSED(title);
142+ Q_UNUSED(comment);
143+ Q_UNUSED(dnd_uri);
144+ Q_UNUSED(metadata);
145+}
146+
147+void Scope::preview(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
148+ const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
149+ const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata)
150+{
151+ Q_UNUSED(uri);
152+ Q_UNUSED(icon_hint);
153+ Q_UNUSED(category);
154+ Q_UNUSED(result_type);
155+ Q_UNUSED(mimetype);
156+ Q_UNUSED(title);
157+ Q_UNUSED(comment);
158+ Q_UNUSED(dnd_uri);
159+ Q_UNUSED(metadata);
160+}
161+
130162static const gchar * categories_model_schema[] = {
131163 "s", //ID
132164 "s", // DISPLAY_NAME
@@ -168,14 +200,6 @@ static const gchar * results_model_schema[] = {
168200 "a{sv}" // METADATA
169201};
170202
171−static const gchar * icons[] = {
172− "Applications.png",
173− "Home.png",
174− "Music.png",
175− "People.png",
176− "Videos.png",
177−};
178−
179203DeeModel* create_results_model(unsigned category_count, unsigned result_count) {
180204 DeeModel* results_model = dee_sequence_model_new();
181205 dee_model_set_schema_full(results_model, results_model_schema, G_N_ELEMENTS(results_model_schema));
@@ -187,7 +211,7 @@ DeeModel* create_results_model(unsigned category_count, unsigned result_count) {
187211
188212 dee_model_append(results_model,
189213 ("uri://result."+std::to_string(i)).c_str(),
190− (shellAppDirectory() + "Dash/graphics/scopeIcons/" + (icons[i%G_N_ELEMENTS(icons)])).toLatin1().data(),
214+ (shellAppDirectory() + "graphics/applicationIcons/dash.png").toLatin1().data(),
191215 category,
192216 0,
193217 "application/x-desktop",
tests/mocks/Unity/fake_scope.h+15−1
@@ -21,6 +21,8 @@
2121#include <QObject>
2222#include "fake_categories.h"
2323
24+class Preview;
25+
2426class Scope : public QObject
2527{
2628 Q_OBJECT
@@ -63,6 +65,13 @@ public:
6365 void setNoResultsHint(const QString& hint);
6466 void setFormFactor(const QString& form_factor);
6567
68+ Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
69+ const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
70+ const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata);
71+ Q_INVOKABLE void preview(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
72+ const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
73+ const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata);
74+
6675Q_SIGNALS:
6776 void idChanged(const QString&);
6877 void nameChanged(const QString&);
@@ -78,7 +87,12 @@ Q_SIGNALS:
7887 void noResultsHintChanged();
7988 void formFactorChanged();
8089
81−private:
90+ // signals triggered by activate(..) or preview(..) requests.
91+ void previewReady(Preview *preview);
92+ void activateApplication(const QString &desktop);
93+
94+protected:
95+
8296 QString m_id;
8397 QString m_iconHint;
8498 QString m_description;
tests/mocks/Unity/fake_scopes.cpp+4−1
@@ -19,6 +19,9 @@
1919// Self
2020#include "fake_scopes.h"
2121
22+// Local
23+#include "fake_applications_scope.h"
24+
2225// TODO: Implement remaining pieces, like Categories (i.e. LensView now gives warnings)
2326
2427// Qt
@@ -53,7 +56,7 @@ void Scopes::updateScopes()
5356 addScope(new Scope("MockScope1", "People", true, this));
5457 addScope(new Scope("MockScope2", "Music", false, this));
5558 addScope(new Scope("home.scope", "Home", true, this));
56− addScope(new Scope("applications.scope", "Applications", true, this));
59+ addScope(new ApplicationsScope(true, this));
5760 addScope(new Scope("MockScope5", "Videos", true, this));
5861
5962 if (!m_loaded) {
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/CMakeLists.txt+4
@@ -5,6 +5,7 @@ pkg_check_modules(UNITYCORE REQUIRED unity-core-6.0)
55pkg_check_modules(LIBUNITYPROTO REQUIRED unity-protocol-private)
66pkg_check_modules(LIBUNITY REQUIRED unity)
77pkg_check_modules(LIBSIGCPP REQUIRED sigc++-2.0)
8+pkg_check_modules(QTDEE REQUIRED libdee-qt5>=3.2)
89
910include_directories(
1011 ${Unity-qml_SOURCE_DIR}
@@ -14,6 +15,7 @@ include_directories(
1415 ${LIBUNITY_INCLUDE_DIRS}
1516 ${LIBSIGCPP_INCLUDE_DIRS}
1617 ${UNITYCORE_INCLUDE_DIRS}
18+ ${QTDEE_INCLUDE_DIRS}
1719 )
1820
1921macro(run_tests)
@@ -36,6 +38,7 @@ macro(run_tests)
3638 ${LIBUNITY_LDFLAGS}
3739 ${LIBUNITYPROTO_LDFLAGS}
3840 ${LIBSIGCPP_LDFLAGS}
41+ ${QTDEE_LDFLAGS}
3942 )
4043
4144 set(_test_list "${_test_list};${_test}")
@@ -46,4 +49,5 @@ run_tests(
4649 signalslisttest
4750 previewbindingstest
4851 filtersbindingstest
52+ resultstest
4953 )
tests/plugins/Unity/Launcher/CMakeLists.txt+53−4
@@ -1,22 +1,71 @@
1+pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
2+pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=3)
3+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=1)
4+
15include_directories(
26 ${CMAKE_CURRENT_BINARY_DIR}
37 ${CMAKE_SOURCE_DIR}/plugins/AccountsService
48 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher
59 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/backend
10+ ${GSETTINGS_QT_INCLUDE_DIRS}
611 )
712
813add_definitions(-DSM_BUSNAME=sessionBus)
914add_definitions(-DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
15+add_definitions(-DLAUNCHER_TESTING)
1016
11−set(testCommand ${CMAKE_CURRENT_BINARY_DIR}/launcherbackendtestExec
17+### LauncherBackendTest
18+set(testBackendCommand ${CMAKE_CURRENT_BINARY_DIR}/launcherbackendtestExec
1219 -o ${CMAKE_BINARY_DIR}/launcherbackendtest.xml,xunitxml
1320 -o -,txt)
14−add_test(NAME launcherbackendtest COMMAND ${testCommand})
15−add_custom_target(launcherbackendtest ${testCommand})
21+add_test(NAME launcherbackendtest COMMAND ${testBackendCommand})
22+add_custom_target(launcherbackendtest ${testBackendCommand})
1623add_executable(launcherbackendtestExec
1724 launcherbackendtest.cpp
18− ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsService.cpp
25+ ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsServiceDBusAdaptor.cpp
1926 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/backend/launcherbackend.cpp
2027 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/common/quicklistentry.cpp
2128 )
29+target_link_libraries(launcherbackendtestExec ${GSETTINGS_QT_LDFLAGS})
2230qt5_use_modules(launcherbackendtestExec Test Core DBus)
31+
32+### LauncherModelTest
33+set(testModelCommand ${CMAKE_CURRENT_BINARY_DIR}/launchermodeltestExec
34+ -o ${CMAKE_BINARY_DIR}/launchermodeltest.xml,xunitxml
35+ -o -,txt)
36+add_test(NAME launchermodeltest COMMAND ${testModelCommand})
37+add_custom_target(launchermodeltest ${testModelCommand})
38+add_executable(launchermodeltestExec
39+ launchermodeltest.cpp
40+ ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/launchermodel.cpp
41+ ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/launcheritem.cpp
42+ ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/quicklistmodel.cpp
43+ ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsServiceDBusAdaptor.cpp
44+ ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/backend/launcherbackend.cpp
45+ ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher/common/quicklistentry.cpp
46+ ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h
47+ ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherModelInterface.h
48+ ${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
51+ )
52+target_link_libraries(launchermodeltestExec ${GSETTINGS_QT_LDFLAGS} )
53+qt5_use_modules(launchermodeltestExec Test Core DBus)
54+
55+# copy .desktop files into build directory for shadow builds
56+file(GLOB DESKTOP_FILES *.desktop)
57+
58+foreach(DESKTOP_FILE ${DESKTOP_FILES})
59+ file(COPY "${DESKTOP_FILE}"
60+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
61+ )
62+endforeach()
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/click-icon.svgnew file

No changes to the content.

tests/plugins/Unity/Launcher/launcherbackendtest.cpp+41−42
@@ -20,73 +20,72 @@
2020#include "launcherbackend.h"
2121
2222#include <QtTest>
23−#include <QDebug>
2423
2524class LauncherBackendTest : public QObject
2625{
2726 Q_OBJECT
2827
2928private Q_SLOTS:
29+
30+ void initTestCase()
31+ {
32+ // As we want to test absolute file paths in the .desktop file, we need to modify the
33+ // sample file and replace the path in there with the current build dir.
34+ QSettings settings(QDir::currentPath() + "/click-icon.desktop", QSettings::IniFormat);
35+ settings.setValue("Desktop Entry/Path", QDir::currentPath());
36+ }
37+
3038 void testFileNames()
3139 {
3240 LauncherBackend backend(false);
3341
34− backend.setStoredApplications(QStringList() << "relative.path" << "/full/path");
35− QCOMPARE(backend.storedApplications(), QStringList() << "/usr/share/applications/relative.path" << "/full/path");
36−
37− QCOMPARE(backend.desktopFile("one.desktop"), QString("/usr/share/applications/one.desktop"));
38− QCOMPARE(backend.desktopFile("two"), QString("/usr/share/applications/two"));
39− QCOMPARE(backend.desktopFile("/full"), QString("/full"));
40−
41− QCOMPARE(backend.desktopFile("/usr/share/applications/one.desktop"), QString("/usr/share/applications/one.desktop"));
42+ backend.setStoredApplications(QStringList() << "rel-icon" << "abs-icon" << "invalid");
43+ QCOMPARE(backend.storedApplications(), QStringList() << "rel-icon" << "abs-icon");
4244 }
4345
44− void testDesktopReading()
46+ void testPinning()
4547 {
4648 LauncherBackend backend(false);
4749
48− QCOMPARE(backend.displayName(SRCDIR "/rel-icon.desktop"), QString("Relative Icon"));
49− QCOMPARE(backend.icon(SRCDIR "/rel-icon.desktop"), QString("image://gicon/rel-icon"));
50+ backend.setStoredApplications(QStringList() << "rel-icon" << "abs-icon");
51+ QCOMPARE(backend.isPinned("rel-icon"), false);
52+ QCOMPARE(backend.isPinned("abs-icon"), false);
5053
51− QCOMPARE(backend.displayName(SRCDIR "/abs-icon.desktop"), QString("Absolute Icon"));
52− QCOMPARE(backend.icon(SRCDIR "/abs-icon.desktop"), QString("/path/to/icon.png"));
54+ backend.setPinned("rel-icon", true);
55+ QCOMPARE(backend.isPinned("rel-icon"), true);
5356
54− QCOMPARE(backend.displayName(SRCDIR "/no-icon.desktop"), QString("No Icon"));
55− QCOMPARE(backend.icon(SRCDIR "/no-icon.desktop"), QString(""));
57+ backend.setStoredApplications(QStringList() << "rel-icon" << "abs-icon" << "no-name");
58+ QCOMPARE(backend.isPinned("rel-icon"), true);
59+ QCOMPARE(backend.isPinned("no-name"), false);
5660
57− QCOMPARE(backend.displayName(SRCDIR "/no-name.desktop"), QString(""));
58− QCOMPARE(backend.icon(SRCDIR "/no-name.desktop"), QString("image://gicon/no-name"));
59−
60− QCOMPARE(backend.displayName(SRCDIR "/no-exist.desktop"), QString(""));
61− QCOMPARE(backend.icon(SRCDIR "/no-exist.desktop"), QString(""));
61+ backend.setPinned("no-name", true);
62+ backend.setStoredApplications(QStringList() << "rel-icon" << "abs-icon");
63+ QCOMPARE(backend.isPinned("rel-icon"), true);
64+ QCOMPARE(backend.isPinned("no-name"), false); // doesn't exist anymore!
6265 }
6366
64− void testPinning()
65− {
66− LauncherBackend backend(false);
67+ void testIcon_data() {
68+ QTest::addColumn<QString>("appId");
69+ QTest::addColumn<QString>("expectedIcon");
6770
68− // Confirm that default entries are all pinned
69− auto defaultApps = backend.storedApplications();
70− QVERIFY(defaultApps.size() > 0);
71− for (auto app: defaultApps) {
72− QCOMPARE(backend.isPinned(app), true);
73− }
71+ // Needs to expand a relative icon to the absolute path
72+ QTest::newRow("relative icon path") << "rel-icon" << QDir::currentPath() + "/rel-icon.svg";
7473
75− backend.setStoredApplications(QStringList() << "one" << "two");
76− QCOMPARE(backend.isPinned("one"), false);
77− QCOMPARE(backend.isPinned("two"), false);
74+ // In case an icon is not found on disk, it needs to fallback on image://theme/ for it
75+ QTest::newRow("fallback on theme") << "abs-icon" << "image://theme//path/to/icon.png";
7876
79− backend.setPinned("two", true);
80− QCOMPARE(backend.isPinned("two"), true);
77+ // Click packages have a relative icon path but an absolute path as a separate entry
78+ QTest::newRow("click package icon") << "click-icon" << QDir::currentPath() + "/click-icon.svg";
79+ }
80+
81+ void testIcon() {
82+ QFETCH(QString, appId);
83+ QFETCH(QString, expectedIcon);
8184
82− backend.setStoredApplications(QStringList() << "one" << "two" << "three");
83− QCOMPARE(backend.isPinned("two"), true);
84− QCOMPARE(backend.isPinned("three"), false);
85+ LauncherBackend backend(false);
86+ backend.setStoredApplications(QStringList() << appId);
8587
86− backend.setPinned("three", true);
87− backend.setStoredApplications(QStringList() << "one" << "two");
88− QCOMPARE(backend.isPinned("two"), true);
89− QCOMPARE(backend.isPinned("three"), false); // doesn't exist anymore!
88+ QCOMPARE(backend.icon(appId), expectedIcon);
9089 }
9190};
9291
tests/plugins/Unity/Launcher/launchermodeltest.cppnew file+275
@@ -0,0 +1,275 @@
1+/*
2+ * Copyright 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 Lesser 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 Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authors:
17+ * Michael Zanetti <michael.zanetti@canonical.com>
18+ */
19+
20+// unity-api
21+#include <unity/shell/launcher/LauncherModelInterface.h>
22+#include <unity/shell/application/ApplicationInfoInterface.h>
23+
24+#include "launcheritem.h"
25+#include "launchermodel.h"
26+
27+#include <QtTest>
28+
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 &appId) const {
66+ Q_FOREACH(MockApp* app, m_list) {
67+ if (app->appId() == appId) {
68+ return app;
69+ }
70+ }
71+ return nullptr;
72+ }
73+ unity::shell::application::ApplicationInfoInterface *startApplication(const QString &, const QStringList &) { return nullptr; }
74+ bool stopApplication(const QString &) { return false; }
75+ bool focusApplication(const QString &appId) {
76+ Q_FOREACH(MockApp* app, m_list) {
77+ app->setFocused(app->appId() == appId);
78+ }
79+ Q_EMIT focusedApplicationIdChanged();
80+ return true;
81+ }
82+
83+ void unfocusCurrentApplication() { }
84+
85+ void addApplication(MockApp *app) {
86+ beginInsertRows(QModelIndex(), count(), count());
87+ m_list.append(app);
88+ endInsertRows();
89+ }
90+ void removeApplication(int index) {
91+ beginRemoveRows(QModelIndex(), index, index);
92+ m_list.takeAt(index)->deleteLater();
93+ endRemoveRows();
94+ }
95+
96+private:
97+ QList<MockApp*> m_list;
98+};
99+
100+class LauncherModelTest : public QObject
101+{
102+ Q_OBJECT
103+
104+private:
105+ LauncherModel *launcherModel;
106+ MockAppManager *appManager;
107+
108+private Q_SLOTS:
109+
110+ void initTestCase() {
111+ launcherModel = new LauncherModel(this);
112+ QCOMPARE(launcherModel->rowCount(QModelIndex()), 0);
113+
114+ appManager = new MockAppManager(this);
115+ launcherModel->setApplicationManager(appManager);
116+ }
117+
118+ // Adding 2 apps to the mock appmanager. Both should appear in the launcher.
119+ void init() {
120+ appManager->addApplication(new MockApp("abs-icon"));
121+ QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
122+
123+ appManager->addApplication(new MockApp("no-icon"));
124+ QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
125+ }
126+
127+ // Removing apps from appmanager and launcher as pinned ones would stick
128+ void cleanup() {
129+ while (appManager->count() > 0) {
130+ appManager->removeApplication(0);
131+ }
132+ while (launcherModel->rowCount(QModelIndex()) > 0) {
133+ launcherModel->requestRemove(launcherModel->get(0)->appId());
134+ }
135+ }
136+
137+ void testMove() {
138+ QCOMPARE(launcherModel->get(0)->pinned(), false);
139+ QCOMPARE(launcherModel->get(1)->pinned(), false);
140+
141+ LauncherItemInterface *item0BeforeMove = launcherModel->get(0);
142+ LauncherItemInterface *item1BeforeMove = launcherModel->get(1);
143+ launcherModel->move(1, 0);
144+
145+ QCOMPARE(item0BeforeMove, launcherModel->get(1));
146+ QCOMPARE(item1BeforeMove, launcherModel->get(0));
147+
148+ // moved item must be pinned now
149+ QCOMPARE(item0BeforeMove->pinned(), false);
150+ QCOMPARE(item1BeforeMove->pinned(), true);
151+ }
152+
153+ void testPinning() {
154+ QCOMPARE(launcherModel->get(0)->pinned(), false);
155+ QCOMPARE(launcherModel->get(1)->pinned(), false);
156+ launcherModel->pin(launcherModel->get(0)->appId());
157+ QCOMPARE(launcherModel->get(0)->pinned(), true);
158+ QCOMPARE(launcherModel->get(1)->pinned(), false);
159+ }
160+
161+ void testRemove_data() {
162+
163+ QTest::addColumn<bool>("pinned");
164+ QTest::addColumn<bool>("running");
165+
166+ QTest::newRow("non-pinned, running") << false << true;
167+ QTest::newRow("pinned, running") << true << false;
168+ QTest::newRow("pinned, non-running") << true << false;
169+ }
170+
171+ void testRemove() {
172+ QFETCH(bool, pinned);
173+ QFETCH(bool, running);
174+
175+ // In the beginning we always have two items
176+ QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
177+
178+ // pin one if required
179+ if (pinned) {
180+ launcherModel->pin(launcherModel->get(1)->appId());
181+ }
182+
183+ // stop it if required
184+ if (!running) {
185+ appManager->removeApplication(1);
186+ }
187+
188+ // Now remove it
189+ launcherModel->requestRemove(launcherModel->get(1)->appId());
190+
191+ if (running) {
192+ // both apps are running, both apps must still be here
193+ QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
194+
195+ // Item must be unpinned now
196+ QCOMPARE(launcherModel->get(1)->pinned(), false);
197+
198+ } else if (pinned) {
199+ // Item 1 must go away, item 0 is here to stay
200+ QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
201+ }
202+
203+ // done our checks. now stop the app if was still running
204+ if (running) {
205+ appManager->removeApplication(1);
206+ }
207+
208+ // It needs to go away in any case now
209+ QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
210+ }
211+
212+ void testQuickListPinningRemoving() {
213+ // we start with 2 unpinned items
214+ QCOMPARE(launcherModel->get(0)->pinned(), false);
215+ QCOMPARE(launcherModel->get(1)->pinned(), false);
216+ QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
217+
218+ // find the Pin item in the quicklist
219+ QuickListModel *model = qobject_cast<QuickListModel*>(launcherModel->get(0)->quickList());
220+ int pinActionIndex = -1;
221+ for (int i = 0; i < model->rowCount(QModelIndex()); ++i) {
222+ if (model->get(i).actionId() == "pin_item") {
223+ pinActionIndex = i;
224+ break;
225+ }
226+ }
227+ QVERIFY(pinActionIndex >= 0);
228+
229+ // trigger pin item quicklist action => Item must be pinned now.
230+ launcherModel->quickListActionInvoked(launcherModel->get(0)->appId(), pinActionIndex);
231+ QCOMPARE(launcherModel->get(0)->pinned(), true);
232+ QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
233+
234+ // quicklist needs to transform to remove item. trigger it and check it item goes away
235+ launcherModel->quickListActionInvoked(launcherModel->get(0)->appId(), pinActionIndex);
236+ QCOMPARE(launcherModel->get(0)->pinned(), false);
237+
238+ // still needs to be here as the app is still here
239+ QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
240+ // close the app
241+ appManager->removeApplication(0);
242+ // Now it needs to go away
243+ QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
244+ }
245+
246+ void testApplicationFocused() {
247+ // all apps unfocused at beginning...
248+ QCOMPARE(launcherModel->get(0)->focused(), false);
249+ QCOMPARE(launcherModel->get(1)->focused(), false);
250+
251+ appManager->focusApplication("abs-icon");
252+ QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
253+ QCOMPARE(launcherModel->get(0)->focused(), true);
254+ QCOMPARE(launcherModel->get(1)->focused(), false);
255+
256+ appManager->focusApplication("no-icon");
257+ QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
258+ QCOMPARE(launcherModel->get(0)->focused(), false);
259+ QCOMPARE(launcherModel->get(1)->focused(), true);
260+ }
261+
262+ void testClosingApps() {
263+ // At the start there are 2 items. Let's pin one.
264+ launcherModel->pin("abs-icon");
265+ while (appManager->count() > 0) {
266+ appManager->removeApplication(0);
267+ }
268+ // The pinned one needs to stay, the other needs to disappear
269+ QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
270+ QCOMPARE(launcherModel->get(0)->appId(), QLatin1String("abs-icon"));
271+ }
272+};
273+
274+QTEST_GUILESS_MAIN(LauncherModelTest)
275+#include "launchermodeltest.moc"
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/plugins/Unity/resultstest.cppnew file+104
@@ -0,0 +1,104 @@
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:
17+ * Michal Hruby <michal.hruby@canonical.com>
18+ */
19+
20+#include <QTest>
21+#include <dee.h>
22+
23+#include "resultstest.h"
24+#include "categoryresults.h"
25+
26+static DeeModel* createBackendModel()
27+{
28+ auto model = dee_sequence_model_new();
29+ dee_model_set_schema(model, "s", "s", "u", "u", "s", "s", "s", "s", "a{sv}", NULL);
30+
31+ return model;
32+}
33+
34+void ResultsTest::testAllColumns()
35+{
36+ auto deeModel = createBackendModel();
37+ GVariantBuilder builder;
38+ g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
39+ g_variant_builder_add(&builder, "{sv}", "metadata-field", g_variant_new_string("foo"));
40+ dee_model_append (deeModel,
41+ "test:uri",
42+ "themed-icon",
43+ 4,
44+ 0,
45+ "application/octet-stream",
46+ "Test",
47+ "Comment",
48+ "test:dnd-uri",
49+ g_variant_builder_end(&builder));
50+
51+ CategoryResults* results = new CategoryResults(this);
52+ results->setModel(deeModel);
53+
54+ auto index = results->index(0, 0); // there's just one result
55+ QCOMPARE(index.data(CategoryResults::Roles::RoleUri).toString(), QString("test:uri"));
56+ QCOMPARE(index.data(CategoryResults::Roles::RoleIconHint).toString(), QString("image://theme/themed-icon"));
57+ QCOMPARE(index.data(CategoryResults::Roles::RoleCategory).toInt(), 4);
58+ QCOMPARE(index.data(CategoryResults::Roles::RoleMimetype).toString(), QString("application/octet-stream"));
59+ QCOMPARE(index.data(CategoryResults::Roles::RoleTitle).toString(), QString("Test"));
60+ QCOMPARE(index.data(CategoryResults::Roles::RoleComment).toString(), QString("Comment"));
61+ QCOMPARE(index.data(CategoryResults::Roles::RoleDndUri).toString(), QString("test:dnd-uri"));
62+ auto metadata = index.data(CategoryResults::Roles::RoleMetadata).toHash();
63+ QCOMPARE(metadata["metadata-field"].toString(), QString("foo"));
64+}
65+
66+void ResultsTest::testIconColumn_data()
67+{
68+ QTest::addColumn<QString>("giconString");
69+ QTest::addColumn<QString>("result");
70+
71+ QTest::newRow("absolute path") << "/usr/share/icons/example.png" << "/usr/share/icons/example.png";
72+ QTest::newRow("file uri") << "file:///usr/share/icons/example.png" << "file:///usr/share/icons/example.png";
73+ QTest::newRow("http uri") << "http://images.ubuntu.com/example.jpg" << "http://images.ubuntu.com/example.jpg";
74+ QTest::newRow("themed icon") << "accessories-other" << "image://theme/accessories-other";
75+ QTest::newRow("fileicon") << ". GFileIcon http://example.org/resource.gif" << "http://example.org/resource.gif";
76+ QTest::newRow("themedicon") << ". GThemedIcon accessories-other accessories generic" << "image://theme/accessories-other,accessories,generic";
77+ QTest::newRow("annotatedicon") << ". UnityProtocolAnnotatedIcon %7B'base-icon':%20%3C'.%20GThemedIcon%20accessories-other%20accessories%20generic'%3E%7D" << "image://theme/accessories-other,accessories,generic";
78+}
79+
80+void ResultsTest::testIconColumn()
81+{
82+ QFETCH(QString, giconString);
83+ QFETCH(QString, result);
84+ auto deeModel = createBackendModel();
85+ dee_model_append (deeModel,
86+ "test:uri",
87+ giconString.toLocal8Bit().constData(),
88+ 0,
89+ 0,
90+ "application/octet-stream",
91+ "Test",
92+ "",
93+ "test:dnd-uri",
94+ g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), NULL, 0));
95+
96+ CategoryResults* results = new CategoryResults(this);
97+ results->setModel(deeModel);
98+
99+ auto index = results->index(0, 0); // there's just one result
100+ auto transformedIcon = index.data(CategoryResults::Roles::RoleIconHint).toString();
101+ QCOMPARE(transformedIcon, result);
102+}
103+
104+QTEST_MAIN(ResultsTest)
tests/plugins/Unity/resultstest.hnew file+35
@@ -0,0 +1,35 @@
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:
17+ * Michal Hruby <michal.hruby@canonical.com>
18+ */
19+
20+#ifndef RESULTSTEST_H
21+#define RESULTSTEST_H
22+
23+#include <QObject>
24+
25+class ResultsTest : public QObject
26+{
27+ Q_OBJECT
28+
29+ private Q_SLOTS:
30+ void testAllColumns();
31+ void testIconColumn_data();
32+ void testIconColumn();
33+};
34+
35+#endif
tests/qmltests/CMakeLists.txt+1−1
@@ -66,7 +66,7 @@ add_qml_test(Launcher Launcher IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltes
6666add_qml_test(Notifications Notifications IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_SOURCE_DIR}/tests/mocks)
6767add_qml_test(Panel IndicatorRow)
6868add_qml_test(Panel Indicators IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
69−add_qml_test(Panel MenuContent)
69+add_qml_test(Panel MenuContent IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
7070add_qml_test(Panel Panel IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
7171add_qml_test(Panel SearchIndicator)
7272add_qml_test(SideStage SideStage IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS}
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/Dash/tst_DashContent.qml+1−1
@@ -106,7 +106,7 @@ Item {
106106 contentEndReachedSpy.clear()
107107 clear_scope_status();
108108
109− // clear, wait for dahs to empty and load scopes.
109+ // clear, wait for dash to empty and load scopes.
110110 var dashContentList = findChild(dashContent, "dashContentList");
111111 verify(dashContentList != undefined)
112112 scopesModel.clear();
tests/qmltests/Dash/tst_GenericScopeView.qml+3
@@ -44,10 +44,13 @@ Item {
4444
4545 function test_isCurrent() {
4646 var pageHeader = findChild(genericScopeView, "pageHeader");
47+ var previewLoader = findChild(genericScopeView, "previewLoader");
4748 genericScopeView.isCurrent = true
4849 pageHeader.searchQuery = "test"
50+ previewLoader.open = true
4951 genericScopeView.isCurrent = false
5052 tryCompare(pageHeader, "searchQuery", "")
53+ tryCompare(genericScopeView, "previewShown", false);
5154 }
5255 }
5356 }
tests/qmltests/Greeter/tst_Phone.qml+19−1
@@ -18,8 +18,8 @@ import QtQuick 2.0
1818import QtTest 1.0
1919import ".."
2020import "../../../Greeter"
21+import AccountsService 0.1
2122import Ubuntu.Components 0.1
22−import LightDM 0.1 as LightDM
2323import Unity.Test 0.1 as UT
2424
2525Item {
@@ -32,6 +32,8 @@ Item {
3232 height: parent.height
3333 x: 0; y: 0
3434
35+ defaultBackground: "../../../graphics/phone_background.jpg"
36+
3537 property int minX: 0
3638
3739 onXChanged: {
@@ -102,5 +104,21 @@ Item {
102104 // Wait until we're back to 0
103105 tryCompareFunction(function() { return greeter.x;}, 0);
104106 }
107+
108+ function test_wallpaper_data() {
109+ return [
110+ {tag: "set", accounts: "../tests/data/unity/backgrounds/blue.png", expected: "blue.png"},
111+ {tag: "unset", accounts: "", expected: "background.jpg"},
112+ {tag: "invalid", accounts: "invalid", expected: "background.jpg"},
113+ ]
114+ }
115+
116+ function test_wallpaper(data) {
117+ var loader = findChild(greeter, "greeterContentLoader")
118+ var wallpaper = findChild(loader.item, "wallpaper")
119+ AccountsService.backgroundFile = data.accounts
120+ tryCompareFunction(function() { return wallpaper.source.toString().indexOf(data.expected) !== -1; }, true)
121+ tryCompare(wallpaper, "status", Image.Ready)
122+ }
105123 }
106124}
tests/qmltests/Launcher/tst_Launcher.qml+10−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()
@@ -198,6 +198,14 @@ Item {
198198 compare(findChild(delegate, "progressOverlay").visible, LauncherModel.get(i).progress >= 0)
199199 }
200200 }
201+
202+ function test_focusedHighlight() {
203+ var launcherListView = findChild(launcher, "launcherListView");
204+ for (var i = 0; i < launcherListView.count; ++i) {
205+ var delegate = findChild(launcherListView, "launcherDelegate" + i)
206+ compare(findChild(delegate, "focusedHighlight").visible, LauncherModel.get(i).focused)
207+ }
208+ }
201209 }
202210
203211 UT.UnityTestCase {
tests/qmltests/Panel/tst_IndicatorItem.qml+2−2
@@ -53,9 +53,9 @@ Rectangle {
5353 }
5454
5555 function test_empty() {
56− compare(indicatorItem.visible, false, "IndicatorItem should not be visible.");
56+ compare(indicatorItem.indicatorVisible, false, "IndicatorItem should not be visible.");
5757 indicatorItem.widgetSource = "qrc:/tests/indciators/qml/fake_menu_widget1.qml";
58− tryCompare(indicatorItem, "visible", true);
58+ tryCompare(indicatorItem, "indicatorVisible", true);
5959 }
6060 }
6161}
tests/qmltests/Panel/tst_Indicators.qml+30−11
@@ -100,26 +100,29 @@ Item {
100100 {
101101 // tests changing the lateral position of the revealer activates the correct indicator items.
102102
103− var indicator_row = findChild(indicators, "indicatorRow")
104− var row_repeater = findChild(indicators, "rowRepeater")
103+ var indicatorRow = findChild(indicators, "indicatorRow")
104+ var rowRepeater = findChild(indicators, "rowRepeater")
105105
106− for (var i = 0; i < row_repeater.count; i++) {
107− var indicator_item = row_repeater.itemAt(i);
106+ for (var i = 0; i < rowRepeater.count; i++) {
107+ var indicatorItem = rowRepeater.itemAt(i);
108108
109− var indicator_position = indicators.mapFromItem(indicator_item,
110− indicator_item.width/2, indicator_item.height/2)
109+ if (!indicatorItem.visible)
110+ continue;
111+
112+ var indicatorPosition = indicators.mapFromItem(indicatorItem,
113+ indicatorItem.width/2, indicatorItem.height/2)
111114
112115 touchFlick(indicators,
113− indicator_position.x, indicator_position.y,
114− indicator_position.x, indicators.openedHeight * 0.4,
116+ indicatorPosition.x, indicatorPosition.y,
117+ indicatorPosition.x, indicators.openedHeight * 0.4,
115118 true /* beginTouch */, false /* endTouch */)
116119
117− compare(indicator_row.currentItem, indicator_item,
120+ compare(indicatorRow.currentItem, indicatorItem,
118121 "Incorrect item activated at position " + i);
119122
120123 touchFlick(indicators,
121− indicator_position.x, indicators.openedHeight * 0.4,
122− indicator_position.x, indicator_position.y,
124+ indicatorPosition.x, indicators.openedHeight * 0.4,
125+ indicatorPosition.x, indicatorPosition.y,
123126 false /* beginTouch */, true /* endTouch */)
124127
125128 // wait until fully closed
@@ -158,5 +161,21 @@ Item {
158161 compare(indicators.fullyOpened, true);
159162 }
160163
164+ function test_row_visible_menuContent_visible_data() { return [
165+ {tag: "visible", index: 0, name: "indicator-fake1", visible: true },
166+ {tag: "invisible", index: 1, name: "indicator-fake2", visible: false }]
167+ }
168+
169+ function test_row_visible_menuContent_visible(data) {
170+ var indicatorTabs = findChild(indicators, "tabs");
171+ var rowRepeater = findChild(indicators, "rowRepeater");
172+
173+ var indicatorItem = rowRepeater.itemAt(data.index);
174+ tryCompareFunction(function() { return indicatorItem.width > 0}, true);
175+ tryCompare(indicatorItem, "visible", data.visible);
176+
177+ var indicatorTab = findChild(indicatorTabs, data.name)
178+ tryCompareFunction(function() { return indicatorTab !== undefined }, data.visible);
179+ }
161180 }
162181}
tests/qmltests/Panel/tst_MenuContent.qml+9−2
@@ -48,8 +48,15 @@ Item {
4848 id: menuContent
4949 indicatorsModel: indicatorsModel
5050 contentReleaseInterval: 50
51−
5251 height: parent.height - 50
52+
53+ visibleIndicators: {
54+ 'indicator-fake1': true,
55+ 'indicator-fake2': true,
56+ 'indicator-fake3': true,
57+ 'indicator-fake4': true,
58+ 'indicator-fake5': true
59+ }
5360 }
5461
5562 Rectangle {
@@ -134,7 +141,7 @@ Item {
134141 var menuIndex = i%menuCount;
135142
136143 activate_content(menuIndex);
137− testTabObjectName = indicatorsModel.data(menuIndex, Indicators.IndicatorsModelRole.Identifier);
144+ testTabObjectName = indicatorsModel.get(menuIndex).identifier;
138145 compare(tabs.selectedTabIndex, menuIndex, "Current tab index does not match selected tab index");
139146 tryCompareFunction(selected_tab_equals_test_tab, true);
140147 }
tests/qmltests/Panel/tst_Panel.qml+3
@@ -159,6 +159,9 @@ Item {
159159 var indicatorItem = get_indicator_item(i);
160160 verify(indicatorItem != undefined);
161161
162+ if (!indicatorItem.visible)
163+ continue;
164+
162165 var indicatorItemCoord = get_indicator_item_position(i);
163166
164167 touchPress(panel,
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
tests/uqmlscene/main.cpp−2
@@ -497,8 +497,6 @@ int main(int argc, char ** argv)
497497 }
498498
499499 if (window) {
500− mouseTouchAdaptor.setTargetWindow(window);
501−
502500 QSurfaceFormat surfaceFormat = window->requestedFormat();
503501 if (options.multisample)
504502 surfaceFormat.setSamples(16);