Browse Source

qml: styling TxDetails

master
Sander van Grieken 3 years ago
parent
commit
5fd8b63091
  1. 598
      electrum/gui/qml/components/TxDetails.qml

598
electrum/gui/qml/components/TxDetails.qml

@ -11,8 +11,7 @@ Pane {
id: root id: root
width: parent.width width: parent.width
height: parent.height height: parent.height
padding: 0
// property string title: qsTr("Transaction details")
property string txid property string txid
property string rawtx property string rawtx
@ -25,374 +24,361 @@ Pane {
app.stack.pop() app.stack.pop()
} }
property QtObject menu: Menu { ColumnLayout {
id: menu
parent: Overlay.overlay
dim: true
Overlay.modeless: Rectangle {
color: "#44000000"
}
MenuItem {
icon.color: 'transparent'
action: Action {
text: qsTr('Export')
onTriggered: {
var dialog = exportTxDialog.createObject(root, { txdetails: txdetails })
dialog.open()
}
}
}
MenuItem {
icon.color: 'transparent'
action: Action {
text: qsTr('Bump fee')
enabled: txdetails.canBump
onTriggered: {
var dialog = bumpFeeDialog.createObject(root, { txid: root.txid })
dialog.open()
}
}
}
MenuItem {
icon.color: 'transparent'
action: Action {
text: qsTr('Child pays for parent')
enabled: txdetails.canCpfp
onTriggered: notificationPopup.show('Not implemented')
}
}
MenuItem {
icon.color: 'transparent'
action: Action {
text: qsTr('Cancel double-spend')
enabled: txdetails.canCancel
onTriggered: notificationPopup.show('Not implemented')
}
}
MenuItem {
icon.color: 'transparent'
action: Action {
text: qsTr('Remove')
enabled: txdetails.canRemove
onTriggered: txdetails.removeLocalTx()
}
}
}
Flickable {
anchors.fill: parent anchors.fill: parent
contentHeight: rootLayout.height spacing: 0
clip: true
interactive: height < contentHeight
GridLayout {
id: rootLayout
width: parent.width
columns: 2
Label {
Layout.columnSpan: 2
text: qsTr('Transaction Details')
font.pixelSize: constants.fontSizeLarge
color: Material.accentColor
}
Rectangle { Flickable {
Layout.columnSpan: 2 Layout.fillWidth: true
Layout.fillWidth: true Layout.fillHeight: true
height: 1 Layout.topMargin: constants.paddingLarge
color: Material.accentColor Layout.leftMargin: constants.paddingLarge
} Layout.rightMargin: constants.paddingLarge
contentHeight: contentLayout.height
clip: true
interactive: height < contentHeight
GridLayout {
id: contentLayout
width: parent.width
columns: 2
RowLayout {
Layout.fillWidth: true
Layout.columnSpan: 2
visible: txdetails.isUnrelated
Image {
source: '../../icons/warning.png'
Layout.preferredWidth: constants.iconSizeSmall
Layout.preferredHeight: constants.iconSizeSmall
}
Label { Label {
text: qsTr('Transaction is unrelated to this wallet') Layout.columnSpan: 2
text: qsTr('Transaction Details')
font.pixelSize: constants.fontSizeLarge
color: Material.accentColor color: Material.accentColor
} }
}
Label { Rectangle {
Layout.fillWidth: true Layout.columnSpan: 2
visible: !txdetails.isUnrelated && txdetails.lnAmount.satsInt == 0 Layout.fillWidth: true
text: txdetails.amount.satsInt > 0 height: 1
? qsTr('Amount received') color: Material.accentColor
: qsTr('Amount sent') }
color: Material.accentColor
}
Label {
Layout.fillWidth: true
visible: !txdetails.isUnrelated && txdetails.lnAmount.satsInt != 0
text: txdetails.lnAmount.satsInt > 0
? qsTr('Amount received in channels')
: qsTr('Amount withdrawn from channels')
color: Material.accentColor
wrapMode: Text.Wrap
}
RowLayout { RowLayout {
visible: !txdetails.isUnrelated Layout.fillWidth: true
Layout.fillWidth: true Layout.columnSpan: 2
Label { visible: txdetails.isUnrelated
visible: txdetails.lnAmount.satsInt == 0 Image {
text: Config.formatSats(txdetails.amount) source: '../../icons/warning.png'
font.family: FixedFont Layout.preferredWidth: constants.iconSizeSmall
Layout.preferredHeight: constants.iconSizeSmall
}
Label {
text: qsTr('Transaction is unrelated to this wallet')
color: Material.accentColor
}
} }
Label { Label {
visible: txdetails.lnAmount.satsInt != 0 Layout.fillWidth: true
text: Config.formatSats(txdetails.lnAmount) visible: !txdetails.isUnrelated && txdetails.lnAmount.satsInt == 0
font.family: FixedFont text: txdetails.amount.satsInt > 0
? qsTr('Amount received')
: qsTr('Amount sent')
color: Material.accentColor
} }
Label { Label {
text: Config.baseUnit Layout.fillWidth: true
visible: !txdetails.isUnrelated && txdetails.lnAmount.satsInt != 0
text: txdetails.lnAmount.satsInt > 0
? qsTr('Amount received in channels')
: qsTr('Amount withdrawn from channels')
color: Material.accentColor color: Material.accentColor
wrapMode: Text.Wrap
} }
}
Item { RowLayout {
visible: !txdetails.isUnrelated && Daemon.fx.enabled; Layout.preferredWidth: 1; Layout.preferredHeight: 1 visible: !txdetails.isUnrelated
} Layout.fillWidth: true
Label {
visible: txdetails.lnAmount.satsInt == 0
text: Config.formatSats(txdetails.amount)
font.family: FixedFont
}
Label {
visible: txdetails.lnAmount.satsInt != 0
text: Config.formatSats(txdetails.lnAmount)
font.family: FixedFont
}
Label {
text: Config.baseUnit
color: Material.accentColor
}
}
Label { Item {
visible: !txdetails.isUnrelated && Daemon.fx.enabled && txdetails.lnAmount.satsInt == 0 visible: !txdetails.isUnrelated && Daemon.fx.enabled; Layout.preferredWidth: 1; Layout.preferredHeight: 1
text: Daemon.fx.fiatValue(txdetails.amount, false) + ' ' + Daemon.fx.fiatCurrency }
}
Label { Label {
visible: !txdetails.isUnrelated && Daemon.fx.enabled && txdetails.lnAmount.satsInt != 0 visible: !txdetails.isUnrelated && Daemon.fx.enabled && txdetails.lnAmount.satsInt == 0
text: Daemon.fx.fiatValue(txdetails.lnAmount, false) + ' ' + Daemon.fx.fiatCurrency text: Daemon.fx.fiatValue(txdetails.amount, false) + ' ' + Daemon.fx.fiatCurrency
} }
Label {
visible: !txdetails.isUnrelated && Daemon.fx.enabled && txdetails.lnAmount.satsInt != 0
text: Daemon.fx.fiatValue(txdetails.lnAmount, false) + ' ' + Daemon.fx.fiatCurrency
}
Label {
Layout.fillWidth: true
visible: txdetails.fee.satsInt != 0
text: qsTr('Transaction fee')
color: Material.accentColor
}
RowLayout {
Layout.fillWidth: true
visible: txdetails.fee.satsInt != 0
Label { Label {
text: Config.formatSats(txdetails.fee) Layout.fillWidth: true
font.family: FixedFont visible: txdetails.fee.satsInt != 0
text: qsTr('Transaction fee')
color: Material.accentColor
} }
RowLayout {
Layout.fillWidth: true
visible: txdetails.fee.satsInt != 0
Label {
text: Config.formatSats(txdetails.fee)
font.family: FixedFont
}
Label {
text: Config.baseUnit
color: Material.accentColor
}
}
Label { Label {
text: Config.baseUnit text: qsTr('Status')
color: Material.accentColor color: Material.accentColor
} }
}
Label {
text: qsTr('Status')
color: Material.accentColor
}
Label { Label {
Layout.fillWidth: true Layout.fillWidth: true
text: txdetails.status text: txdetails.status
} }
Label { Label {
text: qsTr('Mempool depth') text: qsTr('Mempool depth')
color: Material.accentColor color: Material.accentColor
visible: !txdetails.isMined && txdetails.canBroadcast visible: !txdetails.isMined && txdetails.canBroadcast
} }
Label { Label {
text: txdetails.mempoolDepth text: txdetails.mempoolDepth
visible: !txdetails.isMined && txdetails.canBroadcast visible: !txdetails.isMined && txdetails.canBroadcast
} }
Label { Label {
visible: txdetails.isMined visible: txdetails.isMined
text: qsTr('Date') text: qsTr('Date')
color: Material.accentColor color: Material.accentColor
} }
Label { Label {
visible: txdetails.isMined visible: txdetails.isMined
text: txdetails.date text: txdetails.date
} }
Label { Label {
visible: txdetails.isMined visible: txdetails.isMined
text: qsTr('Height') text: qsTr('Height')
color: Material.accentColor color: Material.accentColor
} }
Label { Label {
visible: txdetails.isMined visible: txdetails.isMined
text: txdetails.height text: txdetails.height
} }
Label { Label {
visible: txdetails.isMined visible: txdetails.isMined
text: qsTr('TX index') text: qsTr('TX index')
color: Material.accentColor color: Material.accentColor
} }
Label { Label {
visible: txdetails.isMined visible: txdetails.isMined
text: txdetails.txpos text: txdetails.txpos
} }
Label { Label {
text: qsTr('Label') text: qsTr('Label')
Layout.columnSpan: 2 Layout.columnSpan: 2
color: Material.accentColor color: Material.accentColor
} }
TextHighlightPane { TextHighlightPane {
id: labelContent id: labelContent
property bool editmode: false property bool editmode: false
Layout.columnSpan: 2 Layout.columnSpan: 2
Layout.fillWidth: true Layout.fillWidth: true
padding: 0 padding: 0
leftPadding: constants.paddingSmall leftPadding: constants.paddingSmall
RowLayout { RowLayout {
width: parent.width width: parent.width
Label { Label {
visible: !labelContent.editmode visible: !labelContent.editmode
text: txdetails.label text: txdetails.label
wrapMode: Text.Wrap wrapMode: Text.Wrap
Layout.fillWidth: true Layout.fillWidth: true
font.pixelSize: constants.fontSizeLarge font.pixelSize: constants.fontSizeLarge
}
ToolButton {
visible: !labelContent.editmode
icon.source: '../../icons/pen.png'
icon.color: 'transparent'
onClicked: {
labelEdit.text = txdetails.label
labelContent.editmode = true
labelEdit.focus = true
} }
} ToolButton {
TextField { visible: !labelContent.editmode
id: labelEdit icon.source: '../../icons/pen.png'
visible: labelContent.editmode icon.color: 'transparent'
text: txdetails.label onClicked: {
font.pixelSize: constants.fontSizeLarge labelEdit.text = txdetails.label
Layout.fillWidth: true labelContent.editmode = true
} labelEdit.focus = true
ToolButton { }
visible: labelContent.editmode
icon.source: '../../icons/confirmed.png'
icon.color: 'transparent'
onClicked: {
labelContent.editmode = false
txdetails.set_label(labelEdit.text)
} }
} TextField {
ToolButton { id: labelEdit
visible: labelContent.editmode visible: labelContent.editmode
icon.source: '../../icons/closebutton.png' text: txdetails.label
icon.color: 'transparent' font.pixelSize: constants.fontSizeLarge
onClicked: labelContent.editmode = false Layout.fillWidth: true
} }
} ToolButton {
} visible: labelContent.editmode
icon.source: '../../icons/confirmed.png'
Label { icon.color: 'transparent'
text: qsTr('Transaction ID') onClicked: {
Layout.columnSpan: 2 labelContent.editmode = false
color: Material.accentColor txdetails.set_label(labelEdit.text)
} }
}
TextHighlightPane { ToolButton {
Layout.columnSpan: 2 visible: labelContent.editmode
Layout.fillWidth: true icon.source: '../../icons/closebutton.png'
padding: 0 icon.color: 'transparent'
leftPadding: constants.paddingSmall onClicked: labelContent.editmode = false
RowLayout {
width: parent.width
Label {
text: txdetails.txid
font.pixelSize: constants.fontSizeLarge
font.family: FixedFont
Layout.fillWidth: true
wrapMode: Text.Wrap
}
ToolButton {
icon.source: '../../icons/share.png'
icon.color: 'transparent'
enabled: txdetails.txid
onClicked: {
var dialog = app.genericShareDialog.createObject(root,
{ title: qsTr('Transaction ID'), text: txdetails.txid }
)
dialog.open()
} }
} }
} }
}
Label { Label {
text: qsTr('Outputs') text: qsTr('Transaction ID')
Layout.columnSpan: 2 Layout.columnSpan: 2
color: Material.accentColor color: Material.accentColor
} }
Repeater { TextHighlightPane {
model: txdetails.outputs
delegate: TextHighlightPane {
Layout.columnSpan: 2 Layout.columnSpan: 2
Layout.fillWidth: true Layout.fillWidth: true
padding: 0 padding: 0
leftPadding: constants.paddingSmall leftPadding: constants.paddingSmall
RowLayout { RowLayout {
width: parent.width width: parent.width
Label { Label {
text: modelData.address text: txdetails.txid
Layout.fillWidth: true
wrapMode: Text.Wrap
font.pixelSize: constants.fontSizeLarge font.pixelSize: constants.fontSizeLarge
font.family: FixedFont font.family: FixedFont
color: modelData.is_mine ? constants.colorMine : Material.foreground Layout.fillWidth: true
} wrapMode: Text.Wrap
Label {
text: Config.formatSats(modelData.value)
font.pixelSize: constants.fontSizeMedium
font.family: FixedFont
} }
Label { ToolButton {
text: Config.baseUnit icon.source: '../../icons/share.png'
font.pixelSize: constants.fontSizeMedium icon.color: 'transparent'
color: Material.accentColor enabled: txdetails.txid
onClicked: {
var dialog = app.genericShareDialog.createObject(root,
{ title: qsTr('Transaction ID'), text: txdetails.txid }
)
dialog.open()
}
} }
} }
} }
}
RowLayout { Label {
visible: !txdetails.isMined && !txdetails.isUnrelated text: qsTr('Outputs')
Layout.columnSpan: 2 Layout.columnSpan: 2
Button { color: Material.accentColor
text: qsTr('Sign')
enabled: txdetails.canSign
onClicked: txdetails.sign()
} }
Button {
text: qsTr('Broadcast') Repeater {
enabled: txdetails.canBroadcast model: txdetails.outputs
onClicked: txdetails.broadcast() delegate: TextHighlightPane {
Layout.columnSpan: 2
Layout.fillWidth: true
padding: 0
leftPadding: constants.paddingSmall
RowLayout {
width: parent.width
Label {
text: modelData.address
Layout.fillWidth: true
wrapMode: Text.Wrap
font.pixelSize: constants.fontSizeLarge
font.family: FixedFont
color: modelData.is_mine ? constants.colorMine : Material.foreground
}
Label {
text: Config.formatSats(modelData.value)
font.pixelSize: constants.fontSizeMedium
font.family: FixedFont
}
Label {
text: Config.baseUnit
font.pixelSize: constants.fontSizeMedium
color: Material.accentColor
}
}
}
} }
} }
}
RowLayout {
visible: !txdetails.isMined && !txdetails.isUnrelated
FlatButton {
Layout.fillWidth: true
Layout.preferredWidth: 1
text: qsTr('Sign')
enabled: txdetails.canSign
onClicked: txdetails.sign()
}
FlatButton {
Layout.fillWidth: true
Layout.preferredWidth: 1
text: qsTr('Broadcast')
enabled: txdetails.canBroadcast
onClicked: txdetails.broadcast()
}
}
FlatButton {
Layout.fillWidth: true
text: qsTr('Export')
onClicked: {
var dialog = exportTxDialog.createObject(root, { txdetails: txdetails })
dialog.open()
}
} }
FlatButton {
Layout.fillWidth: true
text: qsTr('Bump fee')
visible: txdetails.canBump
onClicked: {
var dialog = bumpFeeDialog.createObject(root, { txid: root.txid })
dialog.open()
}
}
FlatButton {
Layout.fillWidth: true
text: qsTr('Remove')
visible: txdetails.canRemove
onClicked: txdetails.removeLocalTx()
}
} }
TxDetails { TxDetails {

Loading…
Cancel
Save