invert (in)validPassword property in QEWalletDB, add invalidPassword signal.
This is to better support state in OpenWallet page
This commit is contained in:
@@ -8,7 +8,7 @@ import "controls"
|
|||||||
|
|
||||||
Pane {
|
Pane {
|
||||||
id: openwalletdialog
|
id: openwalletdialog
|
||||||
|
|
||||||
property string title: qsTr("Open Wallet")
|
property string title: qsTr("Open Wallet")
|
||||||
|
|
||||||
property string name
|
property string name
|
||||||
@@ -39,7 +39,7 @@ Pane {
|
|||||||
Layout.columnSpan: 2
|
Layout.columnSpan: 2
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
text: qsTr("Invalid Password")
|
text: qsTr("Invalid Password")
|
||||||
visible: wallet_db.invalidPassword && _unlockClicked
|
visible: !wallet_db.validPassword && _unlockClicked
|
||||||
width: parent.width * 2/3
|
width: parent.width * 2/3
|
||||||
error: true
|
error: true
|
||||||
}
|
}
|
||||||
@@ -53,16 +53,24 @@ Pane {
|
|||||||
id: password
|
id: password
|
||||||
visible: wallet_db.needsPassword
|
visible: wallet_db.needsPassword
|
||||||
echoMode: TextInput.Password
|
echoMode: TextInput.Password
|
||||||
|
inputMethodHints: Qt.ImhSensitiveData
|
||||||
|
onTextChanged: {
|
||||||
|
unlockButton.enabled = true
|
||||||
|
_unlockClicked = false
|
||||||
|
}
|
||||||
|
onAccepted: {
|
||||||
|
unlock()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
|
id: unlockButton
|
||||||
Layout.columnSpan: 2
|
Layout.columnSpan: 2
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
visible: wallet_db.needsPassword
|
visible: wallet_db.needsPassword
|
||||||
text: qsTr("Unlock")
|
text: qsTr("Unlock")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
_unlockClicked = true
|
unlock()
|
||||||
wallet_db.password = password.text
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,8 +95,22 @@ Pane {
|
|||||||
text: qsTr('Split wallet')
|
text: qsTr('Split wallet')
|
||||||
onClicked: wallet_db.doSplit()
|
onClicked: wallet_db.doSplit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BusyIndicator {
|
||||||
|
id: busy
|
||||||
|
running: false
|
||||||
|
Layout.columnSpan: 2
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function unlock() {
|
||||||
|
unlockButton.enabled = false
|
||||||
|
_unlockClicked = true
|
||||||
|
wallet_db.password = password.text
|
||||||
|
openwalletdialog.forceActiveFocus()
|
||||||
|
}
|
||||||
|
|
||||||
WalletDB {
|
WalletDB {
|
||||||
id: wallet_db
|
id: wallet_db
|
||||||
path: openwalletdialog.path
|
path: openwalletdialog.path
|
||||||
@@ -99,10 +121,17 @@ Pane {
|
|||||||
}
|
}
|
||||||
onReadyChanged: {
|
onReadyChanged: {
|
||||||
if (ready) {
|
if (ready) {
|
||||||
|
busy.running = true
|
||||||
Daemon.load_wallet(openwalletdialog.path, password.text)
|
Daemon.load_wallet(openwalletdialog.path, password.text)
|
||||||
app.stack.pop(null)
|
app.stack.pop(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onInvalidPassword: {
|
||||||
|
password.forceActiveFocus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
password.forceActiveFocus()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class QEDaemon(AuthMixin, QObject):
|
|||||||
self.daemon = daemon
|
self.daemon = daemon
|
||||||
self.qefx = QEFX(daemon.fx, daemon.config)
|
self.qefx = QEFX(daemon.fx, daemon.config)
|
||||||
self._walletdb = QEWalletDB()
|
self._walletdb = QEWalletDB()
|
||||||
self._walletdb.invalidPasswordChanged.connect(self.passwordValidityCheck)
|
self._walletdb.validPasswordChanged.connect(self.passwordValidityCheck)
|
||||||
|
|
||||||
_logger = get_logger(__name__)
|
_logger = get_logger(__name__)
|
||||||
_loaded_wallets = QEWalletListModel()
|
_loaded_wallets = QEWalletListModel()
|
||||||
@@ -115,7 +115,7 @@ class QEDaemon(AuthMixin, QObject):
|
|||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def passwordValidityCheck(self):
|
def passwordValidityCheck(self):
|
||||||
if self._walletdb._invalidPassword:
|
if not self._walletdb._validPassword:
|
||||||
self.walletRequiresPassword.emit()
|
self.walletRequiresPassword.emit()
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
|
|||||||
@@ -25,20 +25,21 @@ class QEWalletDB(QObject):
|
|||||||
needsPasswordChanged = pyqtSignal()
|
needsPasswordChanged = pyqtSignal()
|
||||||
needsHWDeviceChanged = pyqtSignal()
|
needsHWDeviceChanged = pyqtSignal()
|
||||||
passwordChanged = pyqtSignal()
|
passwordChanged = pyqtSignal()
|
||||||
invalidPasswordChanged = pyqtSignal()
|
validPasswordChanged = pyqtSignal()
|
||||||
requiresSplitChanged = pyqtSignal()
|
requiresSplitChanged = pyqtSignal()
|
||||||
splitFinished = pyqtSignal()
|
splitFinished = pyqtSignal()
|
||||||
readyChanged = pyqtSignal()
|
readyChanged = pyqtSignal()
|
||||||
createError = pyqtSignal([str], arguments=["error"])
|
createError = pyqtSignal([str], arguments=["error"])
|
||||||
createSuccess = pyqtSignal()
|
createSuccess = pyqtSignal()
|
||||||
|
invalidPassword = pyqtSignal()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self._path = None
|
self._path = None
|
||||||
self._needsPassword = False
|
self._needsPassword = False
|
||||||
self._needsHWDevice = False
|
self._needsHWDevice = False
|
||||||
self._password = ''
|
self._password = ''
|
||||||
self._requiresSplit = False
|
self._requiresSplit = False
|
||||||
self._invalidPassword = False
|
self._validPassword = True
|
||||||
|
|
||||||
self._storage = None
|
self._storage = None
|
||||||
self._db = None
|
self._db = None
|
||||||
@@ -110,15 +111,15 @@ class QEWalletDB(QObject):
|
|||||||
def requiresSplit(self):
|
def requiresSplit(self):
|
||||||
return self._requiresSplit
|
return self._requiresSplit
|
||||||
|
|
||||||
@pyqtProperty(bool, notify=invalidPasswordChanged)
|
@pyqtProperty(bool, notify=validPasswordChanged)
|
||||||
def invalidPassword(self):
|
def validPassword(self):
|
||||||
return self._invalidPassword
|
return self._validPassword
|
||||||
|
|
||||||
@invalidPassword.setter
|
@validPassword.setter
|
||||||
def invalidPassword(self, invalidPassword):
|
def validPassword(self, validPassword):
|
||||||
if self._invalidPassword != invalidPassword:
|
if self._validPassword != validPassword:
|
||||||
self._invalidPassword = invalidPassword
|
self._validPassword = validPassword
|
||||||
self.invalidPasswordChanged.emit()
|
self.validPasswordChanged.emit()
|
||||||
|
|
||||||
@pyqtProperty(bool, notify=readyChanged)
|
@pyqtProperty(bool, notify=readyChanged)
|
||||||
def ready(self):
|
def ready(self):
|
||||||
@@ -148,9 +149,10 @@ class QEWalletDB(QObject):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self._storage.decrypt('' if not self._password else self._password)
|
self._storage.decrypt('' if not self._password else self._password)
|
||||||
self.invalidPassword = False
|
self.validPassword = True
|
||||||
except InvalidPassword as e:
|
except InvalidPassword as e:
|
||||||
self.invalidPassword = True
|
self.validPassword = False
|
||||||
|
self.invalidPassword.emit()
|
||||||
|
|
||||||
if not self._storage.is_past_initial_decryption():
|
if not self._storage.is_past_initial_decryption():
|
||||||
self._storage = None
|
self._storage = None
|
||||||
|
|||||||
Reference in New Issue
Block a user