Skip to content

Commit 282d27d

Browse files
committed
Merge #389: Introduce Wallet main pages
37e3af6 qml: Remove Done button from Settings in Desktop Wallet (johnny9) 3d3a39e qml: Shorten the DesktopWallet NetworkIndicator (johnny9) 6e42abc qml: Add property to hide NetworkIndicator on BlockClock page (johnny9) 4b79ac2 qml: Introduce DesktopWallets page (johnny9) d556c93 qml: Introduce singlesig-wallet icon (johnny9) bef69da qml: Introduce gear-outline icon (johnny9) f7470ce qml: Add walletEnabled property to AppMode model (johnny9) Pull request description: Adds DesktopWallets.qml and MobileWallets.qml. These pages are the central navigation points for the application when wallets are enabled. A core piece of the page is controlling the navigation flow between the sub pages of the wallet application. For the desktop implementation, a new NavigationBar design is used along with a Stack layout to hold the pages. For mobile, a DirectionalStackView is used to push and pop the wallet sub pages based on the UX designed flow. [![Build Artifacts](https://img.shields.io/badge/Build%20Artifacts-green )]() ACKs for top commit: D33r-Gee: tACK 37e3af6 pablomartin4btc: re tACK 37e3af6 Tree-SHA512: 8ba62f77660ba8bec5682b9dbc1acd400779c2e7edbaa1607dd882a220ea7f4d8c603e2a2f526c817bddb0ce7b207a800ac05bdb654fcf5557ae8ef545e85a06
2 parents b6bf91f + 37e3af6 commit 282d27d

15 files changed

+298
-18
lines changed

src/Makefile.qt.include

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,12 @@ QML_RES_ICONS = \
329329
qml/res/icons/cross.png \
330330
qml/res/icons/export.png \
331331
qml/res/icons/gear.png \
332+
qml/res/icons/gear-outline.png \
332333
qml/res/icons/info.png \
333334
qml/res/icons/network-dark.png \
334335
qml/res/icons/network-light.png \
335336
qml/res/icons/shutdown.png \
337+
qml/res/icons/singlesig-wallet.png \
336338
qml/res/icons/storage-dark.png \
337339
qml/res/icons/storage-light.png
338340

@@ -369,6 +371,7 @@ QML_RES_QML = \
369371
qml/controls/PageIndicator.qml \
370372
qml/controls/NavigationBar.qml \
371373
qml/controls/NavigationBar2.qml \
374+
qml/controls/NavigationTab.qml \
372375
qml/controls/OptionButton.qml \
373376
qml/controls/OptionSwitch.qml \
374377
qml/controls/OutlineButton.qml \
@@ -399,7 +402,8 @@ QML_RES_QML = \
399402
qml/pages/settings/SettingsDisplay.qml \
400403
qml/pages/settings/SettingsProxy.qml \
401404
qml/pages/settings/SettingsStorage.qml \
402-
qml/pages/settings/SettingsTheme.qml
405+
qml/pages/settings/SettingsTheme.qml \
406+
qml/pages/wallet/DesktopWallets.qml
403407

404408
if TARGET_ANDROID
405409
BITCOIN_QT_H += qml/androidnotifier.h

src/qml/appmode.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class AppMode : public QObject
1212
Q_OBJECT
1313
Q_PROPERTY(bool isDesktop READ isDesktop NOTIFY modeChanged)
1414
Q_PROPERTY(bool isMobile READ isMobile NOTIFY modeChanged)
15+
Q_PROPERTY(bool walletEnabled READ walletEnabled NOTIFY walletEnabledChanged)
1516
Q_PROPERTY(QString state READ state NOTIFY modeChanged)
1617

1718
public:
@@ -20,12 +21,15 @@ class AppMode : public QObject
2021
MOBILE
2122
};
2223

23-
explicit AppMode(Mode mode) : m_mode(mode)
24+
explicit AppMode(Mode mode, bool wallet_enabled)
25+
: m_mode(mode)
26+
, m_wallet_enabled(wallet_enabled)
2427
{
2528
}
2629

2730
bool isMobile() { return m_mode == MOBILE; }
2831
bool isDesktop() { return m_mode == DESKTOP; }
32+
bool walletEnabled() { return m_wallet_enabled; }
2933
QString state()
3034
{
3135
switch (m_mode) {
@@ -41,9 +45,11 @@ class AppMode : public QObject
4145

4246
Q_SIGNALS:
4347
void modeChanged();
48+
void walletEnabledChanged();
4449

4550
private:
4651
const Mode m_mode;
52+
const bool m_wallet_enabled;
4753
};
4854

4955
#endif // BITCOIN_QML_APPMODE_H

src/qml/bitcoin.cpp

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,33 @@ void SetupUIArgs(ArgsManager& argsman)
7575
argsman.AddArg("-splash", strprintf("Show splash screen on startup (default: %u)", DEFAULT_SPLASHSCREEN), ArgsManager::ALLOW_ANY, OptionsCategory::GUI);
7676
}
7777

78+
AppMode SetupAppMode()
79+
{
80+
bool wallet_enabled;
81+
AppMode::Mode mode;
82+
#ifdef __ANDROID__
83+
mode = AppMode::MOBILE;
84+
#else
85+
mode = AppMode::DESKTOP;
86+
#endif // __ANDROID__
87+
88+
#ifdef ENABLE_WALLET
89+
wallet_enabled = true;
90+
#else
91+
wallet_enabled = false;
92+
#endif // ENABLE_WALLET
93+
94+
return AppMode(mode, wallet_enabled);
95+
}
96+
7897
bool InitErrorMessageBox(
7998
const bilingual_str& message,
8099
[[maybe_unused]] const std::string& caption,
81100
[[maybe_unused]] unsigned int style)
82101
{
83102
QQmlApplicationEngine engine;
84-
#ifdef __ANDROID__
85-
AppMode app_mode(AppMode::MOBILE);
86-
#else
87-
AppMode app_mode(AppMode::DESKTOP);
88-
#endif // __ANDROID__
103+
104+
AppMode app_mode = SetupAppMode();
89105

90106
qmlRegisterSingletonInstance<AppMode>("org.bitcoincore.qt", 1, 0, "AppMode", &app_mode);
91107
engine.rootContext()->setContextProperty("message", QString::fromStdString(message.translated));
@@ -284,11 +300,8 @@ int QmlGuiMain(int argc, char* argv[])
284300
engine.rootContext()->setContextProperty("optionsModel", &options_model);
285301

286302
engine.rootContext()->setContextProperty("needOnboarding", need_onboarding);
287-
#ifdef __ANDROID__
288-
AppMode app_mode(AppMode::MOBILE);
289-
#else
290-
AppMode app_mode(AppMode::DESKTOP);
291-
#endif // __ANDROID__
303+
304+
AppMode app_mode = SetupAppMode();
292305

293306
qmlRegisterSingletonInstance<AppMode>("org.bitcoincore.qt", 1, 0, "AppMode", &app_mode);
294307
qmlRegisterType<BlockClockDial>("org.bitcoincore.qt", 1, 0, "BlockClockDial");

src/qml/bitcoin_qml.qrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<file>controls/PageIndicator.qml</file>
3232
<file>controls/NavigationBar.qml</file>
3333
<file>controls/NavigationBar2.qml</file>
34+
<file>controls/NavigationTab.qml</file>
3435
<file>controls/OptionButton.qml</file>
3536
<file>controls/OptionSwitch.qml</file>
3637
<file>controls/OutlineButton.qml</file>
@@ -62,6 +63,7 @@
6263
<file>pages/settings/SettingsProxy.qml</file>
6364
<file>pages/settings/SettingsStorage.qml</file>
6465
<file>pages/settings/SettingsTheme.qml</file>
66+
<file>pages/wallet/DesktopWallets.qml</file>
6567
</qresource>
6668
<qresource prefix="/icons">
6769
<file alias="arrow-down">res/icons/arrow-down.png</file>
@@ -78,10 +80,12 @@
7880
<file alias="cross">res/icons/cross.png</file>
7981
<file alias="export">res/icons/export.png</file>
8082
<file alias="gear">res/icons/gear.png</file>
83+
<file alias="gear-outline">res/icons/gear-outline.png</file>
8184
<file alias="info">res/icons/info.png</file>
8285
<file alias="network-dark">res/icons/network-dark.png</file>
8386
<file alias="network-light">res/icons/network-light.png</file>
8487
<file alias="shutdown">res/icons/shutdown.png</file>
88+
<file alias="singlesig-wallet">res/icons/singlesig-wallet.png</file>
8589
<file alias="storage-dark">res/icons/storage-dark.png</file>
8690
<file alias="storage-light">res/icons/storage-light.png</file>
8791
</qresource>

src/qml/components/BlockClock.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Item {
1515
id: root
1616
property real parentWidth: 600
1717
property real parentHeight: 600
18+
property bool showNetworkIndicator: true
1819

1920
width: dial.width
2021
height: dial.height + networkIndicator.height + networkIndicator.anchors.topMargin
@@ -146,6 +147,7 @@ Item {
146147

147148
NetworkIndicator {
148149
id: networkIndicator
150+
show: root.showNetworkIndicator
149151
anchors.top: dial.bottom
150152
anchors.topMargin: networkIndicator.visible ? 30 : 0
151153
anchors.horizontalCenter: root.horizontalCenter

src/qml/components/NetworkIndicator.qml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ import org.bitcoincore.qt 1.0
1212
Button {
1313
id: root
1414
property color bgColor
15+
property bool shorten: false
16+
property bool show: true
1517
property int textSize: 15
1618
topPadding: 2
1719
bottomPadding: 2
1820
leftPadding: 7
1921
rightPadding: 7
20-
state: chainModel.currentNetworkName
22+
state: show ? chainModel.currentNetworkName : "MAIN"
2123
contentItem: CoreText {
2224
text: root.text
2325
font.pixelSize: root.textSize
@@ -47,7 +49,7 @@ Button {
4749
PropertyChanges {
4850
target: root
4951
visible: true
50-
text: qsTr("Test Network")
52+
text: shorten ? qsTr("Testnet") : qsTr("Test Network")
5153
bgColor: Theme.color.green
5254
}
5355
},
@@ -56,7 +58,7 @@ Button {
5658
PropertyChanges {
5759
target: root
5860
visible: true
59-
text: qsTr("Signet Network")
61+
text: shorten ? qsTr("Signet") : qsTr("Signet Network")
6062
bgColor: Theme.color.amber
6163
}
6264
},
@@ -65,7 +67,7 @@ Button {
6567
PropertyChanges {
6668
target: root
6769
visible: true
68-
text: qsTr("Regtest Mode")
70+
text: shorten ? qsTr("Regtest") : qsTr("Regtest Mode")
6971
bgColor: Theme.color.blue
7072
}
7173
}

src/qml/controls/NavigationTab.qml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// Copyright (c) 2024 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
import QtQuick 2.15
6+
import QtQuick.Controls 2.15
7+
import org.bitcoincore.qt 1.0
8+
9+
Button {
10+
property color bgActiveColor: Theme.color.orange
11+
property color textColor: Theme.color.neutral7
12+
property color textHoverColor: Theme.color.neutral9
13+
property color textActiveColor: Theme.color.orange
14+
property color iconColor: "transparent"
15+
property string iconSource: ""
16+
17+
id: root
18+
checkable: true
19+
hoverEnabled: AppMode.isDesktop
20+
implicitHeight: 60
21+
implicitWidth: 80
22+
bottomPadding: 0
23+
topPadding: 0
24+
25+
contentItem: Item {
26+
width: parent.width
27+
height: parent.height
28+
CoreText {
29+
id: buttonText
30+
font.pixelSize: 15
31+
text: root.text
32+
color: root.textColor
33+
bold: true
34+
visible: root.text !== ""
35+
anchors.centerIn: parent
36+
}
37+
Icon {
38+
id: icon
39+
source: root.iconSource
40+
color: iconColor
41+
visible: root.iconSource !== ""
42+
anchors.centerIn: parent
43+
}
44+
}
45+
46+
background: Item {
47+
Rectangle {
48+
id: bg
49+
height: parent.height - 5
50+
width: parent.width
51+
radius: 5
52+
color: Theme.color.neutral3
53+
visible: root.hovered
54+
55+
FocusBorder {
56+
visible: root.visualFocus
57+
}
58+
59+
Behavior on color {
60+
ColorAnimation { duration: 150 }
61+
}
62+
}
63+
Rectangle {
64+
anchors.bottom: parent.bottom
65+
width: parent.width
66+
height: 3
67+
visible: root.checked
68+
color: root.bgActiveColor
69+
}
70+
}
71+
72+
states: [
73+
State {
74+
name: "CHECKED"; when: root.checked
75+
PropertyChanges { target: buttonText; color: root.textActiveColor }
76+
PropertyChanges { target: icon; color: root.textActiveColor }
77+
},
78+
State {
79+
name: "HOVER"; when: root.hovered
80+
PropertyChanges { target: buttonText; color: root.textHoverColor }
81+
PropertyChanges { target: icon; color: root.textHoverColor }
82+
}
83+
]
84+
}

src/qml/imageprovider.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ QPixmap ImageProvider::requestPixmap(const QString& id, QSize* size, const QSize
9292
return QIcon(":/icons/gear").pixmap(requested_size);
9393
}
9494

95+
if (id == "gear-outline") {
96+
*size = requested_size;
97+
return QIcon(":/icons/gear-outline").pixmap(requested_size);
98+
}
99+
95100
if (id == "info") {
96101
*size = requested_size;
97102
return QIcon(":/icons/info").pixmap(requested_size);
@@ -112,6 +117,11 @@ QPixmap ImageProvider::requestPixmap(const QString& id, QSize* size, const QSize
112117
return QIcon(":/icons/shutdown").pixmap(requested_size);
113118
}
114119

120+
if (id == "singlesig-wallet") {
121+
*size = requested_size;
122+
return QIcon(":/icons/singlesig-wallet").pixmap(requested_size);
123+
}
124+
115125
if (id == "storage-dark") {
116126
*size = requested_size;
117127
return QIcon(":/icons/storage-dark").pixmap(requested_size);

src/qml/pages/main.qml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import "../components"
1111
import "../controls"
1212
import "./onboarding"
1313
import "./node"
14+
import "./wallet"
1415

1516
ApplicationWindow {
1617
id: appWindow
@@ -33,7 +34,17 @@ ApplicationWindow {
3334

3435
StackView {
3536
id: main
36-
initialItem: needOnboarding ? onboardingWizard : node
37+
initialItem: {
38+
if (needOnboarding) {
39+
onboardingWizard
40+
} else {
41+
if (AppMode.walletEnabled && AppMode.isDesktop) {
42+
desktopWallets
43+
} else {
44+
node
45+
}
46+
}
47+
}
3748
anchors.fill: parent
3849
focus: true
3950
Keys.onReleased: {
@@ -66,10 +77,21 @@ ApplicationWindow {
6677
OnboardingStorageAmount {}
6778
OnboardingConnection {}
6879

69-
onFinishedChanged: main.push(node)
80+
onFinishedChanged: {
81+
if (AppMode.walletEnabled && AppMode.isDesktop) {
82+
main.push(desktopWallets)
83+
} else {
84+
main.push(node)
85+
}
86+
}
7087
}
7188
}
7289

90+
Component {
91+
id: desktopWallets
92+
DesktopWallets {}
93+
}
94+
7395
Component {
7496
id: shutdown
7597
Shutdown {}

src/qml/pages/node/NodeSettings.qml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import "../settings"
1212
Item {
1313
signal doneClicked
1414

15+
property alias showDoneButton: doneButton.visible
16+
1517
id: root
1618

1719
StackView {
@@ -33,6 +35,7 @@ Item {
3335
header: "Settings"
3436
}
3537
rightItem: NavButton {
38+
id: doneButton
3639
text: qsTr("Done")
3740
onClicked: root.doneClicked()
3841
}

0 commit comments

Comments
 (0)