Browse Source

use configured units everywhere

patch-4
Sander van Grieken 3 years ago
parent
commit
a75960a70d
  1. 41
      electrum/gui/qml/components/BalanceSummary.qml
  2. 16
      electrum/gui/qml/components/History.qml
  3. 135
      electrum/gui/qml/components/Receive.qml
  4. 20
      electrum/gui/qml/components/Send.qml

41
electrum/gui/qml/components/BalanceSummary.qml

@ -2,30 +2,55 @@ import QtQuick 2.6
import QtQuick.Layouts 1.0 import QtQuick.Layouts 1.0
import QtQuick.Controls 2.0 import QtQuick.Controls 2.0
Item { Frame {
id: root
height: layout.height height: layout.height
property string formattedBalance
property string formattedUnconfirmed
function setBalances() {
root.formattedBalance = Config.formatSats(Daemon.currentWallet.confirmedBalance, true)
root.formattedUnconfirmed = Config.formatSats(Daemon.currentWallet.unconfirmedBalance, true)
}
GridLayout { GridLayout {
id: layout id: layout
columns: 3 columns: 3
Label { Label {
id: balance
Layout.columnSpan: 3 Layout.columnSpan: 3
font.pointSize: 14 font.pixelSize: constants.fontSizeLarge
text: 'Balance: ' + Daemon.currentWallet.confirmedBalance //'5.6201 mBTC' text: 'Balance: ' + formattedBalance
} }
Label { Label {
font.pointSize: 8 id: confirmed
text: 'Confirmed: ' + Daemon.currentWallet.confirmedBalance font.pixelSize: constants.fontSizeMedium
text: 'Confirmed: ' + formattedBalance
} }
Label { Label {
font.pointSize: 8 id: unconfirmed
text: 'Unconfirmed: ' + Daemon.currentWallet.unconfirmedBalance font.pixelSize: constants.fontSizeMedium
text: 'Unconfirmed: ' + formattedUnconfirmed
} }
Label { Label {
font.pointSize: 8 id: lightning
font.pixelSize: constants.fontSizeSmall
text: 'Lightning: ?' text: 'Lightning: ?'
} }
} }
Connections {
target: Config
function onBaseUnitChanged() { setBalances() }
function onThousandsSeparatorChanged() { setBalances() }
}
Connections {
target: Daemon
function onWalletLoaded() { setBalances() }
}
Component.onCompleted: setBalances()
} }

16
electrum/gui/qml/components/History.qml

@ -59,8 +59,9 @@ Pane {
color: model.label !== '' ? Material.accentColor : 'gray' color: model.label !== '' ? Material.accentColor : 'gray'
} }
Label { Label {
id: valueLabel
font.pixelSize: 15 font.pixelSize: 15
text: model.bc_value text: Config.formatSats(model.bc_value)
font.bold: true font.bold: true
color: model.incoming ? "#ff80ff80" : "#ffff8080" color: model.incoming ? "#ff80ff80" : "#ffff8080"
} }
@ -112,6 +113,19 @@ Pane {
} }
} }
// as the items in the model are not bindings to QObjects,
// hook up events that might change the appearance
Connections {
target: Config
function onBaseUnitChanged() {
valueLabel.text = Config.formatSats(model.bc_value)
}
function onThousandsSeparatorChanged() {
valueLabel.text = Config.formatSats(model.bc_value)
}
}
} // delegate } // delegate
} }

135
electrum/gui/qml/components/Receive.qml

