on xenial help sign in
First go at slide-out animation for alerting/wobble of a launcher-icon.
commit68bf3b58ff7512358f16d84689b44382adffec86 authorMirco Müller <mirco.mueller@canonical.com> dateFri 22 May 2015, 09:58 (11 years ago) parentb5cf100
5 files changed+135−1
plugins/Unity/Launcher/launchermodel.cpp+10 plugins/Unity/Launcher/launchermodel.h+3 qml/Launcher/LauncherDelegate.qml+2−1 qml/Launcher/LauncherPanel.qml+92 tests/qmltests/Launcher/tst_Launcher.qml+28
plugins/Unity/Launcher/launchermodel.cpp+10
@@ -44,6 +44,8 @@ LauncherModel::LauncherModel(QObject *parent):
4444
4545 connect(m_settings, &GSettings::changed, this, &LauncherModel::refresh);
4646
47+ m_alertIndex = -1;
48+
4749 refresh();
4850}
4951
@@ -87,6 +89,14 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
8789 return QVariant();
8890}
8991
92+void LauncherModel::alert(const QString &appId) const {
93+ int index = findApplication(appId);
94+ if (index >= 0) {
95+ m_alertIndex = index;
96+ Q_EMIT alerting(m_alertIndex);
97+ }
98+}
99+
90100unity::shell::launcher::LauncherItemInterface *LauncherModel::get(int index) const
91101{
92102 if (index < 0 || index >= m_list.count()) {
plugins/Unity/Launcher/launchermodel.h+3
@@ -45,6 +45,7 @@ public:
4545
4646 QVariant data(const QModelIndex &index, int role) const;
4747
48+ Q_INVOKABLE void alert(const QString &appId) const;
4849 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface* get(int index) const;
4950 Q_INVOKABLE void move(int oldIndex, int newIndex);
5051 Q_INVOKABLE void pin(const QString &appId, int index = -1);
@@ -85,6 +86,8 @@ private:
8586 DBusInterface *m_dbusIface;
8687 ASAdapter *m_asAdapter;
8788
89+ int m_alertIndex;
90+
8891 ApplicationManagerInterface *m_appManager;
8992
9093 friend class LauncherModelTest;
qml/Launcher/LauncherDelegate.qml+2−1
@@ -27,6 +27,7 @@ Item {
2727 property bool itemFocused: false
2828 property real maxAngle: 0
2929 property bool inverted: false
30+ property bool alerting: false
3031
3132 readonly property int effectiveHeight: Math.cos(angle * Math.PI / 180) * itemHeight
3233 readonly property real foldedHeight: Math.cos(maxAngle * Math.PI / 180) * itemHeight
@@ -46,7 +47,7 @@ Item {
4647 readonly property double angle: 5.0
4748 readonly property int duration: UbuntuAnimation.SnapDuration
4849
49− running: false
50+ running: alerting
5051 loops: Animation.Infinite
5152
5253 NumberAnimation {
qml/Launcher/LauncherPanel.qml+92
@@ -34,6 +34,7 @@ Rectangle {
3434 property bool moving: launcherListView.moving || launcherListView.flicking
3535 property bool preventHiding: moving || dndArea.draggedIndex >= 0 || quickList.state === "open" || dndArea.pressed
3636 property int highlightIndex: -1
37+ property int alertIndex: -1
3738
3839 signal applicationSelected(string appId)
3940 signal showDashHome()
@@ -44,6 +45,38 @@ Rectangle {
4445 }
4546 }
4647
48+ onAlertIndexChanged: {
49+ if (alertIndex !== -1) {
50+ //unfold
51+
52+ panel.visible = true
53+ fakeAlertingItem.index = alertIndex
54+ fakeAlertingItem.iconName = launcherListView.model.get(alertIndex).icon
55+ fakeAlertingItem.y = alertIndex * fakeAlertingItem.itemHeight + launcherListView.anchors.topMargin + launcherListView.topMargin
56+ fakeAlertingItem.count = LauncherModel.get(alertIndex).count
57+ fakeAlertingItem.progress = LauncherModel.get(alertIndex).progress
58+ fakeAlertingItem.alerting = true
59+ fakeAlertingItem.visible = true
60+ if (launcher.state !== "visible") {
61+ fakeAlertingItem.reveal()
62+ }
63+ print("y = ", fakeAlertingItem.y)
64+ print("index = ", fakeAlertingItem.index)
65+ } else {
66+ // set real icon back to visible
67+
68+ // fold
69+
70+ // hide fake-alerting-icon
71+ fakeAlertingItem.alerting = false
72+
73+ if (launcher.state !== "visible") {
74+ fakeAlertingItem.hide()
75+ }
76+ //fakeAlertingItem.visible = false
77+ }
78+ }
79+
4780 Column {
4881 id: mainColumn
4982 anchors {
@@ -501,6 +534,65 @@ Rectangle {
501534 to: 0
502535 }
503536 }
537+
538+ LauncherDelegate {
539+ id: fakeAlertingItem
540+
541+ property int index
542+
543+ objectName: "fakeAlertingItem"
544+ visible: false
545+ itemWidth: launcherListView.itemWidth
546+ itemHeight: launcherListView.itemHeight
547+ height: itemHeight
548+ width: itemWidth
549+ rotation: root.rotation
550+ alerting: false
551+
552+ function reveal() {
553+ fakeAlertingItemReveal.start();
554+ }
555+
556+ function hide() {
557+ fakeAlertingItemHide.start();
558+ }
559+
560+ ParallelAnimation {
561+ id: fakeAlertingItemReveal
562+
563+ UbuntuNumberAnimation {
564+ target: fakeAlertingItem;
565+ properties: "angle, offset";
566+ to: 0
567+ }
568+
569+ UbuntuNumberAnimation {
570+ target: fakeAlertingItem;
571+ properties: "x";
572+ from: 0
573+ to: units.gu(1) + launcherListView.width * .5
574+ duration: UbuntuAnimation.BriskDuration
575+ }
576+ }
577+
578+ SequentialAnimation {
579+ id: fakeAlertingItemHide
580+
581+ UbuntuNumberAnimation {
582+ target: fakeAlertingItem;
583+ properties: "x";
584+ from: units.gu(1) + launcherListView.width * .5
585+ to: 0
586+ duration: UbuntuAnimation.BriskDuration
587+ }
588+
589+ PropertyAction {
590+ target: fakeAlertingItem
591+ properties: "visible"
592+ value: false
593+ }
594+ }
595+ }
504596 }
505597 }
506598
tests/qmltests/Launcher/tst_Launcher.qml+28
@@ -93,6 +93,34 @@ Item {
9393 onClicked: launcherLoader.item.inverted = !launcherLoader.item.inverted
9494 Layout.fillWidth: true
9595 }
96+
97+ Row {
98+ spacing: units.gu(1)
99+
100+ CheckBox {
101+ anchors.verticalCenter: parent.verticalCenter
102+ checked: false
103+ onClicked: {
104+ var panel = testCase.findChild(launcherLoader, "launcherPanel")
105+ panel.alertIndex = checked ? parseInt(iconIndex.displayText) : -1
106+ }
107+ }
108+
109+ Label {
110+ anchors.verticalCenter: parent.verticalCenter
111+ text: "wiggle of icon"
112+ }
113+
114+ TextArea {
115+ id: iconIndex
116+ anchors.verticalCenter: parent.verticalCenter
117+ width: units.gu(4)
118+ height: units.gu(4)
119+ autoSize: true
120+ text: "2"
121+ maximumLineCount: 1
122+ }
123+ }
96124 }
97125
98126 SignalSpy {