UI on Wallets screen. Add active/not active/current indicator tags.
initial wallet delete/change password boilerplate
This commit is contained in:
@@ -2,7 +2,8 @@ import QtQuick 2.6
|
||||
import QtQuick.Controls.Material 2.0
|
||||
|
||||
Item {
|
||||
readonly property int paddingTiny: 4
|
||||
readonly property int paddingTiny: 4 //deprecated
|
||||
readonly property int paddingXXSmall: 4
|
||||
readonly property int paddingXSmall: 6
|
||||
readonly property int paddingSmall: 8
|
||||
readonly property int paddingMedium: 12
|
||||
|
||||
@@ -35,11 +35,15 @@ Pane {
|
||||
var dialog = app.messageDialog.createObject(rootItem,
|
||||
{'text': qsTr('Really delete this wallet?'), 'yesno': true})
|
||||
dialog.yesClicked.connect(function() {
|
||||
Daemon.currentWallet.deleteWallet()
|
||||
Daemon.delete_wallet(Daemon.currentWallet)
|
||||
})
|
||||
dialog.open()
|
||||
}
|
||||
|
||||
function changePassword() {
|
||||
// TODO: show set password dialog
|
||||
}
|
||||
|
||||
property QtObject menu: Menu {
|
||||
id: menu
|
||||
MenuItem {
|
||||
@@ -66,7 +70,7 @@ Pane {
|
||||
id: deleteWalletComp
|
||||
MenuItem {
|
||||
icon.color: 'transparent'
|
||||
enabled: false
|
||||
enabled: Daemon.currentWallet // != null
|
||||
action: Action {
|
||||
text: qsTr('Delete Wallet');
|
||||
onTriggered: rootItem.deleteWallet()
|
||||
@@ -231,10 +235,14 @@ Pane {
|
||||
clip: true
|
||||
model: Daemon.availableWallets
|
||||
|
||||
delegate: AbstractButton {
|
||||
delegate: ItemDelegate {
|
||||
width: ListView.view.width
|
||||
height: row.height
|
||||
|
||||
onClicked: {
|
||||
Daemon.load_wallet(model.path)
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
id: row
|
||||
spacing: 10
|
||||
@@ -247,19 +255,35 @@ Pane {
|
||||
fillMode: Image.PreserveAspectFit
|
||||
Layout.preferredWidth: constants.iconSizeLarge
|
||||
Layout.preferredHeight: constants.iconSizeLarge
|
||||
Layout.topMargin: constants.paddingSmall
|
||||
Layout.bottomMargin: constants.paddingSmall
|
||||
}
|
||||
|
||||
Label {
|
||||
font.pixelSize: constants.fontSizeLarge
|
||||
text: model.name
|
||||
color: model.active ? Material.foreground : Qt.darker(Material.foreground, 1.20)
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Button {
|
||||
text: 'Open'
|
||||
onClicked: {
|
||||
Daemon.load_wallet(model.path)
|
||||
}
|
||||
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'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -279,6 +303,7 @@ Pane {
|
||||
Connections {
|
||||
target: Daemon
|
||||
function onWalletLoaded() {
|
||||
Daemon.availableWallets.reload()
|
||||
app.stack.pop()
|
||||
}
|
||||
}
|
||||
|
||||
29
electrum/gui/qml/components/controls/Tag.qml
Normal file
29
electrum/gui/qml/components/controls/Tag.qml
Normal file
@@ -0,0 +1,29 @@
|
||||
import QtQuick 2.6
|
||||
import QtQuick.Layouts 1.0
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Controls.Material 2.0
|
||||
|
||||
Rectangle {
|
||||
radius: constants.paddingXSmall
|
||||
width: layout.width
|
||||
height: layout.height
|
||||
color: 'transparent'
|
||||
border.color: Material.accentColor
|
||||
|
||||
property alias text: label.text
|
||||
property alias font: label.font
|
||||
property alias labelcolor: label.color
|
||||
|
||||
RowLayout {
|
||||
id: layout
|
||||
|
||||
Label {
|
||||
id: label
|
||||
Layout.leftMargin: constants.paddingSmall
|
||||
Layout.rightMargin: constants.paddingSmall
|
||||
Layout.topMargin: constants.paddingXXSmall
|
||||
Layout.bottomMargin: constants.paddingXXSmall
|
||||
font.pixelSize: constants.fontSizeXSmall
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -235,4 +235,18 @@ ApplicationWindow
|
||||
dialog.open()
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: Daemon
|
||||
function onAuthRequired() {
|
||||
var dialog = app.messageDialog.createObject(app, {'text': 'Auth placeholder', 'yesno': true})
|
||||
dialog.yesClicked.connect(function() {
|
||||
Daemon.authProceed()
|
||||
})
|
||||
dialog.noClicked.connect(function() {
|
||||
Daemon.authCancel()
|
||||
})
|
||||
dialog.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ from electrum.wallet_db import WalletDB
|
||||
from .qewallet import QEWallet
|
||||
from .qewalletdb import QEWalletDB
|
||||
from .qefx import QEFX
|
||||
from .auth import AuthMixin, auth_protect
|
||||
|
||||
# wallet list model. supports both wallet basenames (wallet file basenames)
|
||||
# and whole Wallet instances (loaded wallets)
|
||||
@@ -84,7 +85,7 @@ class QEAvailableWalletListModel(QEWalletListModel):
|
||||
wallet = self.daemon.get_wallet(path)
|
||||
self.add_wallet(wallet_path = path, wallet = wallet)
|
||||
|
||||
class QEDaemon(QObject):
|
||||
class QEDaemon(AuthMixin, QObject):
|
||||
def __init__(self, daemon, parent=None):
|
||||
super().__init__(parent)
|
||||
self.daemon = daemon
|
||||
@@ -145,6 +146,13 @@ class QEDaemon(QObject):
|
||||
self._logger.error(str(e))
|
||||
self.walletOpenError.emit(str(e))
|
||||
|
||||
@pyqtSlot(QEWallet)
|
||||
@auth_protect
|
||||
def delete_wallet(self, wallet):
|
||||
path = wallet.wallet.storage.path
|
||||
self._logger.debug('Ok to delete wallet with path %s' % path)
|
||||
# TODO checks, e.g. existing LN channels, unpaid requests, etc
|
||||
self.daemon.stop_wallet(path)
|
||||
|
||||
@pyqtProperty('QString')
|
||||
def path(self):
|
||||
|
||||
@@ -235,7 +235,7 @@ class QEWallet(AuthMixin, QObject):
|
||||
return self._channelModel
|
||||
|
||||
nameChanged = pyqtSignal()
|
||||
@pyqtProperty('QString', notify=nameChanged)
|
||||
@pyqtProperty(str, notify=nameChanged)
|
||||
def name(self):
|
||||
return self.wallet.basename()
|
||||
|
||||
@@ -252,7 +252,7 @@ class QEWallet(AuthMixin, QObject):
|
||||
def hasSeed(self):
|
||||
return self.wallet.has_seed()
|
||||
|
||||
@pyqtProperty('QString', notify=dataChanged)
|
||||
@pyqtProperty(str, notify=dataChanged)
|
||||
def txinType(self):
|
||||
return self.wallet.get_txin_type(self.wallet.dummy_address())
|
||||
|
||||
@@ -272,7 +272,7 @@ class QEWallet(AuthMixin, QObject):
|
||||
def isHardware(self):
|
||||
return self.wallet.storage.is_encrypted_with_hw_device()
|
||||
|
||||
@pyqtProperty('QString', notify=dataChanged)
|
||||
@pyqtProperty(str, notify=dataChanged)
|
||||
def derivationPrefix(self):
|
||||
keystores = self.wallet.get_keystores()
|
||||
if len(keystores) > 1:
|
||||
@@ -288,7 +288,6 @@ class QEWallet(AuthMixin, QObject):
|
||||
@pyqtProperty(QEAmount, notify=balanceChanged)
|
||||
def frozenBalance(self):
|
||||
c, u, x = self.wallet.get_frozen_balance()
|
||||
self._logger.info('frozen balance: ' + str(c) + ' ' + str(u) + ' ' + str(x) + ' ')
|
||||
self._frozenbalance = QEAmount(amount_sat=c+x)
|
||||
return self._frozenbalance
|
||||
|
||||
@@ -300,7 +299,6 @@ class QEWallet(AuthMixin, QObject):
|
||||
@pyqtProperty(QEAmount, notify=balanceChanged)
|
||||
def confirmedBalance(self):
|
||||
c, u, x = self.wallet.get_balance()
|
||||
self._logger.info('balance: ' + str(c) + ' ' + str(u) + ' ' + str(x) + ' ')
|
||||
self._confirmedbalance = QEAmount(amount_sat=c+x)
|
||||
return self._confirmedbalance
|
||||
|
||||
@@ -484,3 +482,10 @@ class QEWallet(AuthMixin, QObject):
|
||||
@pyqtSlot('QString', result='QVariant')
|
||||
def get_invoice(self, key: str):
|
||||
return self._invoiceModel.get_model_invoice(key)
|
||||
|
||||
@pyqtSlot(str)
|
||||
@auth_protect
|
||||
def set_password(self, password):
|
||||
storage = self.wallet.storage
|
||||
self._logger.debug('Ok to set password for wallet with path %s' % storage.path)
|
||||
# TODO
|
||||
|
||||
Reference in New Issue
Block a user