@ -14,7 +14,7 @@ Pane {
width: parent.width width: parent.width
rowSpacing: 10 rowSpacing: 10
columnSpacing: 10 columnSpacing: 10
columns: 3 columns: 4
Label { Label {
text: qsTr('Message') text: qsTr('Message')
@ -22,8 +22,7 @@ Pane {
TextField { TextField {
id: message id: message
onTextChanged: img.source = 'image://qrgen/' + text Layout.columnSpan: 3
Layout.columnSpan: 2
Layout.fillWidth: true Layout.fillWidth: true
} }
@ -31,28 +30,25 @@ Pane {
text: qsTr('Requested Amount') text: qsTr('Requested Amount')
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
Layout.preferredWidth: 50 // trigger wordwrap Layout.preferredWidth: 50 // trigger wordwrap
Layout.rightMargin: constants.paddingXLarge
Layout.rowSpan: 2
} }
TextField { TextField {
id: amount id: amount
Layout.fillWidth: true
} }
Item { Label {
Layout.rowSpan: 3 text: Config.baseUnit
width: img.width color: Material.accentColor
height: img.height
Image {
id: img
cache: false
anchors {
top: parent.top
left: parent.left
}
source: 'image://qrgen/test'
}
} }
ColumnLayout {
Layout.rowSpan: 2
Layout.preferredWidth: rootItem.width /3
Layout.leftMargin: constants.paddingXLarge
Label { Label {
text: qsTr('Expires after') text: qsTr('Expires after')
Layout.fillWidth: false Layout.fillWidth: false
@ -60,24 +56,87 @@ Pane {
ComboBox { ComboBox {
id: expires id: expires
Layout.fillWidth: true
textRole: 'text' textRole: 'text'
valueRole: 'value' valueRole: 'value'
model: ListModel { model: ListModel {
id: expiresmodel id: expiresmodel
Component.onCompleted: { Component.onCompleted: {
// we need to fill the model like this, as ListElement can't evaluate script // we need to fill the model like this, as ListElement can't evaluate script
expiresmodel.append({'text': qsTr('Never'), 'value': 0})
expiresmodel.append({'text': qsTr('10 minutes'), 'value': 10*60}) expiresmodel.append({'text': qsTr('10 minutes'), 'value': 10*60})
expiresmodel.append({'text': qsTr('1 hour'), 'value': 60*60}) expiresmodel.append({'text': qsTr('1 hour'), 'value': 60*60})
expiresmodel.append({'text': qsTr('1 day'), 'value': 24*60*60}) expiresmodel.append({'text': qsTr('1 day'), 'value': 24*60*60})
expiresmodel.append({'text': qsTr('1 week'), 'value': 7*24*60*60}) expiresmodel.append({'text': qsTr('1 week'), 'value': 7*24*60*60})
expiresmodel.append({'text': qsTr('1 month'), 'value': 31*7*24*60*60})
expiresmodel.append({'text': qsTr('Never'), 'value': 0})
expires.currentIndex = 0 expires.currentIndex = 0
} }
} }
} }
}
TextField {
id: amountFiat
Layout.fillWidth: true
}
Label {
text: qsTr('EUR')
color: Material.accentColor
}
RowLayout {
Layout.columnSpan: 4
Layout.alignment: Qt.AlignHCenter
CheckBox {
id: cb_onchain
text: qsTr('Onchain')
checked: true
contentItem: RowLayout {
Text {
text: cb_onchain.text
font: cb_onchain.font
opacity: enabled ? 1.0 : 0.3
color: Material.foreground
verticalAlignment: Text.AlignVCenter
leftPadding: cb_onchain.indicator.width + cb_onchain.spacing
}
Image {
x: 16
Layout.preferredWidth: 16
Layout.preferredHeight: 16
source: '../../icons/bitcoin.png'
}
}
}
CheckBox {
id: cb_lightning
text: qsTr('Lightning')
enabled: false
contentItem: RowLayout {
Text {
text: cb_lightning.text
font: cb_lightning.font
opacity: enabled ? 1.0 : 0.3
color: Material.foreground
verticalAlignment: Text.AlignVCenter
leftPadding: cb_lightning.indicator.width + cb_lightning.spacing
}
Image {
x: 16
Layout.preferredWidth: 16
Layout.preferredHeight: 16
source: '../../icons/lightning.png'
}
}
}
}
Button { Button {
Layout.columnSpan: 2 Layout.columnSpan: 4
Layout.alignment: Qt.AlignHCenter
text: qsTr('Create Request') text: qsTr('Create Request')
onClicked: { onClicked: {
createRequest() createRequest()
@ -148,6 +207,12 @@ Pane {
columns: 5 columns: 5
Rectangle {
Layout.columnSpan: 5
Layout.fillWidth: true
Layout.preferredHeight: constants.paddingTiny
color: 'transparent'
}
Image { Image {
Layout.rowSpan: 2 Layout.rowSpan: 2
Layout.preferredWidth: 32 Layout.preferredWidth: 32
@ -166,7 +231,8 @@ Pane {
font.pixelSize: constants.fontSizeSmall font.pixelSize: constants.fontSizeSmall
} }
Label { Label {
text: model.amount id: amount
text: Config.formatSats(model.amount, true)
font.pixelSize: constants.fontSizeSmall font.pixelSize: constants.fontSizeSmall
} }
@ -187,9 +253,26 @@ Pane {
text: model.status text: model.status
font.pixelSize: constants.fontSizeSmall font.pixelSize: constants.fontSizeSmall
} }
Rectangle {
Layout.columnSpan: 5
Layout.fillWidth: true
Layout.preferredHeight: constants.paddingTiny
color: 'transparent'
}
}
Connections {
target: Config
function onBaseUnitChanged() {
amount.text = Config.formatSats(model.amount, true)
}
function onThousandsSeparatorChanged() {
amount.text = Config.formatSats(model.amount, true)
} }
} }
}
add: Transition { add: Transition {
NumberAnimation { properties: 'y'; from: -50; duration: 300 } NumberAnimation { properties: 'y'; from: -50; duration: 300 }
NumberAnimation { properties: 'opacity'; from: 0; to: 1.0; duration: 700 } NumberAnimation { properties: 'opacity'; from: 0; to: 1.0; duration: 700 }
@ -198,12 +281,20 @@ Pane {
NumberAnimation { properties: 'y'; duration: 100 } NumberAnimation { properties: 'y'; duration: 100 }
NumberAnimation { properties: 'opacity'; to: 1.0; duration: 700 * (1-from) } NumberAnimation { properties: 'opacity'; to: 1.0; duration: 700 * (1-from) }
} }
ScrollBar.vertical: ScrollBar {
parent: parent.parent
anchors.top: parent.top
anchors.left: parent.right
anchors.bottom: parent.bottom
}
} }
} }
} }
function createRequest(ignoreGaplimit = false) { function createRequest(ignoreGaplimit = false) {
var a = parseFloat(amount.text) var a = Config.unitsToSats(amount.text)
Daemon.currentWallet.create_invoice(a, message.text, expires.currentValue, false, ignoreGaplimit) Daemon.currentWallet.create_invoice(a, message.text, expires.currentValue, false, ignoreGaplimit)
} }
@ -212,6 +303,8 @@ Pane {
function onRequestCreateSuccess() { function onRequestCreateSuccess() {
message.text = '' message.text = ''
amount.text = '' amount.text = ''
// var dialog = app.showAsQrDialog.createObject(app, {'text': 'test'})
// dialog.open()
} }
function onRequestCreateError(code, error) { function onRequestCreateError(code, error) {
if (code == 'gaplimit') { if (code == 'gaplimit') {

20
electrum/gui/qml/components/Send.qml

@ -1,6 +1,7 @@
import QtQuick 2.6 import QtQuick 2.6
import QtQuick.Controls 2.0 import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0 import QtQuick.Layouts 1.0
import QtQuick.Controls.Material 2.0
Pane { Pane {
id: rootItem id: rootItem
@ -11,7 +12,7 @@ Pane {
BalanceSummary { BalanceSummary {
Layout.columnSpan: 4 Layout.columnSpan: 4
//Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
} }
Label { Label {
@ -20,11 +21,18 @@ Pane {
TextField { TextField {
id: address id: address
Layout.columnSpan: 3 Layout.columnSpan: 2
placeholderText: 'Paste address or invoice' placeholderText: 'Paste address or invoice'
Layout.fillWidth: true Layout.fillWidth: true
} }
ToolButton {
icon.source: '../../icons/copy.png'
icon.color: 'transparent'
icon.height: 16
icon.width: 16
}
Label { Label {
text: "Amount" text: "Amount"
} }
@ -34,6 +42,12 @@ Pane {
placeholderText: 'Amount' placeholderText: 'Amount'
} }
Label {
text: Config.baseUnit
color: Material.accentColor
Layout.columnSpan: 2
}
Label { Label {
text: "Fee" text: "Fee"
} }
@ -41,6 +55,7 @@ Pane {
TextField { TextField {
id: fee id: fee
placeholderText: 'sat/vB' placeholderText: 'sat/vB'
Layout.columnSpan: 2
} }
Item { Item {
@ -51,7 +66,6 @@ Pane {
spacing: 10 spacing: 10
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
Button { Button {
// anchors.horizontalCenter: parent.horizontalCenter
text: 'Pay' text: 'Pay'
enabled: address.text != '' && amount.text != '' && fee.text != '' // TODO proper validation enabled: address.text != '' && amount.text != '' && fee.text != '' // TODO proper validation
onClicked: { onClicked: {

Loading…
Cancel
Save