diff --git a/electrum/gui/qml/components/AddressDetails.qml b/electrum/gui/qml/components/AddressDetails.qml index cb58e668c..6cbe6e848 100644 --- a/electrum/gui/qml/components/AddressDetails.qml +++ b/electrum/gui/qml/components/AddressDetails.qml @@ -200,11 +200,13 @@ Pane { } Label { + visible: addressdetails.derivationPath text: qsTr('Derivation path') color: Material.accentColor } Label { + visible: addressdetails.derivationPath text: addressdetails.derivationPath } diff --git a/electrum/gui/qml/components/Addresses.qml b/electrum/gui/qml/components/Addresses.qml index 76fa768e2..f56aadddd 100644 --- a/electrum/gui/qml/components/Addresses.qml +++ b/electrum/gui/qml/components/Addresses.qml @@ -31,14 +31,7 @@ Pane { section.criteria: ViewSection.FullString section.delegate: sectionDelegate - delegate: ItemDelegate { - id: delegate - width: ListView.view.width - height: delegateLayout.height - highlighted: ListView.isCurrentItem - - font.pixelSize: constants.fontSizeMedium // set default font size for child controls - + delegate: AddressDelegate { onClicked: { var page = app.stack.push(Qt.resolvedUrl('AddressDetails.qml'), {'address': model.address}) page.addressDetailsChanged.connect(function() { @@ -46,84 +39,6 @@ Pane { listview.model.update_address(model.address) }) } - - ColumnLayout { - id: delegateLayout - width: parent.width - spacing: 0 - - GridLayout { - columns: 2 - Layout.topMargin: constants.paddingSmall - Layout.leftMargin: constants.paddingLarge - Layout.rightMargin: constants.paddingLarge - - Label { - id: indexLabel - font.bold: true - text: '#' + ('00'+model.iaddr).slice(-2) - Layout.fillWidth: true - } - Label { - font.family: FixedFont - text: model.address - elide: Text.ElideMiddle - Layout.fillWidth: true - } - - Rectangle { - id: useIndicator - Layout.preferredWidth: constants.iconSizeMedium - Layout.preferredHeight: constants.iconSizeMedium - color: model.held - ? constants.colorAddressFrozen - : model.numtx > 0 - ? model.balance.satsInt == 0 - ? constants.colorAddressUsed - : constants.colorAddressUsedWithBalance - : model.type == 'receive' - ? constants.colorAddressExternal - : constants.colorAddressInternal - } - - RowLayout { - Label { - id: labelLabel - font.pixelSize: model.label != '' ? constants.fontSizeLarge : constants.fontSizeSmall - text: model.label != '' ? model.label : qsTr('') - opacity: model.label != '' ? 1.0 : 0.8 - elide: Text.ElideRight - maximumLineCount: 2 - wrapMode: Text.WordWrap - Layout.fillWidth: true - } - Label { - font.family: FixedFont - text: Config.formatSats(model.balance, false) - visible: model.balance.satsInt != 0 - } - Label { - color: Material.accentColor - text: Config.baseUnit + ',' - visible: model.balance.satsInt != 0 - } - Label { - text: model.numtx - visible: model.numtx > 0 - } - Label { - color: Material.accentColor - text: qsTr('tx') - visible: model.numtx > 0 - } - } - } - - Item { - Layout.preferredWidth: 1 - Layout.preferredHeight: constants.paddingSmall - } - } } ScrollIndicator.vertical: ScrollIndicator { } diff --git a/electrum/gui/qml/components/controls/AddressDelegate.qml b/electrum/gui/qml/components/controls/AddressDelegate.qml new file mode 100644 index 000000000..f81171537 --- /dev/null +++ b/electrum/gui/qml/components/controls/AddressDelegate.qml @@ -0,0 +1,95 @@ +import QtQuick 2.6 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 +import QtQuick.Controls.Material 2.0 + +import org.electrum 1.0 + +ItemDelegate { + id: delegate + width: ListView.view.width + height: delegateLayout.height + highlighted: ListView.isCurrentItem + + font.pixelSize: constants.fontSizeMedium // set default font size for child controls + + ColumnLayout { + id: delegateLayout + width: parent.width + spacing: 0 + + GridLayout { + columns: 2 + Layout.topMargin: constants.paddingSmall + Layout.leftMargin: constants.paddingLarge + Layout.rightMargin: constants.paddingLarge + + Label { + id: indexLabel + font.bold: true + text: model.iaddr < 10 + ? '#' + ('0'+model.iaddr).slice(-2) + : '#' + model.iaddr + Layout.fillWidth: true + } + Label { + font.family: FixedFont + text: model.address + elide: Text.ElideMiddle + Layout.fillWidth: true + } + + Rectangle { + id: useIndicator + Layout.preferredWidth: constants.iconSizeMedium + Layout.preferredHeight: constants.iconSizeMedium + color: model.held + ? constants.colorAddressFrozen + : model.numtx > 0 + ? model.balance.satsInt == 0 + ? constants.colorAddressUsed + : constants.colorAddressUsedWithBalance + : model.type == 'change' + ? constants.colorAddressInternal + : constants.colorAddressExternal + } + + RowLayout { + Label { + id: labelLabel + font.pixelSize: model.label != '' ? constants.fontSizeLarge : constants.fontSizeSmall + text: model.label != '' ? model.label : qsTr('') + opacity: model.label != '' ? 1.0 : 0.8 + elide: Text.ElideRight + maximumLineCount: 2 + wrapMode: Text.WordWrap + Layout.fillWidth: true + } + Label { + font.family: FixedFont + text: Config.formatSats(model.balance, false) + visible: model.balance.satsInt != 0 + } + Label { + color: Material.accentColor + text: Config.baseUnit + ',' + visible: model.balance.satsInt != 0 + } + Label { + text: model.numtx + visible: model.numtx > 0 + } + Label { + color: Material.accentColor + text: qsTr('tx') + visible: model.numtx > 0 + } + } + } + + Item { + Layout.preferredWidth: 1 + Layout.preferredHeight: constants.paddingSmall + } + } +} diff --git a/electrum/gui/qml/qeaddresslistmodel.py b/electrum/gui/qml/qeaddresslistmodel.py index ba17ae5a9..29c2cb900 100644 --- a/electrum/gui/qml/qeaddresslistmodel.py +++ b/electrum/gui/qml/qeaddresslistmodel.py @@ -73,7 +73,7 @@ class QEAddressListModel(QAbstractListModel): return r_addresses = self.wallet.get_receiving_addresses() - c_addresses = self.wallet.get_change_addresses() + c_addresses = self.wallet.get_change_addresses() if self.wallet.wallet_type != 'imported' else [] n_addresses = len(r_addresses) + len(c_addresses) def insert_row(atype, alist, address, iaddr): @@ -84,10 +84,14 @@ class QEAddressListModel(QAbstractListModel): self.clear() self.beginInsertRows(QModelIndex(), 0, n_addresses - 1) - for i, address in enumerate(r_addresses): - insert_row('receive', self.receive_addresses, address, i) - for i, address in enumerate(c_addresses): - insert_row('change', self.change_addresses, address, i) + if self.wallet.wallet_type != 'imported': + for i, address in enumerate(r_addresses): + insert_row('receive', self.receive_addresses, address, i) + for i, address in enumerate(c_addresses): + insert_row('change', self.change_addresses, address, i) + else: + for i, address in enumerate(r_addresses): + insert_row('imported', self.receive_addresses, address, i) self.endInsertRows() self._dirty = False