Skip to content

Commit

Permalink
qml: introduce external link warning popup
Browse files Browse the repository at this point in the history
  • Loading branch information
jarolrod committed Jun 3, 2023
1 parent 48e6277 commit 3a3f8c2
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions src/qml/bitcoin_qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<file>components/ConnectionSettings.qml</file>
<file>components/PeersIndicator.qml</file>
<file>components/DeveloperOptions.qml</file>
<file>components/ExternalPopup.qml</file>
<file>components/NetworkTrafficGraph.qml</file>
<file>components/NetworkIndicator.qml</file>
<file>components/ProxySettings.qml</file>
Expand Down
18 changes: 14 additions & 4 deletions src/qml/components/AboutOptions.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ColumnLayout {
description: "bitcoincore.org"
link: "https://bitcoincore.org"
}
onClicked: loadedItem.clicked()
onClicked: openPopup(loadedItem.link)
}
Separator { Layout.fillWidth: true }
Setting {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -57,7 +57,7 @@ ColumnLayout {
iconWidth: 18
iconHeight: 18
}
onClicked: loadedItem.clicked()
onClicked: openPopup(loadedItem.link)
}
Separator { Layout.fillWidth: true }
Setting {
Expand All @@ -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()
}
}
91 changes: 91 additions & 0 deletions src/qml/components/ExternalPopup.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// 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: "https://bitcoin.org/en/download"
padding: 30
modal: true

background: Rectangle {
color: Theme.color.background
radius: 10
}

ColumnLayout {
id: popupContent
anchors.fill: parent
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()
}
}
}
}
}

0 comments on commit 3a3f8c2

Please sign in to comment.