1
0
Files
electrum/electrum/gui/qml/components/Wallets.qml
f321x 378a9e6112 qml: disable 'Create Wallet' before first unlock
If the user has not unlocked any wallet yet and tries to create a new
wallet in the overview a dialog will prompt them to first unlock an
existing wallet in order to be able to create a new wallet.

This ensures they remember at least one password so they can complete
the wizard. The wizard will ask them for an existing password later and
it would be annoying for the user to go through all steps (writing down
the seed etc.) only to find out they need a password they don't
remember. This way they can reinstall the app right before going through
the wizard.
2025-12-18 11:07:37 +01:00

151 lines
5.4 KiB
QML

import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Controls.Material
import org.electrum 1.0
import "controls"
Pane {
id: rootItem
objectName: 'Wallets'
padding: 0
property string title: qsTr('Wallets')
function createWallet() {
var dialog = app.newWalletWizard.createObject(app)
dialog.open()
dialog.walletCreated.connect(function() {
Daemon.availableWallets.reload()
// and load the new wallet
Daemon.loadWallet(dialog.path, dialog.wizard_data['password'])
})
}
ColumnLayout {
id: rootLayout
anchors.fill: parent
spacing: 0
ColumnLayout {
Layout.fillWidth: true
Layout.margins: constants.paddingLarge
Heading {
text: qsTr('Wallets')
}
Frame {
id: detailsFrame
Layout.fillWidth: true
Layout.fillHeight: true
verticalPadding: 0
horizontalPadding: 0
background: PaneInsetBackground {}
ElListView {
id: listview
anchors.fill: parent
clip: true
model: Daemon.availableWallets
delegate: ItemDelegate {
width: ListView.view.width
height: row.height
onClicked: {
if (!Daemon.currentWallet || Daemon.currentWallet.name != model.name) {
if (!Daemon.loading) // wallet load in progress
Daemon.loadWallet(model.path)
} else {
app.stack.pop()
}
}
RowLayout {
id: row
spacing: 10
x: constants.paddingSmall
width: parent.width - 2 * constants.paddingSmall
Image {
id: walleticon
source: "../../icons/wallet.png"
fillMode: Image.PreserveAspectFit
Layout.preferredWidth: constants.iconSizeLarge
Layout.preferredHeight: constants.iconSizeLarge
Layout.topMargin: constants.paddingSmall
Layout.bottomMargin: constants.paddingSmall
}
Label {
Layout.fillWidth: true
font.pixelSize: constants.fontSizeLarge
text: model.name
elide: Label.ElideRight
color: model.active ? Material.foreground : Qt.darker(Material.foreground, 1.20)
}
Tag {
visible: Daemon.currentWallet && model.name == Daemon.currentWallet.name
text: qsTr('Current')
border.color: Material.foreground
font.bold: true
labelcolor: Material.foreground
}
Tag {
visible: model.active
text: qsTr('Active')
border.color: 'green'
labelcolor: 'green'
}
Tag {
visible: !model.active
text: qsTr('Not loaded')
border.color: 'grey'
labelcolor: 'grey'
}
}
}
ScrollIndicator.vertical: ScrollIndicator { }
}
}
}
FlatButton {
Layout.fillWidth: true
text: qsTr('Create Wallet')
icon.source: '../../icons/add.png'
onClicked: {
if (Daemon.availableWallets.rowCount() > 0 && Config.walletShouldUseSinglePassword
&& (!Daemon.singlePassword || Daemon.numWalletsWithPassword(Daemon.singlePassword) < 1)) {
// if the user has wallets but hasn't unlocked any wallet yet force them to do so.
// this ensures they know at least one wallets password and can complete the wizard
// where they will need to enter the password of an existing wallet.
var dialog = app.messageDialog.createObject(app, {
title: qsTr('Wallet unlock required'),
text: qsTr("You have to unlock any existing wallet first before creating a new wallet."),
})
dialog.open()
} else {
rootItem.createWallet()
}
}
}
}
Connections {
target: Daemon
function onWalletLoaded() {
if (app.stack.currentItem.objectName == 'Wallets')
app.stack.pop()
}
}
}