use configured units everywhere
This commit is contained in:
@@ -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()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,53 +30,113 @@ 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 {
|
|
||||||
Layout.rowSpan: 3
|
|
||||||
width: img.width
|
|
||||||
height: img.height
|
|
||||||
|
|
||||||
Image {
|
|
||||||
id: img
|
|
||||||
cache: false
|
|
||||||
anchors {
|
|
||||||
top: parent.top
|
|
||||||
left: parent.left
|
|
||||||
}
|
|
||||||
source: 'image://qrgen/test'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: qsTr('Expires after')
|
text: Config.baseUnit
|
||||||
Layout.fillWidth: false
|
color: Material.accentColor
|
||||||
}
|
}
|
||||||
|
|
||||||
ComboBox {
|
ColumnLayout {
|
||||||
id: expires
|
Layout.rowSpan: 2
|
||||||
textRole: 'text'
|
Layout.preferredWidth: rootItem.width /3
|
||||||
valueRole: 'value'
|
Layout.leftMargin: constants.paddingXLarge
|
||||||
model: ListModel {
|
|
||||||
id: expiresmodel
|
Label {
|
||||||
Component.onCompleted: {
|
text: qsTr('Expires after')
|
||||||
// we need to fill the model like this, as ListElement can't evaluate script
|
Layout.fillWidth: false
|
||||||
expiresmodel.append({'text': qsTr('Never'), 'value': 0})
|
}
|
||||||
expiresmodel.append({'text': qsTr('10 minutes'), 'value': 10*60})
|
|
||||||
expiresmodel.append({'text': qsTr('1 hour'), 'value': 60*60})
|
ComboBox {
|
||||||
expiresmodel.append({'text': qsTr('1 day'), 'value': 24*60*60})
|
id: expires
|
||||||
expiresmodel.append({'text': qsTr('1 week'), 'value': 7*24*60*60})
|
Layout.fillWidth: true
|
||||||
expires.currentIndex = 0
|
textRole: 'text'
|
||||||
|
valueRole: 'value'
|
||||||
|
|
||||||
|
model: ListModel {
|
||||||
|
id: expiresmodel
|
||||||
|
Component.onCompleted: {
|
||||||
|
// we need to fill the model like this, as ListElement can't evaluate script
|
||||||
|
expiresmodel.append({'text': qsTr('10 minutes'), 'value': 10*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 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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,7 +253,24 @@ 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 {
|
||||||
@@ -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') {
|
||||||
|
|||||||
@@ -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: {
|
||||||
|
|||||||
Reference in New Issue
Block a user