Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/gui-functional-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ jobs:
python3 test/functional/qml_test_bridge_sanity.py
python3 test/functional/qml_test_onboarding.py
python3 test/functional/qml_test_preinit_onboarding.py
python3 test/functional/qml_test_external_link_confirm.py
python3 test/functional/qml_test_disablewallet_boot.py
python3 test/functional/qml_test_blockclock.py
python3 test/functional/qml_test_blocksonly_settings.py
Expand Down
17 changes: 13 additions & 4 deletions qml/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <qml/guiargs.h>
#include <qml/legacy_settings_migration.h>
#include <qml/onboarding_settings.h>
#include <qml/urlopener.h>
#ifdef __ANDROID__
#include <qml/androidnotifier.h>
#endif
Expand Down Expand Up @@ -156,7 +157,7 @@ AppMode SetupAppMode()
return AppMode(mode, WalletEnabledFromArgs());
}

void RegisterQmlTypes(AppMode& app_mode, BuildInfo& build_info, Clipboard& clipboard, BitcoinUriModel& bitcoin_uri_model);
void RegisterQmlTypes(AppMode& app_mode, BuildInfo& build_info, Clipboard& clipboard, UrlOpener& url_opener, BitcoinUriModel& bitcoin_uri_model);

bool InitErrorMessageBox(
const bilingual_str& message,
Expand All @@ -165,8 +166,9 @@ bool InitErrorMessageBox(
static AppMode error_app_mode = SetupAppMode();
static BuildInfo error_build_info;
static Clipboard error_clipboard;
static UrlOpener error_url_opener;
static BitcoinUriModel error_bitcoin_uri_model;
RegisterQmlTypes(error_app_mode, error_build_info, error_clipboard, error_bitcoin_uri_model);
RegisterQmlTypes(error_app_mode, error_build_info, error_clipboard, error_url_opener, error_bitcoin_uri_model);

QQmlApplicationEngine engine;

Expand Down Expand Up @@ -233,17 +235,19 @@ void ApplyTestSettingsDir()
}
#endif

void RegisterQmlTypes(AppMode& app_mode, BuildInfo& build_info, Clipboard& clipboard, BitcoinUriModel& bitcoin_uri_model)
void RegisterQmlTypes(AppMode& app_mode, BuildInfo& build_info, Clipboard& clipboard, UrlOpener& url_opener, BitcoinUriModel& bitcoin_uri_model)
{
static bool registered{false};
static AppMode* app_mode_instance{nullptr};
static BuildInfo* build_info_instance{nullptr};
static Clipboard* clipboard_instance{nullptr};
static UrlOpener* url_opener_instance{nullptr};
static BitcoinUriModel* bitcoin_uri_model_instance{nullptr};
if (registered) return;
app_mode_instance = &app_mode;
build_info_instance = &build_info;
clipboard_instance = &clipboard;
url_opener_instance = &url_opener;
bitcoin_uri_model_instance = &bitcoin_uri_model;

qmlRegisterSingletonType<AppMode>("org.bitcoincore.qt", 1, 0, "AppMode", [](QQmlEngine*, QJSEngine*) -> QObject* {
Expand All @@ -258,6 +262,10 @@ void RegisterQmlTypes(AppMode& app_mode, BuildInfo& build_info, Clipboard& clipb
QQmlEngine::setObjectOwnership(clipboard_instance, QQmlEngine::CppOwnership);
return clipboard_instance;
});
qmlRegisterSingletonType<UrlOpener>("org.bitcoincore.qt", 1, 0, "UrlOpener", [](QQmlEngine*, QJSEngine*) -> QObject* {
QQmlEngine::setObjectOwnership(url_opener_instance, QQmlEngine::CppOwnership);
return url_opener_instance;
});
qmlRegisterSingletonType<BitcoinUriModel>("org.bitcoincore.qt", 1, 0, "BitcoinUri", [](QQmlEngine*, QJSEngine*) -> QObject* {
QQmlEngine::setObjectOwnership(bitcoin_uri_model_instance, QQmlEngine::CppOwnership);
return bitcoin_uri_model_instance;
Expand Down Expand Up @@ -480,8 +488,9 @@ int QmlGuiMain(int argc, char* argv[])
AppMode app_mode = SetupAppMode();
BuildInfo build_info;
Clipboard clipboard;
UrlOpener url_opener;
BitcoinUriModel bitcoin_uri_model;
RegisterQmlTypes(app_mode, build_info, clipboard, bitcoin_uri_model);
RegisterQmlTypes(app_mode, build_info, clipboard, url_opener, bitcoin_uri_model);

const QString cli_lang = QString::fromStdString(gArgs.GetArg("-lang", ""));
const QString startup_language = cli_lang.isEmpty()
Expand Down
4 changes: 2 additions & 2 deletions qml/bitcoin_qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<file>components/MempoolInformationRows.qml</file>
<file>components/DeveloperOptions.qml</file>
<file>components/ExternalSignerReviewActions.qml</file>
<file>components/ExternalPopup.qml</file>
<file>components/FeeSelection.qml</file>
<file>components/MiniBlockClock.qml</file>
<file>components/MonospaceOutputView.qml</file>
Expand All @@ -34,7 +33,6 @@
<file>components/ProxySettings.qml</file>
<file>components/SettingsRestartNotice.qml</file>
<file>components/StorageLocations.qml</file>
<file>components/Separator.qml</file>
<file>components/StorageOptions.qml</file>
<file>components/StorageSettings.qml</file>
<file>components/ThemeSettings.qml</file>
Expand Down Expand Up @@ -66,6 +64,7 @@
<file>controls/CoreTextField.qml</file>
<file>controls/EditableKeyValueRow.qml</file>
<file>controls/ExternalLink.qml</file>
<file>controls/ExternalPopup.qml</file>
<file>controls/FocusBorder.qml</file>
<file>controls/Header.qml</file>
<file>controls/Icon.qml</file>
Expand All @@ -87,6 +86,7 @@
<file>controls/ProxyLocationInput.qml</file>
<file>controls/QRImage.qml</file>
<file>controls/RightContentIcon.qml</file>
<file>controls/Separator.qml</file>
<file>controls/qmldir</file>
<file>controls/SendOptionsPopup.qml</file>
<file>controls/SegmentedPicker.qml</file>
Expand Down
31 changes: 13 additions & 18 deletions qml/components/AboutOptions.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 The Bitcoin Core developers
// Copyright (c) 2022-2026 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand All @@ -14,53 +14,58 @@ ColumnLayout {
spacing: 0
Setting {
id: websiteLink
objectName: "aboutWebsiteLink"
Layout.fillWidth: true
header: qsTr("Website")
actionItem: ExternalLink {
objectName: "aboutWebsiteLinkIcon"
parentState: websiteLink.visualState
description: "bitcoincore.org"
link: "https://bitcoincore.org"
}
onClicked: openPopup(loadedItem.link)
onClicked: loadedItem.requestOpen()
}
Separator { Layout.fillWidth: true }
Setting {
id: sourceLink
objectName: "aboutSourceCodeLink"
Layout.fillWidth: true
header: qsTr("Source code")
actionItem: ExternalLink {
objectName: "aboutSourceCodeLinkIcon"
parentState: sourceLink.visualState
description: "github.com/bitcoin/bitcoin"
link: "https://github.com/bitcoin/bitcoin"
}
onClicked: openPopup(loadedItem.link)
onClicked: loadedItem.requestOpen()
}
Separator { Layout.fillWidth: true }
Setting {
id: licenseLink
objectName: "aboutLicenseLink"
Layout.fillWidth: true
header: qsTr("License")
actionItem: ExternalLink {
objectName: "aboutLicenseLinkIcon"
parentState: licenseLink.visualState
description: "MIT"
link: "https://opensource.org/licenses/MIT"
}
onClicked: openPopup(loadedItem.link)
onClicked: loadedItem.requestOpen()
}
Separator { Layout.fillWidth: true }
Setting {
id: versionLink
objectName: "aboutVersionLink"
Layout.fillWidth: true
header: qsTr("Version")
actionItem: ExternalLink {
objectName: "aboutVersionLinkIcon"
parentState: versionLink.visualState
description: BuildInfo.fullClientVersion
link: "https://bitcoin.org/en/download"
iconSource: "image://images/caret-right"
iconWidth: 18
iconHeight: 18
}
onClicked: openPopup(loadedItem.link)
onClicked: loadedItem.requestOpen()
}
Separator { Layout.fillWidth: true }
Setting {
Expand All @@ -78,14 +83,4 @@ ColumnLayout {
root.next()
}
}
ExternalPopup {
id: confirmPopup
anchors.centerIn: Overlay.overlay
width: parent.width
}

function openPopup(link) {
confirmPopup.link = link
confirmPopup.open()
}
}
79 changes: 0 additions & 79 deletions qml/components/ExternalPopup.qml

This file was deleted.

21 changes: 20 additions & 1 deletion qml/components/ToastBanner.qml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ Rectangle {
color: backgroundColor
radius: 5
implicitHeight: Math.max(50, contentRow.implicitHeight + 20)
opacity: 0
// Follows the initial visibility instead of always starting transparent.
// A banner whose condition already holds when it is built inside an
// already visible page never sees visible change, so the fade-in below
// would not run and the banner would keep its space in the layout while
// drawing nothing. Whether that happens depends on creation order (a page
// whose tree becomes visible only after construction still gets the
// change), so both orders must draw. The animations assign opacity
// directly, which drops this binding once one of them runs.
opacity: visible ? 1 : 0

onVisibleChanged: {
if (visible) {
Expand All @@ -43,6 +51,12 @@ Rectangle {
}
}

// Shown outright rather than faded in, so the auto-dismiss countdown that
// normally starts when the fade completes has to be started here instead.
Component.onCompleted: {
if (root.opacity === 1 && root.dismissAfter > 0) dismissTimer.start()
}

NumberAnimation {
id: fadeInAnim
target: root
Expand Down Expand Up @@ -96,6 +110,11 @@ Rectangle {
objectName: root.textObjectName
Layout.fillWidth: true
text: root.text
// Banner text is a message, never markup. Without this the Text
// default of AutoText would silently upgrade markup-looking
// strings (an error can interpolate a filesystem path) to rich
// text.
textFormat: Text.PlainText
color: root.textColor
font: Theme.text.description.font
horizontalAlignment: root.iconSource != "" ? Text.AlignLeft : Text.AlignHCenter
Expand Down
42 changes: 39 additions & 3 deletions qml/controls/ExternalLink.qml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// Copyright (c) 2022 The Bitcoin Core developers
// Copyright (c) 2022-2026 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 org.bitcoincore.qt 1.0

AbstractButton {
id: root
Expand All @@ -18,8 +19,24 @@ AbstractButton {
property int iconSlotSize: 30
property color iconColor: Theme.color.neutral9
property color textColor: Theme.color.neutral9

// The confirmation dialog belongs to the link rather than to each page
// that hosts one. A page that forgot to wire it up would produce a link
// that silently does nothing, which is the failure this control exists to
// prevent. Derived from objectName so several links on one page stay
// individually addressable from tests.
readonly property string popupObjectName: root.objectName.length > 0
? root.objectName + "_popup"
: "externalLinkPopup"

enabled: root.parentState !== "DISABLED"
state: root.parentState
hoverEnabled: AppMode.isDesktop
state: root.enabled && root.hovered ? "HOVER" : root.parentState

HoverHandler {
cursorShape: AppMode.isDesktop && root.enabled ? Qt.PointingHandCursor
: Qt.ArrowCursor
}

states: [
State {
Expand Down Expand Up @@ -76,5 +93,24 @@ AbstractButton {
slotSize: root.iconSlotSize
}
}
onClicked: Qt.openUrlExternally(link)
// Opening always goes through ExternalPopup, which confirms the
// destination, checks whether the open succeeded, and offers a copy-URL
// fallback when it did not.
function requestOpen() {
popupLoader.active = true
popupLoader.item.link = root.link
popupLoader.item.open()
}

onClicked: root.requestOpen()

// Created on first use: most links are never clicked, and a popup per link
// on a page full of them is not worth instantiating up front.
Loader {
id: popupLoader
active: false
sourceComponent: ExternalPopup {
objectName: root.popupObjectName
}
}
}
Loading
Loading