1
0

qml: styling addresses/address details

This commit is contained in:
Sander van Grieken
2022-11-11 16:00:11 +01:00
parent ff0f180fab
commit 18131e5a38
2 changed files with 197 additions and 223 deletions

View File

@@ -11,247 +11,229 @@ Pane {
id: root id: root
width: parent.width width: parent.width
height: parent.height height: parent.height
padding: 0
property string address property string address
property string title: qsTr("Address details")
signal addressDetailsChanged signal addressDetailsChanged
property QtObject menu: Menu { ColumnLayout {
id: menu
MenuItem {
icon.color: 'transparent'
action: Action {
text: qsTr('Spend from')
icon.source: '../../icons/tab_send.png'
enabled: false
}
}
MenuItem {
icon.color: 'transparent'
action: Action {
text: qsTr('Sign/Verify')
icon.source: '../../icons/key.png'
enabled: false
}
}
MenuItem {
icon.color: 'transparent'
action: Action {
text: qsTr('Encrypt/Decrypt')
icon.source: '../../icons/mail_icon.png'
enabled: false
}
}
MenuItem {
icon.color: 'transparent'
action: Action {
text: addressdetails.isFrozen ? qsTr('Unfreeze') : qsTr('Freeze')
onTriggered: addressdetails.freeze(!addressdetails.isFrozen)
icon.source: '../../icons/seal.png'
}
}
}
Flickable {
anchors.fill: parent anchors.fill: parent
contentHeight: rootLayout.height spacing: 0
clip:true
interactive: height < contentHeight
GridLayout { Flickable {
id: rootLayout Layout.preferredWidth: parent.width
width: parent.width Layout.fillHeight: true
columns: 2
Label { leftMargin: constants.paddingLarge
text: qsTr('Address') rightMargin: constants.paddingLarge
Layout.columnSpan: 2 topMargin: constants.paddingLarge
color: Material.accentColor
}
TextHighlightPane { contentHeight: rootLayout.height
Layout.columnSpan: 2 clip:true
Layout.fillWidth: true interactive: height < contentHeight
padding: 0
leftPadding: constants.paddingSmall
RowLayout { GridLayout {
width: parent.width id: rootLayout
Label { width: parent.width
text: root.address
font.pixelSize: constants.fontSizeLarge columns: 2
font.family: FixedFont
Layout.fillWidth: true Label {
wrapMode: Text.Wrap text: qsTr('Address')
} Layout.columnSpan: 2
ToolButton { color: Material.accentColor
icon.source: '../../icons/share.png'
icon.color: 'transparent'
onClicked: {
var dialog = app.genericShareDialog.createObject(root,
{ title: qsTr('Address'), text: root.address }
)
dialog.open()
}
}
} }
}
Label { TextHighlightPane {
text: qsTr('Label')
Layout.columnSpan: 2
color: Material.accentColor
}
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
font.pixelSize: constants.fontSizeLarge
}
ToolButton {
visible: !labelContent.editmode
icon.source: '../../icons/pen.png'
icon.color: 'transparent'
onClicked: {
labelEdit.text = addressdetails.label
labelContent.editmode = true
labelEdit.focus = true
}
}
TextField {
id: labelEdit
visible: labelContent.editmode
text: addressdetails.label
font.pixelSize: constants.fontSizeLarge
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/closebutton.png'
icon.color: 'transparent'
onClicked: labelContent.editmode = false
}
}
}
Label {
text: qsTr('Public keys')
Layout.columnSpan: 2
color: Material.accentColor
}
Repeater {
model: addressdetails.pubkeys
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 text: root.address
Layout.fillWidth: true
wrapMode: Text.Wrap
font.pixelSize: constants.fontSizeLarge font.pixelSize: constants.fontSizeLarge
font.family: FixedFont font.family: FixedFont
Layout.fillWidth: true
wrapMode: Text.Wrap
} }
ToolButton { ToolButton {
icon.source: '../../icons/share.png' icon.source: '../../icons/share.png'
icon.color: 'transparent' icon.color: 'transparent'
onClicked: { onClicked: {
var dialog = app.genericShareDialog.createObject(root, var dialog = app.genericShareDialog.createObject(root,
{ title: qsTr('Public key'), text: modelData } { title: qsTr('Address'), text: root.address }
) )
dialog.open() dialog.open()
} }
} }
} }
} }
}
Label {
text: qsTr('Script type')
color: Material.accentColor
}
Label {
text: addressdetails.scriptType
Layout.fillWidth: true
}
Label {
text: qsTr('Balance')
color: Material.accentColor
}
RowLayout {
Label {
font.family: FixedFont
text: Config.formatSats(addressdetails.balance)
}
Label { Label {
text: qsTr('Label')
Layout.columnSpan: 2
color: Material.accentColor color: Material.accentColor
text: Config.baseUnit
} }
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
font.pixelSize: constants.fontSizeLarge
}
ToolButton {
visible: !labelContent.editmode
icon.source: '../../icons/pen.png'
icon.color: 'transparent'
onClicked: {
labelEdit.text = addressdetails.label
labelContent.editmode = true
labelEdit.focus = true
}
}
TextField {
id: labelEdit
visible: labelContent.editmode
text: addressdetails.label
font.pixelSize: constants.fontSizeLarge
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/closebutton.png'
icon.color: 'transparent'
onClicked: labelContent.editmode = false
}
}
}
Label { Label {
text: Daemon.fx.enabled text: qsTr('Public keys')
? '(' + Daemon.fx.fiatValue(addressdetails.balance) + ' ' + Daemon.fx.fiatCurrency + ')' Layout.columnSpan: 2
: '' color: Material.accentColor
}
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.pixelSize: constants.fontSizeLarge
font.family: FixedFont
}
ToolButton {
icon.source: '../../icons/share.png'
icon.color: 'transparent'
onClicked: {
var dialog = app.genericShareDialog.createObject(root,
{ title: qsTr('Public key'), text: modelData }
)
dialog.open()
}
}
}
}
}
Label {
text: qsTr('Script type')
color: Material.accentColor
}
Label {
text: addressdetails.scriptType
Layout.fillWidth: true
}
Label {
text: qsTr('Balance')
color: Material.accentColor
}
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('Transactions')
color: Material.accentColor
}
Label {
text: addressdetails.numTx
}
Label {
text: qsTr('Derivation path')
color: Material.accentColor
}
Label {
text: addressdetails.derivationPath
}
Label {
text: qsTr('Frozen')
color: Material.accentColor
}
Label {
text: addressdetails.isFrozen ? qsTr('Frozen') : qsTr('Not frozen')
} }
} }
}
Label { FlatButton {
text: qsTr('Transactions') Layout.fillWidth: true
color: Material.accentColor text: addressdetails.isFrozen ? qsTr('Unfreeze address') : qsTr('Freeze address')
} onClicked: addressdetails.freeze(!addressdetails.isFrozen)
icon.source: '../../icons/seal.png'
Label {
text: addressdetails.numTx
}
Label {
text: qsTr('Derivation path')
color: Material.accentColor
}
Label {
text: addressdetails.derivationPath
}
Label {
text: qsTr('Frozen')
color: Material.accentColor
}
Label {
text: addressdetails.isFrozen ? qsTr('Frozen') : qsTr('Not frozen')
}
} }
} }

