Skip to content

Commit

Permalink
qml: Introduce Create Wallet Single-Sig flow
Browse files Browse the repository at this point in the history
  • Loading branch information
johnny9 committed May 28, 2024
1 parent 0266742 commit fb61899
Show file tree
Hide file tree
Showing 22 changed files with 615 additions and 6 deletions.
18 changes: 15 additions & 3 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ QT_MOC_CPP = \
qml/models/moc_options_model.cpp \
qml/models/moc_peerlistsortproxy.cpp \
qml/moc_appmode.cpp \
qml/moc_walletcontroller.cpp \
qt/moc_addressbookpage.cpp \
qt/moc_addresstablemodel.cpp \
qt/moc_askpassphrasedialog.cpp \
Expand Down Expand Up @@ -310,7 +311,8 @@ BITCOIN_QML_BASE_CPP = \
qml/models/options_model.cpp \
qml/models/peerlistsortproxy.cpp \
qml/imageprovider.cpp \
qml/util.cpp
qml/util.cpp \
qml/walletcontroller.cpp

QML_RES_FONTS = \
qml/res/fonts/Inter-Regular.otf \
Expand All @@ -332,6 +334,7 @@ QML_RES_ICONS = \
qml/res/icons/export.png \
qml/res/icons/gear.png \
qml/res/icons/gear-outline.png \
qml/res/icons/hidden.png \
qml/res/icons/info.png \
qml/res/icons/network-dark.png \
qml/res/icons/network-light.png \
Expand All @@ -340,7 +343,9 @@ QML_RES_ICONS = \
qml/res/icons/storage-dark.png \
qml/res/icons/storage-light.png \
qml/res/icons/tooltip-arrow-dark.png \
qml/res/icons/tooltip-arrow-light.png
qml/res/icons/tooltip-arrow-light.png \
qml/res/icons/wallet.png \
qml/res/icons/visible.png

QML_QRC_CPP = qml/qrc_bitcoin.cpp
QML_QRC = qml/bitcoin_qml.qrc
Expand All @@ -349,7 +354,6 @@ QML_RES_QML = \
qml/components/BlockClock.qml \
qml/components/BlockClockDisplayMode.qml \
qml/components/BlockCounter.qml \
qml/controls/CaretRightIcon.qml \
qml/components/ConnectionOptions.qml \
qml/components/ConnectionSettings.qml \
qml/components/DeveloperOptions.qml \
Expand All @@ -365,8 +369,10 @@ QML_RES_QML = \
qml/components/ThemeSettings.qml \
qml/components/TotalBytesIndicator.qml \
qml/components/Tooltip.qml \
qml/controls/CaretRightIcon.qml \
qml/controls/ContinueButton.qml \
qml/controls/CoreText.qml \
qml/controls/CoreTextField.qml \
qml/controls/ExternalLink.qml \
qml/controls/FocusBorder.qml \
qml/controls/Header.qml \
Expand Down Expand Up @@ -410,6 +416,12 @@ QML_RES_QML = \
qml/pages/settings/SettingsProxy.qml \
qml/pages/settings/SettingsStorage.qml \
qml/pages/settings/SettingsTheme.qml \
qml/pages/wallet/AddWallet.qml \
qml/pages/wallet/CreateBackup.qml \
qml/pages/wallet/CreateConfirm.qml \
qml/pages/wallet/CreateIntro.qml \
qml/pages/wallet/CreateName.qml \
qml/pages/wallet/CreatePassword.qml \
qml/pages/wallet/DesktopWallets.qml

if TARGET_ANDROID
Expand Down
6 changes: 5 additions & 1 deletion src/qml/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
#endif
#include <qml/components/blockclockdial.h>
#include <qml/controls/linegraph.h>
#include <qml/guiconstants.h>
#include <qml/models/chainmodel.h>
#include <qml/models/networktraffictower.h>
#include <qml/models/nodemodel.h>
#include <qml/models/options_model.h>
#include <qml/models/peerlistsortproxy.h>
#include <qml/imageprovider.h>
#include <qml/util.h>
#include <qml/guiconstants.h>
#include <qml/walletcontroller.h>
#include <qt/guiutil.h>
#include <qt/initexecutor.h>
#include <qt/networkstyle.h>
Expand Down Expand Up @@ -286,6 +287,8 @@ int QmlGuiMain(int argc, char* argv[])
GUIUtil::LoadFont(":/fonts/inter/regular");
GUIUtil::LoadFont(":/fonts/inter/semibold");

