Skip to content

QML Snapshot Load #488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: qt6
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "bitcoin"]
path = bitcoin
url = https://github.com/bitcoin/bitcoin
url = https://github.com/D33r-Gee/bitcoin
2 changes: 1 addition & 1 deletion bitcoin
Submodule bitcoin updated 383 files
7 changes: 7 additions & 0 deletions qml/bitcoin_qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<file>components/ProxySettings.qml</file>
<file>components/StorageLocations.qml</file>
<file>components/Separator.qml</file>
<file>components/SnapshotLoadSettings.qml</file>
<file>components/StorageOptions.qml</file>
<file>components/StorageSettings.qml</file>
<file>components/ThemeSettings.qml</file>
Expand All @@ -29,6 +30,7 @@
<file>controls/CoreTextField.qml</file>
<file>controls/ExternalLink.qml</file>
<file>controls/FocusBorder.qml</file>
<file>controls/GreenCheckIcon.qml</file>
<file>controls/Header.qml</file>
<file>controls/Icon.qml</file>
<file>controls/IconButton.qml</file>
Expand Down Expand Up @@ -79,6 +81,7 @@
<file>pages/settings/SettingsDeveloper.qml</file>
<file>pages/settings/SettingsDisplay.qml</file>
<file>pages/settings/SettingsProxy.qml</file>
<file>pages/settings/SettingsSnapshotLoad.qml</file>
<file>pages/settings/SettingsStorage.qml</file>
<file>pages/settings/SettingsTheme.qml</file>
<file>pages/wallet/Activity.qml</file>
Expand Down Expand Up @@ -115,13 +118,17 @@
<file alias="check">res/icons/check.png</file>
<file alias="copy">res/icons/copy.png</file>
<file alias="coinbase">res/icons/coinbase.png</file>
<file alias="circle-file">res/icons/circle-file.png</file>
<file alias="circle-green-check">res/icons/circle-green-check.png</file>
<file alias="circle-red-cross">res/icons/circle-red-cross.png</file>
<file alias="cross">res/icons/cross.png</file>
<file alias="ellipsis">res/icons/ellipsis.png</file>
<file alias="error">res/icons/error.png</file>
<file alias="export">res/icons/export.png</file>
<file alias="flip-vertical">res/icons/flip-vertical.png</file>
<file alias="gear">res/icons/gear.png</file>
<file alias="gear-outline">res/icons/gear-outline.png</file>
<file alias="green-check">res/icons/green-check.png</file>
<file alias="hidden">res/icons/hidden.png</file>
<file alias="info">res/icons/info.png</file>
<file alias="lock">res/icons/lock.png</file>
Expand Down
31 changes: 31 additions & 0 deletions qml/components/ConnectionSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,38 @@ import "../controls"
ColumnLayout {
id: root
signal next
signal gotoSnapshot
property bool onboarding: false
property bool snapshotImportCompleted: onboarding ? false : chainModel.isSnapshotActive
property bool isIBDCompleted: nodeModel.isIBDCompleted
spacing: 4
Setting {
id: gotoSnapshot
visible: !snapshotImportCompleted && !root.isIBDCompleted
Layout.fillWidth: true
header: qsTr("Load snapshot")
description: qsTr("Instant use with background sync")
actionItem: Item {
width: 26
height: 26
CaretRightIcon {
anchors.centerIn: parent
visible: !snapshotImportCompleted
color: gotoSnapshot.stateColor
}
GreenCheckIcon {
anchors.centerIn: parent
visible: snapshotImportCompleted
color: Theme.color.transparent
size: 30
}
}
onClicked: root.gotoSnapshot()
}
Separator {
visible: !snapshotImportCompleted && !root.isIBDCompleted
Layout.fillWidth: true
}
Setting {
Layout.fillWidth: true
header: qsTr("Enable listening")
Expand Down
269 changes: 269 additions & 0 deletions qml/components/SnapshotLoadSettings.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
// Copyright (c) 2023-present 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 QtQuick.Dialogs

import "../controls"

ColumnLayout {
id: columnLayout
signal back
property bool snapshotLoading: nodeModel.snapshotLoading
property bool snapshotLoaded: nodeModel.isSnapshotLoaded
property bool snapshotImportCompleted: onboarding ? false : chainModel.isSnapshotActive
property bool onboarding: false
property bool snapshotVerified: onboarding ? false : chainModel.isSnapshotActive
property string snapshotFileName: ""
property var snapshotInfo: (snapshotVerified || snapshotLoaded) ? chainModel.getSnapshotInfo() : ({})
property string selectedFile: ""
property bool headersSynced: nodeModel.headersSynced
property bool snapshotError: nodeModel.snapshotError

width: Math.min(parent.width, 450)
anchors.horizontalCenter: parent.horizontalCenter

StackLayout {
id: settingsStack
currentIndex: onboarding ? 0 : snapshotLoaded ? 2 : snapshotVerified ? 2 : snapshotLoading ? 1 : snapshotError ? 3 : 0

ColumnLayout {
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: Math.min(parent.width, 450)

Image {
Layout.alignment: Qt.AlignCenter
source: "image://images/circle-file"

sourceSize.width: 200
sourceSize.height: 200
}

Header {
Layout.fillWidth: true
Layout.topMargin: 20
headerBold: true
header: qsTr("Load snapshot")
descriptionBold: false
descriptionColor: Theme.color.neutral6
descriptionSize: 17
descriptionLineHeight: 1.1
description: qsTr("You can start using the application more quickly by loading a recent transaction snapshot." +
" It will be automatically verified in the background.")
}

CoreText {
Layout.fillWidth: true
Layout.topMargin: 20
color: Theme.color.neutral6
font.pixelSize: 17
visible: !headersSynced && !onboarding
text: !headersSynced
? qsTr("Please wait for headers to sync before loading a snapshot.")
: qsTr("")
wrap: true
wrapMode: Text.WordWrap
}

ContinueButton {
Layout.preferredWidth: Math.min(300, columnLayout.width - 2 * Layout.leftMargin)
Layout.topMargin: 40
Layout.leftMargin: 20
Layout.rightMargin: Layout.leftMargin
Layout.bottomMargin: 20
Layout.alignment: Qt.AlignCenter
text: qsTr("Choose snapshot file")
enabled: headersSynced || onboarding
onClicked: fileDialog.open()
}

FileDialog {
id: fileDialog
currentFolder: optionsModel.getDefaultDataDirectory
nameFilters: ["Snapshot files (*.dat)", "All files (*)"]
onAccepted: {
snapshotFileName = selectedFile
console.log("snapshotFileName", snapshotFileName)
if (!onboarding) {
nodeModel.snapshotLoadThread(snapshotFileName)
} else {
nodeModel.setSnapshotFilePath(snapshotFileName)
back()
}
}
}
}

ColumnLayout {
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: Math.min(parent.width, 450)

Image {
Layout.alignment: Qt.AlignCenter
source: "image://images/circle-file"

sourceSize.width: 200
sourceSize.height: 200
}

Header {
Layout.fillWidth: true
Layout.topMargin: 20
Layout.leftMargin: 20
Layout.rightMargin: 20
header: qsTr("Loading Snapshot")
description: qsTr("This might take a while...")
}

ProgressIndicator {
id: progressIndicator
Layout.topMargin: 20
width: 200
height: 20
progress: nodeModel.snapshotProgress
Layout.alignment: Qt.AlignCenter
progressColor: Theme.color.blue
}
}

ColumnLayout {
id: loadedSnapshotColumn
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: Math.min(parent.width, 450)

Image {
Layout.alignment: Qt.AlignCenter
source: "image://images/circle-green-check"

sourceSize.width: 60
sourceSize.height: 60
}

Header {
Layout.fillWidth: true
Layout.topMargin: 20
headerBold: true
header: qsTr("Snapshot Loaded")
descriptionBold: false
descriptionColor: Theme.color.neutral6
descriptionSize: 17
descriptionLineHeight: 1.1
description: snapshotInfo && snapshotInfo["date"] ?
qsTr("It contains unspent transactions up to %1. Next, transactions will be verified and newer transactions downloaded.").arg(snapshotInfo["date"]) :
qsTr("It contains transactions up to DEBUG. Newer transactions still need to be downloaded." +
" The data will be verified in the background.")
}

ContinueButton {
Layout.preferredWidth: Math.min(300, columnLayout.width - 2 * Layout.leftMargin)
Layout.topMargin: 40
Layout.alignment: Qt.AlignCenter
text: qsTr("Done")
onClicked: {
chainModel.isSnapshotActiveChanged()
back()
}
}

Setting {
id: viewDetails
Layout.alignment: Qt.AlignCenter
header: qsTr("View details")
actionItem: CaretRightIcon {
id: caretIcon
color: viewDetails.stateColor
rotation: viewDetails.expanded ? 90 : 0
Behavior on rotation { NumberAnimation { duration: 200 } }
}

property bool expanded: false

onClicked: {
expanded = !expanded
}
}

ColumnLayout {
id: detailsContent
visible: viewDetails.expanded
Layout.preferredWidth: Math.min(300, parent.width - 2 * Layout.leftMargin)
Layout.alignment: Qt.AlignCenter
Layout.leftMargin: 80
Layout.rightMargin: 80
Layout.topMargin: 10
spacing: 10
// TODO: make sure the block height number aligns right
RowLayout {
CoreText {
text: qsTr("Block Height:")
Layout.alignment: Qt.AlignLeft
font.pixelSize: 14
}
CoreText {
text: snapshotInfo && snapshotInfo["height"] ?
snapshotInfo["height"] : qsTr("DEBUG")
Layout.alignment: Qt.AlignRight
font.pixelSize: 14
}
}
Separator { Layout.fillWidth: true }
ColumnLayout {
Layout.fillWidth: true
spacing: 5
CoreText {
text: qsTr("Hash:")
font.pixelSize: 14
}
CoreText {
text: snapshotInfo && snapshotInfo["hashSerializedFirstHalf"] ?
snapshotInfo["hashSerializedFirstHalf"] + "\n" + snapshotInfo["hashSerializedSecondHalf"] :
qsTr("DEBUG")
Layout.fillWidth: true
font.pixelSize: 14
textFormat: Text.PlainText
}
}
}
}

ColumnLayout {
id: snapshotErrorColumn
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: Math.min(parent.width, 450)

Image {
Layout.alignment: Qt.AlignCenter
source: "image://images/circle-red-cross"

sourceSize.width: 60
sourceSize.height: 60
}

Header {
Layout.fillWidth: true
Layout.topMargin: 20
headerBold: true
header: qsTr("Snapshot Could Not Be Verified")
descriptionBold: false
descriptionColor: Theme.color.neutral6
descriptionSize: 17
descriptionLineHeight: 1.1
description: qsTr("There was a problem with the transactions in the snapshot. Please try a different file.")
}

ContinueButton {
Layout.preferredWidth: Math.min(300, columnLayout.width - 2 * Layout.leftMargin)
Layout.topMargin: 40
Layout.alignment: Qt.AlignCenter
text: qsTr("OK")
onClicked: {
nodeModel.setSnapshotError(false)
back()
}
}
}
}
}
11 changes: 11 additions & 0 deletions qml/controls/GreenCheckIcon.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) 2023 - present 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

Icon {
source: "image://images/green-check"
size: 30
}
2 changes: 2 additions & 0 deletions qml/controls/Header.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ ColumnLayout {
property int subtextSize: 15
property color subtextColor: Theme.color.neutral9
property bool wrap: true
property real descriptionLineHeight: 1

spacing: 0
Loader {
Expand Down Expand Up @@ -60,6 +61,7 @@ ColumnLayout {
text: root.description
horizontalAlignment: root.center ? Text.AlignHCenter : Text.AlignLeft
wrapMode: wrap ? Text.WordWrap : Text.NoWrap
lineHeight: root.descriptionLineHeight

Behavior on color {
ColorAnimation { duration: 150 }
Expand Down
Loading
Loading