diff --git a/electrum/gui/qml/components/Addresses.qml b/electrum/gui/qml/components/Addresses.qml index bfa45fb26..90ea357f8 100644 --- a/electrum/gui/qml/components/Addresses.qml +++ b/electrum/gui/qml/components/Addresses.qml @@ -25,58 +25,125 @@ Pane { height: parent.height clip: true model: Daemon.currentWallet.addressModel + currentIndex: -1 section.property: 'type' section.criteria: ViewSection.FullString section.delegate: sectionDelegate - delegate: AbstractButton { + delegate: ItemDelegate { id: delegate width: ListView.view.width height: delegateLayout.height - - background: Rectangle { - color: model.held ? Qt.rgba(1,0,0,0.5) : - model.numtx > 0 && model.balance == 0 ? Qt.rgba(1,1,1,0.25) : - model.type == 'receive' ? Qt.rgba(0,1,0,0.25) : - Qt.rgba(1,0.93,0,0.25) - Rectangle { - height: 1 - width: parent.width - anchors.top: parent.top - border.color: Material.accentColor - visible: model.index > 0 + highlighted: ListView.isCurrentItem + onClicked: ListView.view.currentIndex == index + ? ListView.view.currentIndex = -1 + : ListView.view.currentIndex = index + + states: [ + State { + name: 'normal'; when: !highlighted + PropertyChanges { target: drawer; visible: false } + PropertyChanges { target: labelLabel; maximumLineCount: 2 } + + }, + State { + name: 'highlighted'; when: highlighted + PropertyChanges { target: drawer; visible: true } + PropertyChanges { target: labelLabel; maximumLineCount: 4 } } - } + ] - RowLayout { + + ColumnLayout { id: delegateLayout - x: constants.paddingSmall - spacing: constants.paddingSmall - width: parent.width - 2*constants.paddingSmall - - Label { - font.pixelSize: constants.fontSizeLarge - font.family: FixedFont - text: model.address - elide: Text.ElideMiddle - Layout.maximumWidth: delegate.width / 3 +// x: constants.paddingSmall + spacing: 0 + //width: parent.width - 2*constants.paddingSmall + width: parent.width + + Item { + Layout.preferredWidth: 1 + Layout.preferredHeight: constants.paddingTiny } - Label { - font.pixelSize: constants.fontSizeMedium - text: model.label - elide: Text.ElideRight - Layout.minimumWidth: delegate.width / 3 - Layout.fillWidth: true + + GridLayout { + columns: 2 + Label { + id: indexLabel + font.pixelSize: constants.fontSizeMedium + font.bold: true + text: '#' + ('00'+model.iaddr).slice(-2) + Layout.fillWidth: true + } + Label { + font.pixelSize: constants.fontSizeMedium + font.family: FixedFont + text: model.address + Layout.fillWidth: true + } + + Rectangle { + Layout.preferredWidth: constants.iconSizeMedium + Layout.preferredHeight: constants.iconSizeMedium + color: model.held + ? Qt.rgba(1,0.93,0,0.75) + : model.numtx > 0 && model.balance == 0 + ? Qt.rgba(0.75,0.75,0.75,1) + : model.type == 'receive' + ? Qt.rgba(0,1,0,0.5) + : Qt.rgba(1,0.93,0,0.25) + } + + RowLayout { + Label { + id: labelLabel + font.pixelSize: model.label != '' ? constants.fontSizeLarge : constants.fontSizeSmall + text: model.label != '' ? model.label : '<no label>' + opacity: model.label != '' ? 1.0 : 0.8 + elide: Text.ElideRight + maximumLineCount: 2 + wrapMode: Text.WordWrap + Layout.fillWidth: true + } + Label { + font.pixelSize: constants.fontSizeMedium + font.family: FixedFont + text: Config.formatSats(model.balance, false) + } + Label { + font.pixelSize: constants.fontSizeMedium + color: Material.accentColor + text: Config.baseUnit + ',' + } + Label { + font.pixelSize: constants.fontSizeMedium + text: model.numtx + } + Label { + font.pixelSize: constants.fontSizeMedium + color: Material.accentColor + text: qsTr('tx') + } + } } - Label { - font.pixelSize: constants.fontSizeMedium - font.family: FixedFont - text: model.balance + + RowLayout { + id: drawer + Layout.fillWidth: true + Layout.preferredHeight: 50 + + ToolButton { + icon.source: '../../icons/qrcode.png' + icon.color: 'transparent' + icon.width: constants.iconSizeMedium + icon.height: constants.iconSizeMedium + } } - Label { - font.pixelSize: constants.fontSizeMedium - text: model.numtx + + Item { + Layout.preferredWidth: 1 + Layout.preferredHeight: constants.paddingSmall } } } diff --git a/electrum/gui/qml/qeaddresslistmodel.py b/electrum/gui/qml/qeaddresslistmodel.py index a9b60fd7b..5549c87b4 100644 --- a/electrum/gui/qml/qeaddresslistmodel.py +++ b/electrum/gui/qml/qeaddresslistmodel.py @@ -15,7 +15,7 @@ class QEAddressListModel(QAbstractListModel): _logger = get_logger(__name__) # define listmodel rolemap - _ROLE_NAMES=('type','address','label','balance','numtx', 'held') + _ROLE_NAMES=('type','iaddr','address','label','balance','numtx', 'held') _ROLE_KEYS = range(Qt.UserRole + 1, Qt.UserRole + 1 + len(_ROLE_NAMES)) _ROLE_MAP = dict(zip(_ROLE_KEYS, [bytearray(x.encode()) for x in _ROLE_NAMES])) @@ -51,7 +51,7 @@ class QEAddressListModel(QAbstractListModel): c_addresses = self.wallet.get_change_addresses() n_addresses = len(r_addresses) + len(c_addresses) - def insert_row(atype, alist, address): + def insert_row(atype, alist, address, iaddr): item = {} item['type'] = atype item['address'] = address @@ -61,12 +61,17 @@ class QEAddressListModel(QAbstractListModel): item['balance'] = c + u + x item['held'] = self.wallet.is_frozen_address(address) alist.append(item) + item['iaddr'] = iaddr self.clear() self.beginInsertRows(QModelIndex(), 0, n_addresses - 1) + i = 0 for address in r_addresses: - insert_row('receive', self.receive_addresses, address) + insert_row('receive', self.receive_addresses, address, i) + i = i + 1 + i = 0 for address in c_addresses: - insert_row('change', self.change_addresses, address) + insert_row('change', self.change_addresses, address, i) + i = i + 1 self.endInsertRows()