7 changed files with 483 additions and 70 deletions
|
After Width: | Height: | Size: 1.6 KiB |
@ -0,0 +1,243 @@
|
||||
import QtQuick 2.6 |
||||
import QtQuick.Layouts 1.0 |
||||
import QtQuick.Controls 2.3 |
||||
import QtQuick.Controls.Material 2.0 |
||||
|
||||
import org.electrum 1.0 |
||||
|
||||
import "controls" |
||||
|
||||
Pane { |
||||
id: root |
||||
width: parent.width |
||||
height: parent.height |
||||
|
||||
property string address |
||||
|
||||
property string title: qsTr("Address details") |
||||
|
||||
signal addressDetailsChanged |
||||
|
||||
property QtObject menu: Menu { |
||||
id: menu |
||||
MenuItem { |
||||
icon.color: 'transparent' |
||||
action: Action { |
||||
text: qsTr('Spend from') |
||||
//onTriggered: |
||||
icon.source: '../../icons/tab_send.png' |
||||
} |
||||
} |
||||
MenuItem { |
||||
icon.color: 'transparent' |
||||
action: Action { |
||||
text: qsTr('Sign/Verify') |
||||
icon.source: '../../icons/key.png' |
||||
} |
||||
} |
||||
MenuItem { |
||||
icon.color: 'transparent' |
||||
action: Action { |
||||
text: qsTr('Encrypt/Decrypt') |
||||
icon.source: '../../icons/mail_icon.png' |
||||
} |
||||
} |
||||
} |
||||
|
||||
Flickable { |
||||
anchors.fill: parent |
||||
contentHeight: rootLayout.height |
||||
clip:true |
||||
interactive: height < contentHeight |
||||
|
||||
GridLayout { |
||||
id: rootLayout |
||||
width: parent.width |
||||
columns: 2 |
||||
|
||||
Label { |
||||
text: qsTr('Address') |
||||
Layout.columnSpan: 2 |
||||
} |
||||
|
||||
TextHighlightPane { |
||||
Layout.columnSpan: 2 |
||||
Layout.fillWidth: true |
||||
padding: 0 |
||||
leftPadding: constants.paddingSmall |
||||
|
||||
RowLayout { |
||||
width: parent.width |
||||
Label { |
||||
text: root.address |
||||
font.family: FixedFont |
||||
Layout.fillWidth: true |
||||
} |
||||
ToolButton { |
||||
icon.source: '../../icons/share.png' |
||||
icon.color: 'transparent' |
||||
onClicked: { |
||||
var dialog = share.createObject(root, { 'title': qsTr('Address'), 'text': root.address }) |
||||
dialog.open() |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
Label { |
||||
text: qsTr('Label') |
||||
Layout.columnSpan: 2 |
||||
} |
||||
|
||||
TextHighlightPane { |
||||
id: labelContent |
||||
|
||||
property bool editmode: false |
||||
|
||||
Layout.columnSpan: 2 |
||||
Layout.fillWidth: true |
||||
padding: 0 |
||||
leftPadding: constants.paddingSmall |
||||
|
||||
RowLayout { |
||||
width: parent.width |
||||
Label { |
||||
visible: !labelContent.editmode |
||||
text: addressdetails.label |
||||
wrapMode: Text.Wrap |
||||
Layout.fillWidth: true |
||||
} |
||||
ToolButton { |
||||
visible: !labelContent.editmode |
||||
icon.source: '../../icons/pen.png' |
||||
icon.color: 'transparent' |
||||
onClicked: { |
||||
labelEdit.text = addressdetails.label |
||||
labelContent.editmode = true |
||||
} |
||||
} |
||||
TextField { |
||||
id: labelEdit |
||||
visible: labelContent.editmode |
||||
text: addressdetails.label |
||||
Layout.fillWidth: true |
||||
} |
||||
ToolButton { |
||||
visible: labelContent.editmode |
||||
icon.source: '../../icons/confirmed.png' |
||||
icon.color: 'transparent' |
||||
onClicked: { |
||||
labelContent.editmode = false |
||||
addressdetails.set_label(labelEdit.text) |
||||
} |
||||
} |
||||
ToolButton { |
||||
visible: labelContent.editmode |
||||
icon.source: '../../icons/delete.png' |
||||
icon.color: 'transparent' |
||||
onClicked: labelContent.editmode = false |
||||
} |
||||
} |
||||
} |
||||
|
||||
Label { |
||||
text: qsTr('Public keys') |
||||
Layout.columnSpan: 2 |
||||
} |
||||
|
||||
Repeater { |
||||
model: addressdetails.pubkeys |
||||
delegate: TextHighlightPane { |
||||
Layout.columnSpan: 2 |
||||
Layout.fillWidth: true |
||||
padding: 0 |
||||
leftPadding: constants.paddingSmall |
||||
RowLayout { |
||||
width: parent.width |
||||
Label { |
||||
text: modelData |
||||
Layout.fillWidth: true |
||||
wrapMode: Text.Wrap |
||||
font.family: FixedFont |
||||
} |
||||
ToolButton { |
||||
icon.source: '../../icons/share.png' |
||||
icon.color: 'transparent' |
||||
onClicked: { |
||||
var dialog = share.createObject(root, { 'title': qsTr('Public key'), 'text': modelData }) |
||||
dialog.open() |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
Label { |
||||
text: qsTr('Script type') |
||||
} |
||||
|
||||
Label { |
||||
text: addressdetails.scriptType |
||||
Layout.fillWidth: true |
||||
} |
||||
|
||||
Label { |
||||
text: qsTr('Balance') |
||||
} |
||||
|
||||
RowLayout { |
||||
Label { |
||||
font.family: FixedFont |
||||
text: Config.formatSats(addressdetails.balance) |
||||
} |
||||
Label { |
||||
color: Material.accentColor |
||||
text: Config.baseUnit |
||||
} |
||||
Label { |
||||
text: Daemon.fx.enabled |
||||
? '(' + Daemon.fx.fiatValue(addressdetails.balance) + ' ' + Daemon.fx.fiatCurrency + ')' |
||||
: '' |
||||
} |
||||
} |
||||
|
||||
Label { |
||||
text: qsTr('Derivation path') |
||||
} |
||||
|
||||
Label { |
||||
text: addressdetails.derivationPath |
||||
} |
||||
|
||||
Label { |
||||
text: qsTr('Frozen') |
||||
} |
||||
|
||||
Label { |
||||
text: addressdetails.isFrozen ? qsTr('Frozen') : qsTr('Not frozen') |
||||
} |
||||
|
||||
ColumnLayout { |
||||
Layout.columnSpan: 2 |
||||
|
||||
Button { |
||||
text: addressdetails.isFrozen ? qsTr('Unfreeze') : qsTr('Freeze') |
||||
onClicked: addressdetails.freeze(!addressdetails.isFrozen) |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
AddressDetails { |
||||
id: addressdetails |
||||
wallet: Daemon.currentWallet |
||||
address: root.address |
||||
onFrozenChanged: addressDetailsChanged() |
||||
onLabelChanged: addressDetailsChanged() |
||||
} |
||||
|
||||
Component { |
||||
id: share |
||||
GenericShareDialog {} |
||||
} |
||||
} |
||||
@ -0,0 +1,107 @@
|
||||
import QtQuick 2.6 |
||||
import QtQuick.Layouts 1.0 |
||||
import QtQuick.Controls 2.14 |
||||
import QtQuick.Controls.Material 2.0 |
||||
|
||||
Dialog { |
||||
id: dialog |
||||
|
||||
property string text |
||||
|
||||
title: '' |
||||
parent: Overlay.overlay |
||||
modal: true |
||||
standardButtons: Dialog.Ok |
||||
|
||||
width: parent.width |
||||
height: parent.height |
||||
|
||||
Overlay.modal: Rectangle { |
||||
color: "#aa000000" |
||||
} |
||||
|
||||
header: RowLayout { |
||||
width: dialog.width |
||||
Label { |
||||
Layout.fillWidth: true |
||||
text: dialog.title |
||||
visible: dialog.title |
||||
elide: Label.ElideRight |
||||
padding: constants.paddingXLarge |
||||
bottomPadding: 0 |
||||
font.bold: true |
||||
font.pixelSize: constants.fontSizeMedium |
||||
} |
||||
} |
||||
|
||||
ColumnLayout { |
||||
id: rootLayout |
||||
width: parent.width |
||||
spacing: constants.paddingMedium |
||||
|
||||
Rectangle { |
||||
height: 1 |
||||
Layout.fillWidth: true |
||||
color: Material.accentColor |
||||
} |
||||
|
||||
Image { |
||||
id: qr |
||||
Layout.alignment: Qt.AlignHCenter |
||||
Layout.topMargin: constants.paddingSmall |
||||
Layout.bottomMargin: constants.paddingSmall |
||||
|
||||
Rectangle { |
||||
property int size: 57 // should be qr pixel multiple |
||||
color: 'white' |
||||
x: (parent.width - size) / 2 |
||||
y: (parent.height - size) / 2 |
||||
width: size |
||||
height: size |
||||
|
||||
Image { |
||||
source: '../../../icons/electrum.png' |
||||
x: 1 |
||||
y: 1 |
||||
width: parent.width - 2 |
||||
height: parent.height - 2 |
||||
scale: 0.9 |
||||
} |
||||
} |
||||
} |
||||
|
||||
Rectangle { |
||||
height: 1 |
||||
Layout.fillWidth: true |
||||
color: Material.accentColor |
||||
} |
||||
|
||||
TextHighlightPane { |
||||
Layout.fillWidth: true |
||||
Label { |
||||
width: parent.width |
||||
text: dialog.text |
||||
wrapMode: Text.Wrap |
||||
} |
||||
} |
||||
|
||||
RowLayout { |
||||
Layout.fillWidth: true |
||||
Layout.alignment: Qt.AlignHCenter |
||||
Button { |
||||
text: qsTr('Copy') |
||||
icon.source: '../../../icons/copy_bw.png' |
||||
onClicked: AppController.textToClipboard(dialog.text) |
||||
} |
||||
Button { |
||||
text: qsTr('Share') |
||||
icon.source: '../../../icons/share.png' |
||||
onClicked: console.log('TODO') |
||||
} |
||||
} |
||||
} |
||||
|
||||
Component.onCompleted: { |
||||
qr.source = 'image://qrgen/' + dialog.text |
||||
} |
||||
} |
||||
@ -0,0 +1,10 @@
|
||||
import QtQuick 2.6 |
||||
import QtQuick.Layouts 1.0 |
||||
import QtQuick.Controls 2.0 |
||||
import QtQuick.Controls.Material 2.0 |
||||
|
||||
Pane { |
||||
background: Rectangle { |
||||
color: Qt.lighter(Material.background, 1.15) |
||||
} |
||||
} |
||||
@ -0,0 +1,113 @@
|
||||
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject |
||||
|
||||
from decimal import Decimal |
||||
|
||||
from electrum.logging import get_logger |
||||
from electrum.util import DECIMAL_POINT_DEFAULT |
||||
|
||||
from .qetransactionlistmodel import QEAddressTransactionListModel |
||||
from .qewallet import QEWallet |
||||
from .qetypes import QEAmount |
||||
|
||||
class QEAddressDetails(QObject): |
||||
def __init__(self, parent=None): |
||||
super().__init__(parent) |
||||
|
||||
_logger = get_logger(__name__) |
||||
|
||||
_wallet = None |
||||
_address = None |
||||
|
||||
_label = None |
||||
_frozen = False |
||||
_scriptType = None |
||||
_status = None |
||||
_balance = QEAmount() |
||||
_pubkeys = None |
||||
_privkey = None |
||||
_derivationPath = None |
||||
|
||||
_txlistmodel = None |
||||
|
||||
detailsChanged = pyqtSignal() |
||||
|
||||
walletChanged = pyqtSignal() |
||||
@pyqtProperty(QEWallet, notify=walletChanged) |
||||
def wallet(self): |
||||
return self._wallet |
||||
|
||||
@wallet.setter |
||||
def wallet(self, wallet: QEWallet): |
||||
if self._wallet != wallet: |
||||
self._wallet = wallet |
||||
self.walletChanged.emit() |
||||
|
||||
addressChanged = pyqtSignal() |
||||
@pyqtProperty(str, notify=addressChanged) |
||||
def address(self): |
||||
return self._address |
||||
|
||||
@address.setter |
||||
def address(self, address: str): |
||||
if self._address != address: |
||||
self._logger.debug('address changed') |
||||
self._address = address |
||||
self.addressChanged.emit() |
||||
self.update() |
||||
|
||||
@pyqtProperty(str, notify=detailsChanged) |
||||
def scriptType(self): |
||||
return self._scriptType |
||||
|
||||
@pyqtProperty(QEAmount, notify=detailsChanged) |
||||
def balance(self): |
||||
return self._balance |
||||
|
||||
@pyqtProperty('QStringList', notify=detailsChanged) |
||||
def pubkeys(self): |
||||
return self._pubkeys |
||||
|
||||
@pyqtProperty(str, notify=detailsChanged) |
||||
def derivationPath(self): |
||||
return self._derivationPath |
||||
|
||||
|
||||
frozenChanged = pyqtSignal() |
||||
@pyqtProperty(bool, notify=frozenChanged) |
||||
def isFrozen(self): |
||||
return self._frozen |
||||
|
||||
labelChanged = pyqtSignal() |
||||
@pyqtProperty(str, notify=labelChanged) |
||||
def label(self): |
||||
return self._label |
||||
|
||||
@pyqtSlot(bool) |
||||
def freeze(self, freeze: bool): |
||||
if freeze != self._frozen: |
||||
self._wallet.wallet.set_frozen_state_of_addresses([self._address], freeze=freeze) |
||||
self._frozen = freeze |
||||
self.frozenChanged.emit() |
||||
|
||||
@pyqtSlot(str) |
||||
def set_label(self, label: str): |
||||
if label != self._label: |
||||
self._wallet.wallet.set_label(self._address, label) |
||||
self._label = label |
||||
self.labelChanged.emit() |
||||
|
||||
def update(self): |
||||
if self._wallet is None: |
||||
self._logger.error('wallet undefined') |
||||
return |
||||
|
||||
self._frozen = self._wallet.wallet.is_frozen_address(self._address) |
||||
self.frozenChanged.emit() |
||||
|
||||
self._scriptType = self._wallet.wallet.get_txin_type(self._address) |
||||
self._label = self._wallet.wallet.get_label(self._address) |
||||
c, u, x = self._wallet.wallet.get_addr_balance(self._address) |
||||
self._balance = QEAmount(amount_sat=c + u + x) |
||||
self._pubkeys = self._wallet.wallet.get_public_keys(self._address) |
||||
self._derivationPath = self._wallet.wallet.get_address_path_str(self._address) |
||||
self.detailsChanged.emit() |
||||
Loading…
Reference in new issue