1
0

qml: wizard support for back button

This commit is contained in:
Sander van Grieken
2022-11-16 12:12:43 +01:00
parent d95b18c510
commit 5380b21568
6 changed files with 26 additions and 38 deletions

View File

@@ -9,7 +9,7 @@ import "wizard"
Wizard {
id: walletwizard
title: qsTr('New Wallet')
wizardTitle: qsTr('New Wallet')
signal walletCreated

View File

@@ -7,7 +7,7 @@ import "wizard"
Wizard {
id: serverconnectwizard
title: qsTr('How do you want to connect to a server?')
wizardTitle: qsTr('Network configuration')
enter: null // disable transition

View File

@@ -8,6 +8,10 @@ Dialog {
property bool allowClose: true
property string iconSource
function doClose() {
close()
}
onOpenedChanged: {
if (opened) {
app.activeDialogs.push(abstractdialog)

View File

@@ -276,7 +276,7 @@ ApplicationWindow
if (activeDialogs.length > 0) {
var activeDialog = activeDialogs[activeDialogs.length - 1]
if (activeDialog.allowClose) {
activeDialog.close()
activeDialog.doClose()
} else {
console.log('dialog disallowed close')
}

View File

@@ -13,6 +13,10 @@ WizardComponent {
ColumnLayout {
width: parent.width
Label {
text: qsTr('How do you want to connect to a server?')
}
InfoTextArea {
text: qsTr('Electrum communicates with remote servers to get information about your transactions and addresses. The servers all fulfill the same purpose only differing in hardware. In most cases you simply want to let Electrum pick one at random. However if you prefer feel free to select a server manually.')
Layout.fillWidth: true

View File

@@ -2,7 +2,9 @@ import QtQuick 2.6
import QtQuick.Layouts 1.0
import QtQuick.Controls 2.1
Dialog {
import "../controls"
ElDialog {
id: wizard
modal: true
focus: true
@@ -10,10 +12,22 @@ Dialog {
width: parent.width
height: parent.height
title: wizardTitle + (pages.currentItem.title ? ' - ' + pages.currentItem.title : '')
iconSource: '../../../icons/electrum.png'
property string wizardTitle
property var wizard_data
property alias pages: pages
property QtObject wiz
function doClose() {
if (pages.currentIndex == 0)
reject()
else
pages.prev()
}
function _setWizardData(wdata) {
wizard_data = {}
Object.assign(wizard_data, wdata) // deep copy
@@ -32,7 +46,6 @@ Dialog {
}
var url = Qt.resolvedUrl(wiz.viewToComponent(view))
console.log(url)
var comp = Qt.createComponent(url)
if (comp.status == Component.Error) {
console.log(comp.errorString())
@@ -156,39 +169,6 @@ Dialog {
}
}
header: GridLayout {
columns: 2
rowSpacing: 0
Image {
source: "../../../icons/electrum.png"
Layout.preferredWidth: constants.iconSizeXLarge
Layout.preferredHeight: constants.iconSizeXLarge
Layout.leftMargin: constants.paddingMedium
Layout.topMargin: constants.paddingMedium
Layout.bottomMargin: constants.paddingMedium
}
Label {
text: title + (pages.currentItem.title ? ' - ' + pages.currentItem.title : '')
elide: Label.ElideRight
Layout.fillWidth: true
topPadding: constants.paddingXLarge
bottomPadding: constants.paddingXLarge
font.bold: true
font.pixelSize: constants.fontSizeMedium
}
Rectangle {
Layout.columnSpan: 2
Layout.fillWidth: true
Layout.leftMargin: constants.paddingTiny
Layout.rightMargin: constants.paddingTiny
height: 1
color: Qt.rgba(0,0,0,0.5)
}
}
// make clicking the dialog background move the scope away from textedit fields
// so the keyboard goes away
// TODO: here it works on desktop, but not android. hmm.