diff options
author | Janne Myöhänen <janne.myohanen@code-q.fi> | 2020-07-15 15:39:27 +0300 |
---|---|---|
committer | Janne Myöhänen <janne.myohanen@code-q.fi> | 2020-07-24 12:24:03 +0300 |
commit | e409ba186bcd670e7741740c410a32f35b1dbe2e (patch) | |
tree | 59f35829845208cd79ef4c1883967c639911c5e1 /examples/virtualkeyboard/basic/basic-b2qt.qml | |
parent | fe1fea70b402fc333a9a4e91cccf415b92a45a2e (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
Pick-to: 5.15
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'examples/virtualkeyboard/basic/basic-b2qt.qml')
-rw-r--r-- | examples/virtualkeyboard/basic/basic-b2qt.qml | 31 |
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 } } |