WalletController wallet_controller(*node);

QQmlApplicationEngine engine;

QScopedPointer<const NetworkStyle> network_style{NetworkStyle::instantiate(Params().GetChainType())};
Expand All @@ -297,6 +300,7 @@ int QmlGuiMain(int argc, char* argv[])
engine.rootContext()->setContextProperty("chainModel", &chain_model);
engine.rootContext()->setContextProperty("peerTableModel", &peer_model);
engine.rootContext()->setContextProperty("peerListModelProxy", &peer_model_sort_proxy);
engine.rootContext()->setContextProperty("walletController", &wallet_controller);

OptionsQmlModel options_model(*node, !need_onboarding.toBool());
engine.rootContext()->setContextProperty("optionsModel", &options_model);
Expand Down
9 changes: 9 additions & 0 deletions src/qml/bitcoin_qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<file>components/Tooltip.qml</file>
<file>controls/ContinueButton.qml</file>
<file>controls/CoreText.qml</file>
<file>controls/CoreTextField.qml</file>
<file>controls/ExternalLink.qml</file>
<file>controls/FocusBorder.qml</file>
<file>controls/Header.qml</file>
Expand Down Expand Up @@ -66,6 +67,11 @@
<file>pages/settings/SettingsStorage.qml</file>
<file>pages/settings/SettingsTheme.qml</file>
<file>pages/wallet/AddWallet.qml</file>
<file>pages/wallet/CreateBackup.qml</file>
<file>pages/wallet/CreateConfirm.qml</file>
<file>pages/wallet/CreateIntro.qml</file>
<file>pages/wallet/CreateName.qml</file>
<file>pages/wallet/CreatePassword.qml</file>
<file>pages/wallet/DesktopWallets.qml</file>
</qresource>
<qresource prefix="/icons">
Expand All @@ -85,6 +91,7 @@
<file alias="export">res/icons/export.png</file>
<file alias="gear">res/icons/gear.png</file>
<file alias="gear-outline">res/icons/gear-outline.png</file>
<file alias="hidden">res/icons/hidden.png</file>
<file alias="info">res/icons/info.png</file>
<file alias="network-dark">res/icons/network-dark.png</file>
<file alias="network-light">res/icons/network-light.png</file>
Expand All @@ -94,6 +101,8 @@
<file alias="storage-light">res/icons/storage-light.png</file>
<file alias="tooltip-arrow-dark">res/icons/tooltip-arrow-dark.png</file>
<file alias="tooltip-arrow-light">res/icons/tooltip-arrow-light.png</file>
<file alias="wallet">res/icons/wallet.png</file>
<file alias="visible">res/icons/visible.png</file>
</qresource>
<qresource prefix="/fonts">
<file alias="inter/regular">res/fonts/Inter-Regular.otf</file>
Expand Down
50 changes: 50 additions & 0 deletions src/qml/controls/CoreTextField.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) 2022 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

