From 1e60cb740ff15ddad1a344b861e5a19706a14cbb Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Thu, 9 Feb 2023 01:13:05 +0100 Subject: [PATCH] qml: fixes TextHighlightPane --- .../gui/qml/components/AddressDetails.qml | 9 +- .../gui/qml/components/ChannelDetails.qml | 2 - .../gui/qml/components/CloseChannelDialog.qml | 2 - .../gui/qml/components/ConfirmTxDialog.qml | 8 +- electrum/gui/qml/components/Constants.qml | 1 + electrum/gui/qml/components/InvoiceDialog.qml | 97 +++++++++++++------ .../components/LightningPaymentDetails.qml | 8 -- .../gui/qml/components/RbfBumpFeeDialog.qml | 3 +- .../gui/qml/components/RbfCancelDialog.qml | 6 +- electrum/gui/qml/components/TxDetails.qml | 7 +- .../components/controls/TextHighlightPane.qml | 11 ++- .../components/wizard/WCCosignerKeystore.qml | 8 +- .../qml/components/wizard/WCHaveMasterKey.qml | 8 +- .../gui/qml/components/wizard/WCHaveSeed.qml | 5 +- .../components/wizard/WCShowMasterPubkey.qml | 2 - 15 files changed, 93 insertions(+), 84 deletions(-) diff --git a/electrum/gui/qml/components/AddressDetails.qml b/electrum/gui/qml/components/AddressDetails.qml index 20534c45c..b07d4fd99 100644 --- a/electrum/gui/qml/components/AddressDetails.qml +++ b/electrum/gui/qml/components/AddressDetails.qml @@ -22,7 +22,7 @@ Pane { spacing: 0 Flickable { - Layout.preferredWidth: parent.width + Layout.fillWidth: true Layout.fillHeight: true leftMargin: constants.paddingLarge @@ -48,8 +48,6 @@ Pane { TextHighlightPane { Layout.columnSpan: 2 Layout.fillWidth: true - padding: 0 - leftPadding: constants.paddingSmall RowLayout { width: parent.width @@ -86,8 +84,6 @@ Pane { Layout.columnSpan: 2 Layout.fillWidth: true - padding: 0 - leftPadding: constants.paddingSmall RowLayout { width: parent.width @@ -144,8 +140,7 @@ Pane { delegate: TextHighlightPane { Layout.columnSpan: 2 Layout.fillWidth: true - padding: 0 - leftPadding: constants.paddingSmall + RowLayout { width: parent.width Label { diff --git a/electrum/gui/qml/components/ChannelDetails.qml b/electrum/gui/qml/components/ChannelDetails.qml index 22d5b75f3..c9dc39778 100644 --- a/electrum/gui/qml/components/ChannelDetails.qml +++ b/electrum/gui/qml/components/ChannelDetails.qml @@ -175,8 +175,6 @@ Pane { TextHighlightPane { Layout.columnSpan: 2 Layout.fillWidth: true - padding: 0 - leftPadding: constants.paddingSmall RowLayout { width: parent.width diff --git a/electrum/gui/qml/components/CloseChannelDialog.qml b/electrum/gui/qml/components/CloseChannelDialog.qml index ec1bbfe71..24631ef3c 100644 --- a/electrum/gui/qml/components/CloseChannelDialog.qml +++ b/electrum/gui/qml/components/CloseChannelDialog.qml @@ -71,8 +71,6 @@ ElDialog { TextHighlightPane { Layout.columnSpan: 2 Layout.fillWidth: true - padding: 0 - leftPadding: constants.paddingSmall Label { width: parent.width diff --git a/electrum/gui/qml/components/ConfirmTxDialog.qml b/electrum/gui/qml/components/ConfirmTxDialog.qml index 5b66966dd..c4fce4b44 100644 --- a/electrum/gui/qml/components/ConfirmTxDialog.qml +++ b/electrum/gui/qml/components/ConfirmTxDialog.qml @@ -49,11 +49,12 @@ ElDialog { spacing: 0 GridLayout { - width: parent.width - columns: 2 + Layout.fillWidth: true Layout.leftMargin: constants.paddingLarge Layout.rightMargin: constants.paddingLarge + columns: 2 + Label { id: amountLabel text: qsTr('Amount to send') @@ -181,8 +182,7 @@ ElDialog { delegate: TextHighlightPane { Layout.columnSpan: 2 Layout.fillWidth: true - padding: 0 - leftPadding: constants.paddingSmall + RowLayout { width: parent.width Label { diff --git a/electrum/gui/qml/components/Constants.qml b/electrum/gui/qml/components/Constants.qml index 94d17d4cf..d4a24e6e3 100644 --- a/electrum/gui/qml/components/Constants.qml +++ b/electrum/gui/qml/components/Constants.qml @@ -37,6 +37,7 @@ Item { property color colorMine: "yellow" property color colorError: '#ffff8080' + property color colorWarning: 'yellow' property color colorLightningLocal: "blue" property color colorLightningRemote: "yellow" property color colorChannelOpen: "#ff80ff80" diff --git a/electrum/gui/qml/components/InvoiceDialog.qml b/electrum/gui/qml/components/InvoiceDialog.qml index a36db7c6a..f089f2e4c 100644 --- a/electrum/gui/qml/components/InvoiceDialog.qml +++ b/electrum/gui/qml/components/InvoiceDialog.qml @@ -50,6 +50,28 @@ ElDialog { columns: 2 + TextHighlightPane { + Layout.columnSpan: 2 + Layout.fillWidth: true + + visible: invoice.userinfo + borderColor: constants.colorWarning + padding: constants.paddingXLarge + + RowLayout { + Image { + source: '../../icons/warning.png' + Layout.preferredWidth: constants.iconSizeMedium + Layout.preferredHeight: constants.iconSizeMedium + } + Label { + width: parent.width + text: invoice.userinfo + wrapMode: Text.Wrap + } + } + } + Label { text: qsTr('Type') color: Material.accentColor @@ -92,12 +114,10 @@ ElDialog { } TextHighlightPane { - visible: invoice.invoiceType == Invoice.OnchainInvoice - Layout.columnSpan: 2 Layout.fillWidth: true - padding: 0 + visible: invoice.invoiceType == Invoice.OnchainInvoice leftPadding: constants.paddingMedium Label { @@ -115,19 +135,32 @@ ElDialog { } TextHighlightPane { - visible: invoice.invoiceType == Invoice.LightningInvoice - Layout.columnSpan: 2 Layout.fillWidth: true - padding: 0 + visible: invoice.invoiceType == Invoice.LightningInvoice leftPadding: constants.paddingMedium - Label { + RowLayout { width: parent.width - text: 'pubkey' in invoice.lnprops ? invoice.lnprops.pubkey : '' - font.family: FixedFont - wrapMode: Text.Wrap + Label { + id: pubkeyLabel + Layout.fillWidth: true + text: 'pubkey' in invoice.lnprops ? invoice.lnprops.pubkey : '' + font.family: FixedFont + wrapMode: Text.Wrap + } + ToolButton { + icon.source: '../../icons/share.png' + icon.color: 'transparent' + enabled: pubkeyLabel.text + onClicked: { + var dialog = app.genericShareDialog.createObject(app, + { title: qsTr('Node public key'), text: invoice.lnprops.pubkey } + ) + dialog.open() + } + } } } @@ -138,19 +171,32 @@ ElDialog { } TextHighlightPane { - visible: invoice.invoiceType == Invoice.LightningInvoice - Layout.columnSpan: 2 Layout.fillWidth: true - padding: 0 + visible: invoice.invoiceType == Invoice.LightningInvoice leftPadding: constants.paddingMedium - Label { + RowLayout { width: parent.width - text: 'payment_hash' in invoice.lnprops ? invoice.lnprops.payment_hash : '' - font.family: FixedFont - wrapMode: Text.Wrap + Label { + id: paymenthashLabel + Layout.fillWidth: true + text: 'payment_hash' in invoice.lnprops ? invoice.lnprops.payment_hash : '' + font.family: FixedFont + wrapMode: Text.Wrap + } + ToolButton { + icon.source: '../../icons/share.png' + icon.color: 'transparent' + enabled: paymenthashLabel.text + onClicked: { + var dialog = app.genericShareDialog.createObject(app, + { title: qsTr('Payment hash'), text: invoice.lnprops.payment_hash } + ) + dialog.open() + } + } } } @@ -162,13 +208,10 @@ ElDialog { } TextHighlightPane { - visible: invoice.message - Layout.columnSpan: 2 Layout.fillWidth: true - Layout.alignment: Qt.AlignHCenter - padding: 0 + visible: invoice.message leftPadding: constants.paddingMedium Label { @@ -193,8 +236,7 @@ ElDialog { Layout.fillWidth: true Layout.alignment: Qt.AlignHCenter - padding: 0 - leftPadding: constants.paddingXXLarge + leftPadding: constants.paddingXLarge property bool editmode: false @@ -325,15 +367,6 @@ ElDialog { } - Item { Layout.preferredHeight: constants.paddingLarge; Layout.preferredWidth: 1 } - - InfoTextArea { - Layout.columnSpan: 2 - Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: parent.width * 3/4 - visible: invoice.userinfo - text: invoice.userinfo - } } } diff --git a/electrum/gui/qml/components/LightningPaymentDetails.qml b/electrum/gui/qml/components/LightningPaymentDetails.qml index 05da7a5b6..2a120d19a 100644 --- a/electrum/gui/qml/components/LightningPaymentDetails.qml +++ b/electrum/gui/qml/components/LightningPaymentDetails.qml @@ -92,8 +92,6 @@ Pane { Layout.columnSpan: 2 Layout.fillWidth: true - padding: 0 - leftPadding: constants.paddingSmall RowLayout { width: parent.width @@ -148,8 +146,6 @@ Pane { TextHighlightPane { Layout.columnSpan: 2 Layout.fillWidth: true - padding: 0 - leftPadding: constants.paddingSmall RowLayout { width: parent.width @@ -182,8 +178,6 @@ Pane { TextHighlightPane { Layout.columnSpan: 2 Layout.fillWidth: true - padding: 0 - leftPadding: constants.paddingSmall RowLayout { width: parent.width @@ -216,8 +210,6 @@ Pane { TextHighlightPane { Layout.columnSpan: 2 Layout.fillWidth: true - padding: 0 - leftPadding: constants.paddingSmall RowLayout { width: parent.width diff --git a/electrum/gui/qml/components/RbfBumpFeeDialog.qml b/electrum/gui/qml/components/RbfBumpFeeDialog.qml index 3bc7045d3..099fc5b3f 100644 --- a/electrum/gui/qml/components/RbfBumpFeeDialog.qml +++ b/electrum/gui/qml/components/RbfBumpFeeDialog.qml @@ -197,8 +197,7 @@ ElDialog { delegate: TextHighlightPane { Layout.columnSpan: 2 Layout.fillWidth: true - padding: 0 - leftPadding: constants.paddingSmall + RowLayout { width: parent.width Label { diff --git a/electrum/gui/qml/components/RbfCancelDialog.qml b/electrum/gui/qml/components/RbfCancelDialog.qml index b9643bb44..06dd9b7d9 100644 --- a/electrum/gui/qml/components/RbfCancelDialog.qml +++ b/electrum/gui/qml/components/RbfCancelDialog.qml @@ -32,9 +32,10 @@ ElDialog { spacing: 0 GridLayout { - Layout.preferredWidth: parent.width + Layout.fillWidth: true Layout.leftMargin: constants.paddingLarge Layout.rightMargin: constants.paddingLarge + columns: 2 Label { @@ -169,8 +170,7 @@ ElDialog { delegate: TextHighlightPane { Layout.columnSpan: 2 Layout.fillWidth: true - padding: 0 - leftPadding: constants.paddingSmall + RowLayout { width: parent.width Label { diff --git a/electrum/gui/qml/components/TxDetails.qml b/electrum/gui/qml/components/TxDetails.qml index 15edf83f1..4bc013f21 100644 --- a/electrum/gui/qml/components/TxDetails.qml +++ b/electrum/gui/qml/components/TxDetails.qml @@ -197,8 +197,6 @@ Pane { Layout.columnSpan: 2 Layout.fillWidth: true - padding: 0 - leftPadding: constants.paddingSmall RowLayout { width: parent.width @@ -253,8 +251,6 @@ Pane { TextHighlightPane { Layout.columnSpan: 2 Layout.fillWidth: true - padding: 0 - leftPadding: constants.paddingSmall RowLayout { width: parent.width @@ -290,8 +286,7 @@ Pane { delegate: TextHighlightPane { Layout.columnSpan: 2 Layout.fillWidth: true - padding: 0 - leftPadding: constants.paddingSmall + RowLayout { width: parent.width Label { diff --git a/electrum/gui/qml/components/controls/TextHighlightPane.qml b/electrum/gui/qml/components/controls/TextHighlightPane.qml index 7d715af2f..9b5349879 100644 --- a/electrum/gui/qml/components/controls/TextHighlightPane.qml +++ b/electrum/gui/qml/components/controls/TextHighlightPane.qml @@ -4,13 +4,14 @@ import QtQuick.Controls 2.0 import QtQuick.Controls.Material 2.0 Pane { - topPadding: constants.paddingSmall - bottomPadding: constants.paddingSmall - leftPadding: constants.paddingSmall - rightPadding: constants.paddingSmall + padding: constants.paddingSmall + + property color backgroundColor: Qt.lighter(Material.background, 1.15) + property color borderColor: null background: Rectangle { - color: Qt.lighter(Material.background, 1.15) + color: backgroundColor + border.color: borderColor ? borderColor : backgroundColor radius: constants.paddingSmall } } diff --git a/electrum/gui/qml/components/wizard/WCCosignerKeystore.qml b/electrum/gui/qml/components/wizard/WCCosignerKeystore.qml index e16237b2d..94e5895b4 100644 --- a/electrum/gui/qml/components/wizard/WCCosignerKeystore.qml +++ b/electrum/gui/qml/components/wizard/WCCosignerKeystore.qml @@ -30,17 +30,17 @@ WizardComponent { width: parent.width Label { + Layout.fillWidth: true + visible: cosigner text: qsTr('Here is your master public key. Please share it with your cosigners') - Layout.fillWidth: true wrapMode: Text.Wrap } TextHighlightPane { - visible: cosigner Layout.fillWidth: true - padding: 0 - leftPadding: constants.paddingSmall + + visible: cosigner RowLayout { width: parent.width diff --git a/electrum/gui/qml/components/wizard/WCHaveMasterKey.qml b/electrum/gui/qml/components/wizard/WCHaveMasterKey.qml index 4cfa74f98..b35b8df07 100644 --- a/electrum/gui/qml/components/wizard/WCHaveMasterKey.qml +++ b/electrum/gui/qml/components/wizard/WCHaveMasterKey.qml @@ -54,17 +54,17 @@ WizardComponent { width: parent.width Label { + Layout.fillWidth: true + visible: cosigner text: qsTr('Here is your master public key. Please share it with your cosigners') - Layout.fillWidth: true wrapMode: Text.Wrap } TextHighlightPane { - visible: cosigner Layout.fillWidth: true - padding: 0 - leftPadding: constants.paddingSmall + + visible: cosigner RowLayout { width: parent.width diff --git a/electrum/gui/qml/components/wizard/WCHaveSeed.qml b/electrum/gui/qml/components/wizard/WCHaveSeed.qml index ca08de3e2..d8e7ed272 100644 --- a/electrum/gui/qml/components/wizard/WCHaveSeed.qml +++ b/electrum/gui/qml/components/wizard/WCHaveSeed.qml @@ -93,11 +93,10 @@ WizardComponent { } TextHighlightPane { - visible: cosigner Layout.columnSpan: 2 Layout.fillWidth: true - padding: 0 - leftPadding: constants.paddingSmall + + visible: cosigner RowLayout { width: parent.width diff --git a/electrum/gui/qml/components/wizard/WCShowMasterPubkey.qml b/electrum/gui/qml/components/wizard/WCShowMasterPubkey.qml index 6dae7ea8a..f5e0497e3 100644 --- a/electrum/gui/qml/components/wizard/WCShowMasterPubkey.qml +++ b/electrum/gui/qml/components/wizard/WCShowMasterPubkey.qml @@ -22,8 +22,6 @@ WizardComponent { TextHighlightPane { Layout.fillWidth: true - padding: 0 - leftPadding: constants.paddingSmall RowLayout { width: parent.width