on xenial help sign in
Add support for the persistent alert state.
bfaa2aaMichael Zanetti
debian/control+1−1
@@ -33,7 +33,7 @@ Build-Depends: cmake,
33 libubuntugestures5-dev,
33 libubuntugestures5-dev,
34 libubuntugestures5-private-dev,
34 libubuntugestures5-private-dev,
35 libudev-dev,
35 libudev-dev,
36− libunity-api-dev (>= 7.114),
36+ libunity-api-dev (>= 7.115),
37 libusermetricsoutput1-dev,
37 libusermetricsoutput1-dev,
38# Need those X11 libs touch emulation from mouse events in manual QML tests on a X11 desktop
38# Need those X11 libs touch emulation from mouse events in manual QML tests on a X11 desktop
39 libx11-dev[!armhf],
39 libx11-dev[!armhf],
plugins/Greeter/Unity/Launcher/CMakeLists.txt+1−1
@@ -1,4 +1,4 @@
1−pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=8)
1+pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=9)
2pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
2pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
3
3
4add_definitions(-DSM_BUSNAME=systemBus)
4add_definitions(-DSM_BUSNAME=systemBus)
plugins/Greeter/Unity/Launcher/launchermodelas.cpp−7
@@ -76,13 +76,6 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
76 return QVariant();
76 return QVariant();
77}
77}
78
78
79−void LauncherModel::setAlerting(const QString &appId, bool alerting)
80−{
81− Q_UNUSED(appId)
82− Q_UNUSED(alerting)
83− qWarning() << "This is a read only implementation. Cannot set alert-state of items.";
84−}
85−
86unity::shell::launcher::LauncherItemInterface *LauncherModel::get(int index) const
79unity::shell::launcher::LauncherItemInterface *LauncherModel::get(int index) const
87{
80{
88 if (index < 0 || index >= m_list.count()) {
81 if (index < 0 || index >= m_list.count()) {
plugins/Greeter/Unity/Launcher/launchermodelas.h−1
@@ -41,7 +41,6 @@ public:
41
41
42 QVariant data(const QModelIndex &index, int role) const override;
42 QVariant data(const QModelIndex &index, int role) const override;
43
43
44− Q_INVOKABLE void setAlerting(const QString &appId, bool alerting) override;
45 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface* get(int index) const override;
44 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface* get(int index) const override;
46 Q_INVOKABLE void move(int oldIndex, int newIndex) override;
45 Q_INVOKABLE void move(int oldIndex, int newIndex) override;
47 Q_INVOKABLE void pin(const QString &appId, int index = -1) override;
46 Q_INVOKABLE void pin(const QString &appId, int index = -1) override;
plugins/Unity/Launcher/CMakeLists.txt+1−1
@@ -1,4 +1,4 @@
1−pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=8)
1+pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=9)
2pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
2pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
3
3
4add_definitions(-DSM_BUSNAME=systemBus)
4add_definitions(-DSM_BUSNAME=systemBus)
plugins/Unity/Launcher/launcheritem.cpp−9
@@ -163,9 +163,6 @@ void LauncherItem::setCount(int count)
163 if (m_count != count) {
163 if (m_count != count) {
164 m_count = count;
164 m_count = count;
165 Q_EMIT countChanged(count);
165 Q_EMIT countChanged(count);
166− if (m_countVisible) {
167− setAlerting(true);
168− }
169 }
166 }
170}
167}
171
168
@@ -179,9 +176,6 @@ void LauncherItem::setCountVisible(bool countVisible)
179 if (m_countVisible != countVisible) {
176 if (m_countVisible != countVisible) {
180 m_countVisible = countVisible;
177 m_countVisible = countVisible;
181 Q_EMIT countVisibleChanged(countVisible);
178 Q_EMIT countVisibleChanged(countVisible);
182− if (countVisible) {
183− setAlerting(true);
184− }
185 }
179 }
186}
180}
187
181
@@ -194,9 +188,6 @@ void LauncherItem::setFocused(bool focused)
194{
188{
195 if (m_focused != focused) {
189 if (m_focused != focused) {
196 m_focused = focused;
190 m_focused = focused;
197− if (focused) {
198− setAlerting(false);
199− }
200 Q_EMIT focusedChanged(focused);
191 Q_EMIT focusedChanged(focused);
201 }
192 }
202}
193}
plugins/Unity/Launcher/launchermodel.cpp+29−24
@@ -99,18 +99,6 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
99 return QVariant();
99 return QVariant();
100}
100}
101
101
102−void LauncherModel::setAlerting(const QString &appId, bool alerting) {
103− int index = findApplication(appId);
104− if (index >= 0) {
105− QModelIndex modelIndex = this->index(index);
106− LauncherItem *item = m_list.at(index);
107− if (!item->focused()) {
108− item->setAlerting(alerting);
109− Q_EMIT dataChanged(modelIndex, modelIndex, {RoleAlerting});
110− }
111− }
112−}
113−
114unity::shell::launcher::LauncherItemInterface *LauncherModel::get(int index) const
102unity::shell::launcher::LauncherItemInterface *LauncherModel::get(int index) const
115{
103{
116 if (index < 0 || index >= m_list.count()) {
104 if (index < 0 || index >= m_list.count()) {
@@ -361,11 +349,13 @@ void LauncherModel::countChanged(const QString &appId, int count)
361 if (idx >= 0) {
349 if (idx >= 0) {
362 LauncherItem *item = m_list.at(idx);
350 LauncherItem *item = m_list.at(idx);
363 item->setCount(count);
351 item->setCount(count);
352+ QVector<int> changedRoles = {RoleCount};
364− if (item->countVisible()) {
353+ if (item->countVisible() && !item->alerting() && !item->focused()) {
354+ changedRoles << RoleAlerting;
365− setAlerting(item->appId(), true);
355+ item->setAlerting(true);
366 }
356 }
367 m_asAdapter->syncItems(m_list);
357 m_asAdapter->syncItems(m_list);
368− Q_EMIT dataChanged(index(idx), index(idx), {RoleCount});
358+ Q_EMIT dataChanged(index(idx), index(idx), changedRoles);
369 }
359 }
370}
360}
371
361
@@ -375,10 +365,12 @@ void LauncherModel::countVisibleChanged(const QString &appId, bool countVisible)
375 if (idx >= 0) {
365 if (idx >= 0) {
376 LauncherItem *item = m_list.at(idx);
366 LauncherItem *item = m_list.at(idx);
377 item->setCountVisible(countVisible);
367 item->setCountVisible(countVisible);
368+ QVector<int> changedRoles = {RoleCount};
378− if (countVisible) {
369+ if (countVisible && !item->alerting() && !item->focused()) {
370+ changedRoles << RoleAlerting;
379− setAlerting(item->appId(), true);
371+ item->setAlerting(true);
380 }
372 }
381− Q_EMIT dataChanged(index(idx), index(idx), {RoleCountVisible});
373+ Q_EMIT dataChanged(index(idx), index(idx), changedRoles);
382
374
383 // If countVisible goes to false, and the item is neither pinned nor recent we can drop it
375 // If countVisible goes to false, and the item is neither pinned nor recent we can drop it
384 if (!countVisible && !item->pinned() && !item->recent()) {
376 if (!countVisible && !item->pinned() && !item->recent()) {
@@ -501,8 +493,10 @@ void LauncherModel::alert(const QString &appId)
501 int idx = findApplication(appId);
493 int idx = findApplication(appId);
502 if (idx >= 0) {
494 if (idx >= 0) {
503 LauncherItem *item = m_list.at(idx);
495 LauncherItem *item = m_list.at(idx);
496+ if (!item->focused() && !item->alerting()) {
504− setAlerting(item->appId(), true);
497+ item->setAlerting(true);
505− Q_EMIT dataChanged(index(idx), index(idx), {RoleAlerting});
498+ Q_EMIT dataChanged(index(idx), index(idx), {RoleAlerting});
499+ }
506 }
500 }
507}
501}
508
502
@@ -585,16 +579,21 @@ void LauncherModel::applicationRemoved(const QModelIndex &parent, int row)
585 disconnect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::applicationSurfaceCountChanged);
579 disconnect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::applicationSurfaceCountChanged);
586
580
587 LauncherItem * item = m_list.at(appIndex);
581 LauncherItem * item = m_list.at(appIndex);
588− item->setRunning(false);
589
582
590 if (!item->pinned()) {
583 if (!item->pinned()) {
591 beginRemoveRows(QModelIndex(), appIndex, appIndex);
584 beginRemoveRows(QModelIndex(), appIndex, appIndex);
592 m_list.takeAt(appIndex)->deleteLater();
585 m_list.takeAt(appIndex)->deleteLater();
593 endRemoveRows();
586 endRemoveRows();
594 m_asAdapter->syncItems(m_list);
587 m_asAdapter->syncItems(m_list);
588+ } else {
589+ QVector<int> changedRoles = {RoleRunning};
590+ item->setRunning(false);
591+ if (item->focused()) {
592+ changedRoles << RoleFocused;
593+ item->setFocused(false);
594+ }
595− Q_EMIT dataChanged(index(appIndex), index(appIndex), {RolePinned});
595+ Q_EMIT dataChanged(index(appIndex), index(appIndex), changedRoles);
596 }
596 }
597− Q_EMIT dataChanged(index(appIndex), index(appIndex), {RoleRunning});
598}
597}
599
598
600void LauncherModel::focusedAppIdChanged()
599void LauncherModel::focusedAppIdChanged()
@@ -603,8 +602,14 @@ void LauncherModel::focusedAppIdChanged()
603 for (int i = 0; i < m_list.count(); ++i) {
602 for (int i = 0; i < m_list.count(); ++i) {
604 LauncherItem *item = m_list.at(i);
603 LauncherItem *item = m_list.at(i);
605 if (!item->focused() && item->appId() == appId) {
604 if (!item->focused() && item->appId() == appId) {
605+ QVector<int> changedRoles;
606+ changedRoles << RoleFocused;
606 item->setFocused(true);
607 item->setFocused(true);
607− Q_EMIT dataChanged(index(i), index(i), {RoleFocused});
608+ if (item->alerting()) {
609+ changedRoles << RoleAlerting;
610+ item->setAlerting(false);
611+ }
612+ Q_EMIT dataChanged(index(i), index(i), changedRoles);
608 } else if (item->focused() && item->appId() != appId) {
613 } else if (item->focused() && item->appId() != appId) {
609 item->setFocused(false);
614 item->setFocused(false);
610 Q_EMIT dataChanged(index(i), index(i), {RoleFocused});
615 Q_EMIT dataChanged(index(i), index(i), {RoleFocused});
plugins/Unity/Launcher/launchermodel.h−1
@@ -45,7 +45,6 @@ public:
45
45
46 QVariant data(const QModelIndex &index, int role) const override;
46 QVariant data(const QModelIndex &index, int role) const override;
47
47
48− Q_INVOKABLE void setAlerting(const QString &appId, bool alerting) override;
49 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface* get(int index) const override;
48 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface* get(int index) const override;
50 Q_INVOKABLE void move(int oldIndex, int newIndex) override;
49 Q_INVOKABLE void move(int oldIndex, int newIndex) override;
51 Q_INVOKABLE void pin(const QString &appId, int index = -1) override;
50 Q_INVOKABLE void pin(const QString &appId, int index = -1) override;
qml/Launcher/LauncherDelegate.qml+1−7
@@ -115,12 +115,6 @@ Item {
115 duration: priv.wiggleDuration
115 duration: priv.wiggleDuration
116 easing.type: Easing.OutQuad
116 easing.type: Easing.OutQuad
117 }
117 }
118−
119− UbuntuNumberAnimation {
120− target: root
121− property: "alerting"
122− to: 0
123− }
124 }
118 }
125
119
126 Item {
120 Item {
@@ -228,7 +222,7 @@ Item {
228 objectName: "runningHighlight" + index
222 objectName: "runningHighlight" + index
229 width: units.gu(0.25)
223 width: units.gu(0.25)
230 height: units.gu(.5)
224 height: units.gu(.5)
231− color: "white"
225+ color: root.alerting ? theme.palette.normal.activity : "white"
232 visible: root.itemRunning
226 visible: root.itemRunning
233 }
227 }
234 }
228 }
qml/Launcher/LauncherPanel.qml+1
@@ -272,6 +272,7 @@ Rectangle {
272
272
273 PropertyAction { target: launcherListViewItem; property: "clip"; value: 1 }
273 PropertyAction { target: launcherListViewItem; property: "clip"; value: 1 }
274 PropertyAction { target: root; property: "visible"; value: (launcher.visibleWidth === 0) ? 0 : 1 }
274 PropertyAction { target: root; property: "visible"; value: (launcher.visibleWidth === 0) ? 0 : 1 }
275+ PropertyAction { target: launcherListView; property: "peekingIndex"; value: -1 }
275 }
276 }
276
277
277 onAlertingChanged: {
278 onAlertingChanged: {
tests/mocks/Unity/Launcher/CMakeLists.txt+1−1
@@ -1,4 +1,4 @@
1−pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=8)
1+pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=9)
2
2
3include_directories(
3include_directories(
4 ${CMAKE_CURRENT_SOURCE_DIR}
4 ${CMAKE_CURRENT_SOURCE_DIR}
tests/mocks/Unity/Launcher/MockLauncherModel.h+1−1
@@ -38,7 +38,7 @@ public:
38
38
39 QVariant data(const QModelIndex& index, int role) const override;
39 QVariant data(const QModelIndex& index, int role) const override;
40
40
41− Q_INVOKABLE void setAlerting(const QString &appId, bool alerting) override;
41+ Q_INVOKABLE void setAlerting(const QString &appId, bool alerting); // Only for testing
42 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface *get(int index) const override;
42 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface *get(int index) const override;
43 Q_INVOKABLE void move(int oldIndex, int newIndex) override;
43 Q_INVOKABLE void move(int oldIndex, int newIndex) override;
44 Q_INVOKABLE void pin(const QString &appId, int index = -1) override;
44 Q_INVOKABLE void pin(const QString &appId, int index = -1) override;
tests/plugins/Unity/Launcher/launchermodeltest.cpp+8
@@ -491,6 +491,10 @@ private Q_SLOTS:
491
491
492 // Finally check, that the change to "count" implicitly also set the alerting-state to true
492 // Finally check, that the change to "count" implicitly also set the alerting-state to true
493 QVERIFY(launcherModel->get(index)->alerting() == true);
493 QVERIFY(launcherModel->get(index)->alerting() == true);
494+
495+ // Focus the app, make sure the alert gets cleared
496+ appManager->focusApplication("abs-icon");
497+ QVERIFY(launcherModel->get(index)->alerting() == false);
494 }
498 }
495
499
496 void testCountEmblemAddsRemovesItem_data() {
500 void testCountEmblemAddsRemovesItem_data() {
@@ -562,6 +566,10 @@ private Q_SLOTS:
562
566
563 // Check that the alerting-status is now true
567 // Check that the alerting-status is now true
564 QVERIFY(launcherModel->get(index)->alerting() == true);
568 QVERIFY(launcherModel->get(index)->alerting() == true);
569+
570+ // Focus the app, make sure the alert gets cleared
571+ appManager->focusApplication("abs-icon");
572+ QVERIFY(launcherModel->get(index)->alerting() == false);
565 }
573 }
566
574
567 void testRefreshAfterDeletedDesktopFiles_data() {
575 void testRefreshAfterDeletedDesktopFiles_data() {