From b7964253a8ef0550163f1649714dc74ec2371bd7 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Tue, 17 Jan 2023 00:34:01 +0100 Subject: [PATCH] qml: define a common Heading component for page section headings --- electrum/gui/qml/components/Addresses.qml | 15 ++------ .../gui/qml/components/ChannelDetails.qml | 11 +----- electrum/gui/qml/components/Channels.qml | 11 +----- electrum/gui/qml/components/Invoices.qml | 10 +---- .../components/LightningPaymentDetails.qml | 11 +----- .../gui/qml/components/NetworkOverview.qml | 33 ++-------------- electrum/gui/qml/components/TxDetails.qml | 11 +----- electrum/gui/qml/components/WalletDetails.qml | 21 +--------- electrum/gui/qml/components/Wallets.qml | 10 +---- .../gui/qml/components/controls/Heading.qml | 38 +++++++++++++++++++ .../qml/components/controls/PrefsHeading.qml | 29 +------------- .../qml/components/controls/ServerConfig.qml | 10 +---- 12 files changed, 56 insertions(+), 154 deletions(-) create mode 100644 electrum/gui/qml/components/controls/Heading.qml diff --git a/electrum/gui/qml/components/Addresses.qml b/electrum/gui/qml/components/Addresses.qml index 8b8b2308b..f0e9e05bd 100644 --- a/electrum/gui/qml/components/Addresses.qml +++ b/electrum/gui/qml/components/Addresses.qml @@ -5,6 +5,8 @@ import QtQuick.Controls.Material 2.0 import org.electrum 1.0 +import "controls" + Pane { id: rootItem padding: 0 @@ -143,19 +145,10 @@ Pane { ColumnLayout { width: parent.width - Label { - Layout.topMargin: constants.paddingLarge - Layout.leftMargin: constants.paddingLarge - text: root.section + ' ' + qsTr('addresses') - font.pixelSize: constants.fontSizeLarge - color: Material.accentColor - } - Rectangle { + Heading { Layout.leftMargin: constants.paddingLarge Layout.rightMargin: constants.paddingLarge - Layout.preferredHeight: 1 - Layout.fillWidth: true - color: Material.accentColor + text: root.section + ' ' + qsTr('addresses') } } } diff --git a/electrum/gui/qml/components/ChannelDetails.qml b/electrum/gui/qml/components/ChannelDetails.qml index e613a383d..ab03dffb0 100644 --- a/electrum/gui/qml/components/ChannelDetails.qml +++ b/electrum/gui/qml/components/ChannelDetails.qml @@ -36,18 +36,9 @@ Pane { width: parent.width columns: 2 - Label { + Heading { Layout.columnSpan: 2 text: qsTr('Channel details') - font.pixelSize: constants.fontSizeLarge - color: Material.accentColor - } - - Rectangle { - Layout.columnSpan: 2 - Layout.fillWidth: true - height: 1 - color: Material.accentColor } Label { diff --git a/electrum/gui/qml/components/Channels.qml b/electrum/gui/qml/components/Channels.qml index 59f24a503..4db86b07e 100644 --- a/electrum/gui/qml/components/Channels.qml +++ b/electrum/gui/qml/components/Channels.qml @@ -26,18 +26,9 @@ Pane { columns: 2 - Label { + Heading { Layout.columnSpan: 2 text: qsTr('Lightning Channels') - font.pixelSize: constants.fontSizeLarge - color: Material.accentColor - } - - Rectangle { - Layout.columnSpan: 2 - Layout.fillWidth: true - height: 1 - color: Material.accentColor } Label { diff --git a/electrum/gui/qml/components/Invoices.qml b/electrum/gui/qml/components/Invoices.qml index 7879c8c28..a7a28f895 100644 --- a/electrum/gui/qml/components/Invoices.qml +++ b/electrum/gui/qml/components/Invoices.qml @@ -13,16 +13,8 @@ Pane { ColumnLayout { anchors.fill: parent - Label { + Heading { text: qsTr('Invoices') - font.pixelSize: constants.fontSizeLarge - color: Material.accentColor - } - - Rectangle { - height: 1 - Layout.fillWidth: true - color: Material.accentColor } Frame { diff --git a/electrum/gui/qml/components/LightningPaymentDetails.qml b/electrum/gui/qml/components/LightningPaymentDetails.qml index e7127fc73..05da7a5b6 100644 --- a/electrum/gui/qml/components/LightningPaymentDetails.qml +++ b/electrum/gui/qml/components/LightningPaymentDetails.qml @@ -28,18 +28,9 @@ Pane { width: parent.width columns: 2 - Label { + Heading { Layout.columnSpan: 2 text: qsTr('Lightning payment details') - font.pixelSize: constants.fontSizeLarge - color: Material.accentColor - } - - Rectangle { - Layout.columnSpan: 2 - Layout.fillWidth: true - height: 1 - color: Material.accentColor } Label { diff --git a/electrum/gui/qml/components/NetworkOverview.qml b/electrum/gui/qml/components/NetworkOverview.qml index 201ba2ae4..f668b579f 100644 --- a/electrum/gui/qml/components/NetworkOverview.qml +++ b/electrum/gui/qml/components/NetworkOverview.qml @@ -29,18 +29,9 @@ Pane { width: parent.width columns: 2 - Label { + Heading { Layout.columnSpan: 2 text: qsTr('Network') - font.pixelSize: constants.fontSizeLarge - color: Material.accentColor - } - - Rectangle { - Layout.columnSpan: 2 - Layout.fillWidth: true - height: 1 - color: Material.accentColor } Label { @@ -79,18 +70,9 @@ Pane { } } - Label { + Heading { Layout.columnSpan: 2 text: qsTr('On-chain') - font.pixelSize: constants.fontSizeLarge - color: Material.accentColor - } - - Rectangle { - Layout.columnSpan: 2 - Layout.fillWidth: true - height: 1 - color: Material.accentColor } Label { @@ -138,18 +120,9 @@ Pane { id: feeHistogram } - Label { + Heading { Layout.columnSpan: 2 text: qsTr('Lightning') - font.pixelSize: constants.fontSizeLarge - color: Material.accentColor - } - - Rectangle { - Layout.columnSpan: 2 - Layout.fillWidth: true - height: 1 - color: Material.accentColor } Label { diff --git a/electrum/gui/qml/components/TxDetails.qml b/electrum/gui/qml/components/TxDetails.qml index 048bf27f3..1e2840b0a 100644 --- a/electrum/gui/qml/components/TxDetails.qml +++ b/electrum/gui/qml/components/TxDetails.qml @@ -49,18 +49,9 @@ Pane { width: parent.width columns: 2 - Label { + Heading { Layout.columnSpan: 2 text: qsTr('Transaction Details') - font.pixelSize: constants.fontSizeLarge - color: Material.accentColor - } - - Rectangle { - Layout.columnSpan: 2 - Layout.fillWidth: true - height: 1 - color: Material.accentColor } RowLayout { diff --git a/electrum/gui/qml/components/WalletDetails.qml b/electrum/gui/qml/components/WalletDetails.qml index 744bfa668..b8389d49d 100644 --- a/electrum/gui/qml/components/WalletDetails.qml +++ b/electrum/gui/qml/components/WalletDetails.qml @@ -63,25 +63,8 @@ Pane { width: parent.width spacing: constants.paddingLarge - RowLayout { - Label { - text: qsTr('Wallet:') - font.pixelSize: constants.fontSizeLarge - color: Material.accentColor - } - - Label { - text: Daemon.currentWallet.name; - font.bold: true - font.pixelSize: constants.fontSizeLarge - Layout.fillWidth: true - } - } - - Rectangle { - Layout.fillWidth: true - height: 1 - color: Material.accentColor + Heading { + text: qsTr('Wallet details') } GridLayout { diff --git a/electrum/gui/qml/components/Wallets.qml b/electrum/gui/qml/components/Wallets.qml index 9e925aa10..4796274da 100644 --- a/electrum/gui/qml/components/Wallets.qml +++ b/electrum/gui/qml/components/Wallets.qml @@ -33,16 +33,8 @@ Pane { Layout.preferredWidth: parent.width Layout.margins: constants.paddingLarge - Label { + Heading { text: qsTr('Wallets') - font.pixelSize: constants.fontSizeLarge - color: Material.accentColor - } - - Rectangle { - Layout.fillWidth: true - height: 1 - color: Material.accentColor } Frame { diff --git a/electrum/gui/qml/components/controls/Heading.qml b/electrum/gui/qml/components/controls/Heading.qml new file mode 100644 index 000000000..d67bcbfd5 --- /dev/null +++ b/electrum/gui/qml/components/controls/Heading.qml @@ -0,0 +1,38 @@ +import QtQuick 2.6 +import QtQuick.Layouts 1.0 +import QtQuick.Controls 2.1 + +RowLayout { + id: root + + property string text + property alias font: label.font + + Layout.fillWidth: true + Layout.topMargin: constants.paddingMedium + Layout.bottomMargin: constants.paddingMedium + + spacing: constants.paddingLarge + + Rectangle { + color: constants.mutedForeground + height: 1 + Layout.fillWidth: true + } + + Label { + id: label + Layout.leftMargin: constants.paddingMedium + Layout.rightMargin: constants.paddingMedium + text: root.text + color: constants.mutedForeground + font.pixelSize: constants.fontSizeLarge + } + + Rectangle { + color: constants.mutedForeground + height: 1 + Layout.fillWidth: true + } + +} diff --git a/electrum/gui/qml/components/controls/PrefsHeading.qml b/electrum/gui/qml/components/controls/PrefsHeading.qml index 1b1ce12db..2389a1311 100644 --- a/electrum/gui/qml/components/controls/PrefsHeading.qml +++ b/electrum/gui/qml/components/controls/PrefsHeading.qml @@ -2,34 +2,9 @@ import QtQuick 2.6 import QtQuick.Layouts 1.0 import QtQuick.Controls 2.1 -RowLayout { +Heading { id: root - property string text - - Layout.fillWidth: true Layout.topMargin: constants.paddingXLarge - - spacing: constants.paddingLarge - - Rectangle { - color: constants.mutedForeground - height: 1 - Layout.fillWidth: true - } - - Label { - Layout.leftMargin: constants.paddingMedium - Layout.rightMargin: constants.paddingMedium - text: root.text - color: constants.mutedForeground - font.pixelSize: constants.fontSizeLarge - } - - Rectangle { - color: constants.mutedForeground - height: 1 - Layout.fillWidth: true - } - + Layout.bottomMargin: constants.paddingMedium } diff --git a/electrum/gui/qml/components/controls/ServerConfig.qml b/electrum/gui/qml/components/controls/ServerConfig.qml index 4c39e87d8..6538be1a9 100644 --- a/electrum/gui/qml/components/controls/ServerConfig.qml +++ b/electrum/gui/qml/components/controls/ServerConfig.qml @@ -44,16 +44,8 @@ Item { ColumnLayout { - Label { + Heading { text: qsTr('Servers') - font.pixelSize: constants.fontSizeLarge - color: Material.accentColor - } - - Rectangle { - Layout.fillWidth: true - height: 1 - color: Material.accentColor } Frame {