on xenial help sign in
re-merge again on top of use-set-progress-api to fix failing QML tests
commit708d8347f989c7abf42851740b08269d7a04422f authorLukáš Tinkl <lukas.tinkl@canonical.com> dateWed 29 Jul 2015, 14:32 (11 years ago) parentef55e4dfaf26a9
5 files changed+27−23
plugins/Unity/Launcher/dbusinterface.cpp+5−1 plugins/Unity/Launcher/launchermodel.cpp+1−2 plugins/Unity/Launcher/launchermodel.h+1−1 qml/Launcher/LauncherPanel.qml+19−18 tests/mocks/Unity/Launcher/MockLauncherModel.cpp+1−1
plugins/Unity/Launcher/dbusinterface.cpp+5−1
@@ -159,7 +159,11 @@ bool DBusInterface::handleMessage(const QDBusMessage& message, const QDBusConnec
159159 return false;
160160 }
161161
162− if (message.member() != "GetAll" && message.arguments()[0].toString() != "com.canonical.Unity.Launcher.Item") {
162+ if (message.member() == "Get" && (message.arguments().count() != 2 || message.arguments()[0].toString() != "com.canonical.Unity.Launcher.Item")) {
163+ return false;
164+ }
165+
166+ if (message.member() == "Set" && (message.arguments().count() != 3 || message.arguments()[0].toString() != "com.canonical.Unity.Launcher.Item")) {
163167 return false;
164168 }
165169
plugins/Unity/Launcher/launchermodel.cpp+1−2
@@ -366,7 +366,7 @@ void LauncherModel::countChanged(const QString &appId, int count)
366366 }
367367}
368368
369−void LauncherModel::countVisibleChanged(const QString &appId, int countVisible)
369+void LauncherModel::countVisibleChanged(const QString &appId, bool countVisible)
370370{
371371 int idx = findApplication(appId);
372372 if (idx >= 0) {
@@ -394,7 +394,6 @@ void LauncherModel::countVisibleChanged(const QString &appId, int countVisible)
394394 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
395395 m_list.append(item);
396396 endInsertRows();
397− Q_EMIT hint();
398397 }
399398 }
400399 m_asAdapter->syncItems(m_list);
plugins/Unity/Launcher/launchermodel.h+1−1
@@ -73,7 +73,7 @@ private:
7373
7474private Q_SLOTS:
7575 void countChanged(const QString &appId, int count);
76− void countVisibleChanged(const QString &appId, int count);
76+ void countVisibleChanged(const QString &appId, bool count);
7777 void progressChanged(const QString &appId, int progress);
7878
7979 void applicationAdded(const QModelIndex &parent, int row);
qml/Launcher/LauncherPanel.qml+19−18
@@ -119,12 +119,6 @@ Rectangle {
119119 // need to be smaller than this size to avoid breakage.
120120 property int extensionSize: 0
121121
122− // These properties are needed to facilitate implicitly unfolding the
123− // launcher to the peeking icon, if it is not already fully flat
124− // and in view for the user
125− property real moveToIndexYFrom
126− property real moveToIndexYTo
127−
128122 // Setting extensionSize after the list has been populated because it has
129123 // the potential to mess up with the intial positioning in combination
130124 // with snapping to the center of the list. This catches all the cases
@@ -138,14 +132,6 @@ Rectangle {
138132 flick(0, clickFlickSpeed)
139133 }
140134
141− UbuntuNumberAnimation {
142− id: moveToIndexAnimation
143− target: launcherListView
144− property: "contentY"
145− from: launcherListView.moveToIndexYFrom
146− to: launcherListView.moveToIndexYTo
147− }
148−
149135 // The height of the area where icons start getting folded
150136 property int foldingStartHeight: units.gu(6.5)
151137 // The height of the area where the items reach the final folding angle
@@ -177,6 +163,17 @@ Rectangle {
177163 to: launcherListView.contentHeight - launcherListView.height + launcherListView.originY - launcherListView.topMargin
178164 }
179165
166+ UbuntuNumberAnimation {
167+ id: moveAnimation
168+ target: launcherListView
169+ property: "contentY"
170+ function moveTo(contentY) {
171+ from = launcherListView.contentY;
172+ to = contentY;
173+ start();
174+ }
175+ }
176+
180177 displaced: Transition {
181178 NumberAnimation { properties: "x,y"; duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
182179 }
@@ -236,10 +233,14 @@ Rectangle {
236233 onAlertingChanged: {
237234 if(alerting) {
238235 if (!dragging && (launcherListView.peekingIndex === -1 || launcher.visibleWidth > 0)) {
239− launcherListView.moveToIndexYFrom = launcherListView.contentY
240− launcherListView.positionViewAtIndex(index, ListView.Center)
241− launcherListView.moveToIndexYTo = launcherListView.contentY
242− moveToIndexAnimation.start()
236+ var itemPosition = index * launcherListView.itemHeight;
237+ var height = launcherListView.height - launcherListView.topMargin - launcherListView.bottomMargin
238+ var distanceToEnd = index == 0 || index == launcherListView.count - 1 ? 0 : launcherListView.itemHeight
239+ if (itemPosition + launcherListView.itemHeight + distanceToEnd > launcherListView.contentY + launcherListView.topMargin + height) {
240+ moveAnimation.moveTo(itemPosition + launcherListView.itemHeight - launcherListView.topMargin - height + distanceToEnd);
241+ } else if (itemPosition - distanceToEnd < launcherListView.contentY + launcherListView.topMargin) {
242+ moveAnimation.moveTo(itemPosition - distanceToEnd - launcherListView.topMargin);
243+ }
243244 if (!dragging && launcher.state !== "visible") {
244245 peekingAnimation.start()
245246 }
tests/mocks/Unity/Launcher/MockLauncherModel.cpp+1−1
@@ -265,7 +265,7 @@ void MockLauncherModel::setCount(const QString &appId, int count)
265265 if (index >= 0) {
266266 m_list.at(index)->setCount(count);
267267 QModelIndex modelIndex = this->index(index);
268− Q_EMIT dataChanged(modelIndex, modelIndex, QVector<int>() << RoleCount);
268+ Q_EMIT dataChanged(modelIndex, modelIndex);
269269 }
270270}
271271