195 lines
6.3 KiB
QML
Raw Normal View History

2026-02-20 18:10:59 +01:00
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Dialogs
import Logos.Theme
import Logos.Controls
2026-07-03 23:43:48 -03:00
import "../controls"
2026-02-20 18:10:59 +01:00
Control {
id: root
property string configPath: ""
property string storePath: ""
2026-02-20 18:10:59 +01:00
property string createError: ""
2026-06-05 03:24:03 -03:00
signal createWallet(string configPath, string storagePath, string password, string sequencerUrl)
readonly property string testnetUrl: "https://testnet.lez.logos.co"
readonly property string localhostUrl: "http://127.0.0.1:3040"
2026-02-20 18:10:59 +01:00
QtObject {
id: d
function configParentFolderUrl(path) {
if (!path || path.length === 0) return ""
var p = path
var i = Math.max(p.lastIndexOf("/"), p.lastIndexOf("\\"))
if (i <= 0) return ""
var dir = p.substring(0, i)
return dir.indexOf("file://") === 0 ? dir : "file://" + dir
}
}
2026-02-20 18:10:59 +01:00
ColumnLayout {
id: cardColumn
anchors.fill: parent
anchors.margins: Theme.spacing.xlarge
spacing: Theme.spacing.large
LogosText {
text: qsTr("Set up LEZ Wallet")
font.pixelSize: Theme.typography.titleText
font.weight: Theme.typography.weightBold
color: Theme.palette.text
}
LogosText {
text: qsTr("Configure storage and secure with a password.")
font.pixelSize: Theme.typography.secondaryText
color: Theme.palette.textSecondary
Layout.topMargin: -Theme.spacing.small
}
LogosText {
text: qsTr("Storage")
font.pixelSize: Theme.typography.secondaryText
font.weight: Theme.typography.weightMedium
color: Theme.palette.text
}
RowLayout {
Layout.fillWidth: true
spacing: Theme.spacing.small
2026-02-21 21:26:04 +01:00
LogosTextField {
2026-02-20 18:10:59 +01:00
id: storagePathField
2026-02-21 21:26:04 +01:00
Layout.fillWidth: true
placeholderText: qsTr("Add store path")
text: root.storePath
2026-02-20 18:10:59 +01:00
}
2026-07-03 23:43:48 -03:00
FeedbackButton {
2026-02-20 18:10:59 +01:00
text: qsTr("Browse")
onClicked: storageFolderDialog.open()
}
}
LogosText {
2026-02-21 21:26:04 +01:00
text: qsTr("Config file")
2026-02-20 18:10:59 +01:00
font.pixelSize: Theme.typography.secondaryText
font.weight: Theme.typography.weightMedium
color: Theme.palette.text
}
RowLayout {
Layout.fillWidth: true
spacing: Theme.spacing.small
2026-02-21 21:26:04 +01:00
LogosTextField {
2026-02-20 18:10:59 +01:00
id: configPathField
2026-02-21 21:26:04 +01:00
Layout.fillWidth: true
placeholderText: qsTr("Add path to config")
text: root.configPath
2026-02-20 18:10:59 +01:00
}
2026-07-03 23:43:48 -03:00
FeedbackButton {
2026-02-21 21:26:04 +01:00
Layout.preferredHeight: configPathField.height
2026-02-20 18:10:59 +01:00
text: qsTr("Browse")
onClicked: configFileDialog.open()
}
}
2026-06-05 03:24:03 -03:00
RowLayout {
Layout.fillWidth: true
Layout.topMargin: Theme.spacing.medium
spacing: Theme.spacing.small
LogosText {
text: qsTr("Network")
font.pixelSize: Theme.typography.secondaryText
font.weight: Theme.typography.weightMedium
color: Theme.palette.text
}
LogosTextField {
id: sequencerUrlField
Layout.fillWidth: true
placeholderText: qsTr("Sequencer URL")
text: root.testnetUrl
}
}
RowLayout {
Layout.fillWidth: true
spacing: Theme.spacing.small
2026-07-03 23:43:48 -03:00
FeedbackButton {
2026-06-05 03:24:03 -03:00
text: qsTr("Testnet")
opacity: sequencerUrlField.text === root.testnetUrl ? 1.0 : 0.4
onClicked: sequencerUrlField.text = root.testnetUrl
}
2026-07-03 23:43:48 -03:00
FeedbackButton {
2026-06-05 03:24:03 -03:00
text: qsTr("Localhost")
opacity: sequencerUrlField.text === root.localhostUrl ? 1.0 : 0.4
onClicked: sequencerUrlField.text = root.localhostUrl
}
}
2026-02-20 18:10:59 +01:00
LogosText {
text: qsTr("Security")
font.pixelSize: Theme.typography.secondaryText
font.weight: Theme.typography.weightMedium
color: Theme.palette.text
Layout.topMargin: Theme.spacing.medium
}
2026-02-21 21:26:04 +01:00
LogosTextField {
2026-02-20 18:10:59 +01:00
id: passwordField
2026-02-21 21:26:04 +01:00
Layout.fillWidth: true
2026-02-20 18:10:59 +01:00
placeholderText: qsTr("Password")
echoMode: TextInput.Password
}
2026-02-21 21:26:04 +01:00
LogosTextField {
2026-02-20 18:10:59 +01:00
id: confirmField
2026-02-21 21:26:04 +01:00
Layout.fillWidth: true
2026-02-20 18:10:59 +01:00
placeholderText: qsTr("Confirm")
echoMode: TextInput.Password
}
LogosText {
id: errorLabel
Layout.fillWidth: true
font.pixelSize: Theme.typography.secondaryText
color: Theme.palette.error
wrapMode: Text.WordWrap
visible: text.length > 0
text: root.createError
}
2026-07-03 23:43:48 -03:00
FeedbackButton {
2026-02-20 18:10:59 +01:00
Layout.alignment: Qt.AlignRight
text: qsTr("Create Wallet")
font.pixelSize: Theme.typography.secondaryText
onClicked: {
if (passwordField.text.length === 0) {
root.createError = qsTr("Password cannot be empty.")
} else if (passwordField.text !== confirmField.text) {
root.createError = qsTr("Passwords do not match.")
} else {
root.createError = ""
2026-06-05 03:24:03 -03:00
root.createWallet(configPathField.text, storagePathField.text, passwordField.text, sequencerUrlField.text)
2026-02-20 18:10:59 +01:00
}
}
}
}
FileDialog {
2026-02-20 18:10:59 +01:00
id: storageFolderDialog
modality: Qt.NonModal
nameFilters: ["JSON files (*.json)"]
currentFolder: root.storePath ? d.configParentFolderUrl(root.storePath) : ""
onAccepted: storagePathField.text = selectedFile.toString().replace(/^file:\/\//, "")
2026-02-20 18:10:59 +01:00
}
FileDialog {
id: configFileDialog
modality: Qt.NonModal
nameFilters: ["JSON files (*.json)"]
currentFolder: root.configPath ? d.configParentFolderUrl(root.configPath) : ""
2026-02-20 18:10:59 +01:00
onAccepted: {
if (selectedFile) configPathField.text = selectedFile.toString().replace(/^file:\/\//, "")
}
}
}