Skip to content

Commit 7b8b81c

Browse files
committed
Merge #255: Properly relinquish activeFocus on ValueInput when editing is finished
90fd65b qml: Give up focus on ValueInput when editing finished (jarolrod) ef26265 qml: Make ValueInput a TextInput instead of a TextEdit (jarolrod) Pull request description: On master, pressing `enter` while editing a setting that has a ValueInput does not properly relinquish focus from the ValueInput, still leaving it in an editing state. This fixes that by: a. Making ValueInput a [TextInput](https://doc.qt.io/qt-5/qml-qtquick-textinput.html#text-prop) instead of a [TextEdit](https://doc.qt.io/qt-5/qml-qtquick-textedit.html) - TextEdit allows for multi-line input, so an `enter` in this would add a new line, which we don't want. There is no use case for a ValueInput to be multiple lines, it should only be one. Additionally, this prevents `enter` from signaling that editing is finished - TextInput is specifically for single line input. This QML type also allows us to do necessary validations with a [validator](https://doc.qt.io/qt-5/qml-qtquick-textinput.html#validator-prop), [inputMask](https://doc.qt.io/qt-5/qml-qtquick-textinput.html#inputMask-prop), and signal what kind of keyboard we want with [inputMethodHints](https://doc.qt.io/qt-5/qml-qtquick-textinput.html#inputMethodHints-prop). Additionally, this allows for `enter` to signal that editing is finished. b. Relinquishing focus on the ValueInput itself, by forcing focus back to the parent Setting. [![Windows](https://img.shields.io/badge/OS-Windows-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/win64/insecure_win_gui.zip?branch=pull/255) [![Intel macOS](https://img.shields.io/badge/OS-Intel%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos/insecure_mac_gui.zip?branch=pull/255) [![Apple Silicon macOS](https://img.shields.io/badge/OS-Apple%20Silicon%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos_arm64/insecure_mac_arm64_gui.zip?branch=pull/255) [![ARM64 Android](https://img.shields.io/badge/OS-Android-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/android/insecure_android_apk.zip?branch=pull/255) ACKs for top commit: johnny9: ACK 90fd65b Tree-SHA512: 6b2d40b9f715b05b239112835eb9078ce5637005bbea28888161179ac8ea9f736471b8e734542a90538e1bfca0c0c41de426954d311852534859cf51431d755f
2 parents 29f26f8 + 90fd65b commit 7b8b81c

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/qml/components/DeveloperOptions.qml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ ColumnLayout {
3030
actionItem: ValueInput {
3131
parentState: dbcacheSetting.state
3232
description: optionsModel.dbcacheSizeMiB
33-
onEditingFinished: optionsModel.dbcacheSizeMiB = parseInt(text)
33+
onEditingFinished: {
34+
optionsModel.dbcacheSizeMiB = parseInt(text)
35+
dbcacheSetting.forceActiveFocus()
36+
}
3437
}
3538
onClicked: loadedItem.forceActiveFocus()
3639
}
@@ -42,7 +45,10 @@ ColumnLayout {
4245
actionItem: ValueInput {
4346
parentState: parSetting.state
4447
description: optionsModel.scriptThreads
45-
onEditingFinished: optionsModel.scriptThreads = parseInt(text)
48+
onEditingFinished: {
49+
optionsModel.scriptThreads = parseInt(text)
50+
parSetting.forceActiveFocus()
51+
}
4652
}
4753
onClicked: loadedItem.forceActiveFocus()
4854
}

src/qml/components/StorageSettings.qml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ ColumnLayout {
3636
actionItem: ValueInput {
3737
parentState: pruneTargetSetting.state
3838
description: optionsModel.pruneSizeGB
39-
onEditingFinished: optionsModel.pruneSizeGB = parseInt(text)
39+
onEditingFinished: {
40+
optionsModel.pruneSizeGB = parseInt(text)
41+
pruneTargetSetting.forceActiveFocus()
42+
}
4043
}
4144
onClicked: loadedItem.forceActiveFocus()
4245
}

src/qml/controls/ValueInput.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import QtQuick 2.15
66
import QtQuick.Controls 2.15
77

8-
TextEdit {
8+
TextInput {
99
id: root
1010
required property string parentState
1111
property string description: ""
@@ -44,7 +44,7 @@ TextEdit {
4444
font.styleName: "Regular"
4545
font.pixelSize: root.descriptionSize
4646
color: root.textColor
47-
text: description
47+
text: root.description
4848
horizontalAlignment: Text.AlignRight
4949
wrapMode: Text.WordWrap
5050

0 commit comments

Comments
 (0)