TextField {
id: root

property bool hideText: false

implicitHeight: 56
implicitWidth: 450
font.family: "Inter"
font.styleName: "Regular"
font.pixelSize: 18
color: Theme.color.neutral9
placeholderTextColor: Theme.color.neutral5
echoMode: hideText ? TextInput.Password : TextInput.Normal
rightPadding: hideText ? 46 : 20
leftPadding: 20
background: Rectangle {
border.color: Theme.color.neutral5
border.width: 1
color: "transparent"
radius: 5

Icon {
id: visibleIcon
enabled: hideText
visible: hideText
anchors.right: parent.right
anchors.rightMargin: 12
size: 24
anchors.verticalCenter: parent.verticalCenter
source: "qrc:/icons/visible"
color: Theme.color.neutral5
onClicked: {
if (root.echoMode == TextInput.Password) {
root.echoMode = TextInput.Normal
visibleIcon.source = "qrc:/icons/hidden"
} else {
root.echoMode = TextInput.Password
visibleIcon.source = "qrc:/icons/visible"
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/qml/controls/Setting.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.bitcoincore.qt 1.0

AbstractButton {
id: root
required property string header
property string header
property alias actionItem: action_loader.sourceComponent
property alias loadedItem: action_loader.item
property string description
Expand Down
3 changes: 3 additions & 0 deletions src/qml/pages/wallet/AddWallet.qml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ StackView {
Layout.bottomMargin: 20
Layout.alignment: Qt.AlignCenter
text: qsTr("Create wallet")
onClicked: {
addWalletStack.push("qrc:/qml/pages/wallet/CreateIntro.qml");
}
}

ContinueButton {
Expand Down
89 changes: 89 additions & 0 deletions src/qml/pages/wallet/CreateBackup.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Copyright (c) 2024 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 "../../controls"
import "../../components"
import "../settings"

Page {
id: root
background: null

header: NavigationBar2 {
id: navbar
leftItem: NavButton {
iconSource: "image://images/caret-left"
text: qsTr("Back")
onClicked: {
root.StackView.view.pop()
}
}
}

ColumnLayout {
id: columnLayout
width: Math.min(parent.width, 450)
anchors.horizontalCenter: parent.horizontalCenter

Item {
Layout.alignment: Qt.AlignCenter
Layout.preferredHeight: circle.height
Layout.preferredWidth: circle.width
Rectangle {
id: circle
width: 60
height: width
radius: width / 2
color: Theme.color.blue
}
Icon {
source: "image://images/wallet"
color: Theme.color.white
width: 30
height: width
anchors.centerIn: circle
}
}

Header {
Layout.topMargin: 20
Layout.leftMargin: 20
Layout.rightMargin: 20
header: qsTr("Back up your wallet")
description: qsTr("Your wallet is a file stored on your hard disk.\nTo prevent accidental loss, it is recommended you keep a copy of your wallet file in a secure place, like a dedicated USB Drive.")
}

ContinueButton {
Layout.preferredWidth: Math.min(300, parent.width - 2 * Layout.leftMargin)
Layout.topMargin: 30
Layout.leftMargin: 20
Layout.rightMargin: Layout.leftMargin
Layout.alignment: Qt.AlignCenter
text: qsTr("View file")
borderColor: Theme.color.neutral6
borderHoverColor: Theme.color.orangeLight1
borderPressedColor: Theme.color.orangeLight2
textColor: Theme.color.orange
backgroundColor: "transparent"
backgroundHoverColor: "transparent"
backgroundPressedColor: "transparent"
}

ContinueButton {
Layout.preferredWidth: Math.min(300, parent.width - 2 * Layout.leftMargin)
Layout.topMargin: 30
Layout.leftMargin: 20
Layout.rightMargin: Layout.leftMargin
Layout.alignment: Qt.AlignCenter
text: qsTr("Done")
onClicked: {
root.StackView.view.finished()
}
}
}
}
73 changes: 73 additions & 0 deletions src/qml/pages/wallet/CreateConfirm.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright (c) 2024 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 "../../controls"
import "../../components"
import "../settings"

Page {
id: root
background: null

header: NavigationBar2 {
id: navbar
leftItem: NavButton {
iconSource: "image://images/caret-left"
text: qsTr("Back")
onClicked: {
root.StackView.view.pop()
}
}
}

ColumnLayout {
id: columnLayout
width: Math.min(parent.width, 450)
anchors.horizontalCenter: parent.horizontalCenter

Item {
Layout.alignment: Qt.AlignCenter
Layout.preferredHeight: circle.height
Layout.preferredWidth: circle.width
Rectangle {
id: circle
width: 60
height: width
radius: width / 2
color: Theme.color.green
}
Icon {
source: "image://images/wallet"
color: Theme.color.white
width: 30
height: width
anchors.centerIn: circle
}
}

Header {
Layout.topMargin: 20
Layout.leftMargin: 20
Layout.rightMargin: 20
header: qsTr("Your wallet has been created")
description: qsTr("It is good practice to make a small test transaction before you actively use this wallet for larger amounts.")
}

ContinueButton {
Layout.preferredWidth: Math.min(300, parent.width - 2 * Layout.leftMargin)
Layout.topMargin: 30
Layout.leftMargin: 20
Layout.rightMargin: Layout.leftMargin
Layout.alignment: Qt.AlignCenter
text: qsTr("Next")
onClicked: {
root.StackView.view.push("qrc:/qml/pages/wallet/CreateBackup.qml")
}
}
}
}
Loading

0 comments on commit fb61899

Please sign in to comment.