diff options
author | Lasse Räihä <lasse.raiha@digia.com> | 2013-05-27 10:01:48 +0300 |
---|---|---|
committer | Kimmo Ollila <kimmo.ollila@digia.com> | 2013-05-27 10:03:42 +0300 |
commit | 98e13651a6109a64fb9d63984c3396359d9feab7 (patch) | |
tree | 8fd216d5a2a68e6fe62b755ca9b164e45e642bd1 | |
parent | eadf3f9c43bd89358695da72db5e66c96a9d8f39 (diff) |
Fixed freezing when changing orientation.
Change-Id: I0242db32654938d9b583cfd6151f08a1ed741a52
Reviewed-by: Kimmo Ollila <kimmo.ollila@digia.com>
-rw-r--r-- | QtDemo/qml/QtDemo/Button.qml | 2 | ||||
-rw-r--r-- | QtDemo/qml/QtDemo/NavigationPanel.qml | 30 | ||||
-rw-r--r-- | QtDemo/qml/QtDemo/WorldCanvas.qml | 10 | ||||
-rw-r--r-- | QtDemo/qml/QtDemo/WorldMouseArea.qml | 2 | ||||
-rw-r--r-- | QtDemo/qml/QtDemo/main.qml | 20 |
5 files changed, 37 insertions, 27 deletions
diff --git a/QtDemo/qml/QtDemo/Button.qml b/QtDemo/qml/QtDemo/Button.qml index 991db78..d62dd28 100644 --- a/QtDemo/qml/QtDemo/Button.qml +++ b/QtDemo/qml/QtDemo/Button.qml @@ -2,7 +2,7 @@ import QtQuick 2.0 Rectangle { id: root - width: Math.min(app.height, app.width) * 0.10 + width: (app.height + app.width) * 0.04 height: width color: "transparent" diff --git a/QtDemo/qml/QtDemo/NavigationPanel.qml b/QtDemo/qml/QtDemo/NavigationPanel.qml index 8ac6694..901f0cc 100644 --- a/QtDemo/qml/QtDemo/NavigationPanel.qml +++ b/QtDemo/qml/QtDemo/NavigationPanel.qml @@ -1,12 +1,29 @@ import QtQuick 2.0 -Column{ +Grid { + id: root - function rotateButtons(angle) - { - prevButton.rotation = angle - nextButton.rotation = angle - homeButton.rotation = angle + function checkOrientation() { + root.spacing = (app.height + app.width) * 0.02 + + if (app.width >= app.height) { + root.columns = 1 + root.anchors.bottom = undefined + root.anchors.horizontalCenter = undefined + root.anchors.right = app.right + root.anchors.verticalCenter = app.verticalCenter + root.anchors.rightMargin = app.width * 0.02 + root.anchors.bottomMargin = 0 + } + else { + root.columns = 3 + root.anchors.right = undefined + root.anchors.verticalCenter = undefined + root.anchors.bottom = app.bottom + root.anchors.horizontalCenter = app.horizontalCenter + root.anchors.rightMargin = 0 + root.anchors.bottomMargin = app.width * 0.02 + } } Button { @@ -26,5 +43,4 @@ Column{ imageSource: "images/btn_home.svg" onClicked: canvas.goHome() } - } diff --git a/QtDemo/qml/QtDemo/WorldCanvas.qml b/QtDemo/qml/QtDemo/WorldCanvas.qml index 69a0ba9..0edd09d 100644 --- a/QtDemo/qml/QtDemo/WorldCanvas.qml +++ b/QtDemo/qml/QtDemo/WorldCanvas.qml @@ -30,10 +30,9 @@ Item{ zoomInTarget = app.homeScaleFactor; app.navigationState = 0 //home app.forceActiveFocus() - navigationPanel.rotateButtons(0); zoomAnimation.restart(); } - function goTo(target) + function goTo(target, updateScalingFactor) { if (target) { @@ -44,17 +43,18 @@ Item{ rotationOriginY = target.y; angle = target.targetAngle; zoomInTarget = target.targetScale; + if (updateScalingFactor) + scalingFactor = zoomInTarget app.navigationState = 1 //slide - navigationPanel.rotateButtons(target.targetAngle); } } function goNext() { - goTo(app.getNext()); + goTo(app.getNext(), false); navigationAnimation.restart() } function goPrevious() { - goTo(app.getPrevious()); + goTo(app.getPrevious(), false); navigationAnimation.restart() } diff --git a/QtDemo/qml/QtDemo/WorldMouseArea.qml b/QtDemo/qml/QtDemo/WorldMouseArea.qml index f7873b7..1ad0072 100644 --- a/QtDemo/qml/QtDemo/WorldMouseArea.qml +++ b/QtDemo/qml/QtDemo/WorldMouseArea.qml @@ -27,7 +27,7 @@ MouseArea{ // If we found target, go to the target if (target) { - canvas.goTo(target) + canvas.goTo(target, false) zoomAnimation.restart() } else // If not target under mouse -> go home diff --git a/QtDemo/qml/QtDemo/main.qml b/QtDemo/qml/QtDemo/main.qml index f1286f4..afdfd21 100644 --- a/QtDemo/qml/QtDemo/main.qml +++ b/QtDemo/qml/QtDemo/main.qml @@ -6,7 +6,7 @@ Rectangle{ id: app clip: true focus: true - color: "white" + property real homeScaleFactor: .2 property int homeCenterX: 0 property int homeCenterY: 0 @@ -29,12 +29,12 @@ Rectangle{ tapLimitY = Math.max(1,app.height * 0.02); var target = Engine.getCurrent(); - if (navigationState == 1 && target !== null) { - canvas.goTo(target); - zoomAnimation.restart() - } + if (navigationState == 1 && target !== null) + canvas.goTo(target, true); else canvas.goHome() + + navigationPanel.checkOrientation() } } @@ -75,13 +75,7 @@ Rectangle{ WorldMouseArea { id: worldMouseArea } WorldPinchArea { id: worldPinchArea } WorldCanvas { id:canvas } - NavigationPanel{ - id: navigationPanel - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - anchors.rightMargin: app.width * 0.02 - spacing: app.height * 0.05 - } + NavigationPanel{ id: navigationPanel } /*Image{ id: logo @@ -111,7 +105,7 @@ Rectangle{ onRunningChanged: { if (!running) { - if (canvas.zoomInTarget !== app.homeScaleFactor) + if (app.navigationState === 1) Engine.loadCurrentDemo(); else Engine.releaseDemos(); |