diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 9dcb95c1f8..c9bdb051e8 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 591615b1ca..ae36776d5a 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 55123f577d..e20adf9609 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 { @@ -72,4 +72,14 @@ ColumnLayout { aboutSwipe.incrementCurrentIndex() } } + 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() + } + } + } + } +} 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 {