From 90d6a7e5359d37770ca54108971934a6ae4ebc3f Mon Sep 17 00:00:00 2001 From: jarolrod Date: Fri, 2 Jun 2023 22:43:32 -0400 Subject: [PATCH 1/2] qml: remove implicitWidth from Continue & OutlineButton All usage of this defines the width. This makes the buttons usable in a wider range of situations. We keep the implicitHeight. --- src/qml/controls/ContinueButton.qml | 1 - src/qml/controls/OutlineButton.qml | 1 - 2 files changed, 2 deletions(-) diff --git a/src/qml/controls/ContinueButton.qml b/src/qml/controls/ContinueButton.qml index dd1fa76bab..454ff7524d 100644 --- a/src/qml/controls/ContinueButton.qml +++ b/src/qml/controls/ContinueButton.qml @@ -17,7 +17,6 @@ Button { background: Rectangle { id: bg implicitHeight: 46 - implicitWidth: 300 color: Theme.color.orange radius: 5 diff --git a/src/qml/controls/OutlineButton.qml b/src/qml/controls/OutlineButton.qml index dac386dec6..398462566d 100644 --- a/src/qml/controls/OutlineButton.qml +++ b/src/qml/controls/OutlineButton.qml @@ -18,7 +18,6 @@ Button { background: Rectangle { id: bg implicitHeight: 46 - implicitWidth: 340 color: Theme.color.background radius: 5 border { From 726bfa2c1eb3ae6f1148812f350c12b8354f0f0b Mon Sep 17 00:00:00 2001 From: jarolrod Date: Fri, 2 Jun 2023 22:43:51 -0400 Subject: [PATCH 2/2] qml: introduce external link warning popup --- src/Makefile.qt.include | 1 + src/qml/bitcoin_qml.qrc | 1 + src/qml/components/AboutOptions.qml | 18 ++++- src/qml/components/ExternalPopup.qml | 114 +++++++++++++++++++++++++++ 4 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 src/qml/components/ExternalPopup.qml diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index ba032ee58f..dd44f1dedb 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -347,6 +347,7 @@ QML_RES_QML = \ qml/components/ConnectionOptions.qml \ qml/components/ConnectionSettings.qml \ qml/components/DeveloperOptions.qml \ + qml/components/ExternalPopup.qml \ qml/components/PeersIndicator.qml \ qml/components/NetworkTrafficGraph.qml \ qml/components/NetworkIndicator.qml \ diff --git a/src/qml/bitcoin_qml.qrc b/src/qml/bitcoin_qml.qrc index 44e0448884..1e52917f14 100644 --- a/src/qml/bitcoin_qml.qrc +++ b/src/qml/bitcoin_qml.qrc @@ -9,6 +9,7 @@ components/ConnectionSettings.qml components/PeersIndicator.qml components/DeveloperOptions.qml + components/ExternalPopup.qml components/NetworkTrafficGraph.qml components/NetworkIndicator.qml components/ProxySettings.qml diff --git a/src/qml/components/AboutOptions.qml b/src/qml/components/AboutOptions.qml index f0f118f18d..a8629bc2a8 100644 --- a/src/qml/components/AboutOptions.qml +++ b/src/qml/components/AboutOptions.qml @@ -18,7 +18,7 @@ ColumnLayout { description: "bitcoincore.org" link: "https://bitcoincore.org" } - onClicked: loadedItem.clicked() + onClicked: openPopup(loadedItem.link) } Separator { Layout.fillWidth: true } Setting { @@ -30,7 +30,7 @@ ColumnLayout { description: "github.com/bitcoin/bitcoin" link: "https://github.com/bitcoin/bitcoin" } - onClicked: loadedItem.clicked() + onClicked: openPopup(loadedItem.link) } Separator { Layout.fillWidth: true } Setting { @@ -42,7 +42,7 @@ ColumnLayout { description: "MIT" link: "https://opensource.org/licenses/MIT" } - onClicked: loadedItem.clicked() + onClicked: openPopup(loadedItem.link) } Separator { Layout.fillWidth: true } Setting { @@ -57,7 +57,7 @@ ColumnLayout { iconWidth: 18 iconHeight: 18 } - onClicked: loadedItem.clicked() + onClicked: openPopup(loadedItem.link) } Separator { Layout.fillWidth: true } Setting { @@ -73,4 +73,14 @@ ColumnLayout { } onClicked: loadedItem.clicked() } + ExternalPopup { + id: confirmPopup + anchors.centerIn: Overlay.overlay + width: parent.width + } + + function openPopup(link) { + confirmPopup.link = link + confirmPopup.open() + } } diff --git a/src/qml/components/ExternalPopup.qml b/src/qml/components/ExternalPopup.qml new file mode 100644 index 0000000000..e76b460e68 --- /dev/null +++ b/src/qml/components/ExternalPopup.qml @@ -0,0 +1,114 @@ +// Copyright (c) 2023 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.15 +import Qt.labs.settings 1.0 +import org.bitcoincore.qt 1.0 +import "../controls" + +Popup { + id: externalConfirmPopup + property string link: "" + modal: true + padding: 0 + + background: Rectangle { + color: Theme.color.background + radius: 10 + } + + ColumnLayout { + anchors.fill: parent + spacing: 0 + + NavigationBar { + Layout.preferredHeight: 55 + middleDetail: Header { + Layout.fillWidth: true + header: qsTr("External Link") + headerBold: true + headerSize: 24 + } + } + + Separator { + Layout.fillWidth: true + } + + ColumnLayout { + id: popupContent + Layout.fillWidth: true + Layout.rightMargin: 20 + Layout.leftMargin: 20 + Layout.topMargin: 20 + Layout.bottomMargin: 20 + spacing: 30 + Header { + Layout.fillWidth: true + header: qsTr("Do you want to open the following website in your browser?") + headerBold: false + headerSize: 18 + description: ("\"" + externalConfirmPopup.link + "\"") + descriptionMargin: 3 + } + Loader { + id: layoutLoader + Layout.fillWidth: true + sourceComponent: AppMode.isDesktop ? desktopLayout : mobileLayout + } + } + } + + Component { + id: desktopLayout + RowLayout { + Layout.fillWidth: true + spacing: 15 + OutlineButton { + text: qsTr("Cancel") + Layout.fillWidth: true + Layout.minimumWidth: 150 + onClicked: { + externalConfirmPopup.close() + } + } + ContinueButton { + text: qsTr("Ok") + Layout.fillWidth: true + Layout.minimumWidth: 150 + onClicked: { + Qt.openUrlExternally(externalConfirmPopup.link) + externalConfirmPopup.close() + } + } + } + } + + Component { + id: mobileLayout + ColumnLayout { + Layout.fillWidth: true + spacing: 15 + OutlineButton { + text: qsTr("Cancel") + Layout.fillWidth: true + Layout.minimumWidth: 150 + onClicked: { + externalConfirmPopup.close() + } + } + ContinueButton { + text: qsTr("Ok") + Layout.fillWidth: true + Layout.minimumWidth: 150 + onClicked: { + Qt.openUrlExternally(externalConfirmPopup.link) + externalConfirmPopup.close() + } + } + } + } +}