on xenial help sign in
In split mode, determine whether the application identifiers in AccountsService are click packages or not, so we know the correct url prefix to use.
commit53527e20864bd63e0cd0016267b49dc50ebc7faf authorMichael Terry <michael.terry@canonical.com> dateFri 30 May 2014, 09:28 (12 years ago) parent65045afcf40464
7 files changed+34−2
plugins/Unity/Launcher/launchermodel.cpp+16 plugins/Unity/Launcher/launchermodel.h+1 qml/GreeterShell.qml+1−1 tests/mocks/Unity/Launcher/MockLauncherModel.cpp+5 tests/mocks/Unity/Launcher/MockLauncherModel.h+1 tests/plugins/Unity/Launcher/CMakeLists.txt+1−1 tests/plugins/Unity/Launcher/launchermodeltest.cpp+9
plugins/Unity/Launcher/launchermodel.cpp+16
@@ -195,6 +195,22 @@ void LauncherModel::setUser(const QString &username)
195195 m_backend->setUser(username);
196196}
197197
198+QString LauncherModel::getUrlForAppId(const QString &appId) const
199+{
200+ // appId is either an appId or a legacy app name. Let's find out which
201+ if (appId.isEmpty())
202+ return QString();
203+
204+ QString df = m_backend->desktopFile(appId + ".desktop");
205+ if (!df.isEmpty())
206+ return "application:///" + appId + ".desktop";
207+
208+ QStringList parts = appId.split('_');
209+ QString package = parts.value(0);
210+ QString app = parts.value(1, "first-listed-app");
211+ return "appid://" + package + "/" + app + "/current-user-version";
212+}
213+
198214void LauncherModel::refreshStoredApplications()
199215{
200216 // First remove any existing ones
plugins/Unity/Launcher/launchermodel.h+1
@@ -51,6 +51,7 @@ public:
5151 Q_INVOKABLE void requestRemove(const QString &appId);
5252 Q_INVOKABLE void quickListActionInvoked(const QString &appId, int actionIndex);
5353 Q_INVOKABLE void setUser(const QString &username);
54+ Q_INVOKABLE QString getUrlForAppId(const QString &appId) const;
5455
5556 unity::shell::application::ApplicationManagerInterface* applicationManager() const;
5657 void setApplicationManager(unity::shell::application::ApplicationManagerInterface *appManager);
qml/GreeterShell.qml+1−1
@@ -201,7 +201,7 @@ BasicShell {
201201 dragAreaWidth: shell.edgeSize
202202 available: !edgeDemo.active
203203 onLauncherApplicationSelected: {
204− shell.activateApplication("application:///" + appId + ".desktop")
204+ shell.activateApplication(LauncherModel.getUrlForAppId(appId))
205205 }
206206 onShownChanged: {
207207 if (shown) {
tests/mocks/Unity/Launcher/MockLauncherModel.cpp+5
@@ -183,6 +183,11 @@ void MockLauncherModel::setUser(const QString &username)
183183 // TODO: implement this...
184184}
185185
186+QString MockLauncherModel::getUrlForAppId(const QString &appId) const
187+{
188+ return "application:///" + appId + ".desktop";
189+}
190+
186191void MockLauncherModel::setApplicationManager(unity::shell::application::ApplicationManagerInterface *applicationManager)
187192{
188193 Q_UNUSED(applicationManager)
tests/mocks/Unity/Launcher/MockLauncherModel.h+1
@@ -44,6 +44,7 @@ public:
4444 Q_INVOKABLE void requestRemove(const QString &appId);
4545 Q_INVOKABLE void quickListActionInvoked(const QString &appId, int actionIndex);
4646 Q_INVOKABLE void setUser(const QString &username);
47+ Q_INVOKABLE QString getUrlForAppId(const QString &appId) const;
4748
4849 unity::shell::application::ApplicationManagerInterface *applicationManager() const;
4950 void setApplicationManager(unity::shell::application::ApplicationManagerInterface *applicationManager);
tests/plugins/Unity/Launcher/CMakeLists.txt+1−1
@@ -49,7 +49,7 @@ add_executable(launchermodeltestExec
4949 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
5050 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
5151 )
52−target_link_libraries(launchermodeltestExec ${GSETTINGS_QT_LDFLAGS} )
52+target_link_libraries(launchermodeltestExec ${GSETTINGS_QT_LDFLAGS})
5353qt5_use_modules(launchermodeltestExec Test Core DBus)
5454
5555# copy .desktop files into build directory for shadow builds
tests/plugins/Unity/Launcher/launchermodeltest.cpp+9
@@ -274,6 +274,15 @@ private Q_SLOTS:
274274 QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
275275 QCOMPARE(launcherModel->get(0)->appId(), QLatin1String("abs-icon"));
276276 }
277+
278+ void testGetUrlForAppId() {
279+ QCOMPARE(launcherModel->getUrlForAppId(QString()), QString());
280+ QCOMPARE(launcherModel->getUrlForAppId(""), QString());
281+ QCOMPARE(launcherModel->getUrlForAppId("no-name"), QString("application:///no-name.desktop"));
282+ QCOMPARE(launcherModel->getUrlForAppId("com.test.good"), QString("appid://com.test.good/first-listed-app/current-user-version"));
283+ QCOMPARE(launcherModel->getUrlForAppId("com.test.good_application"), QString("appid://com.test.good/application/current-user-version"));
284+ QCOMPARE(launcherModel->getUrlForAppId("com.test.good_application_1.2.3"), QString("appid://com.test.good/application/current-user-version"));
285+ }
277286};
278287
279288QTEST_GUILESS_MAIN(LauncherModelTest)