View File

@@ -9,7 +9,6 @@ Pane {
id: rootItem id: rootItem
padding: 0 padding: 0
width: parent.width width: parent.width
property string title: Daemon.currentWallet.name + ' - ' + qsTr('Addresses')
ColumnLayout { ColumnLayout {
id: layout id: layout
@@ -50,17 +49,15 @@ Pane {
ColumnLayout { ColumnLayout {
id: delegateLayout id: delegateLayout
width: parent.width
spacing: 0 spacing: 0
x: constants.paddingMedium
width: parent.width - 2*constants.paddingMedium
Item {
Layout.preferredWidth: 1
Layout.preferredHeight: constants.paddingTiny
}
GridLayout { GridLayout {
columns: 2 columns: 2
Layout.topMargin: constants.paddingSmall
Layout.leftMargin: constants.paddingLarge
Layout.rightMargin: constants.paddingLarge
Label { Label {
id: indexLabel id: indexLabel
font.bold: true font.bold: true
@@ -137,30 +134,25 @@ Pane {
Component { Component {
id: sectionDelegate id: sectionDelegate
Rectangle { Item {
id: root id: root
width: ListView.view.width width: ListView.view.width
height: childrenRect.height height: childrenRect.height
color: 'transparent'
required property string section required property string section
RowLayout { ColumnLayout {
x: constants.paddingMedium width: parent.width
width: parent.width - 2 * constants.paddingMedium Label {
Layout.topMargin: constants.paddingLarge
Rectangle { Layout.leftMargin: constants.paddingLarge
Layout.preferredHeight: 1 text: root.section + ' ' + qsTr('addresses')
Layout.fillWidth: true font.pixelSize: constants.fontSizeLarge
color: Material.accentColor color: Material.accentColor
} }
Label {
padding: constants.paddingMedium
text: root.section + ' ' + qsTr('addresses')
font.bold: true
font.pixelSize: constants.fontSizeMedium
}
Rectangle { Rectangle {
Layout.leftMargin: constants.paddingLarge
Layout.rightMargin: constants.paddingLarge
Layout.preferredHeight: 1 Layout.preferredHeight: 1
Layout.fillWidth: true Layout.fillWidth: true
color: Material.accentColor color: Material.accentColor