on xenial help sign in
Trying to make the launcher's qmltest trigger the alerting/wobble-animation...
commit9b59ecbb2cd8e4271d9ed994a4cc00fefdeae2eb authorMirco Müller <mirco.mueller@ubuntu.com> dateFri 5 Jun 2015, 15:51 (11 years ago) parent78e952d
9 files changed+45−17
plugins/Unity/Launcher/launcheritem.cpp+2 plugins/Unity/Launcher/launchermodel.cpp+2−2 plugins/Unity/Launcher/launchermodel.h+1−1 qml/Launcher/LauncherDelegate.qml+4 qml/Launcher/LauncherPanel.qml+4−2 tests/mocks/Unity/Launcher/MockLauncherItem.cpp+2 tests/mocks/Unity/Launcher/MockLauncherModel.cpp+13 tests/mocks/Unity/Launcher/MockLauncherModel.h+1 tests/qmltests/Launcher/tst_Launcher.qml+16−12
plugins/Unity/Launcher/launcheritem.cpp+2
@@ -21,6 +21,7 @@
2121#include "quicklistmodel.h"
2222
2323#include <libintl.h>
24+#include <iostream>
2425
2526LauncherItem::LauncherItem(const QString &appId, const QString &name, const QString &icon, QObject *parent) :
2627 LauncherItemInterface(parent),
@@ -190,6 +191,7 @@ bool LauncherItem::alerting() const
190191
191192void LauncherItem::setAlerting(bool alerting)
192193{
194+ std::cout << "LauncherItem::setAlerting()" << std::endl;
193195 if (m_alerting != alerting) {
194196 m_alerting = alerting;
195197 Q_EMIT alertingChanged(alerting);
plugins/Unity/Launcher/launchermodel.cpp+2−2
@@ -89,11 +89,11 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
8989 return QVariant();
9090}
9191
92−void LauncherModel::alert(const QString &appId) {
92+void LauncherModel::alert(const QString &appId, bool alerting) {
9393 int index = findApplication(appId);
9494 if (index >= 0) {
9595 LauncherItem *item = m_list.at(index);
96− item->setAlerting(true);
96+ item->setAlerting(alerting);
9797 }
9898}
9999
plugins/Unity/Launcher/launchermodel.h+1−1
@@ -45,7 +45,7 @@ public:
4545
4646 QVariant data(const QModelIndex &index, int role) const;
4747
48− Q_INVOKABLE void alert(const QString &appId);
48+ Q_INVOKABLE void alert(const QString &appId, bool alerting);
4949 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface* get(int index) const;
5050 Q_INVOKABLE void move(int oldIndex, int newIndex);
5151 Q_INVOKABLE void pin(const QString &appId, int index = -1);
qml/Launcher/LauncherDelegate.qml+4
@@ -41,6 +41,10 @@ Item {
4141 property real itemOpacity: 1
4242 property real brightness: 0
4343
44+ onAlertingChanged: {
45+ print("alerting changed for ", iconName)
46+ }
47+
4448 SequentialAnimation {
4549 id: wiggleAnim
4650
qml/Launcher/LauncherPanel.qml+4−2
@@ -204,6 +204,7 @@ Rectangle {
204204 progress: model.progress
205205 itemFocused: model.focused
206206 inverted: root.inverted
207+ alerting: model.alerting
207208 z: -Math.abs(offset)
208209 maxAngle: 55
209210 property bool dragging: false
@@ -429,6 +430,7 @@ Rectangle {
429430 }
430431
431432 onPositionChanged: {
433+ print("position:", mouseX, "/", mouseY)
432434 if (draggedIndex >= 0) {
433435 if (!selectedItem.dragging) {
434436 var distance = Math.max(Math.abs(mouseX - startX), Math.abs(mouseY - startY))
@@ -554,11 +556,11 @@ Rectangle {
554556 ParallelAnimation {
555557 id: fakeAlertingItemReveal
556558
557− UbuntuNumberAnimation {
559+ /*UbuntuNumberAnimation {
558560 target: fakeAlertingItem;
559561 properties: "angle, offset";
560562 to: 0
561− }
563+ }*/
562564
563565 UbuntuNumberAnimation {
564566 target: fakeAlertingItem;
tests/mocks/Unity/Launcher/MockLauncherItem.cpp+2
@@ -21,6 +21,7 @@
2121#include "MockQuickListModel.h"
2222
2323#include <paths.h>
24+#include <iostream>
2425
2526using namespace unity::shell::launcher;
2627
@@ -169,6 +170,7 @@ void MockLauncherItem::setAlerting(bool alerting)
169170{
170171 if (m_alerting != alerting)
171172 {
173+ std::cout << "MockLauncherItem::setAlerting()" << std::endl;
172174 m_alerting = alerting;
173175 Q_EMIT alertingChanged(alerting);
174176 }
tests/mocks/Unity/Launcher/MockLauncherModel.cpp+13
@@ -20,6 +20,8 @@
2020#include "MockLauncherModel.h"
2121#include "MockLauncherItem.h"
2222
23+#include <iostream>
24+
2325MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(parent)
2426{
2527 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
103105 return item->countVisible();
104106 case RoleFocused:
105107 return item->focused();
108+ case RoleAlerting:
109+ return item->alerting();
106110 }
107111
108112 return QVariant();
@@ -117,6 +121,15 @@ unity::shell::launcher::LauncherItemInterface *MockLauncherModel::get(int index)
117121 return m_list.at(index);
118122}
119123
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+
120133void MockLauncherModel::move(int oldIndex, int newIndex)
121134{
122135 // Make sure its not moved outside the lists
tests/mocks/Unity/Launcher/MockLauncherModel.h+1
@@ -38,6 +38,7 @@ public:
3838
3939 QVariant data(const QModelIndex& index, int role) const;
4040
41+ Q_INVOKABLE void alert(const QString &appId, bool alerting);
4142 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface *get(int index) const;
4243 Q_INVOKABLE void move(int oldIndex, int newIndex);
4344 Q_INVOKABLE void pin(const QString &appId, int index = -1);
tests/qmltests/Launcher/tst_Launcher.qml+16−12
@@ -97,29 +97,33 @@ Item {
9797 Row {
9898 spacing: units.gu(1)
9999
100− CheckBox {
101− anchors.verticalCenter: parent.verticalCenter
102− checked: false
100+ Button {
101+ text: "set alert"
103102 onClicked: {
104− var panel = testCase.findChild(launcherLoader, "launcherPanel")
105− panel.alertIndex = checked ? parseInt(iconIndex.displayText) : -1
106− }
107− }
103+ print(appIdEntry.displayText)
104+ LauncherModel.alert(appIdEntry.displayText, true)
108105
109− Label {
110− anchors.verticalCenter: parent.verticalCenter
111− text: "wiggle of icon"
106+ }
107+ Layout.fillWidth: true
112108 }
113109
114110 TextArea {
115− id: iconIndex
111+ id: appIdEntry
116112 anchors.verticalCenter: parent.verticalCenter
117113 width: units.gu(4)
118114 height: units.gu(4)
119115 autoSize: true
120− text: "2"
116+ text: "gallery-app"
121117 maximumLineCount: 1
122118 }
119+
120+ Button {
121+ text: "unset alert"
122+ onClicked: {
123+ LauncherModel.alert(appIdEntry.displayText, false)
124+ }
125+ Layout.fillWidth: true
126+ }
123127 }
124128 }
125129