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. 48
      electrum/gui/qml/components/main.qml

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

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

48
electrum/gui/qml/components/main.qml

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

Loading…
Cancel
Save