on xenial help sign in
Remove debugging output... make count-emblem part of fakeAlertItem... emit dataChanged-signal upon change of alert-state.
commit9e6c268a639653f07363f9506f4f0c64038be2bc authorMirco Müller <mirco.mueller@ubuntu.com> dateWed 10 Jun 2015, 12:48 (11 years ago) parentaf18ef9
6 files changed+33−68
plugins/Unity/Launcher/launchermodel.cpp+2 qml/Launcher/LauncherDelegate.qml+28−30 qml/Launcher/LauncherPanel.qml+1 tests/mocks/Unity/Launcher/MockLauncherItem.cpp−2 tests/mocks/Unity/Launcher/MockLauncherModel.cpp+2−5 tests/qmltests/Launcher/tst_Launcher.qml−31
plugins/Unity/Launcher/launchermodel.cpp+2
@@ -92,8 +92,10 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
9292void LauncherModel::alert(const QString &appId, bool alerting) {
9393 int index = findApplication(appId);
9494 if (index >= 0) {
95+ QModelIndex modelIndex = this->index(index);
9596 LauncherItem *item = m_list.at(index);
9697 item->setAlerting(alerting);
98+ Q_EMIT dataChanged(modelIndex, modelIndex, QVector<int>() << RoleAlerting);
9799 }
98100}
99101
qml/Launcher/LauncherDelegate.qml+28−30
@@ -41,74 +41,71 @@ Item {
4141 property real itemOpacity: 1
4242 property real brightness: 0
4343
44− onAlertingChanged: {
45− print("alerting changed for ", appId)
46− }
44+ QtObject {
45+ id: privWiggleAnim
4746
48− onInvertedChanged: {
49− print("inverted changed for ", appId)
47+ readonly property double angle: 5.0
48+ readonly property int duration: UbuntuAnimation.SnapDuration
49+ readonly property var target: root
5050 }
5151
5252 SequentialAnimation {
5353 id: wiggleAnim
5454
55− readonly property double angle: 5.0
56− readonly property int duration: UbuntuAnimation.SnapDuration
57−
5855 running: alerting
5956 loops: Animation.Infinite
6057
6158 NumberAnimation {
62− target: root
59+ target: privWiggleAnim.target
6360 property: "rotation"
6461 from: 0
65− to: wiggleAnim.angle
66− duration: wiggleAnim.duration
62+ to: privWiggleAnim.angle
63+ duration: privWiggleAnim.duration
6764 easing.type: Easing.InQuad
6865 }
6966
7067 NumberAnimation {
71− target: root
68+ target: privWiggleAnim.target
7269 property: "rotation"
73− from: wiggleAnim.angle
74− to: -wiggleAnim.angle
75− duration: wiggleAnim.duration
70+ from: privWiggleAnim.angle
71+ to: -privWiggleAnim.angle
72+ duration: privWiggleAnim.duration
7673 easing.type: Easing.InOutQuad
7774 }
7875
7976 NumberAnimation {
80− target: root
77+ target: privWiggleAnim.target
8178 property: "rotation"
82− from: -wiggleAnim.angle
83− to: wiggleAnim.angle
84− duration: wiggleAnim.duration
79+ from: -privWiggleAnim.angle
80+ to: privWiggleAnim.angle
81+ duration: privWiggleAnim.duration
8582 easing.type: Easing.InOutQuad
8683 }
8784
8885 NumberAnimation {
89− target: root
86+ target: privWiggleAnim.target
9087 property: "rotation"
91− from: -wiggleAnim.angle
92− to: wiggleAnim.angle
93− duration: wiggleAnim.duration
88+ from: -privWiggleAnim.angle
89+ to: privWiggleAnim.angle
90+ duration: privWiggleAnim.duration
9491 easing.type: Easing.InOutQuad
9592 }
9693
9794 NumberAnimation {
98− target: root
95+ target: privWiggleAnim.target
9996 property: "rotation"
100− from: wiggleAnim.angle
101− to: -wiggleAnim.angle
102− duration: wiggleAnim.duration
97+ from: privWiggleAnim.angle
98+ to: -privWiggleAnim.angle
99+ duration: privWiggleAnim.duration
103100 easing.type: Easing.InOutQuad
104101 }
105102
106103 NumberAnimation {
107− target: root
104+ target: privWiggleAnim.target
108105 property: "rotation"
109− from: -wiggleAnim.angle
106+ from: -privWiggleAnim.angle
110107 to: 0
111− duration: wiggleAnim.duration
108+ duration: privWiggleAnim.duration
112109 easing.type: Easing.OutQuad
113110 }
114111
@@ -214,6 +211,7 @@ Item {
214211 }
215212 }
216213 }
214+
217215 Image {
218216 objectName: "focusedHighlight"
219217 anchors {
qml/Launcher/LauncherPanel.qml+1
@@ -59,6 +59,7 @@ Rectangle {
5959 fakeAlertingItem.y = alertIndex * fakeAlertingItem.itemHeight + launcherListView.anchors.topMargin + launcherListView.topMargin
6060 fakeAlertingItem.progress = launcherListView.model.get(alertIndex).progress
6161 fakeAlertingItem.alerting = true
62+ fakeAlertingItem.countVisible = launcherListView.model.get(alertIndex).countVisible
6263 fakeAlertingItem.visible = true
6364 } else {
6465 // fold
tests/mocks/Unity/Launcher/MockLauncherItem.cpp−2
@@ -21,7 +21,6 @@
2121#include "MockQuickListModel.h"
2222
2323#include <paths.h>
24−#include <iostream>
2524
2625using namespace unity::shell::launcher;
2726
@@ -170,7 +169,6 @@ void MockLauncherItem::setAlerting(bool alerting)
170169{
171170 if (m_alerting != alerting)
172171 {
173− std::cout << "MockLauncherItem::setAlerting()" << std::endl;
174172 m_alerting = alerting;
175173 Q_EMIT alertingChanged(alerting);
176174 }
tests/mocks/Unity/Launcher/MockLauncherModel.cpp+2−5
@@ -20,20 +20,16 @@
2020#include "MockLauncherModel.h"
2121#include "MockLauncherItem.h"
2222
23−#include <iostream>
24−
2523MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(parent)
2624{
2725 MockLauncherItem *item = new MockLauncherItem("dialer-app", "/usr/share/applications/dialer-app.desktop", "Dialer", "dialer-app", this);
2826 item->setProgress(0);
2927 item->setPinned(true);
3028 item->setFocused(true);
31− item->setAlerting(true);
3229 m_list.append(item);
3330 item = new MockLauncherItem("camera-app", "/usr/share/applications/camera-app.desktop", "Camera", "camera", this);
3431 item->setProgress(10);
3532 item->setPinned(true);
36− item->setAlerting(true);
3733 m_list.append(item);
3834 item = new MockLauncherItem("gallery-app", "/usr/share/applications/gallery-app.desktop", "Gallery", "gallery", this);
3935 item->setProgress(50);
@@ -126,9 +122,10 @@ unity::shell::launcher::LauncherItemInterface *MockLauncherModel::get(int index)
126122void MockLauncherModel::alert(const QString &appId, bool alerting) {
127123 int index = findApp(appId);
128124 if (index >= 0) {
129− std::cout << "MockLauncherModel::alert()" << std::endl;
125+ QModelIndex modelIndex = this->index(index);
130126 MockLauncherItem *item = m_list.at(index);
131127 item->setAlerting(alerting);
128+ Q_EMIT dataChanged(modelIndex, modelIndex, QVector<int>() << RoleAlerting);
132129 }
133130}
134131
tests/qmltests/Launcher/tst_Launcher.qml−31
@@ -128,24 +128,7 @@ Item {
128128 Button {
129129 text: "set alert"
130130 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−
140131 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−
149132 }
150133 Layout.fillWidth: true
151134 }
@@ -163,21 +146,7 @@ Item {
163146 Button {
164147 text: "unset alert"
165148 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−
173149 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−
181150 }
182151 Layout.fillWidth: true
183152 }