Browse Source

qml: styling addresses/address details

master
Sander van Grieken 3 years ago
parent
commit
18131e5a38
  1. 356
      electrum/gui/qml/components/AddressDetails.qml
  2. 36
      electrum/gui/qml/components/Addresses.qml

356
electrum/gui/qml/components/AddressDetails.qml

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

36
electrum/gui/qml/components/Addresses.qml

@ -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
Rectangle {
Layout.preferredHeight: 1
Layout.fillWidth: true
color: Material.accentColor
}
Label { Label {
padding: constants.paddingMedium Layout.topMargin: constants.paddingLarge
Layout.leftMargin: constants.paddingLarge
text: root.section + ' ' + qsTr('addresses') text: root.section + ' ' + qsTr('addresses')
font.bold: true font.pixelSize: constants.fontSizeLarge
font.pixelSize: constants.fontSizeMedium color: Material.accentColor
} }
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

Loading…
Cancel
Save