on xenial help sign in
Updated mocked launchermodel/item with new alerting-API... made peeking-wobble almost seamlessly merge with dragging the launcher out... some visual quirks still remain.
commit9b49c7f766fc8a7f7e8288e8bbf4ef3d2d2cdeb9 authorMirco Müller <mirco.mueller@ubuntu.com> dateTue 2 Jun 2015, 15:50 (11 years ago) parent68bf3b5
9 files changed+80−37
plugins/Greeter/Unity/Launcher/launcheritem.cpp+14 plugins/Greeter/Unity/Launcher/launcheritem.h+4 plugins/Unity/Launcher/launcheritem.cpp+17 plugins/Unity/Launcher/launcheritem.h+3 plugins/Unity/Launcher/launchermodel.cpp+5−5 plugins/Unity/Launcher/launchermodel.h+1−3 qml/Launcher/LauncherPanel.qml+19−29 tests/mocks/Unity/Launcher/MockLauncherItem.cpp+14 tests/mocks/Unity/Launcher/MockLauncherItem.h+3
plugins/Greeter/Unity/Launcher/launcheritem.cpp+14
@@ -31,6 +31,7 @@ LauncherItem::LauncherItem(const QString &appId, const QString &name, const QStr
3131 m_count(0),
3232 m_countVisible(false),
3333 m_focused(false),
34+ m_alerting(false),
3435 m_quickList(new QuickListModel(this))
3536{
3637 QuickListEntry nameAction;
@@ -165,6 +166,19 @@ void LauncherItem::setFocused(bool focused)
165166 }
166167}
167168
169+bool LauncherItem::alerting() const
170+{
171+ return m_alerting;
172+}
173+
174+void LauncherItem::setAlerting(bool alerting)
175+{
176+ if (m_alerting != alerting) {
177+ m_alerting = alerting;
178+ Q_EMIT alertingChanged(alerting);
179+ }
180+}
181+
168182unity::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
169183{
170184 return m_quickList;
plugins/Greeter/Unity/Launcher/launcheritem.h+4
@@ -41,6 +41,7 @@ public:
4141 int count() const override;
4242 bool countVisible() const override;
4343 bool focused() const override;
44+ bool alerting() const override;
4445
4546 unity::shell::launcher::QuickListModelInterface *quickList() const override;
4647
@@ -54,6 +55,8 @@ private:
5455 void setCount(int count);
5556 void setCountVisible(bool countVisible);
5657 void setFocused(bool focused);
58+ void setAlerting(bool alerting);
59+
5760
5861private:
5962 QString m_appId;
@@ -66,6 +69,7 @@ private:
6669 int m_count;
6770 bool m_countVisible;
6871 bool m_focused;
72+ bool m_alerting;
6973 QuickListModel *m_quickList;
7074
7175 friend class LauncherModel;
plugins/Unity/Launcher/launcheritem.cpp+17
@@ -34,6 +34,7 @@ LauncherItem::LauncherItem(const QString &appId, const QString &name, const QStr
3434 m_count(0),
3535 m_countVisible(false),
3636 m_focused(false),
37+ m_alerting(false),
3738 m_quickList(new QuickListModel(this))
3839{
3940 QuickListEntry nameAction;
@@ -175,10 +176,26 @@ void LauncherItem::setFocused(bool focused)
175176{
176177 if (m_focused != focused) {
177178 m_focused = focused;
179+ if (!focused) {
180+ setAlerting(false);
181+ }
178182 Q_EMIT focusedChanged(focused);
179183 }
180184}
181185
186+bool LauncherItem::alerting() const
187+{
188+ return m_alerting;
189+}
190+
191+void LauncherItem::setAlerting(bool alerting)
192+{
193+ if (m_alerting != alerting) {
194+ m_alerting = alerting;
195+ Q_EMIT alertingChanged(alerting);
196+ }
197+}
198+
182199unity::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
183200{
184201 return m_quickList;
plugins/Unity/Launcher/launcheritem.h+3
@@ -44,6 +44,7 @@ public:
4444 int count() const override;
4545 bool countVisible() const override;
4646 bool focused() const override;
47+ bool alerting() const override;
4748
4849 unity::shell::launcher::QuickListModelInterface *quickList() const override;
4950
@@ -57,6 +58,7 @@ private:
5758 void setCount(int count);
5859 void setCountVisible(bool countVisible);
5960 void setFocused(bool focused);
61+ void setAlerting(bool alerting);
6062
6163private:
6264 QString m_appId;
@@ -69,6 +71,7 @@ private:
6971 int m_count;
7072 bool m_countVisible;
7173 bool m_focused;
74+ bool m_alerting;
7275 QuickListModel *m_quickList;
7376
7477 friend class LauncherModel;
plugins/Unity/Launcher/launchermodel.cpp+5−5
@@ -44,8 +44,6 @@ LauncherModel::LauncherModel(QObject *parent):
4444
4545 connect(m_settings, &GSettings::changed, this, &LauncherModel::refresh);
4646
47− m_alertIndex = -1;
48−
4947 refresh();
5048}
5149
@@ -84,16 +82,18 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
8482 return item->progress();
8583 case RoleFocused:
8684 return item->focused();
85+ case RoleAlerting:
86+ return item->alerting();
8787 }
8888
8989 return QVariant();
9090}
9191
92−void LauncherModel::alert(const QString &appId) const {
92+void LauncherModel::alert(const QString &appId) {
9393 int index = findApplication(appId);
9494 if (index >= 0) {
95− m_alertIndex = index;
96− Q_EMIT alerting(m_alertIndex);
95+ LauncherItem *item = m_list.at(index);
96+ item->setAlerting(true);
9797 }
9898}
9999
plugins/Unity/Launcher/launchermodel.h+1−3
@@ -45,7 +45,7 @@ public:
4545
4646 QVariant data(const QModelIndex &index, int role) const;
4747
48− Q_INVOKABLE void alert(const QString &appId) const;
48+ Q_INVOKABLE void alert(const QString &appId);
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);
@@ -86,8 +86,6 @@ private:
8686 DBusInterface *m_dbusIface;
8787 ASAdapter *m_asAdapter;
8888
89− int m_alertIndex;
90−
9189 ApplicationManagerInterface *m_appManager;
9290
9391 friend class LauncherModelTest;
qml/Launcher/LauncherPanel.qml+19−29
@@ -43,6 +43,10 @@ Rectangle {
4343 if (quickList.state == "open") {
4444 quickList.state = ""
4545 }
46+
47+ if (fakeAlertingItem.visible && fakeAlertingItem.x > units.gu(.5)) {
48+ fakeAlertingItem.x = 72 - parent.visibleWidth
49+ }
4650 }
4751
4852 onAlertIndexChanged: {
@@ -53,27 +57,14 @@ Rectangle {
5357 fakeAlertingItem.index = alertIndex
5458 fakeAlertingItem.iconName = launcherListView.model.get(alertIndex).icon
5559 fakeAlertingItem.y = alertIndex * fakeAlertingItem.itemHeight + launcherListView.anchors.topMargin + launcherListView.topMargin
56− fakeAlertingItem.count = LauncherModel.get(alertIndex).count
57− fakeAlertingItem.progress = LauncherModel.get(alertIndex).progress
60+ fakeAlertingItem.progress = launcherListView.model.get(alertIndex).progress
5861 fakeAlertingItem.alerting = true
5962 fakeAlertingItem.visible = true
60− if (launcher.state !== "visible") {
61− fakeAlertingItem.reveal()
62− }
63− print("y = ", fakeAlertingItem.y)
64− print("index = ", fakeAlertingItem.index)
6563 } else {
66− // set real icon back to visible
67−
6864 // fold
6965
7066 // hide fake-alerting-icon
7167 fakeAlertingItem.alerting = false
72−
73− if (launcher.state !== "visible") {
74− fakeAlertingItem.hide()
75− }
76− //fakeAlertingItem.visible = false
7768 }
7869 }
7970
@@ -216,6 +207,7 @@ Rectangle {
216207 z: -Math.abs(offset)
217208 maxAngle: 55
218209 property bool dragging: false
210+ itemOpacity: index === alertIndex ? 0 : 1
219211
220212 ThinDivider {
221213 id: dropIndicator
@@ -546,15 +538,19 @@ Rectangle {
546538 itemHeight: launcherListView.itemHeight
547539 height: itemHeight
548540 width: itemWidth
549− rotation: root.rotation
541+ rotation: root.rotation1G
550542 alerting: false
551543
552− function reveal() {
553− fakeAlertingItemReveal.start();
554− }
555−
556− function hide() {
557− fakeAlertingItemHide.start();
544+ onAlertingChanged: {
545+ if (alerting) {
546+ if (launcher.state !== "visible") {
547+ fakeAlertingItemReveal.start();
548+ }
549+ } else {
550+ if (launcher.state !== "visible") {
551+ fakeAlertingItemHide.start();
552+ }
553+ }
558554 }
559555
560556 ParallelAnimation {
@@ -569,7 +565,7 @@ Rectangle {
569565 UbuntuNumberAnimation {
570566 target: fakeAlertingItem;
571567 properties: "x";
572− from: 0
568+ from: units.gu(.5)
573569 to: units.gu(1) + launcherListView.width * .5
574570 duration: UbuntuAnimation.BriskDuration
575571 }
@@ -582,15 +578,9 @@ Rectangle {
582578 target: fakeAlertingItem;
583579 properties: "x";
584580 from: units.gu(1) + launcherListView.width * .5
585− to: 0
581+ to: units.gu(.5)
586582 duration: UbuntuAnimation.BriskDuration
587583 }
588−
589− PropertyAction {
590− target: fakeAlertingItem
591− properties: "visible"
592− value: false
593− }
594584 }
595585 }
596586 }
tests/mocks/Unity/Launcher/MockLauncherItem.cpp+14
@@ -37,6 +37,7 @@ MockLauncherItem::MockLauncherItem(const QString &appId, const QString& desktopF
3737 m_count(0),
3838 m_countVisible(false),
3939 m_focused(false),
40+ m_alerting(false),
4041 m_quickList(new MockQuickListModel(this))
4142{
4243
@@ -159,6 +160,19 @@ void MockLauncherItem::setFocused(bool focused)
159160 }
160161}
161162
163+bool MockLauncherItem::alerting() const
164+{
165+ return m_alerting;
166+}
167+
168+void MockLauncherItem::setAlerting(bool alerting)
169+{
170+ if (m_alerting != alerting)
171+ {
172+ m_alerting = alerting;
173+ Q_EMIT alertingChanged(alerting);
174+ }
175+}
162176
163177unity::shell::launcher::QuickListModelInterface *MockLauncherItem::quickList() const
164178{
tests/mocks/Unity/Launcher/MockLauncherItem.h+3
@@ -44,6 +44,7 @@ public:
4444 int count() const override;
4545 bool countVisible() const override;
4646 bool focused() const;
47+ bool alerting() const;
4748
4849 unity::shell::launcher::QuickListModelInterface *quickList() const;
4950
@@ -55,6 +56,7 @@ private:
5556 void setCount(int count);
5657 void setCountVisible(bool countVisible);
5758 void setFocused(bool focused);
59+ void setAlerting(bool alerting);
5860
5961 QString m_appId;
6062 QString m_desktopFile;
@@ -67,6 +69,7 @@ private:
6769 int m_count;
6870 bool m_countVisible;
6971 bool m_focused;
72+ bool m_alerting;
7073 MockQuickListModel *m_quickList;
7174
7275 friend class MockLauncherModel;