mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-24 04:28:58 +00:00
- changes the order of the "Create profile on empty Keycard" flow to match Figma (seedphrase -> create pin -> add key pair) - fixup tests to match the order Fixes #17216
140 lines
4.1 KiB
QML
140 lines
4.1 KiB
QML
import QtQuick 2.15
|
|
import QtQuick.Controls 2.15
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import StatusQ.Core 0.1
|
|
import StatusQ.Components 0.1
|
|
import StatusQ.Controls 0.1
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
StatusTextField {
|
|
id: root
|
|
|
|
required property bool valid
|
|
required property var seedSuggestions // [{seedWord:string}, ...]
|
|
|
|
placeholderText: qsTr("Enter word")
|
|
|
|
leftPadding: Theme.padding
|
|
rightPadding: Theme.padding + clearIcon.width + d.contentSpacing
|
|
topPadding: Theme.smallPadding
|
|
bottomPadding: Theme.smallPadding
|
|
|
|
background: Rectangle {
|
|
radius: Theme.radius
|
|
|
|
color: {
|
|
if (root.activeFocus || d.isEmpty)
|
|
return Theme.palette.baseColor2
|
|
if (root.valid)
|
|
return Theme.palette.successColor2
|
|
return Theme.palette.dangerColor3
|
|
}
|
|
|
|
border.width: root.activeFocus ? 1 : 0
|
|
border.color: {
|
|
if (root.activeFocus || d.isEmpty)
|
|
return Theme.palette.primaryColor1
|
|
if (root.valid)
|
|
return Theme.palette.successColor1
|
|
return Theme.palette.dangerColor1
|
|
}
|
|
}
|
|
|
|
QtObject {
|
|
id: d
|
|
readonly property int contentSpacing: 4
|
|
readonly property int delegateHeight: 33
|
|
readonly property bool isEmpty: root.text === ""
|
|
}
|
|
|
|
Keys.onPressed: {
|
|
switch (event.key) {
|
|
case Qt.Key_Tab:
|
|
case Qt.Key_Return:
|
|
case Qt.Key_Enter: {
|
|
if (root.text === "") {
|
|
event.accepted = true
|
|
return
|
|
}
|
|
if (filteredModel.count > 0) {
|
|
event.accepted = true
|
|
root.text = filteredModel.get(suggestionsList.currentIndex).seedWord
|
|
root.accepted()
|
|
return
|
|
}
|
|
break
|
|
}
|
|
case Qt.Key_Space: {
|
|
event.accepted = !event.text.match(/^[a-zA-Z]$/)
|
|
break
|
|
}
|
|
}
|
|
}
|
|
Keys.forwardTo: [suggestionsList]
|
|
|
|
StatusDropdown {
|
|
x: 0
|
|
y: parent.height + d.contentSpacing
|
|
width: parent.width
|
|
contentHeight: ((suggestionsList.count <= 5) ? suggestionsList.count : 5) * d.delegateHeight // max 5 delegates
|
|
visible: filteredModel.count > 0 && root.cursorVisible && !d.isEmpty && !root.valid
|
|
verticalPadding: Theme.halfPadding
|
|
horizontalPadding: 0
|
|
contentItem: StatusListView {
|
|
id: suggestionsList
|
|
currentIndex: 0
|
|
model: SortFilterProxyModel {
|
|
id: filteredModel
|
|
sourceModel: root.seedSuggestions
|
|
filters: RegExpFilter {
|
|
pattern: `^${root.text}`
|
|
caseSensitivity: Qt.CaseInsensitive
|
|
}
|
|
sorters: StringSorter {
|
|
roleName: "seedWord"
|
|
}
|
|
}
|
|
delegate: StatusItemDelegate {
|
|
width: ListView.view.width
|
|
height: d.delegateHeight
|
|
text: model.seedWord
|
|
font.pixelSize: Theme.additionalTextSize
|
|
highlightColor: Theme.palette.primaryColor1
|
|
highlighted: hovered || index === suggestionsList.currentIndex
|
|
onClicked: {
|
|
root.text = text
|
|
root.accepted()
|
|
}
|
|
}
|
|
onCountChanged: currentIndex = 0
|
|
}
|
|
}
|
|
|
|
StatusIcon {
|
|
id: clearIcon
|
|
width: 20
|
|
height: 20
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
anchors.right: parent.right
|
|
anchors.rightMargin: Theme.padding
|
|
visible: !d.isEmpty && root.activeFocus
|
|
icon: "clear"
|
|
color: Theme.palette.directColor9
|
|
|
|
HoverHandler {
|
|
id: hhandler
|
|
cursorShape: hovered ? Qt.PointingHandCursor : undefined
|
|
}
|
|
TapHandler {
|
|
onSingleTapped: root.clear()
|
|
}
|
|
StatusToolTip {
|
|
text: qsTr("Clear")
|
|
visible: hhandler.hovered && clearIcon.visible
|
|
}
|
|
}
|
|
}
|