Files
purple-electrumwallet/electrum/gui/qml/components/Wallets.qml
T

154 lines
5.5 KiB
QML
Raw Normal View History

2023-07-17 10:49:06 +02:00
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Controls.Material
2021-04-05 12:24:45 +02:00
import org.electrum 1.0
import "controls"
2021-04-07 16:50:34 +02:00
Pane {
id: rootItem
objectName: 'Wallets'
2021-04-05 12:24:45 +02:00
padding: 0
property string title: qsTr('Wallets')
2022-06-15 18:19:04 +02:00
function createWallet() {
var dialog = app.newWalletWizard.createObject(app)
2022-06-15 18:19:04 +02:00
dialog.open()
dialog.walletCreated.connect(function() {
Daemon.availableWallets.reload()
// and load the new wallet
Daemon.loadWallet(dialog.path, dialog.wizard_data['password'])
2022-06-15 18:19:04 +02:00
})
}
2021-04-07 16:50:34 +02:00
ColumnLayout {
id: rootLayout
2023-07-14 13:51:08 +02:00
anchors.fill: parent
spacing: 0
2021-04-05 12:24:45 +02:00
ColumnLayout {
2023-07-14 13:51:08 +02:00
Layout.fillWidth: true
2021-04-05 12:24:45 +02:00
Heading {
text: qsTr('Wallets')
2021-04-07 16:50:34 +02:00
}
2022-05-10 19:31:25 +02:00
Frame {
id: detailsFrame
2023-07-14 13:51:08 +02:00
Layout.fillWidth: true
Layout.fillHeight: true
verticalPadding: 0
horizontalPadding: 0
background: PaneInsetBackground {}
2022-03-24 21:10:01 +01:00
ElListView {
2022-05-10 19:31:25 +02:00
id: listview
anchors.fill: parent
2022-05-10 19:31:25 +02:00
clip: true
model: Daemon.availableWallets
delegate: ItemDelegate {
2022-05-10 19:31:25 +02:00
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()
}
}
2022-05-10 19:31:25 +02:00
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
2022-05-10 19:31:25 +02:00
}
Label {
Layout.fillWidth: true
2022-05-10 19:31:25 +02:00
font.pixelSize: constants.fontSizeLarge
text: model.name
elide: Label.ElideRight
color: model.active ? Material.foreground : Qt.darker(Material.foreground, 1.20)
2022-05-10 19:31:25 +02:00
}
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'
2022-03-24 21:10:01 +01:00
}
2022-03-10 12:25:18 +01:00
}
2021-04-07 16:50:34 +02:00
}
2022-03-24 21:10:01 +01:00
2022-05-10 19:31:25 +02:00
ScrollIndicator.vertical: ScrollIndicator { }
}
2021-04-06 14:13:51 +02:00
}
2022-03-24 21:10:01 +01:00
}
2021-04-06 14:13:51 +02:00
FlatButton {
Layout.fillWidth: true
2023-04-24 12:38:41 +02:00
text: qsTr('Create Wallet')
2023-02-07 14:16:29 +01:00
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()
}
}
2021-04-05 12:24:45 +02:00
}
}
Connections {
target: Daemon
function onWalletLoaded() {
if (app.stack.currentItem.objectName == 'Wallets')
if (app.stack.getRoot().objectName == 'Wallets') {
app.stack.replaceRoot('WalletMainView.qml')
} else {
app.stack.pop()
}
}
}
2021-04-05 12:24:45 +02:00
}