From 3a31c0df1b95d73d2e0e22fb5ee93cebbdb9aada Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Tue, 3 Jan 2023 18:22:59 +0100 Subject: [PATCH] qml: fix Switch layout issues and add section headings to preferences --- electrum/gui/qml/components/Preferences.qml | 217 +++++++++++++----- .../qml/components/controls/PrefsHeading.qml | 35 +++ 2 files changed, 189 insertions(+), 63 deletions(-) create mode 100644 electrum/gui/qml/components/controls/PrefsHeading.qml diff --git a/electrum/gui/qml/components/Preferences.qml b/electrum/gui/qml/components/Preferences.qml index 12d7b2a75..46492ad09 100644 --- a/electrum/gui/qml/components/Preferences.qml +++ b/electrum/gui/qml/components/Preferences.qml @@ -29,10 +29,17 @@ Pane { Pane { id: prefsPane + width: parent.width + GridLayout { columns: 2 width: parent.width + PrefsHeading { + Layout.columnSpan: 2 + text: qsTr('User Interface') + } + Label { text: qsTr('Language') } @@ -55,29 +62,55 @@ Pane { } } - Switch { - id: thousands + RowLayout { Layout.columnSpan: 2 - text: qsTr('Add thousands separators to bitcoin amounts') - onCheckedChanged: { - if (activeFocus) - Config.thousandsSeparator = checked + Layout.fillWidth: true + Layout.leftMargin: -constants.paddingSmall + spacing: 0 + Switch { + id: thousands + onCheckedChanged: { + if (activeFocus) + Config.thousandsSeparator = checked + } + } + Label { + Layout.fillWidth: true + text: qsTr('Add thousands separators to bitcoin amounts') + wrapMode: Text.Wrap } } - Switch { - id: checkSoftware + RowLayout { Layout.columnSpan: 2 - text: qsTr('Automatically check for software updates') - enabled: false + Layout.fillWidth: true + Layout.leftMargin: -constants.paddingSmall + spacing: 0 + Switch { + id: checkSoftware + enabled: false + } + Label { + Layout.fillWidth: true + text: qsTr('Automatically check for software updates') + wrapMode: Text.Wrap + } } - Switch { - id: fiatEnable - text: qsTr('Fiat Currency') - onCheckedChanged: { - if (activeFocus) - Daemon.fx.enabled = checked + RowLayout { + Layout.leftMargin: -constants.paddingSmall + spacing: 0 + Switch { + id: fiatEnable + onCheckedChanged: { + if (activeFocus) + Daemon.fx.enabled = checked + } + } + Label { + Layout.fillWidth: true + text: qsTr('Fiat Currency') + wrapMode: Text.Wrap } } @@ -91,19 +124,28 @@ Pane { } } - Switch { - id: historicRates - text: qsTr('Historic rates') - enabled: Daemon.fx.enabled + RowLayout { Layout.columnSpan: 2 - onCheckedChanged: { - if (activeFocus) - Daemon.fx.historicRates = checked + Layout.fillWidth: true + Layout.leftMargin: -constants.paddingSmall + spacing: 0 + Switch { + id: historicRates + enabled: Daemon.fx.enabled + onCheckedChanged: { + if (activeFocus) + Daemon.fx.historicRates = checked + } + } + Label { + Layout.fillWidth: true + text: qsTr('Historic rates') + wrapMode: Text.Wrap } } Label { - text: qsTr('Source') + text: qsTr('Exchange rate provider') enabled: Daemon.fx.enabled } @@ -120,26 +162,9 @@ Pane { } } - Switch { - id: spendUnconfirmed - text: qsTr('Spend unconfirmed') + PrefsHeading { Layout.columnSpan: 2 - onCheckedChanged: { - if (activeFocus) - Config.spendUnconfirmed = checked - } - } - - Label { - text: qsTr('Default request expiry') - Layout.fillWidth: false - } - - RequestExpiryComboBox { - onCurrentValueChanged: { - if (activeFocus) - Config.requestExpiry = currentValue - } + text: qsTr('Wallet behavior') } Label { @@ -185,6 +210,41 @@ Pane { } } + RowLayout { + Layout.columnSpan: 2 + Layout.leftMargin: -constants.paddingSmall + spacing: 0 + Switch { + id: spendUnconfirmed + onCheckedChanged: { + if (activeFocus) + Config.spendUnconfirmed = checked + } + } + Label { + Layout.fillWidth: true + text: qsTr('Spend unconfirmed') + wrapMode: Text.Wrap + } + } + + Label { + text: qsTr('Default request expiry') + Layout.fillWidth: false + } + + RequestExpiryComboBox { + onCurrentValueChanged: { + if (activeFocus) + Config.requestExpiry = currentValue + } + } + + PrefsHeading { + Layout.columnSpan: 2 + text: qsTr('Lightning') + } + Label { text: qsTr('Lightning Routing') } @@ -205,37 +265,68 @@ Pane { } } - Switch { - id: useRecoverableChannels - text: qsTr('Create recoverable channels') + RowLayout { Layout.columnSpan: 2 - onCheckedChanged: { - if (activeFocus) - Config.useRecoverableChannels = checked + Layout.fillWidth: true + Layout.leftMargin: -constants.paddingSmall + spacing: 0 + Switch { + id: useRecoverableChannels + onCheckedChanged: { + if (activeFocus) + Config.useRecoverableChannels = checked + } + } + Label { + Layout.fillWidth: true + text: qsTr('Create recoverable channels') + wrapMode: Text.Wrap } } - Switch { - id: useFallbackAddress - text: qsTr('Use onchain fallback address for Lightning invoices') + RowLayout { Layout.columnSpan: 2 - onCheckedChanged: { - if (activeFocus) - Config.useFallbackAddress = checked + Layout.fillWidth: true + Layout.leftMargin: -constants.paddingSmall + spacing: 0 + Switch { + id: useFallbackAddress + onCheckedChanged: { + if (activeFocus) + Config.useFallbackAddress = checked + } + } + Label { + Layout.fillWidth: true + text: qsTr('Use onchain fallback address for Lightning invoices') + wrapMode: Text.Wrap } } - Switch { - id: enableDebugLogs - text: qsTr('Enable debug logs (for developers)') + PrefsHeading { Layout.columnSpan: 2 - onCheckedChanged: { - if (activeFocus) - Config.enableDebugLogs = checked - } - enabled: Config.canToggleDebugLogs + text: qsTr('Advanced') } + RowLayout { + Layout.columnSpan: 2 + Layout.fillWidth: true + Layout.leftMargin: -constants.paddingSmall + spacing: 0 + Switch { + id: enableDebugLogs + onCheckedChanged: { + if (activeFocus) + Config.enableDebugLogs = checked + } + enabled: Config.canToggleDebugLogs + } + Label { + Layout.fillWidth: true + text: qsTr('Enable debug logs (for developers)') + wrapMode: Text.Wrap + } + } } } diff --git a/electrum/gui/qml/components/controls/PrefsHeading.qml b/electrum/gui/qml/components/controls/PrefsHeading.qml new file mode 100644 index 000000000..1b1ce12db --- /dev/null +++ b/electrum/gui/qml/components/controls/PrefsHeading.qml @@ -0,0 +1,35 @@ +import QtQuick 2.6 +import QtQuick.Layouts 1.0 +import QtQuick.Controls 2.1 + +RowLayout { + 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 + } + +}