on xenial help sign in
Remove debugging output... make count-emblem part of fakeAlertItem... emit dataChanged-signal upon change of alert-state.
9e6c268Mirco Müller
plugins/Unity/Launcher/launchermodel.cpp+2
@@ -92,8 +92,10 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
92void LauncherModel::alert(const QString &appId, bool alerting) {
92void 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+ QModelIndex modelIndex = this->index(index);
95 LauncherItem *item = m_list.at(index);
96 LauncherItem *item = m_list.at(index);
96 item->setAlerting(alerting);
97 item->setAlerting(alerting);
98+ Q_EMIT dataChanged(modelIndex, modelIndex, QVector<int>() << RoleAlerting);
97 }
99 }
98}
100}
99
101
qml/Launcher/LauncherDelegate.qml+28−30
@@ -41,74 +41,71 @@ 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: {
44+ QtObject {
45− print("alerting changed for ", appId)
45+ id: privWiggleAnim
46− }
47
46
48− onInvertedChanged: {
47+ readonly property double angle: 5.0
49− print("inverted changed for ", appId)
48+ readonly property int duration: UbuntuAnimation.SnapDuration
49+ readonly property var target: root
50 }
50 }
51
51
52 SequentialAnimation {
52 SequentialAnimation {
53 id: wiggleAnim
53 id: wiggleAnim
54
54
55− readonly property double angle: 5.0
56− readonly property int duration: UbuntuAnimation.SnapDuration
57−
58 running: alerting
55 running: alerting
59 loops: Animation.Infinite
56 loops: Animation.Infinite
60
57
61 NumberAnimation {
58 NumberAnimation {
62− target: root
59+ target: privWiggleAnim.target
63 property: "rotation"
60 property: "rotation"
64 from: 0
61 from: 0
65− to: wiggleAnim.angle
62+ to: privWiggleAnim.angle
66− duration: wiggleAnim.duration
63+ duration: privWiggleAnim.duration
67 easing.type: Easing.InQuad
64 easing.type: Easing.InQuad
68 }
65 }
69
66
70 NumberAnimation {
67 NumberAnimation {
71− target: root
68+ target: privWiggleAnim.target
72 property: "rotation"
69 property: "rotation"
73− from: wiggleAnim.angle
70+ from: privWiggleAnim.angle
74− to: -wiggleAnim.angle
71+ to: -privWiggleAnim.angle
75− duration: wiggleAnim.duration
72+ duration: privWiggleAnim.duration
76 easing.type: Easing.InOutQuad
73 easing.type: Easing.InOutQuad
77 }
74 }
78
75
79 NumberAnimation {
76 NumberAnimation {
80− target: root
77+ target: privWiggleAnim.target
81 property: "rotation"
78 property: "rotation"
82− from: -wiggleAnim.angle
79+ from: -privWiggleAnim.angle
83− to: wiggleAnim.angle
80+ to: privWiggleAnim.angle
84− duration: wiggleAnim.duration
81+ duration: privWiggleAnim.duration
85 easing.type: Easing.InOutQuad
82 easing.type: Easing.InOutQuad
86 }
83 }
87
84
88 NumberAnimation {
85 NumberAnimation {
89− target: root
86+ target: privWiggleAnim.target
90 property: "rotation"
87 property: "rotation"
91− from: -wiggleAnim.angle
88+ from: -privWiggleAnim.angle
92− to: wiggleAnim.angle
89+ to: privWiggleAnim.angle
93− duration: wiggleAnim.duration
90+ duration: privWiggleAnim.duration
94 easing.type: Easing.InOutQuad
91 easing.type: Easing.InOutQuad
95 }
92 }
96
93
97 NumberAnimation {
94 NumberAnimation {
98− target: root
95+ target: privWiggleAnim.target
99 property: "rotation"
96 property: "rotation"
100− from: wiggleAnim.angle
97+ from: privWiggleAnim.angle
101− to: -wiggleAnim.angle
98+ to: -privWiggleAnim.angle
102− duration: wiggleAnim.duration
99+ duration: privWiggleAnim.duration
103 easing.type: Easing.InOutQuad
100 easing.type: Easing.InOutQuad
104 }
101 }
105
102
106 NumberAnimation {
103 NumberAnimation {
107− target: root
104+ target: privWiggleAnim.target
108 property: "rotation"
105 property: "rotation"
109− from: -wiggleAnim.angle
106+ from: -privWiggleAnim.angle
110 to: 0
107 to: 0
111− duration: wiggleAnim.duration
108+ duration: privWiggleAnim.duration
112 easing.type: Easing.OutQuad
109 easing.type: Easing.OutQuad
113 }
110 }
114
111
@@ -214,6 +211,7 @@ Item {
214 }
211 }
215 }
212 }
216 }
213 }
214+
217 Image {
215 Image {
218 objectName: "focusedHighlight"
216 objectName: "focusedHighlight"
219 anchors {
217 anchors {
qml/Launcher/LauncherPanel.qml+1
@@ -59,6 +59,7 @@ Rectangle {
59 fakeAlertingItem.y = alertIndex * fakeAlertingItem.itemHeight + launcherListView.anchors.topMargin + launcherListView.topMargin
59 fakeAlertingItem.y = alertIndex * fakeAlertingItem.itemHeight + launcherListView.anchors.topMargin + launcherListView.topMargin
60 fakeAlertingItem.progress = launcherListView.model.get(alertIndex).progress
60 fakeAlertingItem.progress = launcherListView.model.get(alertIndex).progress
61 fakeAlertingItem.alerting = true
61 fakeAlertingItem.alerting = true
62+ fakeAlertingItem.countVisible = launcherListView.model.get(alertIndex).countVisible
62 fakeAlertingItem.visible = true
63 fakeAlertingItem.visible = true
63 } else {
64 } else {
64 // fold
65 // fold
tests/mocks/Unity/Launcher/MockLauncherItem.cpp−2
@@ -21,7 +21,6 @@
21#include "MockQuickListModel.h"
21#include "MockQuickListModel.h"
22
22
23#include <paths.h>
23#include <paths.h>
24−#include <iostream>
25
24
26using namespace unity::shell::launcher;
25using namespace unity::shell::launcher;
27
26
@@ -170,7 +169,6 @@ void MockLauncherItem::setAlerting(bool alerting)
170{
169{
171 if (m_alerting != alerting)
170 if (m_alerting != alerting)
172 {
171 {
173− std::cout << "MockLauncherItem::setAlerting()" << std::endl;
174 m_alerting = alerting;
172 m_alerting = alerting;
175 Q_EMIT alertingChanged(alerting);
173 Q_EMIT alertingChanged(alerting);
176 }
174 }
tests/mocks/Unity/Launcher/MockLauncherModel.cpp+2−5
@@ -20,20 +20,16 @@
20#include "MockLauncherModel.h"
20#include "MockLauncherModel.h"
21#include "MockLauncherItem.h"
21#include "MockLauncherItem.h"
22
22
23−#include <iostream>
24−
25MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(parent)
23MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(parent)
26{
24{
27 MockLauncherItem *item = new MockLauncherItem("dialer-app", "/usr/share/applications/dialer-app.desktop", "Dialer", "dialer-app", this);
25 MockLauncherItem *item = new MockLauncherItem("dialer-app", "/usr/share/applications/dialer-app.desktop", "Dialer", "dialer-app", this);
28 item->setProgress(0);
26 item->setProgress(0);
29 item->setPinned(true);
27 item->setPinned(true);
30 item->setFocused(true);
28 item->setFocused(true);
31− item->setAlerting(true);
32 m_list.append(item);
29 m_list.append(item);
33 item = new MockLauncherItem("camera-app", "/usr/share/applications/camera-app.desktop", "Camera", "camera", this);
30 item = new MockLauncherItem("camera-app", "/usr/share/applications/camera-app.desktop", "Camera", "camera", this);
34 item->setProgress(10);
31 item->setProgress(10);
35 item->setPinned(true);
32 item->setPinned(true);
36− item->setAlerting(true);
37 m_list.append(item);
33 m_list.append(item);
38 item = new MockLauncherItem("gallery-app", "/usr/share/applications/gallery-app.desktop", "Gallery", "gallery", this);
34 item = new MockLauncherItem("gallery-app", "/usr/share/applications/gallery-app.desktop", "Gallery", "gallery", this);
39 item->setProgress(50);
35 item->setProgress(50);
@@ -126,9 +122,10 @@ unity::shell::launcher::LauncherItemInterface *MockLauncherModel::get(int index)
126void MockLauncherModel::alert(const QString &appId, bool alerting) {
122void MockLauncherModel::alert(const QString &appId, bool alerting) {
127 int index = findApp(appId);
123 int index = findApp(appId);
128 if (index >= 0) {
124 if (index >= 0) {
129− std::cout << "MockLauncherModel::alert()" << std::endl;
125+ QModelIndex modelIndex = this->index(index);
130 MockLauncherItem *item = m_list.at(index);
126 MockLauncherItem *item = m_list.at(index);
131 item->setAlerting(alerting);
127 item->setAlerting(alerting);
128+ Q_EMIT dataChanged(modelIndex, modelIndex, QVector<int>() << RoleAlerting);
132 }
129 }
133}
130}
134
131
tests/qmltests/Launcher/tst_Launcher.qml−31
@@ -128,24 +128,7 @@ Item {
128 Button {
128 Button {
129 text: "set alert"
129 text: "set alert"
130 onClicked: {
130 onClicked: {
131− print(appIdEntry.displayText)
132−
133− var launcherListView = testCase.findChild(launcherLoader.item, "launcherListView")
134− for (var i = 0; i < launcherListView.count; ++i) {
135− if (LauncherModel.get(i).appId === appIdEntry.displayText) {
136− print(LauncherModel.get(i).alerting)
137− }
138− }
139−
140 LauncherModel.alert(appIdEntry.displayText, true)
131 LauncherModel.alert(appIdEntry.displayText, true)
141−
142−
143− for (var i = 0; i < launcherListView.count; ++i) {
144− if (LauncherModel.get(i).appId === appIdEntry.displayText) {
145− print(LauncherModel.get(i).alerting)
146− }
147− }
148−
149 }
132 }
150 Layout.fillWidth: true
133 Layout.fillWidth: true
151 }
134 }
@@ -163,21 +146,7 @@ Item {
163 Button {
146 Button {
164 text: "unset alert"
147 text: "unset alert"
165 onClicked: {
148 onClicked: {
166− var launcherListView = testCase.findChild(launcherLoader.item, "launcherListView")
167− for (var i = 0; i < launcherListView.count; ++i) {
168− if (LauncherModel.get(i).appId === appIdEntry.displayText) {
169− print(LauncherModel.get(i).alerting)
170− }
171− }
172−
173 LauncherModel.alert(appIdEntry.displayText, false)
149 LauncherModel.alert(appIdEntry.displayText, false)
174−
175− for (var i = 0; i < launcherListView.count; ++i) {
176− if (LauncherModel.get(i).appId === appIdEntry.displayText) {
177− print(LauncherModel.get(i).alerting)
178− }
179− }
180−
181 }
150 }
182 Layout.fillWidth: true
151 Layout.fillWidth: true
183 }
152 }