Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions electrum/gui/qml/components/Wallets.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,38 @@ Pane {
text: qsTr('Wallets')
}

TextField {
id: searchEdit
Layout.fillWidth: true
Layout.leftMargin: constants.paddingLarge
Layout.rightMargin: constants.paddingLarge

placeholderText: qsTr('search')
inputMethodHints: Qt.ImhNoPredictiveText
EnterKey.type: Qt.EnterKeyDone
onAccepted: {
// load a wallet (e.g. a hidden wallet not shown in the list) when
// the search text exactly matches an available wallet name
var path = Daemon.availableWallets.pathForName(text)
if (path && !Daemon.loading) {
if (!Daemon.currentWallet || Daemon.currentWallet.name != text) {
Daemon.loadWallet(path)
} else {
app.stack.pop()
}
}
}

Image {
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: constants.paddingMedium
source: Qt.resolvedUrl('../../icons/zoom.png')
sourceSize.width: constants.iconSizeMedium
sourceSize.height: constants.iconSizeMedium
}
}

Frame {
id: detailsFrame
Layout.fillWidth: true
Expand All @@ -52,9 +84,14 @@ Pane {
model: Daemon.availableWallets

delegate: ItemDelegate {
property bool matchesSearch: searchEdit.text.length === 0
|| model.name.toLowerCase().indexOf(searchEdit.text.toLowerCase()) !== -1
property bool hiddenWallet: model.name.startsWith('.') && !model.active
width: ListView.view.width
height: row.height

height: visible ? row.height : 0
// visible: searchEdit.text.length === 0
// || model.name.toLowerCase().indexOf(searchEdit.text.toLowerCase()) !== -1
visible: matchesSearch && !hiddenWallet
onClicked: {
if (!Daemon.currentWallet || Daemon.currentWallet.name != model.name) {
if (!Daemon.loading) // wallet load in progress
Expand Down Expand Up @@ -118,6 +155,8 @@ Pane {

ButtonContainer {
Layout.fillWidth: true
visible: !searchEdit.text

FlatButton {
Layout.fillWidth: true
text: qsTr('Create Wallet')
Expand Down
15 changes: 12 additions & 3 deletions electrum/gui/qml/qedaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def reload(self):
wallet_folder = os.path.dirname(self.daemon.config.get_wallet_path())
with os.scandir(wallet_folder) as it:
for i in it:
if i.is_file() and not i.name.startswith('.'):
if i.is_file():
available.append(i.path)
for path in sorted(available):
wallet = self.daemon.get_wallet(path)
Expand Down Expand Up @@ -109,6 +109,13 @@ def wallet_name_exists(self, name):
return True
return False

@pyqtSlot(str, result=str)
def pathForName(self, name):
for wallet_name, wallet_path in self._wallets:
if name == wallet_name:
return wallet_path
return ''

@pyqtSlot(str)
def updateWallet(self, path):
i = 0
Expand Down Expand Up @@ -325,8 +332,10 @@ def isValidWalletName(self, wallet_name: str) -> bool:
for forbidden_char in ("/", "\\", ):
if forbidden_char in wallet_name:
return False
if wallet_name.startswith('.'): # not shown in wallet list
# TODO: allow wallets starting with '.' as hidden wallets, opened e.g. through wallet creation wizard
# note: wallet names starting with '.' are allowed as hidden wallets; they are not shown
# in the wallet list unless active (see Wallets.qml) but can be created via the wizard.
# disallow double '..*' filenames though.
if wallet_name.startswith('..'):
return False
if os.path.basename(wallet_name) != wallet_name: # '/foo/bar/' returns 'bar'
return False
Expand Down