@@ -36,7 +36,7 @@ LauncherModel::LauncherModel(QObject *parent):
36 m_settings(new GSettings(this)),
36 m_settings(new GSettings(this)),
37 m_dbusIface(new DBusInterface(this)),
37 m_dbusIface(new DBusInterface(this)),
38 m_asAdapter(new ASAdapter()),
38 m_asAdapter(new ASAdapter()),
39− m_appManager(0)
39+ m_appManager(nullptr)
41 connect(m_dbusIface, &DBusInterface::countChanged, this, &LauncherModel::countChanged);
41 connect(m_dbusIface, &DBusInterface::countChanged, this, &LauncherModel::countChanged);
42 connect(m_dbusIface, &DBusInterface::countVisibleChanged, this, &LauncherModel::countVisibleChanged);
42 connect(m_dbusIface, &DBusInterface::countVisibleChanged, this, &LauncherModel::countVisibleChanged);
@@ -86,6 +86,11 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
86 return item->focused();
86 return item->focused();
87 case RoleAlerting:
87 case RoleAlerting:
88 return item->alerting();
88 return item->alerting();
90+ return item->running();
92+ qWarning() << Q_FUNC_INFO << "missing role, implement me";
91 return QVariant();
96 return QVariant();
@@ -150,7 +155,7 @@ void LauncherModel::pin(const QString &appId, int index)
150 if (index == -1 || index == currentIndex) {
155 if (index == -1 || index == currentIndex) {
151 m_list.at(currentIndex)->setPinned(true);
156 m_list.at(currentIndex)->setPinned(true);
152 QModelIndex modelIndex = this->index(currentIndex);
157 QModelIndex modelIndex = this->index(currentIndex);
153− Q_EMIT dataChanged(modelIndex, modelIndex, QVector<int>() << RolePinned);
158+ Q_EMIT dataChanged(modelIndex, modelIndex, {RolePinned});
155 move(currentIndex, index);
160 move(currentIndex, index);
156 // move() will store the list to the backend itself, so just exit at this point.
161 // move() will store the list to the backend itself, so just exit at this point.
@@ -163,7 +168,7 @@ void LauncherModel::pin(const QString &appId, int index)
164 DesktopFileHandler desktopFile(appId);
169 DesktopFileHandler desktopFile(appId);
165 if (!desktopFile.isValid()) {
170 if (!desktopFile.isValid()) {
166− qWarning() << "Can't pin this application, there is no .destkop file available.";
171+ qWarning() << "Can't pin this application, there is no .desktop file available.";
@@ -188,7 +193,7 @@ void LauncherModel::requestRemove(const QString &appId)
189void LauncherModel::quickListActionInvoked(const QString &appId, int actionIndex)
194void LauncherModel::quickListActionInvoked(const QString &appId, int actionIndex)
191− int index = findApplication(appId);
196+ const int index = findApplication(appId);
192 if (index < 0) {
197 if (index < 0) {
@@ -196,7 +201,7 @@ void LauncherModel::quickListActionInvoked(const QString &appId, int actionIndex
196 LauncherItem *item = m_list.at(index);
201 LauncherItem *item = m_list.at(index);
197 QuickListModel *model = qobject_cast<QuickListModel*>(item->quickList());
202 QuickListModel *model = qobject_cast<QuickListModel*>(item->quickList());
198 if (model) {
203 if (model) {
199− QString actionId = model->get(actionIndex).actionId();
204+ const QString actionId = model->get(actionIndex).actionId();
201 // Check if this is one of the launcher actions we handle ourselves
206 // Check if this is one of the launcher actions we handle ourselves
202 if (actionId == "pin_item") {
207 if (actionId == "pin_item") {
@@ -207,7 +212,10 @@ void LauncherModel::quickListActionInvoked(const QString &appId, int actionIndex
208 } else if (actionId == "launch_item") {
213 } else if (actionId == "launch_item") {
209 QDesktopServices::openUrl(getUrlForAppId(appId));
214 QDesktopServices::openUrl(getUrlForAppId(appId));
210−
215+ } else if (actionId == "stop_item") { // Quit
217+ m_appManager->stopApplication(appId);
211 // Nope, we don't know this action, let the backend forward it to the application
219 // Nope, we don't know this action, let the backend forward it to the application
213 // TODO: forward quicklist action to app, possibly via m_dbusIface
221 // TODO: forward quicklist action to app, possibly via m_dbusIface
@@ -305,7 +313,7 @@ void LauncherModel::storeAppList()
306void LauncherModel::unpin(const QString &appId)
314void LauncherModel::unpin(const QString &appId)
308− int index = findApplication(appId);
316+ const int index = findApplication(appId);
309 if (index < 0) {
317 if (index < 0) {
@@ -314,7 +322,7 @@ void LauncherModel::unpin(const QString &appId)
314 if (m_list.at(index)->pinned()) {
322 if (m_list.at(index)->pinned()) {
315 m_list.at(index)->setPinned(false);
323 m_list.at(index)->setPinned(false);
316 QModelIndex modelIndex = this->index(index);
324 QModelIndex modelIndex = this->index(index);
317− Q_EMIT dataChanged(modelIndex, modelIndex, QVector<int>() << RolePinned);
325+ Q_EMIT dataChanged(modelIndex, modelIndex, {RolePinned});
320 beginRemoveRows(QModelIndex(), index, index);
328 beginRemoveRows(QModelIndex(), index, index);
@@ -336,25 +344,25 @@ int LauncherModel::findApplication(const QString &appId)
337void LauncherModel::progressChanged(const QString &appId, int progress)
345void LauncherModel::progressChanged(const QString &appId, int progress)
339− int idx = findApplication(appId);
347+ const int idx = findApplication(appId);
340 if (idx >= 0) {
348 if (idx >= 0) {
341 LauncherItem *item = m_list.at(idx);
349 LauncherItem *item = m_list.at(idx);
342 item->setProgress(progress);
350 item->setProgress(progress);
343− Q_EMIT dataChanged(index(idx), index(idx), QVector<int>() << RoleProgress);
351+ Q_EMIT dataChanged(index(idx), index(idx), {RoleProgress});
347void LauncherModel::countChanged(const QString &appId, int count)
355void LauncherModel::countChanged(const QString &appId, int count)
349− int idx = findApplication(appId);
357+ const int idx = findApplication(appId);
350 if (idx >= 0) {
358 if (idx >= 0) {
351 LauncherItem *item = m_list.at(idx);
359 LauncherItem *item = m_list.at(idx);
352 item->setCount(count);
360 item->setCount(count);
353 if (item->countVisible()) {
361 if (item->countVisible()) {
354 setAlerting(item->appId(), true);
362 setAlerting(item->appId(), true);
356− Q_EMIT dataChanged(index(idx), index(idx), QVector<int>() << RoleCount);
357 m_asAdapter->syncItems(m_list);
364 m_asAdapter->syncItems(m_list);
365+ Q_EMIT dataChanged(index(idx), index(idx), {RoleCount});
@@ -367,7 +375,7 @@ void LauncherModel::countVisibleChanged(const QString &appId, bool countVisible)
367 if (countVisible) {
375 if (countVisible) {
368 setAlerting(item->appId(), true);
376 setAlerting(item->appId(), true);
370− Q_EMIT dataChanged(index(idx), index(idx), QVector<int>() << RoleCountVisible);
378+ Q_EMIT dataChanged(index(idx), index(idx), {RoleCountVisible});
372 // If countVisible goes to false, and the item is neither pinned nor recent we can drop it
380 // If countVisible goes to false, and the item is neither pinned nor recent we can drop it
373 if (!countVisible && !item->pinned() && !item->recent()) {
381 if (!countVisible && !item->pinned() && !item->recent()) {
@@ -408,7 +416,8 @@ void LauncherModel::refresh()
408 item->setName(desktopFile.displayName());
416 item->setName(desktopFile.displayName());
409 item->setIcon(desktopFile.icon());
417 item->setIcon(desktopFile.icon());
410 item->setPinned(item->pinned()); // update pinned text if needed
418 item->setPinned(item->pinned()); // update pinned text if needed
419+ item->setRunning(item->running());
411− Q_EMIT dataChanged(index(idx), index(idx), QVector<int>() << RoleName << RoleIcon);
420+ Q_EMIT dataChanged(index(idx), index(idx), {RoleName, RoleIcon, RoleRunning});
@@ -426,7 +435,7 @@ void LauncherModel::refresh()
427 // Now walk through settings and see if we need to add something
436 // Now walk through settings and see if we need to add something
428 for (int settingsIndex = 0; settingsIndex < m_settings->storedApplications().count(); ++settingsIndex) {
437 for (int settingsIndex = 0; settingsIndex < m_settings->storedApplications().count(); ++settingsIndex) {
429− QString entry = m_settings->storedApplications().at(settingsIndex);
438+ const QString entry = m_settings->storedApplications().at(settingsIndex);
430 int itemIndex = -1;
439 int itemIndex = -1;
431 for (int i = 0; i < m_list.count(); ++i) {
440 for (int i = 0; i < m_list.count(); ++i) {
432 if (m_list.at(i)->appId() == entry) {
441 if (m_list.at(i)->appId() == entry) {
@@ -499,25 +508,27 @@ void LauncherModel::applicationAdded(const QModelIndex &parent, int row)
502− int itemIndex = findApplication(app->appId());
511+ const int itemIndex = findApplication(app->appId());
503 if (itemIndex != -1) {
512 if (itemIndex != -1) {
504 LauncherItem *item = m_list.at(itemIndex);
513 LauncherItem *item = m_list.at(itemIndex);
505 if (!item->recent()) {
514 if (!item->recent()) {
506 item->setRecent(true);
515 item->setRecent(true);
507− m_asAdapter->syncItems(m_list);
508− Q_EMIT dataChanged(index(itemIndex), index(itemIndex), QVector<int>() << RoleRecent);
516+ Q_EMIT dataChanged(index(itemIndex), index(itemIndex), {RoleRecent});
518+ item->setRunning(true);
510− // Shall we paint some running/recent app highlight? If yes, do it here.
519+ // TODO Shall we paint some running/recent app highlight? If yes, do it here.
512 LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString(), this);
521 LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString(), this);
513 item->setRecent(true);
522 item->setRecent(true);
523+ item->setRunning(true);
514 item->setFocused(app->focused());
524 item->setFocused(app->focused());
516 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
526 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
517 m_list.append(item);
527 m_list.append(item);
518 endInsertRows();
528 endInsertRows();
519− m_asAdapter->syncItems(m_list);
530+ m_asAdapter->syncItems(m_list);
531+ Q_EMIT dataChanged(index(itemIndex), index(itemIndex), {RoleRunning});
523void LauncherModel::applicationRemoved(const QModelIndex &parent, int row)
534void LauncherModel::applicationRemoved(const QModelIndex &parent, int row)
@@ -532,25 +543,35 @@ void LauncherModel::applicationRemoved(const QModelIndex &parent, int row)
547+ qWarning() << Q_FUNC_INFO << "appIndex not found";
535− if (appIndex > -1 && !m_list.at(appIndex)->pinned()) {
551+ LauncherItem * item = m_list.at(appIndex);
552+ item->setRunning(false);
554+ if (!item->pinned()) {
536 beginRemoveRows(QModelIndex(), appIndex, appIndex);
555 beginRemoveRows(QModelIndex(), appIndex, appIndex);
537 m_list.takeAt(appIndex)->deleteLater();
556 m_list.takeAt(appIndex)->deleteLater();
538 endRemoveRows();
557 endRemoveRows();
539 m_asAdapter->syncItems(m_list);
558 m_asAdapter->syncItems(m_list);
559+ Q_EMIT dataChanged(index(appIndex), index(appIndex), {RolePinned});
561+ Q_EMIT dataChanged(index(appIndex), index(appIndex), {RoleRunning});
543void LauncherModel::focusedAppIdChanged()
564void LauncherModel::focusedAppIdChanged()
545− QString appId = m_appManager->focusedApplicationId();
566+ const QString appId = m_appManager->focusedApplicationId();
546 for (int i = 0; i < m_list.count(); ++i) {
567 for (int i = 0; i < m_list.count(); ++i) {
547 LauncherItem *item = m_list.at(i);
568 LauncherItem *item = m_list.at(i);
548 if (!item->focused() && item->appId() == appId) {
569 if (!item->focused() && item->appId() == appId) {
549 item->setFocused(true);
570 item->setFocused(true);
550− Q_EMIT dataChanged(index(i), index(i), QVector<int>() << RoleFocused);
571+ Q_EMIT dataChanged(index(i), index(i), {RoleFocused});
551 } else if (item->focused() && item->appId() != appId) {
572 } else if (item->focused() && item->appId() != appId) {
552 item->setFocused(false);
573 item->setFocused(false);
553− Q_EMIT dataChanged(index(i), index(i), QVector<int>() << RoleFocused);
574+ Q_EMIT dataChanged(index(i), index(i), {RoleFocused});