1 /****************************************************************************
3 ** Copyright (C) 2011 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 Qt Components project.
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 ****************************************************************************/
46 width: screen.displayWidth
47 height: screen.displayHeight
49 property alias color: background.color
51 default property alias content: windowContent.data
53 // Read only property true if window is in portrait
54 property alias inPortrait: window.portrait
56 signal orientationChangeAboutToStart
57 signal orientationChangeStarted
58 signal orientationChangeFinished
68 property bool portrait
70 width: window.portrait ? screen.displayHeight : screen.displayWidth
71 height: window.portrait ? screen.displayWidth : screen.displayHeight
73 anchors.centerIn : parent
74 transform: Rotation { id: windowRotation;
83 height: parent.height - heightDelta
85 // Used for resizing windowContent when virtual keyboard appears
86 property int heightDelta: 0
88 objectName: "windowContent"
92 id: inputContextConnection
94 onSoftwareInputPanelVisibleChanged: inputContextConnection.updateWindowContentHeightDelta();
96 onSoftwareInputPanelRectChanged: inputContextConnection.updateWindowContentHeightDelta();
98 function updateWindowContentHeightDelta() {
99 if(inputContext.customSoftwareInputPanelVisible)
103 windowContent.heightDelta = inputContext.softwareInputPanelRect.width
105 windowContent.heightDelta = inputContext.softwareInputPanelRect.height
111 id: softwareInputPanel
112 active: inputContext.customSoftwareInputPanelVisible
113 anchors.bottom: parent.bottom
116 windowContent.heightDelta = height
120 id: softwareInputPanelLoader
122 sourceComponent: inputContext.customSoftwareInputPanelComponent
128 anchors.top: parent.top
129 anchors.left: parent.left
130 width: screen.displayWidth
131 height: screen.displayHeight
132 snapshotWidth: screen.displayWidth
133 snapshotHeight: screen.displayHeight
135 transform: Rotation { id: snapshotRotation;
136 origin.x: screen.displayHeight / 2; origin.y: screen.displayHeight / 2;
140 state: screen.orientationString
145 PropertyChanges { target: window; rotation: 0; portrait: false; }
146 PropertyChanges { target: windowRotation;
147 origin.x: root.height / 2;
148 origin.y: root.height / 2; }
149 PropertyChanges { target: snapshot; anchors.leftMargin: 0; anchors.topMargin: 0 }
153 PropertyChanges { target: window; rotation: 270; portrait: true; }
154 PropertyChanges { target: windowRotation;
155 origin.x: root.height - root.width / 2;
156 origin.y: root.width / 2; }
157 PropertyChanges { target: snapshot; anchors.leftMargin: 0; anchors.topMargin: 0 }
160 name: "LandscapeInverted"
161 PropertyChanges { target: window; rotation: 180; portrait: false; }
162 PropertyChanges { target: windowRotation;
163 origin.x: root.height / 2;
164 origin.y: root.height / 2; }
165 PropertyChanges { target: snapshot; anchors.leftMargin: 374; anchors.topMargin: 0 }
168 name: "PortraitInverted"
169 PropertyChanges { target: window; rotation: 90; portrait: true; }
170 PropertyChanges { target: windowRotation;
171 origin.x: root.height - root.width / 2;
172 origin.y: root.width / 2; }
173 PropertyChanges { target: snapshot; anchors.leftMargin: 0; anchors.topMargin: 374 }
179 // use this transition when sip is visible
180 from: (inputContext.softwareInputPanelVisible ? "*" : "disabled")
181 to: (inputContext.softwareInputPanelVisible ? "*" : "disabled")
182 PropertyAction { target: window; properties: "rotation"; }
185 root.orientationChangeAboutToStart();
186 platformWindow.startSipOrientationChange(window.rotation);
187 // note : we should really connect these signals to MInputMethodState
188 // signals so that they are emitted at the appropriate time
189 // but there aren't any
190 root.orientationChangeStarted();
191 root.orientationChangeFinished();
196 // use this transition when sip is not visible
197 from: (screen.minimized ? "disabled" : (inputContext.softwareInputPanelVisible ? "disabled" : "*"))
198 to: (screen.minimized ? "disabled" : (inputContext.softwareInputPanelVisible ? "disabled" : "*"))
199 SequentialAnimation {
205 snapshot.opacity = 1.0;
206 snapshotRotation.angle = -window.rotation;
207 snapshot.smooth = false; // Quick & coarse rotation consistent with MTF
208 platformWindow.animating = true;
209 root.orientationChangeAboutToStart();
212 PropertyAction { target: window; properties: "portrait"; }
215 windowContent.opacity = 0.0;
216 root.orientationChangeStarted();
220 NumberAnimation { target: windowContent; property: "opacity";
221 to: 1.0; easing.type: Easing.InOutExpo; duration: 600; }
222 NumberAnimation { target: snapshot; property: "opacity";
223 to: 0.0; easing.type: Easing.InOutExpo; duration: 600; }
224 PropertyAction { target: windowRotation; properties: "origin.x"; }
225 PropertyAction { target: windowRotation; properties: "origin.y"; }
226 RotationAnimation { target: windowRotation; property: "angle";
227 from: -screen.rotationDirection * 90;
229 direction: RotationAnimation.Shortest;
230 easing.type: Easing.InOutExpo; duration: 600; }
234 windowRotation.angle = 0
236 root.orientationChangeFinished();
237 platformWindow.animating = false;
246 if (event.key == Qt.Key_I && event.modifiers == Qt.AltModifier) {
247 theme.inverted = !theme.inverted;
249 if (event.key == Qt.Key_E && event.modifiers == Qt.AltModifier) {
250 if(screen.currentOrientation == Screen.Landscape) {
251 screen.allowedOrientations = Screen.Portrait;
252 } else if(screen.currentOrientation == Screen.Portrait) {
253 screen.allowedOrientations = Screen.LandscapeInverted;
254 } else if(screen.currentOrientation == Screen.LandscapeInverted) {
255 screen.allowedOrientations = Screen.PortraitInverted;
256 } else if(screen.currentOrientation == Screen.PortraitInverted) {
257 screen.allowedOrientations = Screen.Landscape;
260 if (event.key == Qt.Key_E && event.modifiers == Qt.ControlModifier ) {
261 if(screen.currentOrientation == Screen.Portrait) {
262 screen.allowedOrientations = Screen.Landscape;
263 } else if(screen.currentOrientation == Screen.LandscapeInverted) {
264 screen.allowedOrientations = Screen.Portrait;
265 } else if(screen.currentOrientation == Screen.PortraitInverted) {
266 screen.allowedOrientations = Screen.LandscapeInverted;
267 } else if(screen.currentOrientation == Screen.Landscape) {
268 screen.allowedOrientations = Screen.PortraitInverted;