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.
9b49c7fMirco Müller
plugins/Greeter/Unity/Launcher/launcheritem.cpp+14
@@ -31,6 +31,7 @@ LauncherItem::LauncherItem(const QString &appId, const QString &name, const QStr
31 m_count(0),
31 m_count(0),
32 m_countVisible(false),
32 m_countVisible(false),
33 m_focused(false),
33 m_focused(false),
34+ m_alerting(false),
34 m_quickList(new QuickListModel(this))
35 m_quickList(new QuickListModel(this))
35{
36{
36 QuickListEntry nameAction;
37 QuickListEntry nameAction;
@@ -165,6 +166,19 @@ void LauncherItem::setFocused(bool focused)
165 }
166 }
166}
167}
167
168
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+
168unity::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
182unity::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
169{
183{
170 return m_quickList;
184 return m_quickList;
plugins/Greeter/Unity/Launcher/launcheritem.h+4
@@ -41,6 +41,7 @@ public:
41 int count() const override;
41 int count() const override;
42 bool countVisible() const override;
42 bool countVisible() const override;
43 bool focused() const override;
43 bool focused() const override;
44+ bool alerting() const override;
44
45
45 unity::shell::launcher::QuickListModelInterface *quickList() const override;
46 unity::shell::launcher::QuickListModelInterface *quickList() const override;
46
47
@@ -54,6 +55,8 @@ private:
54 void setCount(int count);
55 void setCount(int count);
55 void setCountVisible(bool countVisible);
56 void setCountVisible(bool countVisible);
56 void setFocused(bool focused);
57 void setFocused(bool focused);
58+ void setAlerting(bool alerting);
59+
57
60
58private:
61private:
59 QString m_appId;
62 QString m_appId;
@@ -66,6 +69,7 @@ private:
66 int m_count;
69 int m_count;
67 bool m_countVisible;
70 bool m_countVisible;
68 bool m_focused;
71 bool m_focused;
72+ bool m_alerting;
69 QuickListModel *m_quickList;
73 QuickListModel *m_quickList;
70
74
71 friend class LauncherModel;
75 friend class LauncherModel;
plugins/Unity/Launcher/launcheritem.cpp+17
@@ -34,6 +34,7 @@ LauncherItem::LauncherItem(const QString &appId, const QString &name, const QStr
34 m_count(0),
34 m_count(0),
35 m_countVisible(false),
35 m_countVisible(false),
36 m_focused(false),
36 m_focused(false),
37+ m_alerting(false),
37 m_quickList(new QuickListModel(this))
38 m_quickList(new QuickListModel(this))
38{
39{
39 QuickListEntry nameAction;
40 QuickListEntry nameAction;
@@ -175,10 +176,26 @@ void LauncherItem::setFocused(bool focused)
175{
176{
176 if (m_focused != focused) {
177 if (m_focused != focused) {
177 m_focused = focused;
178 m_focused = focused;
179+ if (!focused) {
180+ setAlerting(false);
181+ }
178 Q_EMIT focusedChanged(focused);
182 Q_EMIT focusedChanged(focused);
179 }
183 }
180}
184}
181
185
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+
182unity::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
199unity::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
183{
200{
184 return m_quickList;
201 return m_quickList;
plugins/Unity/Launcher/launcheritem.h+3
@@ -44,6 +44,7 @@ public:
44 int count() const override;
44 int count() const override;
45 bool countVisible() const override;
45 bool countVisible() const override;
46 bool focused() const override;
46 bool focused() const override;
47+ bool alerting() const override;
47
48
48 unity::shell::launcher::QuickListModelInterface *quickList() const override;
49 unity::shell::launcher::QuickListModelInterface *quickList() const override;
49
50
@@ -57,6 +58,7 @@ private:
57 void setCount(int count);
58 void setCount(int count);
58 void setCountVisible(bool countVisible);
59 void setCountVisible(bool countVisible);
59 void setFocused(bool focused);
60 void setFocused(bool focused);
61+ void setAlerting(bool alerting);
60
62
61private:
63private:
62 QString m_appId;
64 QString m_appId;
@@ -69,6 +71,7 @@ private:
69 int m_count;
71 int m_count;
70 bool m_countVisible;
72 bool m_countVisible;
71 bool m_focused;
73 bool m_focused;
74+ bool m_alerting;
72 QuickListModel *m_quickList;
75 QuickListModel *m_quickList;
73
76
74 friend class LauncherModel;
77 friend class LauncherModel;
plugins/Unity/Launcher/launchermodel.cpp+5−5
@@ -44,8 +44,6 @@ LauncherModel::LauncherModel(QObject *parent):
44
44
45 connect(m_settings, &GSettings::changed, this, &LauncherModel::refresh);
45 connect(m_settings, &GSettings::changed, this, &LauncherModel::refresh);
46
46
47− m_alertIndex = -1;
48−
49 refresh();
47 refresh();
50}
48}
51
49
@@ -84,16 +82,18 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
84 return item->progress();
82 return item->progress();
85 case RoleFocused:
83 case RoleFocused:
86 return item->focused();
84 return item->focused();
85+ case RoleAlerting:
86+ return item->alerting();
87 }
87 }
88
88
89 return QVariant();
89 return QVariant();
90}
90}
91
91
92−void LauncherModel::alert(const QString &appId) const {
92+void LauncherModel::alert(const QString &appId) {
93 int index = findApplication(appId);
93 int index = findApplication(appId);
94 if (index >= 0) {
94 if (index >= 0) {
95− m_alertIndex = index;
95+ LauncherItem *item = m_list.at(index);
96− Q_EMIT alerting(m_alertIndex);
96+ item->setAlerting(true);
97 }
97 }
98}
98}
99
99
plugins/Unity/Launcher/launchermodel.h+1−3
@@ -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) const;
48+ Q_INVOKABLE void alert(const QString &appId);
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);
@@ -86,8 +86,6 @@ private:
86 DBusInterface *m_dbusIface;
86 DBusInterface *m_dbusIface;
87 ASAdapter *m_asAdapter;
87 ASAdapter *m_asAdapter;
88
88
89− int m_alertIndex;
90−
91 ApplicationManagerInterface *m_appManager;
89 ApplicationManagerInterface *m_appManager;
92
90
93 friend class LauncherModelTest;
91 friend class LauncherModelTest;
qml/Launcher/LauncherPanel.qml+19−29
@@ -43,6 +43,10 @@ Rectangle {
43 if (quickList.state == "open") {
43 if (quickList.state == "open") {
44 quickList.state = ""
44 quickList.state = ""
45 }
45 }
46+
47+ if (fakeAlertingItem.visible && fakeAlertingItem.x > units.gu(.5)) {
48+ fakeAlertingItem.x = 72 - parent.visibleWidth
49+ }
46 }
50 }
47
51
48 onAlertIndexChanged: {
52 onAlertIndexChanged: {
@@ -53,27 +57,14 @@ Rectangle {
53 fakeAlertingItem.index = alertIndex
57 fakeAlertingItem.index = alertIndex
54 fakeAlertingItem.iconName = launcherListView.model.get(alertIndex).icon
58 fakeAlertingItem.iconName = launcherListView.model.get(alertIndex).icon
55 fakeAlertingItem.y = alertIndex * fakeAlertingItem.itemHeight + launcherListView.anchors.topMargin + launcherListView.topMargin
59 fakeAlertingItem.y = alertIndex * fakeAlertingItem.itemHeight + launcherListView.anchors.topMargin + launcherListView.topMargin
56− fakeAlertingItem.count = LauncherModel.get(alertIndex).count
60+ fakeAlertingItem.progress = launcherListView.model.get(alertIndex).progress
57− fakeAlertingItem.progress = LauncherModel.get(alertIndex).progress
58 fakeAlertingItem.alerting = true
61 fakeAlertingItem.alerting = true
59 fakeAlertingItem.visible = true
62 fakeAlertingItem.visible = true
60− if (launcher.state !== "visible") {
61− fakeAlertingItem.reveal()
62− }
63− print("y = ", fakeAlertingItem.y)
64− print("index = ", fakeAlertingItem.index)
65 } else {
63 } else {
66− // set real icon back to visible
67−
68 // fold
64 // fold
69
65
70 // hide fake-alerting-icon
66 // hide fake-alerting-icon
71 fakeAlertingItem.alerting = false
67 fakeAlertingItem.alerting = false
72−
73− if (launcher.state !== "visible") {
74− fakeAlertingItem.hide()
75− }
76− //fakeAlertingItem.visible = false
77 }
68 }
78 }
69 }
79
70
@@ -216,6 +207,7 @@ Rectangle {
216 z: -Math.abs(offset)
207 z: -Math.abs(offset)
217 maxAngle: 55
208 maxAngle: 55
218 property bool dragging: false
209 property bool dragging: false
210+ itemOpacity: index === alertIndex ? 0 : 1
219
211
220 ThinDivider {
212 ThinDivider {
221 id: dropIndicator
213 id: dropIndicator
@@ -546,15 +538,19 @@ Rectangle {
546 itemHeight: launcherListView.itemHeight
538 itemHeight: launcherListView.itemHeight
547 height: itemHeight
539 height: itemHeight
548 width: itemWidth
540 width: itemWidth
549− rotation: root.rotation
541+ rotation: root.rotation1G
550 alerting: false
542 alerting: false
551
543
552− function reveal() {
544+ onAlertingChanged: {
545+ if (alerting) {
546+ if (launcher.state !== "visible") {
553− fakeAlertingItemReveal.start();
547+ fakeAlertingItemReveal.start();
554− }
548+ }
555−
549+ } else {
556− function hide() {
550+ if (launcher.state !== "visible") {
557− fakeAlertingItemHide.start();
551+ fakeAlertingItemHide.start();
552+ }
553+ }
558 }
554 }
559
555
560 ParallelAnimation {
556 ParallelAnimation {
@@ -569,7 +565,7 @@ Rectangle {
569 UbuntuNumberAnimation {
565 UbuntuNumberAnimation {
570 target: fakeAlertingItem;
566 target: fakeAlertingItem;
571 properties: "x";
567 properties: "x";
572− from: 0
568+ from: units.gu(.5)
573 to: units.gu(1) + launcherListView.width * .5
569 to: units.gu(1) + launcherListView.width * .5
574 duration: UbuntuAnimation.BriskDuration
570 duration: UbuntuAnimation.BriskDuration
575 }
571 }
@@ -582,15 +578,9 @@ Rectangle {
582 target: fakeAlertingItem;
578 target: fakeAlertingItem;
583 properties: "x";
579 properties: "x";
584 from: units.gu(1) + launcherListView.width * .5
580 from: units.gu(1) + launcherListView.width * .5
585− to: 0
581+ to: units.gu(.5)
586 duration: UbuntuAnimation.BriskDuration
582 duration: UbuntuAnimation.BriskDuration
587 }
583 }
588−
589− PropertyAction {
590− target: fakeAlertingItem
591− properties: "visible"
592− value: false
593− }
594 }
584 }
595 }
585 }
596 }
586 }
tests/mocks/Unity/Launcher/MockLauncherItem.cpp+14
@@ -37,6 +37,7 @@ MockLauncherItem::MockLauncherItem(const QString &appId, const QString& desktopF
37 m_count(0),
37 m_count(0),
38 m_countVisible(false),
38 m_countVisible(false),
39 m_focused(false),
39 m_focused(false),
40+ m_alerting(false),
40 m_quickList(new MockQuickListModel(this))
41 m_quickList(new MockQuickListModel(this))
41{
42{
42
43
@@ -159,6 +160,19 @@ void MockLauncherItem::setFocused(bool focused)
159 }
160 }
160}
161}
161
162
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+}
162
176
163unity::shell::launcher::QuickListModelInterface *MockLauncherItem::quickList() const
177unity::shell::launcher::QuickListModelInterface *MockLauncherItem::quickList() const
164{
178{
tests/mocks/Unity/Launcher/MockLauncherItem.h+3
@@ -44,6 +44,7 @@ public:
44 int count() const override;
44 int count() const override;
45 bool countVisible() const override;
45 bool countVisible() const override;
46 bool focused() const;
46 bool focused() const;
47+ bool alerting() const;
47
48
48 unity::shell::launcher::QuickListModelInterface *quickList() const;
49 unity::shell::launcher::QuickListModelInterface *quickList() const;
49
50
@@ -55,6 +56,7 @@ private:
55 void setCount(int count);
56 void setCount(int count);
56 void setCountVisible(bool countVisible);
57 void setCountVisible(bool countVisible);
57 void setFocused(bool focused);
58 void setFocused(bool focused);
59+ void setAlerting(bool alerting);
58
60
59 QString m_appId;
61 QString m_appId;
60 QString m_desktopFile;
62 QString m_desktopFile;
@@ -67,6 +69,7 @@ private:
67 int m_count;
69 int m_count;
68 bool m_countVisible;
70 bool m_countVisible;
69 bool m_focused;
71 bool m_focused;
72+ bool m_alerting;
70 MockQuickListModel *m_quickList;
73 MockQuickListModel *m_quickList;
71
74
72 friend class MockLauncherModel;
75 friend class MockLauncherModel;