on xenial help sign in
Added an indication for running app
f5c9375handsome_feng
plugins/Unity/Launcher/launchermodel.cpp+16−5
@@ -74,6 +74,8 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
74 return item->icon();
74 return item->icon();
75 case RolePinned:
75 case RolePinned:
76 return item->pinned();
76 return item->pinned();
77+ case RoleRunning:
78+ return item->running();
77 case RoleCount:
79 case RoleCount:
78 return item->count();
80 return item->count();
79 case RoleCountVisible:
81 case RoleCountVisible:
@@ -476,10 +478,13 @@ void LauncherModel::applicationAdded(const QModelIndex &parent, int row)
476 m_asAdapter->syncItems(m_list);
478 m_asAdapter->syncItems(m_list);
477 Q_EMIT dataChanged(index(itemIndex), index(itemIndex), QVector<int>() << RoleRecent);
479 Q_EMIT dataChanged(index(itemIndex), index(itemIndex), QVector<int>() << RoleRecent);
478 }
480 }
481+ item->setRunning(true);
482+ Q_EMIT dataChanged(index(itemIndex), index(itemIndex), QVector<int>() << RoleRunning);
479 // Shall we paint some running/recent app highlight? If yes, do it here.
483 // Shall we paint some running/recent app highlight? If yes, do it here.
480 } else {
484 } else {
481 LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString(), this);
485 LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString(), this);
482 item->setRecent(true);
486 item->setRecent(true);
487+ item->setRunning(true);
483 item->setFocused(app->focused());
488 item->setFocused(app->focused());
484
489
485 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
490 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
@@ -501,11 +506,17 @@ void LauncherModel::applicationRemoved(const QModelIndex &parent, int row)
501 }
506 }
502 }
507 }
503
508
509+ if (appIndex > -1) {
510+ LauncherItem *item = m_list.at(appIndex);
511+ item->setRunning(false);
512+ Q_EMIT dataChanged(index(appIndex), index(appIndex), QVector<int>() << RoleRunning);
513+
504− if (appIndex > -1 && !m_list.at(appIndex)->pinned()) {
514+ if (!m_list.at(appIndex)->pinned()) {
505− beginRemoveRows(QModelIndex(), appIndex, appIndex);
515+ beginRemoveRows(QModelIndex(), appIndex, appIndex);
506− m_list.takeAt(appIndex)->deleteLater();
516+ m_list.takeAt(appIndex)->deleteLater();
507− endRemoveRows();
517+ endRemoveRows();
508− m_asAdapter->syncItems(m_list);
518+ m_asAdapter->syncItems(m_list);
519+ }
509 }
520 }
510}
521}
511
522
qml/Launcher/LauncherDelegate.qml+12
@@ -24,6 +24,7 @@ Item {
24 property int count: 0
24 property int count: 0
25 property bool countVisible: false
25 property bool countVisible: false
26 property int progress: -1
26 property int progress: -1
27+ property bool itemRunning: false
27 property bool itemFocused: false
28 property bool itemFocused: false
28 property real maxAngle: 0
29 property real maxAngle: 0
29 property bool inverted: false
30 property bool inverted: false
@@ -138,6 +139,17 @@ Item {
138 }
139 }
139 }
140 }
140 }
141 }
142+
143+ Image {
144+ objectName: "runningHighlight"
145+ anchors {
146+ left: parent.left
147+ verticalCenter: parent.verticalCenter
148+ }
149+ visible: root.itemRunning
150+ source: "graphics/running_app_arrow.png"
151+ }
152+
141 Image {
153 Image {
142 objectName: "focusedHighlight"
154 objectName: "focusedHighlight"
143 anchors {
155 anchors {
qml/Launcher/LauncherPanel.qml+1
@@ -178,6 +178,7 @@ Rectangle {
178 count: model.count
178 count: model.count
179 countVisible: model.countVisible
179 countVisible: model.countVisible
180 progress: model.progress
180 progress: model.progress
181+ itemRunning: model.running
181 itemFocused: model.focused
182 itemFocused: model.focused
182 inverted: root.inverted
183 inverted: root.inverted
183 z: -Math.abs(offset)
184 z: -Math.abs(offset)
qml/Launcher/graphics/running_app_arrow@30.pngnew file

Binary file not shown.

tests/mocks/Unity/Launcher/MockLauncherModel.cpp+2
@@ -26,6 +26,7 @@ MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(pa
26 item->setProgress(0);
26 item->setProgress(0);
27 item->setPinned(true);
27 item->setPinned(true);
28 item->setFocused(true);
28 item->setFocused(true);
29+ item->setRunning(true);
29 m_list.append(item);
30 m_list.append(item);
30 item = new MockLauncherItem("camera-app", "/usr/share/applications/camera-app.desktop", "Camera", "camera", this);
31 item = new MockLauncherItem("camera-app", "/usr/share/applications/camera-app.desktop", "Camera", "camera", this);
31 item->setProgress(10);
32 item->setProgress(10);
@@ -57,6 +58,7 @@ MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(pa
57 item->setCount(1234567890);
58 item->setCount(1234567890);
58 item->setCountVisible(true);
59 item->setCountVisible(true);
59 item->setPinned(true);
60 item->setPinned(true);
61+ item->setRunning(true);
60 m_list.append(item);
62 m_list.append(item);
61 item = new MockLauncherItem("notes-app", "/usr/share/applications/notes-app.desktop", "Notepad", "notepad", this);
63 item = new MockLauncherItem("notes-app", "/usr/share/applications/notes-app.desktop", "Notepad", "notepad", this);
62 item->setProgress(50);
64 item->setProgress(50);
tests/plugins/Unity/Launcher/launchermodeltest.cpp+16
@@ -298,6 +298,22 @@ private Q_SLOTS:
298 QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
298 QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
299 }
299 }
300
300
301+ void testApplicationRunning() {
302+ launcherModel->pin("abs-icon");
303+ launcherModel->pin("no-icon");
304+
305+ QCOMPARE(launcherModel->get(0)->running(), true);
306+ QCOMPARE(launcherModel->get(1)->running(), true);
307+
308+ appManager->stopApplication("abs-icon");
309+ QCOMPARE(launcherModel->get(0)->running(), false);
310+ QCOMPARE(launcherModel->get(1)->running(), true);
311+
312+ appManager->stopApplication("no-icon");
313+ QCOMPARE(launcherModel->get(0)->running(), false);
314+ QCOMPARE(launcherModel->get(1)->running(), false);
315+ }
316+
301 void testApplicationFocused() {
317 void testApplicationFocused() {
302 // all apps unfocused at beginning...
318 // all apps unfocused at beginning...
303 QCOMPARE(launcherModel->get(0)->focused(), false);
319 QCOMPARE(launcherModel->get(0)->focused(), false);
tests/qmltests/Launcher/tst_Launcher.qml+9
@@ -321,6 +321,15 @@ Item {
321 }
321 }
322 }
322 }
323
323
324+ function test_runningHighlight() {
325+ dragLauncherIntoView();
326+ var launcherListView = findChild(launcher, "launcherListView");
327+ for (var i = 0; i < launcherListView.count; ++i) {
328+ var delegate = findChild(launcherListView, "launcherDelegate" + i)
329+ compare(findChild(delegate, "runningHighlight").visible, LauncherModel.get(i).running)
330+ }
331+ }
332+
324 function test_focusedHighlight() {
333 function test_focusedHighlight() {
325 dragLauncherIntoView();
334 dragLauncherIntoView();
326 var launcherListView = findChild(launcher, "launcherListView");
335 var launcherListView = findChild(launcher, "launcherListView");