on xenial help sign in
some fixes, tests
commitd2db6b038f7b415f01b55018524ec7fa744ea8a5 authorMichael Zanetti <michael.zanetti@canonical.com> dateMon 28 Nov 2016, 14:27 (10 years ago) parent6824477
3 files changed+27−22
plugins/Utils/appdrawerproxymodel.cpp−3 qml/Launcher/Launcher.qml+14−18 tests/qmltests/Launcher/tst_Drawer.qml+13−1
plugins/Utils/appdrawerproxymodel.cpp−3
@@ -172,12 +172,10 @@ bool AppDrawerProxyModel::filterAcceptsRow(int source_row, const QModelIndex &so
172172
173173QString AppDrawerProxyModel::appId(int index) const
174174{
175− qDebug() << "get called:" << index << this << m_source->staticMetaObject.className() << m_source;
176175 if (index >= 0 && index < rowCount()) {
177176 QModelIndex sourceIndex = mapToSource(this->index(index, 0));
178177
179178 AppDrawerModelInterface* adm = dynamic_cast<AppDrawerModelInterface*>(m_source);
180− qDebug() << "tried casting to ADMI:" << adm;
181179 if (adm) {
182180 return adm->data(sourceIndex, AppDrawerModelInterface::RoleAppId).toString();
183181 }
@@ -187,6 +185,5 @@ QString AppDrawerProxyModel::appId(int index) const
187185 return adpm->appId(sourceIndex.row());
188186 }
189187 }
190− qDebug() << "could nto cast source model";
191188 return nullptr;
192189}
qml/Launcher/Launcher.qml+14−18
@@ -347,12 +347,20 @@ FocusScope {
347347 top: parent.top
348348 topMargin: root.inverted ? root.topPanelHeight : 0
349349 bottom: parent.bottom
350+ right: parent.left
350351 }
351352 width: Math.min(root.width, units.gu(90)) * .9
352− x: -width
353353 panelWidth: panel.width
354354 visible: x > -width
355355
356+ Behavior on anchors.rightMargin {
357+ enabled: !dragArea.dragging && !launcherDragArea.drag.active && panel.animate && !drawer.draggingHorizontally
358+ NumberAnimation {
359+ duration: 300
360+ easing.type: Easing.OutCubic
361+ }
362+ }
363+
356364 onApplicationSelected: {
357365 root.hide();
358366 root.launcherApplicationSelected(appId)
@@ -365,7 +373,7 @@ FocusScope {
365373 }
366374
367375 onDragDistanceChanged: {
368− x = Math.min(0, x-dragDistance);
376+ anchors.rightMargin = Math.max(-drawer.width, anchors.rightMargin + dragDistance);
369377 }
370378 onDraggingHorizontallyChanged: {
371379 if (!draggingHorizontally) {
@@ -496,12 +504,12 @@ FocusScope {
496504 if (root.drawerEnabled && dragging && launcher.state != "drawer") {
497505 var drawerHintDistance = panel.width + units.gu(1)
498506 if (distance < drawerHintDistance) {
499− drawer.x = -drawer.width + Math.min(Math.max(0, distance), drawer.width);
507+ drawer.anchors.rightMargin = -Math.min(Math.max(0, distance), drawer.width);
500508 } else {
501509 var linearDrawerX = Math.min(Math.max(0, distance - drawerHintDistance), drawer.width);
502510 var linearDrawerProgress = linearDrawerX / (drawer.width)
503511 var easedDrawerProgress = easeInOutCubic(linearDrawerProgress);
504− drawer.x = (-drawer.width + drawerHintDistance) + easedDrawerProgress * (drawer.width - drawerHintDistance);
512+ drawer.anchors.rightMargin = -(drawerHintDistance + easedDrawerProgress * (drawer.width - drawerHintDistance));
505513 }
506514 }
507515 }
@@ -532,7 +540,7 @@ FocusScope {
532540 }
533541 PropertyChanges {
534542 target: drawer
535− x: -drawer.width
543+ anchors.rightMargin: 0
536544 }
537545 },
538546 State {
@@ -541,17 +549,13 @@ FocusScope {
541549 target: panel
542550 x: -root.x // so we never go past panelWidth, even when teased by tutorial
543551 }
544− PropertyChanges {
545− target: drawer
546− x: -drawer.width
547− }
548552 },
549553 State {
550554 name: "drawer"
551555 extend: "visible"
552556 PropertyChanges {
553557 target: drawer
554− x: -root.x // so we never go past panelWidth, even when teased by tutorial
558+ anchors.rightMargin: -drawer.width + root.x // so we never go past panelWidth, even when teased by tutorial
555559 }
556560 },
557561 State {
@@ -579,12 +583,4 @@ FocusScope {
579583 }
580584 }
581585 ]
582− transitions: [
583− Transition {
584− from: "*"
585− to: "*"
586− UbuntuNumberAnimation { target: panel; property: "x"; easing: Easing.OutQuad; duration: UbuntuAnimation.SnapDuration }
587− UbuntuNumberAnimation { target: drawer; property: "x"; easing: Easing.OutQuad; duration: UbuntuAnimation.SnapDuration }
588− }
589− ]
590586}
tests/qmltests/Launcher/tst_Drawer.qml+13−1
@@ -89,6 +89,7 @@ StyledItem {
8989 UnityTestCase {
9090 id: testCase
9191 when: windowShown
92+ name: "Drawer"
9293
9394 function dragDrawerIntoView() {
9495 var startX = launcher.dragAreaWidth/2;
@@ -159,10 +160,11 @@ StyledItem {
159160
160161 function test_hideByDraggingDrawer() {
161162 dragDrawerIntoView();
163+ waitForRendering(launcher);
162164
163165 var drawer = findChild(launcher, "drawer");
164166
165− mouseFlick(drawer, drawer.width - units.gu(1), drawer.height / 2, drawer.width - units.gu(12), drawer.height / 2);
167+ mouseFlick(root, drawer.width - units.gu(1), drawer.height / 2, 0, drawer.height / 2, true, true);
166168
167169 tryCompare(launcher, "state", "");
168170 }
@@ -218,5 +220,15 @@ StyledItem {
218220
219221 launcher.drawerEnabled = true;
220222 }
223+
224+ function test_search() {
225+ compare(launcher.lastSelectedApplication, "");
226+
227+ launcher.openDrawer(true)
228+ typeString("cam");
229+ keyClick(Qt.Key_Enter);
230+
231+ compare(launcher.lastSelectedApplication, "camera-app");
232+ }
221233 }
222234}