@@ -20,6 +20,7 @@
20#include "dbusinterface.h"
20#include "dbusinterface.h"
21#include "asadapter.h"
21#include "asadapter.h"
23+#include <ubuntu-app-launch/appid.h>
23#include <ubuntu-app-launch/application.h>
24#include <ubuntu-app-launch/application.h>
24#include <ubuntu-app-launch/registry.h>
25#include <ubuntu-app-launch/registry.h>
25#include <unity/shell/application/ApplicationInfoInterface.h>
26#include <unity/shell/application/ApplicationInfoInterface.h>
@@ -28,6 +29,8 @@
28#include <QDesktopServices>
29#include <QDesktopServices>
29#include <QDebug>
30#include <QDebug>
32+namespace ual = ubuntu::app_launch;
31using namespace unity::shell::application;
34using namespace unity::shell::application;
33LauncherModel::LauncherModel(QObject *parent):
36LauncherModel::LauncherModel(QObject *parent):
@@ -36,7 +39,7 @@ LauncherModel::LauncherModel(QObject *parent):
36 m_dbusIface(new DBusInterface(this)),
39 m_dbusIface(new DBusInterface(this)),
37 m_asAdapter(new ASAdapter()),
40 m_asAdapter(new ASAdapter()),
38 m_appManager(nullptr),
41 m_appManager(nullptr),
39− m_ualRegistry(std::make_shared<ubuntu::app_launch::Registry>())
42+ m_ualRegistry(std::make_shared<ual::Registry>())
41 connect(m_dbusIface, &DBusInterface::countChanged, this, &LauncherModel::countChanged);
44 connect(m_dbusIface, &DBusInterface::countChanged, this, &LauncherModel::countChanged);
42 connect(m_dbusIface, &DBusInterface::countVisibleChanged, this, &LauncherModel::countVisibleChanged);
45 connect(m_dbusIface, &DBusInterface::countVisibleChanged, this, &LauncherModel::countVisibleChanged);
@@ -157,15 +160,15 @@ void LauncherModel::pin(const QString &appId, int index)
159 auto appInfo = getApplicationInfo(appId);
162 auto appInfo = getApplicationInfo(appId);
160− if (!appInfo) {
163+ if (!appInfo.valid) {
161 qWarning() << "Can't pin application, appId not found:" << appId;
164 qWarning() << "Can't pin application, appId not found:" << appId;
165 beginInsertRows(QModelIndex(), index, index);
168 beginInsertRows(QModelIndex(), index, index);
166 LauncherItem *item = new LauncherItem(appId,
169 LauncherItem *item = new LauncherItem(appId,
167− QString::fromStdString(appInfo->info()->name()),
170+ appInfo.name,
168− QString::fromStdString(appInfo->info()->iconPath()),
171+ appInfo.icon,
170 item->setPinned(true);
173 item->setPinned(true);
171 m_list.insert(index, item);
174 m_list.insert(index, item);
@@ -332,22 +335,30 @@ int LauncherModel::findApplication(const QString &appId)
332 return -1;
335 return -1;
335−std::shared_ptr<ubuntu::app_launch::Application> LauncherModel::getApplicationInfo(const QString &appId)
338+LauncherModel::AppInfo LauncherModel::getApplicationInfo(const QString &appId)
337− auto ualAppId = ubuntu::app_launch::AppID::find(appId.toStdString());
342+ ual::AppID ualAppId = ual::AppID::find(appId.toStdString());
338 if (ualAppId.empty()) {
343 if (ualAppId.empty()) {
339− return nullptr;
344+ return info;
347+ std::shared_ptr<ual::Application> ualApp;
344− return ubuntu::app_launch::Application::create(ualAppId, m_ualRegistry);
350+ ualApp = ual::Application::create(ualAppId, m_ualRegistry);
346 catch (std::runtime_error &e)
352 catch (std::runtime_error &e)
348 qWarning() << "Couldn't find application info for" << appId << "-" << e.what();
354 qWarning() << "Couldn't find application info for" << appId << "-" << e.what();
349− return nullptr;
355+ return info;
359+ info.name = QString::fromStdString(ualApp->info()->name());
360+ info.icon = QString::fromStdString(ualApp->info()->iconPath());
353void LauncherModel::progressChanged(const QString &appId, int progress)
364void LauncherModel::progressChanged(const QString &appId, int progress)
@@ -398,10 +409,10 @@ void LauncherModel::countVisibleChanged(const QString &appId, bool countVisible)
399 // Need to create a new LauncherItem and show the highlight
410 // Need to create a new LauncherItem and show the highlight
400 auto appInfo = getApplicationInfo(appId);
411 auto appInfo = getApplicationInfo(appId);
401− if (countVisible && appInfo) {
412+ if (countVisible && appInfo.valid) {
402 LauncherItem *item = new LauncherItem(appId,
413 LauncherItem *item = new LauncherItem(appId,
403− QString::fromStdString(appInfo->info()->name()),
414+ appInfo.name,
404− QString::fromStdString(appInfo->info()->iconPath()),
415+ appInfo.icon,
406 item->setCountVisible(true);
417 item->setCountVisible(true);
407 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
418 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
@@ -418,7 +429,7 @@ void LauncherModel::refresh()
418 QList<LauncherItem*> toBeRemoved;
429 QList<LauncherItem*> toBeRemoved;
419 Q_FOREACH (LauncherItem* item, m_list) {
430 Q_FOREACH (LauncherItem* item, m_list) {
420 auto appInfo = getApplicationInfo(item->appId());
431 auto appInfo = getApplicationInfo(item->appId());
421− if (!appInfo) {
432+ if (!appInfo.valid) {
422 // Application no longer available => drop it!
433 // Application no longer available => drop it!
423 toBeRemoved << item;
434 toBeRemoved << item;
424 } else if (!m_settings->storedApplications().contains(item->appId())) {
435 } else if (!m_settings->storedApplications().contains(item->appId())) {
@@ -426,19 +437,19 @@ void LauncherModel::refresh()
426 toBeRemoved << item;
437 toBeRemoved << item;
428 int idx = m_list.indexOf(item);
439 int idx = m_list.indexOf(item);
429− item->setName(QString::fromStdString(appInfo->info()->name()));
440+ item->setName(appInfo.name);
430 item->setPinned(item->pinned()); // update pinned text if needed
441 item->setPinned(item->pinned()); // update pinned text if needed
431 item->setRunning(item->running());
442 item->setRunning(item->running());
432 Q_EMIT dataChanged(index(idx), index(idx), {RoleName, RoleRunning});
443 Q_EMIT dataChanged(index(idx), index(idx), {RoleName, RoleRunning});
434 const QString oldIcon = item->icon();
445 const QString oldIcon = item->icon();
435− if (oldIcon == QString::fromStdString(appInfo->info()->iconPath())) { // same icon file, perhaps different contents, simulate changing the icon name to force reload
446+ if (oldIcon == appInfo.icon) { // same icon file, perhaps different contents, simulate changing the icon name to force reload
436 item->setIcon(QString());
447 item->setIcon(QString());
437 Q_EMIT dataChanged(index(idx), index(idx), {RoleIcon});
448 Q_EMIT dataChanged(index(idx), index(idx), {RoleIcon});
440 // now set the icon for real
451 // now set the icon for real
441− item->setIcon(QString::fromStdString(appInfo->info()->iconPath()));
452+ item->setIcon(appInfo.icon);
442 Q_EMIT dataChanged(index(idx), index(idx), {RoleIcon});
453 Q_EMIT dataChanged(index(idx), index(idx), {RoleIcon});
@@ -470,13 +481,13 @@ void LauncherModel::refresh()
470 // Need to add it. Just add it into the addedIndex to keep same ordering as the list
481 // Need to add it. Just add it into the addedIndex to keep same ordering as the list
471 // in the settings.
482 // in the settings.
472 auto appInfo = getApplicationInfo(entry);
483 auto appInfo = getApplicationInfo(entry);
473− if (!appInfo) {
484+ if (!appInfo.valid) {
474 continue;
485 continue;
477 LauncherItem *item = new LauncherItem(entry,
488 LauncherItem *item = new LauncherItem(entry,
478− QString::fromStdString(appInfo->info()->name()),
489+ appInfo.name,
479− QString::fromStdString(appInfo->info()->iconPath()),
490+ appInfo.icon,
481 item->setPinned(true);
492 item->setPinned(true);
482 beginInsertRows(QModelIndex(), addedIndex, addedIndex);
493 beginInsertRows(QModelIndex(), addedIndex, addedIndex);