From e88cf0a683816f65cafce75400b2cb5f4d384b4c Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Wed, 1 Nov 2023 17:17:16 +0100 Subject: [PATCH] qml: addresses list formatting, add txid/outpoint and amount to filter --- electrum/gui/qml/components/Addresses.qml | 38 +++++++++---------- .../gui/qml/components/WalletMainView.qml | 2 +- .../qml/components/controls/CoinDelegate.qml | 38 +++++++++---------- electrum/gui/qml/qeaddresslistmodel.py | 5 ++- 4 files changed, 43 insertions(+), 40 deletions(-) diff --git a/electrum/gui/qml/components/Addresses.qml b/electrum/gui/qml/components/Addresses.qml index dabf50e6b..7cd66247c 100644 --- a/electrum/gui/qml/components/Addresses.qml +++ b/electrum/gui/qml/components/Addresses.qml @@ -72,16 +72,15 @@ Pane { } } } - RowLayout { - Layout.columnSpan: 3 + TextField { + id: searchEdit Layout.fillWidth: true - TextField { - id: searchEdit - Layout.fillWidth: true - placeholderText: qsTr('text search') - onTextChanged: listview.filterModel.filterText = text - } + Layout.columnSpan: 3 + placeholderText: qsTr('search') + onTextChanged: listview.filterModel.filterText = text Image { + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter source: Qt.resolvedUrl('../../icons/zoom.png') sourceSize.width: constants.iconSizeMedium sourceSize.height: constants.iconSizeMedium @@ -193,6 +192,7 @@ Pane { width: parent.width property bool selected: loader.DelegateModel.inSelected highlighted: selected + indent: listview.filterModel.showAddressesCoins == 2 ? 0 : constants.paddingLarge * 2 onClicked: { if (!listview.selectMode) { var page = app.stack.push(Qt.resolvedUrl('TxDetails.qml'), { @@ -244,17 +244,17 @@ Pane { selectedGroup.remove(0, selectedGroup.count) } } - FlatButton { - Layout.fillWidth: true - Layout.preferredWidth: 1 - text: qsTr('Pay from...') - icon.source: '../../icons/tab_send.png' - visible: listview.selectMode - enabled: false // TODO - onClicked: { - // - } - } + // FlatButton { + // Layout.fillWidth: true + // Layout.preferredWidth: 1 + // text: qsTr('Pay from...') + // icon.source: '../../icons/tab_send.png' + // visible: listview.selectMode + // enabled: false // TODO + // onClicked: { + // // + // } + // } } } diff --git a/electrum/gui/qml/components/WalletMainView.qml b/electrum/gui/qml/components/WalletMainView.qml index 79a29d00d..c0fa08ac4 100644 --- a/electrum/gui/qml/components/WalletMainView.qml +++ b/electrum/gui/qml/components/WalletMainView.qml @@ -111,7 +111,7 @@ Item { icon.color: action.enabled ? 'transparent' : Material.iconDisabledColor icon.source: '../../icons/tab_addresses.png' action: Action { - text: qsTr('Addresses'); + text: qsTr('Addresses/Coins'); onTriggered: menu.openPage(Qt.resolvedUrl('Addresses.qml')); enabled: Daemon.currentWallet && app.stack.currentItem.objectName != 'Addresses' } diff --git a/electrum/gui/qml/components/controls/CoinDelegate.qml b/electrum/gui/qml/components/controls/CoinDelegate.qml index 1dc93be2c..7f823b794 100644 --- a/electrum/gui/qml/components/controls/CoinDelegate.qml +++ b/electrum/gui/qml/components/controls/CoinDelegate.qml @@ -10,18 +10,20 @@ ItemDelegate { width: ListView.view.width height: delegateLayout.height highlighted: ListView.isCurrentItem - font.pixelSize: constants.fontSizeMedium // set default font size for child controls + property int indent: 0 + ColumnLayout { id: delegateLayout width: parent.width spacing: 0 GridLayout { - columns: 3 + columns: 2 Layout.topMargin: constants.paddingSmall - Layout.leftMargin: constants.paddingLarge + 2*constants.paddingLarge + Layout.bottomMargin: constants.paddingSmall + Layout.leftMargin: constants.paddingLarge + indent Layout.rightMargin: constants.paddingLarge Rectangle { @@ -41,15 +43,15 @@ ItemDelegate { font.family: FixedFont text: model.outpoint elide: Text.ElideMiddle - Layout.preferredWidth: implicitWidth + constants.paddingMedium - } - Label { Layout.fillWidth: true - visible: model.short_id - font.family: FixedFont - font.pixelSize: constants.fontSizeSmall - text: '[' + model.short_id + ']' } + // Label { + // Layout.preferredWidth: implicitWidth + // visible: model.short_id + // font.family: FixedFont + // font.pixelSize: constants.fontSizeSmall + // text: '[' + model.short_id + ']' + // } Item { Layout.fillWidth: true Layout.alignment: Qt.AlignLeft | Qt.AlignTop @@ -60,15 +62,18 @@ ItemDelegate { sourceSize.height: constants.iconSizeSmall } } - } - - RowLayout { Label { + Layout.leftMargin: constants.paddingMedium + Layout.minimumWidth: implicitWidth + Layout.preferredWidth: implicitWidth + horizontalAlignment: Text.AlignRight font.family: FixedFont text: Config.formatSats(model.amount, false) visible: model.amount.satsInt != 0 } Label { + Layout.minimumWidth: implicitWidth + Layout.preferredWidth: implicitWidth color: Material.accentColor text: Config.baseUnit visible: model.amount.satsInt != 0 @@ -78,7 +83,6 @@ ItemDelegate { Label { id: labelLabel Layout.fillWidth: true - Layout.columnSpan: 2 visible: model.label font.pixelSize: constants.fontSizeMedium text: model.label @@ -88,10 +92,6 @@ ItemDelegate { } } - - Item { - Layout.preferredWidth: 1 - Layout.preferredHeight: constants.paddingSmall - } } + } diff --git a/electrum/gui/qml/qeaddresslistmodel.py b/electrum/gui/qml/qeaddresslistmodel.py index f2537d342..d87b027ee 100644 --- a/electrum/gui/qml/qeaddresslistmodel.py +++ b/electrum/gui/qml/qeaddresslistmodel.py @@ -46,7 +46,10 @@ class QEAddressCoinFilterProxyModel(QSortFilterProxyModel): if self._filter_text: label = parent_model.data(parent_model.index(s_row, 0, s_parent), parent_model._ROLE_RMAP['label']) address = parent_model.data(parent_model.index(s_row, 0, s_parent), parent_model._ROLE_RMAP['address']) - for item in [label, address]: + outpoint = parent_model.data(parent_model.index(s_row, 0, s_parent), parent_model._ROLE_RMAP['outpoint']) + amount_i = parent_model.data(parent_model.index(s_row, 0, s_parent), parent_model._ROLE_RMAP['amount']) + amount = parent_model.wallet.config.format_amount(amount_i.satsInt) if amount_i else None + for item in [label, address, outpoint, amount]: if self._filter_text in str(item): return True return False