4 changed files with 111 additions and 20 deletions
@ -1,20 +1,102 @@
|
||||
import QtQuick 2.6 |
||||
import QtQuick 2.15 |
||||
import QtQuick.Layouts 1.0 |
||||
import QtQuick.Controls 2.1 |
||||
import QtQuick.Controls 2.15 |
||||
import QtQuick.Controls.Material 2.0 |
||||
|
||||
TextArea { |
||||
id: seedtext |
||||
Layout.fillWidth: true |
||||
Layout.minimumHeight: 80 |
||||
rightPadding: constants.paddingLarge |
||||
leftPadding: constants.paddingLarge |
||||
wrapMode: TextInput.WordWrap |
||||
font.bold: true |
||||
font.pixelSize: constants.fontSizeLarge |
||||
inputMethodHints: Qt.ImhSensitiveData | Qt.ImhPreferLowercase | Qt.ImhNoPredictiveText |
||||
import org.electrum 1.0 |
||||
|
||||
Pane { |
||||
id: root |
||||
implicitHeight: rootLayout.height |
||||
padding: 0 |
||||
|
||||
property alias readOnly: seedtextarea.readOnly |
||||
property alias text: seedtextarea.text |
||||
property alias placeholderText: seedtextarea.placeholderText |
||||
|
||||
property var _suggestions: [] |
||||
|
||||
background: Rectangle { |
||||
color: "transparent" |
||||
border.color: Material.accentColor |
||||
} |
||||
|
||||
ColumnLayout { |
||||
id: rootLayout |
||||
width: parent.width |
||||
spacing: 0 |
||||
Flickable { |
||||
Layout.preferredWidth: parent.width |
||||
Layout.minimumHeight: fontMetrics.lineSpacing + 2*constants.paddingXXSmall + 2*constants.paddingXSmall + 2 |
||||
implicitHeight: wordsLayout.height |
||||
|
||||
visible: !readOnly |
||||
flickableDirection: Flickable.HorizontalFlick |
||||
contentWidth: wordsLayout.width |
||||
interactive: wordsLayout.width > width |
||||
|
||||
RowLayout { |
||||
id: wordsLayout |
||||
Repeater { |
||||
model: _suggestions |
||||
Rectangle { |
||||
Layout.margins: constants.paddingXXSmall |
||||
width: suggestionLabel.width |
||||
height: suggestionLabel.height |
||||
color: constants.lighterBackground |
||||
radius: constants.paddingXXSmall |
||||
Label { |
||||
id: suggestionLabel |
||||
text: modelData |
||||
padding: constants.paddingXSmall |
||||
leftPadding: constants.paddingSmall |
||||
rightPadding: constants.paddingSmall |
||||
} |
||||
MouseArea { |
||||
anchors.fill: parent |
||||
onClicked: { |
||||
var words = seedtextarea.text.split(' ') |
||||
words.pop() |
||||
words.push(modelData) |
||||
seedtextarea.text = words.join(' ') + ' ' |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
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.ImhPreferLowercase | Qt.ImhNoPredictiveText |
||||
|
||||
background: Rectangle { |
||||
color: constants.darkerBackground |
||||
} |
||||
|
||||
onTextChanged: { |
||||
_suggestions = bitcoin.mnemonicsFor(seedtextarea.text.split(' ').pop()) |
||||
// TODO: cursorPosition only on suggestion apply |
||||
cursorPosition = text.length |
||||
} |
||||
} |
||||
} |
||||
|
||||
FontMetrics { |
||||
id: fontMetrics |
||||
font: seedtextarea.font |
||||
} |
||||
|
||||
Bitcoin { |
||||
id: bitcoin |
||||
} |
||||
} |
||||
|
||||
Loading…
Reference in new issue