From eed0736eb1eb3519ddd217f5a76562a912d7ddc5 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 22 May 2012 11:23:35 +0200 Subject: [PATCH] better decision on when turn the page --- active/app/package/contents/ui/Browser.qml | 11 ++++++++++- active/app/package/contents/ui/FullScreenDelegate.qml | 6 ++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/active/app/package/contents/ui/Browser.qml b/active/app/package/contents/ui/Browser.qml index 46435a636..ebfa961a0 100644 --- a/active/app/package/contents/ui/Browser.qml +++ b/active/app/package/contents/ui/Browser.qml @@ -66,7 +66,13 @@ PlasmaComponents.Page { startX = mouse.screenX startY = mouse.screenY } + onPositionChanged: { + if (Math.abs(mouse.x - startX) > width/5) { + delegate.pageSwitchEnabled = true + } + } onReleased: { + delegate.pageSwitchEnabled = false if (Math.abs(mouse.screenX - startX) < 20 && Math.abs(mouse.screenY - startY) < 20) { if (resourceBrowser.state == "toolsOpen") { @@ -74,7 +80,10 @@ PlasmaComponents.Page { } else { resourceBrowser.state = "toolsOpen" } - } else if (oldDelegate.visible && delegate.delta != 0 && delegate.doSwitch) { + } else if (oldDelegate.visible && delegate.delta != 0 && + delegate.doSwitch && + ((incrementing && mouse.x <= width/5) || + !incrementing && mouse.x >= (width/5)*4)) { oldDelegate = delegate delegate = (delegate == delegate1) ? delegate2 : delegate1 switchAnimation.running = true diff --git a/active/app/package/contents/ui/FullScreenDelegate.qml b/active/app/package/contents/ui/FullScreenDelegate.qml index cd88b40ee..26a51d9b5 100644 --- a/active/app/package/contents/ui/FullScreenDelegate.qml +++ b/active/app/package/contents/ui/FullScreenDelegate.qml @@ -33,8 +33,10 @@ Item { //if true when released will switch the delegate property bool doSwitch: false + property bool pageSwitchEnabled: false property alias document: mainPage.document property alias pageNumber: mainPage.pageNumber + property string label: model["label"] function scale(zoom) @@ -86,7 +88,7 @@ Item { onContentXChanged: { if (atXBeginning && contentX < 0) { root.delta = -1 - root.doSwitch = (contentX < -mainFlickable.width/4) + root.doSwitch = (contentX < -mainFlickable.width/6) } else if (atXEnd) { root.delta = +1 root.doSwitch = (contentX + mainFlickable.width - contentWidth > mainFlickable.width/4) @@ -98,7 +100,7 @@ Item { PinchArea { id: imageMargin - width: Math.max(mainFlickable.width+1, mainPage.width) + width: Math.max(mainFlickable.width + (pageSwitchEnabled ? 1: 0), mainPage.width) height: Math.max(mainFlickable.height, mainPage.height) property real startWidth