Browse Source

qml: fix keyboard exclusion zone

turns out that Qt.inputMethod.keyboardRectangle.height is not suitable for calculating the exact keyboard
dimensions in Qt coordinates. Instead, use Qt.inputMethod.keyboardRectangle.y transformed to Qt coordinates
using Screen.devicePixelRatio

Note: Qt.inputMethod.keyboardRectangle stop being updated after exiting FLAG_SECURE state
(e.g. in seed or master key entry pages)
master
Sander van Grieken 2 years ago
parent
commit
11d39cd942
  1. 2
      electrum/gui/qml/components/controls/ElDialog.qml
  2. 40
      electrum/gui/qml/components/main.qml

2
electrum/gui/qml/components/controls/ElDialog.qml

@ -35,7 +35,7 @@ Dialog {
reject() reject()
} }
parent: resizeWithKeyboard ? Overlay.overlay.children[0] : Overlay.overlay parent: resizeWithKeyboard ? app.keyboardFreeZone : Overlay.overlay
modal: true modal: true
Overlay.modal: Rectangle { Overlay.modal: Rectangle {
color: "#aa000000" color: "#aa000000"

40
electrum/gui/qml/components/main.qml

@ -32,6 +32,7 @@ ApplicationWindow
Constants { id: appconstants } Constants { id: appconstants }
property alias stack: mainStackView property alias stack: mainStackView
property alias keyboardFreeZone: _keyboardFreeZone
property variant activeDialogs: [] property variant activeDialogs: []
@ -210,15 +211,13 @@ ApplicationWindow
} }
// hack to force relayout of toolbar // hack to force relayout of toolbar
// since qt6 watchOnlyIndicator.visible doesn't trigger relayout(?) // since qt6 LightningNetworkStatusIndicator.visible doesn't trigger relayout(?)
Item { Item {
Layout.preferredHeight: 1 Layout.preferredHeight: 1
Layout.topMargin: -1 Layout.topMargin: -1
Layout.preferredWidth: watchOnlyIndicator.visible Layout.preferredWidth: lnnsi.visible
? 1 ? 1
: lnnsi.visible : 2
? 2
: 3
} }
} }
} }
@ -226,7 +225,7 @@ ApplicationWindow
StackView { StackView {
id: mainStackView id: mainStackView
width: parent.width width: parent.width
height: keyboardFreeZone.height - header.height height: _keyboardFreeZone.height - header.height
initialItem: Component { initialItem: Component {
WalletMainView {} WalletMainView {}
} }
@ -270,7 +269,7 @@ ApplicationWindow
} }
Item { Item {
id: keyboardFreeZone id: _keyboardFreeZone
// Item as first child in Overlay that adjusts its size to the available // Item as first child in Overlay that adjusts its size to the available
// screen space minus the virtual keyboard (e.g. to center dialogs in) // screen space minus the virtual keyboard (e.g. to center dialogs in)
// see also ElDialog.resizeWithKeyboard property // see also ElDialog.resizeWithKeyboard property
@ -278,39 +277,42 @@ ApplicationWindow
width: parent.width width: parent.width
height: parent.height height: parent.height
states: State { states: [
name: "visible" State {
when: Qt.inputMethod.visible name: 'visible'
when: Qt.inputMethod.keyboardRectangle.y
PropertyChanges { PropertyChanges {
target: keyboardFreeZone target: _keyboardFreeZone
height: keyboardFreeZone.parent.height - Qt.inputMethod.keyboardRectangle.height / Screen.devicePixelRatio height: _keyboardFreeZone.parent.height - (Screen.desktopAvailableHeight - (Qt.inputMethod.keyboardRectangle.y/Screen.devicePixelRatio))
} }
} }
]
transitions: [ transitions: [
Transition { Transition {
from: '' from: ''
to: 'visible' to: 'visible'
ParallelAnimation {
NumberAnimation { NumberAnimation {
properties: "height" properties: 'height'
duration: 250 duration: 100
easing.type: Easing.OutQuad easing.type: Easing.OutQuad
} }
}
}, },
Transition { Transition {
from: 'visible' from: 'visible'
to: '' to: ''
ParallelAnimation { SequentialAnimation {
PauseAnimation {
duration: 200
}
NumberAnimation { NumberAnimation {
properties: "height" properties: 'height'
duration: 50 duration: 50
easing.type: Easing.OutQuad easing.type: Easing.OutQuad
} }
} }
} }
] ]
} }
property alias newWalletWizard: _newWalletWizard property alias newWalletWizard: _newWalletWizard

Loading…
Cancel
Save