on xenial help sign in
Support for persistent alert states.

Paint pips blue when an app is in alert state

commite053239cbc4c8962692e81822d2ad786816427f1 authorMichael Zanetti <michael.zanetti@canonical.com> dateFri 13 May 2016, 13:14 (10 years ago) parente9cab37
13 files changed+45−50
plugins/Greeter/Unity/Launcher/CMakeLists.txt+1−1 plugins/Greeter/Unity/Launcher/launchermodelas.cpp−7 plugins/Greeter/Unity/Launcher/launchermodelas.h−1 plugins/Unity/Launcher/CMakeLists.txt+1−1 plugins/Unity/Launcher/launcheritem.cpp−9 plugins/Unity/Launcher/launchermodel.cpp+20−20 plugins/Unity/Launcher/launchermodel.h−1 qml/Launcher/LauncherDelegate.qml+5−7 qml/Launcher/LauncherPanel.qml+10 tests/mocks/Unity/Launcher/CMakeLists.txt+1−1 tests/mocks/Unity/Launcher/MockLauncherItem.cpp+2 tests/mocks/Unity/Launcher/MockLauncherModel.h+1−1 tests/qmltests/Launcher/tst_Launcher.qml+4−1
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)
22pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
33
44add_definitions(-DSM_BUSNAME=systemBus)
plugins/Greeter/Unity/Launcher/launchermodelas.cpp−7
@@ -76,13 +76,6 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
7676 return QVariant();
7777}
7878
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−
8679unity::shell::launcher::LauncherItemInterface *LauncherModel::get(int index) const
8780{
8881 if (index < 0 || index >= m_list.count()) {
plugins/Greeter/Unity/Launcher/launchermodelas.h−1
@@ -41,7 +41,6 @@ public:
4141
4242 QVariant data(const QModelIndex &index, int role) const override;
4343
44− Q_INVOKABLE void setAlerting(const QString &appId, bool alerting) override;
4544 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface* get(int index) const override;
4645 Q_INVOKABLE void move(int oldIndex, int newIndex) override;
4746 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)
22pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
33
44add_definitions(-DSM_BUSNAME=systemBus)
plugins/Unity/Launcher/launcheritem.cpp−9
@@ -163,9 +163,6 @@ void LauncherItem::setCount(int count)
163163 if (m_count != count) {
164164 m_count = count;
165165 Q_EMIT countChanged(count);
166− if (m_countVisible) {
167− setAlerting(true);
168− }
169166 }
170167}
171168
@@ -179,9 +176,6 @@ void LauncherItem::setCountVisible(bool countVisible)
179176 if (m_countVisible != countVisible) {
180177 m_countVisible = countVisible;
181178 Q_EMIT countVisibleChanged(countVisible);
182− if (countVisible) {
183− setAlerting(true);
184− }
185179 }
186180}
187181
@@ -194,9 +188,6 @@ void LauncherItem::setFocused(bool focused)
194188{
195189 if (m_focused != focused) {
196190 m_focused = focused;
197− if (focused) {
198− setAlerting(false);
199− }
200191 Q_EMIT focusedChanged(focused);
201192 }
202193}
plugins/Unity/Launcher/launchermodel.cpp+20−20
@@ -99,18 +99,6 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
9999 return QVariant();
100100}
101101
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−
114102unity::shell::launcher::LauncherItemInterface *LauncherModel::get(int index) const
115103{
116104 if (index < 0 || index >= m_list.count()) {
@@ -361,11 +349,13 @@ void LauncherModel::countChanged(const QString &appId, int count)
361349 if (idx >= 0) {
362350 LauncherItem *item = m_list.at(idx);
363351 item->setCount(count);
364− if (item->countVisible()) {
365− setAlerting(item->appId(), true);
352+ QVector<int> changedRoles = {RoleCount};
353+ if (item->countVisible() && !item->alerting() && !item->focused()) {
354+ changedRoles << RoleAlerting;
355+ item->setAlerting(true);
366356 }
367357 m_asAdapter->syncItems(m_list);
368− Q_EMIT dataChanged(index(idx), index(idx), {RoleCount});
358+ Q_EMIT dataChanged(index(idx), index(idx), changedRoles);
369359 }
370360}
371361
@@ -375,10 +365,12 @@ void LauncherModel::countVisibleChanged(const QString &appId, bool countVisible)
375365 if (idx >= 0) {
376366 LauncherItem *item = m_list.at(idx);
377367 item->setCountVisible(countVisible);
378− if (countVisible) {
379− setAlerting(item->appId(), true);
368+ QVector<int> changedRoles = {RoleCount};
369+ if (countVisible && !item->alerting() && !item->focused()) {
370+ changedRoles << RoleAlerting;
371+ item->setAlerting(true);
380372 }
381− Q_EMIT dataChanged(index(idx), index(idx), {RoleCountVisible});
373+ Q_EMIT dataChanged(index(idx), index(idx), changedRoles);
382374
383375 // If countVisible goes to false, and the item is neither pinned nor recent we can drop it
384376 if (!countVisible && !item->pinned() && !item->recent()) {
@@ -498,10 +490,12 @@ void LauncherModel::refresh()
498490
499491void LauncherModel::alert(const QString &appId)
500492{
493+ qDebug() << "alerting for appId" << appId;
501494 int idx = findApplication(appId);
502495 if (idx >= 0) {
503496 LauncherItem *item = m_list.at(idx);
504− setAlerting(item->appId(), true);
497+ if (!item->focused() && !item->alerting())
498+ item->setAlerting(true);
505499 Q_EMIT dataChanged(index(idx), index(idx), {RoleAlerting});
506500 }
507501}
@@ -600,8 +594,14 @@ void LauncherModel::focusedAppIdChanged()
600594 for (int i = 0; i < m_list.count(); ++i) {
601595 LauncherItem *item = m_list.at(i);
602596 if (!item->focused() && item->appId() == appId) {
597+ QVector<int> changedRoles;
598+ changedRoles << RoleFocused;
603599 item->setFocused(true);
604− Q_EMIT dataChanged(index(i), index(i), {RoleFocused});
600+ if (item->alerting()) {
601+ changedRoles << RoleAlerting;
602+ item->setAlerting(false);
603+ }
604+ Q_EMIT dataChanged(index(i), index(i), changedRoles);
605605 } else if (item->focused() && item->appId() != appId) {
606606 item->setFocused(false);
607607 Q_EMIT dataChanged(index(i), index(i), {RoleFocused});
plugins/Unity/Launcher/launchermodel.h−1
@@ -45,7 +45,6 @@ public:
4545
4646 QVariant data(const QModelIndex &index, int role) const override;
4747
48− Q_INVOKABLE void setAlerting(const QString &appId, bool alerting) override;
4948 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface* get(int index) const override;
5049 Q_INVOKABLE void move(int oldIndex, int newIndex) override;
5150 Q_INVOKABLE void pin(const QString &appId, int index = -1) override;
qml/Launcher/LauncherDelegate.qml+5−7
@@ -38,6 +38,10 @@ Item {
3838 readonly property real foldedHeight: Math.cos(maxAngle * Math.PI / 180) * itemHeight
3939 readonly property alias wiggling: wiggleAnim.running
4040
41+ onAlertingChanged: {
42+ print("item", index, "alerting:", alerting)
43+ }
44+
4145 property int itemWidth
4246 property int itemHeight
4347 // The angle used for rotating
@@ -115,12 +119,6 @@ Item {
115119 duration: priv.wiggleDuration
116120 easing.type: Easing.OutQuad
117121 }
118−
119− UbuntuNumberAnimation {
120− target: root
121− property: "alerting"
122− to: 0
123− }
124122 }
125123
126124 Item {
@@ -228,7 +226,7 @@ Item {
228226 objectName: "runningHighlight" + index
229227 width: units.gu(0.25)
230228 height: units.gu(.5)
231− color: "white"
229+ color: root.alerting ? UbuntuColors.blue : "white"
232230 visible: root.itemRunning
233231 }
234232 }
qml/Launcher/LauncherPanel.qml+10
@@ -244,6 +244,15 @@ Rectangle {
244244 maxAngle: 55
245245 property bool dragging: false
246246
247+ Timer {
248+ interval: 1000
249+ running: index == 2
250+ repeat: true
251+ onTriggered: {
252+ print("is alerting", model.alerting)
253+ }
254+ }
255+
247256 SequentialAnimation {
248257 id: peekingAnimation
249258
@@ -275,6 +284,7 @@ Rectangle {
275284 }
276285
277286 onAlertingChanged: {
287+ print("panel alerting changed", alerting)
278288 if(alerting) {
279289 if (!dragging && (launcherListView.peekingIndex === -1 || launcher.visibleWidth > 0)) {
280290 launcherListView.moveToIndex(index)
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)
22
33include_directories(
44 ${CMAKE_CURRENT_SOURCE_DIR}
tests/mocks/Unity/Launcher/MockLauncherItem.cpp+2
@@ -21,6 +21,7 @@
2121#include "MockQuickListModel.h"
2222
2323#include <paths.h>
24+#include <QDebug>
2425
2526using namespace unity::shell::launcher;
2627
@@ -179,6 +180,7 @@ void MockLauncherItem::setAlerting(bool alerting)
179180{
180181 if (m_alerting != alerting) {
181182 m_alerting = alerting;
183+ qDebug() << m_appId << "setting alerting" << alerting;
182184 Q_EMIT alertingChanged(alerting);
183185 }
184186}
tests/mocks/Unity/Launcher/MockLauncherModel.h+1−1
@@ -38,7 +38,7 @@ public:
3838
3939 QVariant data(const QModelIndex& index, int role) const override;
4040
41− Q_INVOKABLE void setAlerting(const QString &appId, bool alerting) override;
41+ Q_INVOKABLE void setAlerting(const QString &appId, bool alerting); // Only for testing
4242 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface *get(int index) const override;
4343 Q_INVOKABLE void move(int oldIndex, int newIndex) override;
4444 Q_INVOKABLE void pin(const QString &appId, int index = -1) override;
tests/qmltests/Launcher/tst_Launcher.qml+4−1
@@ -176,7 +176,10 @@ Rectangle {
176176
177177 Button {
178178 text: "set alert"
179− onClicked: LauncherModel.setAlerting(LauncherModel.get(parseInt(appIdEntryAlert.displayText)).appId, true)
179+ onClicked: {
180+ print("should alert", LauncherModel.get(parseInt(appIdEntryAlert.displayText)).appId)
181+ LauncherModel.setAlerting(LauncherModel.get(parseInt(appIdEntryAlert.displayText)).appId, true)
182+ }
180183 }
181184
182185 TextArea {