From 95f960bb677cd6ddfe4adbf0a027044e2f7d1150 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Tue, 2 May 2023 13:04:33 +0200 Subject: [PATCH] qml: seedtext word suggestions below text area --- .../qml/components/controls/SeedTextArea.qml | 65 ++++++++++--------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/electrum/gui/qml/components/controls/SeedTextArea.qml b/electrum/gui/qml/components/controls/SeedTextArea.qml index 096c7bb52..1681cad5d 100644 --- a/electrum/gui/qml/components/controls/SeedTextArea.qml +++ b/electrum/gui/qml/components/controls/SeedTextArea.qml @@ -29,6 +29,39 @@ Pane { id: rootLayout width: parent.width spacing: 0 + + TextArea { + id: seedtextarea + Layout.fillWidth: true + Layout.minimumHeight: fontMetrics.height * 3 + topPadding + bottomPadding + + rightPadding: constants.paddingLarge + leftPadding: constants.paddingLarge + + wrapMode: TextInput.WordWrap + font.bold: true + font.pixelSize: constants.fontSizeLarge + font.family: FixedFont + inputMethodHints: Qt.ImhSensitiveData | Qt.ImhLowercaseOnly | Qt.ImhNoPredictiveText + readOnly: true + + background: Rectangle { + color: constants.darkerBackground + } + + onTextChanged: { + // work around Qt issue, TextArea fires spurious textChanged events + // NOTE: might be Qt virtual keyboard, or Qt upgrade from 5.15.2 to 5.15.7 + if (root.text != text) + root.text = text + + // update suggestions + _suggestions = bitcoin.mnemonicsFor(seedtextarea.text.split(' ').pop()) + // TODO: cursorPosition only on suggestion apply + cursorPosition = text.length + } + } + Flickable { Layout.preferredWidth: parent.width Layout.minimumHeight: fontMetrics.lineSpacing + 2*constants.paddingXXSmall + 2*constants.paddingXSmall + 2 @@ -70,38 +103,6 @@ Pane { } } - TextArea { - id: seedtextarea - Layout.fillWidth: true - Layout.minimumHeight: fontMetrics.height * 3 + topPadding + bottomPadding - - rightPadding: constants.paddingLarge - leftPadding: constants.paddingLarge - - wrapMode: TextInput.WordWrap - font.bold: true - font.pixelSize: constants.fontSizeLarge - font.family: FixedFont - inputMethodHints: Qt.ImhSensitiveData | Qt.ImhLowercaseOnly | Qt.ImhNoPredictiveText - readOnly: true - - background: Rectangle { - color: constants.darkerBackground - } - - onTextChanged: { - // work around Qt issue, TextArea fires spurious textChanged events - // NOTE: might be Qt virtual keyboard, or Qt upgrade from 5.15.2 to 5.15.7 - if (root.text != text) - root.text = text - - // update suggestions - _suggestions = bitcoin.mnemonicsFor(seedtextarea.text.split(' ').pop()) - // TODO: cursorPosition only on suggestion apply - cursorPosition = text.length - } - } - SeedKeyboard { id: kbd Layout.fillWidth: true