on xenial help sign in
Trying to make the launcher's qmltest trigger the alerting/wobble-animation...
9b59ecbMirco Müller
plugins/Unity/Launcher/launcheritem.cpp+2
@@ -21,6 +21,7 @@
21#include "quicklistmodel.h"
21#include "quicklistmodel.h"
22
22
23#include <libintl.h>
23#include <libintl.h>
24+#include <iostream>
24
25
25LauncherItem::LauncherItem(const QString &appId, const QString &name, const QString &icon, QObject *parent) :
26LauncherItem::LauncherItem(const QString &appId, const QString &name, const QString &icon, QObject *parent) :
26 LauncherItemInterface(parent),
27 LauncherItemInterface(parent),
@@ -190,6 +191,7 @@ bool LauncherItem::alerting() const
190
191
191void LauncherItem::setAlerting(bool alerting)
192void LauncherItem::setAlerting(bool alerting)
192{
193{
194+ std::cout << "LauncherItem::setAlerting()" << std::endl;
193 if (m_alerting != alerting) {
195 if (m_alerting != alerting) {
194 m_alerting = alerting;
196 m_alerting = alerting;
195 Q_EMIT alertingChanged(alerting);
197 Q_EMIT alertingChanged(alerting);
plugins/Unity/Launcher/launchermodel.cpp+2−2
@@ -89,11 +89,11 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
89 return QVariant();
89 return QVariant();
90}
90}
91
91
92−void LauncherModel::alert(const QString &appId) {
92+void LauncherModel::alert(const QString &appId, bool alerting) {
93 int index = findApplication(appId);
93 int index = findApplication(appId);
94 if (index >= 0) {
94 if (index >= 0) {
95 LauncherItem *item = m_list.at(index);
95 LauncherItem *item = m_list.at(index);
96− item->setAlerting(true);
96+ item->setAlerting(alerting);
97 }
97 }
98}
98}
99
99
plugins/Unity/Launcher/launchermodel.h+1−1
@@ -45,7 +45,7 @@ public:
45
45
46 QVariant data(const QModelIndex &index, int role) const;
46 QVariant data(const QModelIndex &index, int role) const;
47
47
48− Q_INVOKABLE void alert(const QString &appId);
48+ Q_INVOKABLE void alert(const QString &appId, bool alerting);
49 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface* get(int index) const;
49 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface* get(int index) const;
50 Q_INVOKABLE void move(int oldIndex, int newIndex);
50 Q_INVOKABLE void move(int oldIndex, int newIndex);
51 Q_INVOKABLE void pin(const QString &appId, int index = -1);
51 Q_INVOKABLE void pin(const QString &appId, int index = -1);
qml/Launcher/LauncherDelegate.qml+4
@@ -41,6 +41,10 @@ Item {
41 property real itemOpacity: 1
41 property real itemOpacity: 1
42 property real brightness: 0
42 property real brightness: 0
43
43
44+ onAlertingChanged: {
45+ print("alerting changed for ", iconName)
46+ }
47+
44 SequentialAnimation {
48 SequentialAnimation {
45 id: wiggleAnim
49 id: wiggleAnim
46
50
qml/Launcher/LauncherPanel.qml+4−2
@@ -204,6 +204,7 @@ Rectangle {
204 progress: model.progress
204 progress: model.progress
205 itemFocused: model.focused
205 itemFocused: model.focused
206 inverted: root.inverted
206 inverted: root.inverted
207+ alerting: model.alerting
207 z: -Math.abs(offset)
208 z: -Math.abs(offset)
208 maxAngle: 55
209 maxAngle: 55
209 property bool dragging: false
210 property bool dragging: false
@@ -429,6 +430,7 @@ Rectangle {
429 }
430 }
430
431
431 onPositionChanged: {
432 onPositionChanged: {
433+ print("position:", mouseX, "/", mouseY)
432 if (draggedIndex >= 0) {
434 if (draggedIndex >= 0) {
433 if (!selectedItem.dragging) {
435 if (!selectedItem.dragging) {
434 var distance = Math.max(Math.abs(mouseX - startX), Math.abs(mouseY - startY))
436 var distance = Math.max(Math.abs(mouseX - startX), Math.abs(mouseY - startY))
@@ -554,11 +556,11 @@ Rectangle {
554 ParallelAnimation {
556 ParallelAnimation {
555 id: fakeAlertingItemReveal
557 id: fakeAlertingItemReveal
556
558
557− UbuntuNumberAnimation {
559+ /*UbuntuNumberAnimation {
558 target: fakeAlertingItem;
560 target: fakeAlertingItem;
559 properties: "angle, offset";
561 properties: "angle, offset";
560 to: 0
562 to: 0
561− }
563+ }*/
562
564
563 UbuntuNumberAnimation {
565 UbuntuNumberAnimation {
564 target: fakeAlertingItem;
566 target: fakeAlertingItem;
tests/mocks/Unity/Launcher/MockLauncherItem.cpp+2
@@ -21,6 +21,7 @@
21#include "MockQuickListModel.h"
21#include "MockQuickListModel.h"
22
22
23#include <paths.h>
23#include <paths.h>
24+#include <iostream>
24
25
25using namespace unity::shell::launcher;
26using namespace unity::shell::launcher;
26
27
@@ -169,6 +170,7 @@ void MockLauncherItem::setAlerting(bool alerting)
169{
170{
170 if (m_alerting != alerting)
171 if (m_alerting != alerting)
171 {
172 {
173+ std::cout << "MockLauncherItem::setAlerting()" << std::endl;
172 m_alerting = alerting;
174 m_alerting = alerting;
173 Q_EMIT alertingChanged(alerting);
175 Q_EMIT alertingChanged(alerting);
174 }
176 }
tests/mocks/Unity/Launcher/MockLauncherModel.cpp+13
@@ -20,6 +20,8 @@
20#include "MockLauncherModel.h"
20#include "MockLauncherModel.h"
21#include "MockLauncherItem.h"
21#include "MockLauncherItem.h"
22
22
23+#include <iostream>
24+
23MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(parent)
25MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(parent)
24{
26{
25 MockLauncherItem *item = new MockLauncherItem("dialer-app", "/usr/share/applications/dialer-app.desktop", "Dialer", "dialer-app", this);
27 MockLauncherItem *item = new MockLauncherItem("dialer-app", "/usr/share/applications/dialer-app.desktop", "Dialer", "dialer-app", this);
@@ -103,6 +105,8 @@ QVariant MockLauncherModel::data(const QModelIndex& index, int role) const
103 return item->countVisible();
105 return item->countVisible();
104 case RoleFocused:
106 case RoleFocused:
105 return item->focused();
107 return item->focused();
108+ case RoleAlerting:
109+ return item->alerting();
106 }
110 }
107
111
108 return QVariant();
112 return QVariant();
@@ -117,6 +121,15 @@ unity::shell::launcher::LauncherItemInterface *MockLauncherModel::get(int index)
117 return m_list.at(index);
121 return m_list.at(index);
118}
122}
119
123
124+void MockLauncherModel::alert(const QString &appId, bool alerting) {
125+ int index = findApp(appId);
126+ if (index >= 0) {
127+ std::cout << "MockLauncherModel::alert()" << std::endl;
128+ MockLauncherItem *item = m_list.at(index);
129+ item->setAlerting(alerting);
130+ }
131+}
132+
120void MockLauncherModel::move(int oldIndex, int newIndex)
133void MockLauncherModel::move(int oldIndex, int newIndex)
121{
134{
122 // Make sure its not moved outside the lists
135 // Make sure its not moved outside the lists
tests/mocks/Unity/Launcher/MockLauncherModel.h+1
@@ -38,6 +38,7 @@ public:
38
38
39 QVariant data(const QModelIndex& index, int role) const;
39 QVariant data(const QModelIndex& index, int role) const;
40
40
41+ Q_INVOKABLE void alert(const QString &appId, bool alerting);
41 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface *get(int index) const;
42 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface *get(int index) const;
42 Q_INVOKABLE void move(int oldIndex, int newIndex);
43 Q_INVOKABLE void move(int oldIndex, int newIndex);
43 Q_INVOKABLE void pin(const QString &appId, int index = -1);
44 Q_INVOKABLE void pin(const QString &appId, int index = -1);
tests/qmltests/Launcher/tst_Launcher.qml+16−12
@@ -97,29 +97,33 @@ Item {
97 Row {
97 Row {
98 spacing: units.gu(1)
98 spacing: units.gu(1)
99
99
100− CheckBox {
100+ Button {
101− anchors.verticalCenter: parent.verticalCenter
101+ text: "set alert"
102− checked: false
103 onClicked: {
102 onClicked: {
104− var panel = testCase.findChild(launcherLoader, "launcherPanel")
103+ print(appIdEntry.displayText)
105− panel.alertIndex = checked ? parseInt(iconIndex.displayText) : -1
104+ LauncherModel.alert(appIdEntry.displayText, true)
106− }
107− }
108
105
109− Label {
106+ }
110− anchors.verticalCenter: parent.verticalCenter
107+ Layout.fillWidth: true
111− text: "wiggle of icon"
112 }
108 }
113
109
114 TextArea {
110 TextArea {
115− id: iconIndex
111+ id: appIdEntry
116 anchors.verticalCenter: parent.verticalCenter
112 anchors.verticalCenter: parent.verticalCenter
117 width: units.gu(4)
113 width: units.gu(4)
118 height: units.gu(4)
114 height: units.gu(4)
119 autoSize: true
115 autoSize: true
120− text: "2"
116+ text: "gallery-app"
121 maximumLineCount: 1
117 maximumLineCount: 1
122 }
118 }
119+
120+ Button {
121+ text: "unset alert"
122+ onClicked: {
123+ LauncherModel.alert(appIdEntry.displayText, false)
124+ }
125+ Layout.fillWidth: true
126+ }
123 }
127 }
124 }
128 }
125
129