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.
53527e2Michael Terry
plugins/Unity/Launcher/launchermodel.cpp+16
@@ -195,6 +195,22 @@ void LauncherModel::setUser(const QString &username)
195 m_backend->setUser(username);
195 m_backend->setUser(username);
196}
196}
197
197
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+
198void LauncherModel::refreshStoredApplications()
214void LauncherModel::refreshStoredApplications()
199{
215{
200 // First remove any existing ones
216 // First remove any existing ones
plugins/Unity/Launcher/launchermodel.h+1
@@ -51,6 +51,7 @@ public:
51 Q_INVOKABLE void requestRemove(const QString &appId);
51 Q_INVOKABLE void requestRemove(const QString &appId);
52 Q_INVOKABLE void quickListActionInvoked(const QString &appId, int actionIndex);
52 Q_INVOKABLE void quickListActionInvoked(const QString &appId, int actionIndex);
53 Q_INVOKABLE void setUser(const QString &username);
53 Q_INVOKABLE void setUser(const QString &username);
54+ Q_INVOKABLE QString getUrlForAppId(const QString &appId) const;
54
55
55 unity::shell::application::ApplicationManagerInterface* applicationManager() const;
56 unity::shell::application::ApplicationManagerInterface* applicationManager() const;
56 void setApplicationManager(unity::shell::application::ApplicationManagerInterface *appManager);
57 void setApplicationManager(unity::shell::application::ApplicationManagerInterface *appManager);
qml/GreeterShell.qml+1−1
@@ -201,7 +201,7 @@ BasicShell {
201 dragAreaWidth: shell.edgeSize
201 dragAreaWidth: shell.edgeSize
202 available: !edgeDemo.active
202 available: !edgeDemo.active
203 onLauncherApplicationSelected: {
203 onLauncherApplicationSelected: {
204− shell.activateApplication("application:///" + appId + ".desktop")
204+ shell.activateApplication(LauncherModel.getUrlForAppId(appId))
205 }
205 }
206 onShownChanged: {
206 onShownChanged: {
207 if (shown) {
207 if (shown) {
tests/mocks/Unity/Launcher/MockLauncherModel.cpp+5
@@ -183,6 +183,11 @@ void MockLauncherModel::setUser(const QString &username)
183 // TODO: implement this...
183 // TODO: implement this...
184}
184}
185
185
186+QString MockLauncherModel::getUrlForAppId(const QString &appId) const
187+{
188+ return "application:///" + appId + ".desktop";
189+}
190+
186void MockLauncherModel::setApplicationManager(unity::shell::application::ApplicationManagerInterface *applicationManager)
191void MockLauncherModel::setApplicationManager(unity::shell::application::ApplicationManagerInterface *applicationManager)
187{
192{
188 Q_UNUSED(applicationManager)
193 Q_UNUSED(applicationManager)
tests/mocks/Unity/Launcher/MockLauncherModel.h+1
@@ -44,6 +44,7 @@ public:
44 Q_INVOKABLE void requestRemove(const QString &appId);
44 Q_INVOKABLE void requestRemove(const QString &appId);
45 Q_INVOKABLE void quickListActionInvoked(const QString &appId, int actionIndex);
45 Q_INVOKABLE void quickListActionInvoked(const QString &appId, int actionIndex);
46 Q_INVOKABLE void setUser(const QString &username);
46 Q_INVOKABLE void setUser(const QString &username);
47+ Q_INVOKABLE QString getUrlForAppId(const QString &appId) const;
47
48
48 unity::shell::application::ApplicationManagerInterface *applicationManager() const;
49 unity::shell::application::ApplicationManagerInterface *applicationManager() const;
49 void setApplicationManager(unity::shell::application::ApplicationManagerInterface *applicationManager);
50 void setApplicationManager(unity::shell::application::ApplicationManagerInterface *applicationManager);
tests/plugins/Unity/Launcher/CMakeLists.txt+1−1
@@ -49,7 +49,7 @@ add_executable(launchermodeltestExec
49 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
49 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
50 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
50 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
51 )
51 )
52−target_link_libraries(launchermodeltestExec ${GSETTINGS_QT_LDFLAGS} )
52+target_link_libraries(launchermodeltestExec ${GSETTINGS_QT_LDFLAGS})
53qt5_use_modules(launchermodeltestExec Test Core DBus)
53qt5_use_modules(launchermodeltestExec Test Core DBus)
54
54
55# copy .desktop files into build directory for shadow builds
55# copy .desktop files into build directory for shadow builds
tests/plugins/Unity/Launcher/launchermodeltest.cpp+9
@@ -274,6 +274,15 @@ private Q_SLOTS:
274 QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
274 QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
275 QCOMPARE(launcherModel->get(0)->appId(), QLatin1String("abs-icon"));
275 QCOMPARE(launcherModel->get(0)->appId(), QLatin1String("abs-icon"));
276 }
276 }
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+ }
277};
286};
278
287
279QTEST_GUILESS_MAIN(LauncherModelTest)
288QTEST_GUILESS_MAIN(LauncherModelTest)