on xenial help sign in
Added an indication for running app
commitf5c9375d026e107773ab42c5a4c84b0a34a75316 authorhandsome_feng <445865575@qq.com> dateMon 13 Jul 2015, 16:27 (11 years ago) parentf1e039a
7 files changed+56−5
plugins/Unity/Launcher/launchermodel.cpp+16−5 qml/Launcher/LauncherDelegate.qml+12 qml/Launcher/LauncherPanel.qml+1 qml/Launcher/graphics/running_app_arrow@30.png tests/mocks/Unity/Launcher/MockLauncherModel.cpp+2 tests/plugins/Unity/Launcher/launchermodeltest.cpp+16 tests/qmltests/Launcher/tst_Launcher.qml+9
plugins/Unity/Launcher/launchermodel.cpp+16−5
@@ -74,6 +74,8 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
7474 return item->icon();
7575 case RolePinned:
7676 return item->pinned();
77+ case RoleRunning:
78+ return item->running();
7779 case RoleCount:
7880 return item->count();
7981 case RoleCountVisible:
@@ -476,10 +478,13 @@ void LauncherModel::applicationAdded(const QModelIndex &parent, int row)
476478 m_asAdapter->syncItems(m_list);
477479 Q_EMIT dataChanged(index(itemIndex), index(itemIndex), QVector<int>() << RoleRecent);
478480 }
481+ item->setRunning(true);
482+ Q_EMIT dataChanged(index(itemIndex), index(itemIndex), QVector<int>() << RoleRunning);
479483 // Shall we paint some running/recent app highlight? If yes, do it here.
480484 } else {
481485 LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString(), this);
482486 item->setRecent(true);
487+ item->setRunning(true);
483488 item->setFocused(app->focused());
484489
485490 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
@@ -501,11 +506,17 @@ void LauncherModel::applicationRemoved(const QModelIndex &parent, int row)
501506 }
502507 }
503508
504− if (appIndex > -1 && !m_list.at(appIndex)->pinned()) {
505− beginRemoveRows(QModelIndex(), appIndex, appIndex);
506− m_list.takeAt(appIndex)->deleteLater();
507− endRemoveRows();
508− m_asAdapter->syncItems(m_list);
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+
514+ if (!m_list.at(appIndex)->pinned()) {
515+ beginRemoveRows(QModelIndex(), appIndex, appIndex);
516+ m_list.takeAt(appIndex)->deleteLater();
517+ endRemoveRows();
518+ m_asAdapter->syncItems(m_list);
519+ }
509520 }
510521}
511522
qml/Launcher/LauncherDelegate.qml+12
@@ -24,6 +24,7 @@ Item {
2424 property int count: 0
2525 property bool countVisible: false
2626 property int progress: -1
27+ property bool itemRunning: false
2728 property bool itemFocused: false
2829 property real maxAngle: 0
2930 property bool inverted: false
@@ -138,6 +139,17 @@ Item {
138139 }
139140 }
140141 }
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+
141153 Image {
142154 objectName: "focusedHighlight"
143155 anchors {
qml/Launcher/LauncherPanel.qml+1
@@ -178,6 +178,7 @@ Rectangle {
178178 count: model.count
179179 countVisible: model.countVisible
180180 progress: model.progress
181+ itemRunning: model.running
181182 itemFocused: model.focused
182183 inverted: root.inverted
183184 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
2626 item->setProgress(0);
2727 item->setPinned(true);
2828 item->setFocused(true);
29+ item->setRunning(true);
2930 m_list.append(item);
3031 item = new MockLauncherItem("camera-app", "/usr/share/applications/camera-app.desktop", "Camera", "camera", this);
3132 item->setProgress(10);
@@ -57,6 +58,7 @@ MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(pa
5758 item->setCount(1234567890);
5859 item->setCountVisible(true);
5960 item->setPinned(true);
61+ item->setRunning(true);
6062 m_list.append(item);
6163 item = new MockLauncherItem("notes-app", "/usr/share/applications/notes-app.desktop", "Notepad", "notepad", this);
6264 item->setProgress(50);
tests/plugins/Unity/Launcher/launchermodeltest.cpp+16
@@ -298,6 +298,22 @@ private Q_SLOTS:
298298 QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
299299 }
300300
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+
301317 void testApplicationFocused() {
302318 // all apps unfocused at beginning...
303319 QCOMPARE(launcherModel->get(0)->focused(), false);
tests/qmltests/Launcher/tst_Launcher.qml+9
@@ -321,6 +321,15 @@ Item {
321321 }
322322 }
323323
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+
324333 function test_focusedHighlight() {
325334 dragLauncherIntoView();
326335 var launcherListView = findChild(launcher, "launcherListView");