aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Myöhänen <janne.myohanen@code-q.fi>2020-07-15 15:39:27 +0300
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-07-24 09:49:54 +0000
commit51d0e4154a75a45740aa66849b289b7e630916aa (patch)
tree4f4b00b7ee4f0202521460711b878d9e23c20c2f
parent5377bb3ce3e69640dc3ac484e977704470ad7965 (diff)
Fix InputPanel position in b2qt example when portrait mode
Fix the position and placement of InputPanel in b2qt example when the screen is rotated to portrait mode. Rotation is now applied to whole window content. InputPanel position and dimensions are calculated based on used screen orientation. Fixes: QTBUG-83217 Change-Id: I3a4fab9aad5aafecea315d804c5521d108484950 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit e409ba186bcd670e7741740c410a32f35b1dbe2e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--examples/virtualkeyboard/basic/basic-b2qt.qml31
1 files changed, 23 insertions, 8 deletions
diff --git a/examples/virtualkeyboard/basic/basic-b2qt.qml b/examples/virtualkeyboard/basic/basic-b2qt.qml
index d61fc868..107e7a0c 100644
--- a/examples/virtualkeyboard/basic/basic-b2qt.qml
+++ b/examples/virtualkeyboard/basic/basic-b2qt.qml
@@ -41,16 +41,15 @@ Item {
Item {
id: appContainer
- width: Screen.width < Screen.height ? parent.height : parent.width
- height: Screen.width < Screen.height ? parent.width : parent.height
+ width: Screen.orientation === Qt.LandscapeOrientation ? parent.width : parent.height
+ height: Screen.orientation === Qt.LandscapeOrientation ? parent.height : parent.width
anchors.centerIn: parent
- rotation: Screen.width < Screen.height ? 90 : 0
Basic {
id: virtualKeyboard
anchors.left: parent.left
anchors.top: parent.top
anchors.right: parent.right
- anchors.bottom: inputPanel.top
+ anchors.bottom: parent.bottom
handwritingInputPanelActive: handwritingInputPanel.available && handwritingInputPanel.active
}
@@ -109,9 +108,14 @@ Item {
InputPanel {
id: inputPanel
z: 89
- y: appContainer.height
- anchors.left: parent.left
- anchors.right: parent.right
+ y: yPositionWhenHidden
+ x: Screen.orientation === Qt.LandscapeOrientation ? 0 : (parent.width-parent.height) / 2
+ width: Screen.orientation === Qt.LandscapeOrientation ? parent.width : parent.height
+
+ keyboard.shadowInputControl.height: (Screen.orientation === Qt.LandscapeOrientation ? parent.height : parent.width) - keyboard.height
+
+ property real yPositionWhenHidden: Screen.orientation === Qt.LandscapeOrientation ? parent.height : parent.width + (parent.height-parent.width) / 2
+
states: State {
name: "visible"
/* The visibility of the InputPanel can be bound to the Qt.inputMethod.visible property,
@@ -122,7 +126,7 @@ Item {
when: inputPanel.active
PropertyChanges {
target: inputPanel
- y: appContainer.height - inputPanel.height
+ y: inputPanel.yPositionWhenHidden - inputPanel.height
}
}
transitions: Transition {
@@ -155,5 +159,16 @@ Item {
value: appContainer.height > 0 && (appContainer.width / appContainer.height) > (16.0 / 9.0)
restoreMode: Binding.RestoreBinding
}
+
+ }
+
+ property bool inLandscapeOrientation: Screen.orientation === Qt.LandscapeOrientation
+
+ Screen.orientationUpdateMask: Qt.LandscapeOrientation | Qt.PortraitOrientation
+
+ Binding {
+ target: appContainer.Window.window !== null ? appContainer.Window.window.contentItem : null
+ property: "rotation"
+ value: inLandscapeOrientation ? 0 : 90
}
}