1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the examples of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:BSD$
10 ** You may use this file under the terms of the BSD license as follows:
12 ** "Redistribution and use in source and binary forms, with or without
13 ** modification, are permitted provided that the following conditions are
15 ** * Redistributions of source code must retain the above copyright
16 ** notice, this list of conditions and the following disclaimer.
17 ** * Redistributions in binary form must reproduce the above copyright
18 ** notice, this list of conditions and the following disclaimer in
19 ** the documentation and/or other materials provided with the
21 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
22 ** the names of its contributors may be used to endorse or promote
23 ** products derived from this software without specific prior written
26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39 ****************************************************************************/
43 import "Core/screenorientation.js" as ScreenOrientation
54 property variant selectedOrientation: Orientation.UnknownOrientation
55 property variant activeOrientation: selectedOrientation == Orientation.UnknownOrientation ? runtime.orientation : selectedOrientation
56 state: "orientation " + activeOrientation
57 property bool inPortrait: (activeOrientation == Orientation.Portrait || activeOrientation == Orientation.PortraitInverted);
59 // rotation correction for landscape devices like N900
60 property bool landscapeWindow: window.width > window.height
61 property variant rotationDelta: landscapeWindow ? -90 : 0
62 rotation: rotationDelta
64 // initial state is portrait
65 property real baseWidth: landscapeWindow ? window.height-10 : window.width-10
66 property real baseHeight: landscapeWindow ? window.width-10 : window.height-10
70 anchors.centerIn: parent
74 GradientStop { position: 0.0; color: Qt.rgba(0.5,0.5,0.5,0.5) }
75 GradientStop { position: 0.8; color: "black" }
76 GradientStop { position: 1.0; color: "black" }
80 property bool rising: false
82 property variant gravityPoint: ScreenOrientation.calculateGravityPoint(main.activeOrientation, runtime.orientation)
86 rising: bubbles.rising
87 verticalRise: ScreenOrientation.parallel(main.activeOrientation, runtime.orientation)
88 xAttractor: parent.gravityPoint.x
89 yAttractor: parent.gravityPoint.y
92 Component.onCompleted: bubbles.rising = true;
96 width: centeredText.width
97 anchors.verticalCenter: parent.verticalCenter
98 anchors.horizontalCenter: parent.horizontalCenter
99 anchors.verticalCenterOffset: 30
104 anchors.horizontalCenter: parent.horizontalCenter
108 text: ScreenOrientation.printOrientation(main.activeOrientation)
111 anchors.horizontalCenter: parent.horizontalCenter
114 text: "sensor: " + ScreenOrientation.printOrientation(runtime.orientation)
117 anchors.horizontalCenter: parent.horizontalCenter
121 anchors.top: parent.top
122 anchors.left: parent.left
123 anchors.right: parent.right
127 width: main.inPortrait ? (parent.width-4)/2 : (parent.width-8)/3
129 onClicked: main.selectedOrientation = Orientation.Portrait
130 toggled: main.selectedOrientation == Orientation.Portrait
133 width: main.inPortrait ? (parent.width-4)/2 : (parent.width-8)/3
134 text: "Portrait inverted"
135 onClicked: main.selectedOrientation = Orientation.PortraitInverted
136 toggled: main.selectedOrientation == Orientation.PortraitInverted
139 width: main.inPortrait ? (parent.width-4)/2 : (parent.width-8)/3
141 onClicked: main.selectedOrientation = Orientation.Landscape
142 toggled: main.selectedOrientation == Orientation.Landscape
145 width: main.inPortrait ? (parent.width-4)/2 : (parent.width-8)/3
146 text: "Landscape inverted"
147 onClicked: main.selectedOrientation = Orientation.LandscapeInverted
148 toggled: main.selectedOrientation == Orientation.LandscapeInverted
151 width: main.inPortrait ? parent.width : 2*(parent.width-2)/3
152 text: "From runtime.orientation"
153 onClicked: main.selectedOrientation = Orientation.UnknownOrientation
154 toggled: main.selectedOrientation == Orientation.UnknownOrientation
159 name: "orientation " + Orientation.Landscape
162 rotation: ScreenOrientation.getAngle(Orientation.Landscape)+rotationDelta
168 name: "orientation " + Orientation.PortraitInverted
171 rotation: ScreenOrientation.getAngle(Orientation.PortraitInverted)+rotationDelta
177 name: "orientation " + Orientation.LandscapeInverted
180 rotation: ScreenOrientation.getAngle(Orientation.LandscapeInverted)+rotationDelta
186 transitions: Transition {
189 direction: RotationAnimation.Shortest
191 easing.type: Easing.InOutQuint
194 properties: "x,y,width,height"
196 easing.type: Easing.InOutQuint