Skip to content

Commit 15df21c

Browse files
committed
Merge #251: Introduce and Use NetworkIndicator component
01b3909 qml: use NetworkIndicator, change layout of NodeRunner to accommodate (jarolrod) 0e01340 qml: introduce NetworkIndicator component (jarolrod) b48f4f2 qml: introduce amber color to our Theme file (jarolrod) 7b8d134 qml: set and expose the current network name from the ChainModel (jarolrod) Pull request description: Signals to the user when they are running on a network other than main. Closes #233 #### Light | testnet | signet | regtest | | ------- | ------ | ------- | | <img width="752" alt="Screen Shot 2023-02-08 at 6 48 47 PM" src="https://user-images.githubusercontent.com/23396902/217695964-9ceaea19-461c-485a-b41e-b3d0d3ff4211.png"> | <img width="752" alt="Screen Shot 2023-02-08 at 6 39 00 PM" src="https://user-images.githubusercontent.com/23396902/217695987-07455475-ede9-4394-bdb5-14e0a8246123.png"> | <img width="752" alt="Screen Shot 2023-02-08 at 6 39 21 PM" src="https://user-images.githubusercontent.com/23396902/217696012-a2dda1e0-e7a1-4ecc-9655-2a7ea55c9f75.png"> | #### Dark | testnet | signet | regtest | | ------- | ------ | ------- | | <img width="752" alt="Screen Shot 2023-02-07 at 5 24 23 PM" src="https://user-images.githubusercontent.com/23396902/217380996-91c16d78-fc49-49b5-9e33-73708dce3c15.png"> | <img width="752" alt="Screen Shot 2023-02-07 at 5 24 50 PM" src="https://user-images.githubusercontent.com/23396902/217381059-3147923e-b73f-4e2f-935d-77ce74554b71.png"> | <img width="752" alt="Screen Shot 2023-02-07 at 5 25 34 PM" src="https://user-images.githubusercontent.com/23396902/217381100-9f1c67e8-70e5-4658-ac73-7a78d6d26339.png"> | [![Windows](https://img.shields.io/badge/OS-Windows-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/win64/insecure_win_gui.zip?branch=pull/<PR>) [![Intel macOS](https://img.shields.io/badge/OS-Intel%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos/insecure_mac_gui.zip?branch=pull/<PR>) [![Apple Silicon macOS](https://img.shields.io/badge/OS-Apple%20Silicon%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos_arm64/insecure_mac_arm64_gui.zip?branch=pull/<PR>) [![ARM64 Android](https://img.shields.io/badge/OS-Android-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/android/insecure_android_apk.zip?branch=pull/<PR>) ACKs for top commit: johnny9: ACK 01b3909 Tree-SHA512: 0e166aca51930b70108d17d094d753d0933183112db7658b4a207f1e8d254a4dfda7b33c6a14470c8e0b8e3e18d3428f079b66c28b8e4a8b63f52f5d6fc1ea16
2 parents 5161711 + 01b3909 commit 15df21c

File tree

9 files changed

+96
-2
lines changed

9 files changed

+96
-2
lines changed

src/Makefile.qt.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ QML_RES_QML = \
335335
qml/components/ConnectionSettings.qml \
336336
qml/components/DeveloperOptions.qml \
337337
qml/components/PeersIndicator.qml \
338+
qml/components/NetworkIndicator.qml \
338339
qml/components/StorageLocations.qml \
339340
qml/components/StorageOptions.qml \
340341
qml/components/StorageSettings.qml \

src/qml/bitcoin.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ int QmlGuiMain(int argc, char* argv[])
175175
// QObject::connect(&init_executor, &InitExecutor::runawayException, &node_model, &NodeModel::handleRunawayException);
176176

177177
ChainModel chain_model{*chain};
178+
chain_model.setCurrentNetworkName(QString::fromStdString(gArgs.GetChainName()));
178179

179180
QObject::connect(&node_model, &NodeModel::setTimeRatioList, &chain_model, &ChainModel::setTimeRatioList);
180181
QObject::connect(&node_model, &NodeModel::setTimeRatioListInitial, &chain_model, &ChainModel::setTimeRatioListInitial);

src/qml/bitcoin_qml.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<file>components/ConnectionSettings.qml</file>
99
<file>components/PeersIndicator.qml</file>
1010
<file>components/DeveloperOptions.qml</file>
11+
<file>components/NetworkIndicator.qml</file>
1112
<file>components/StorageLocations.qml</file>
1213
<file>components/StorageOptions.qml</file>
1314
<file>components/StorageSettings.qml</file>

src/qml/chainmodel.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <qml/chainmodel.h>
66

77
#include <QDateTime>
8+
#include <QString>
89
#include <QThread>
910
#include <QTime>
1011
#include <interfaces/chain.h>
@@ -21,6 +22,12 @@ ChainModel::ChainModel(interfaces::Chain& chain)
2122
timer_thread->start();
2223
}
2324

25+
void ChainModel::setCurrentNetworkName(QString network_name)
26+
{
27+
m_current_network_name = network_name.toUpper();
28+
Q_EMIT currentNetworkNameChanged();
29+
}
30+
2431
void ChainModel::setTimeRatioList(int new_time)
2532
{
2633
if (m_time_ratio_list.isEmpty()) {

src/qml/chainmodel.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <interfaces/chain.h>
99

1010
#include <QObject>
11+
#include <QString>
1112
#include <QTimer>
1213
#include <QVariant>
1314

@@ -21,11 +22,14 @@ static const int SECS_IN_12_HOURS = 43200;
2122
class ChainModel : public QObject
2223
{
2324
Q_OBJECT
25+
Q_PROPERTY(QString currentNetworkName READ currentNetworkName WRITE setCurrentNetworkName NOTIFY currentNetworkNameChanged)
2426
Q_PROPERTY(QVariantList timeRatioList READ timeRatioList NOTIFY timeRatioListChanged)
2527

2628
public:
2729
explicit ChainModel(interfaces::Chain& chain);
2830

31+
QString currentNetworkName() const { return m_current_network_name; };
32+
void setCurrentNetworkName(QString network_name);
2933
QVariantList timeRatioList() const { return m_time_ratio_list; };
3034

3135
int timestampAtMeridian();
@@ -38,8 +42,10 @@ public Q_SLOTS:
3842

3943
Q_SIGNALS:
4044
void timeRatioListChanged();
45+
void currentNetworkNameChanged();
4146

4247
private:
48+
QString m_current_network_name;
4349
/* time_ratio: Ratio between the time at which an event
4450
* happened and 12 hours. So, for example, if a block is
4551
* found at 4 am or pm, the time_ratio would be 0.3.

src/qml/components/BlockClock.qml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import "../controls"
1313
Item {
1414
id: root
1515

16-
Layout.alignment: Qt.AlignCenter
1716
implicitWidth: 200
1817
implicitHeight: 200
1918

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright (c) 2023 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 "../controls"
8+
import "../components"
9+
10+
import org.bitcoincore.qt 1.0
11+
12+
Button {
13+
id: root
14+
property color bgColor
15+
property int textSize: 18
16+
font.family: "Inter"
17+
font.styleName: "Regular"
18+
font.pixelSize: root.textSize
19+
padding: 7
20+
state: chainModel.currentNetworkName
21+
contentItem: Text {
22+
text: root.text
23+
font: root.font
24+
color: Theme.color.white
25+
horizontalAlignment: Text.AlignHCenter
26+
verticalAlignment: Text.AlignVCenter
27+
}
28+
background: Rectangle {
29+
id: bg
30+
color: root.bgColor
31+
radius: 2
32+
}
33+
states: [
34+
State {
35+
name: "MAIN"
36+
PropertyChanges {
37+
target: root
38+
visible: false
39+
}
40+
},
41+
State {
42+
name: "TEST"
43+
PropertyChanges {
44+
target: root
45+
visible: true
46+
text: qsTr("Test Network")
47+
bgColor: Theme.color.green
48+
}
49+
},
50+
State {
51+
name: "SIGNET"
52+
PropertyChanges {
53+
target: root
54+
visible: true
55+
text: qsTr("Signet Network")
56+
bgColor: Theme.color.amber
57+
}
58+
},
59+
State {
60+
name: "REGTEST"
61+
PropertyChanges {
62+
target: root
63+
visible: true
64+
text: qsTr("Regtest Mode")
65+
bgColor: Theme.color.blue
66+
}
67+
}
68+
]
69+
}

src/qml/controls/Theme.qml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Control {
1616
required property color red
1717
required property color green
1818
required property color blue
19+
required property color amber
1920
required property color purple
2021
required property color neutral0
2122
required property color neutral1
@@ -46,6 +47,7 @@ Control {
4647
red: "#EC6363"
4748
green: "#36B46B"
4849
blue: "#3CA3DE"
50+
amber: "#C9B500"
4951
purple: "#C075DC"
5052
neutral0: "#000000"
5153
neutral1: "#1A1A1A"
@@ -77,6 +79,7 @@ Control {
7779
red: "#EB5757"
7880
green: "#27AE60"
7981
blue: "#2D9CDB"
82+
amber: "#C9B500"
8083
purple: "#BB6BD9"
8184
neutral0: "#FFFFFF"
8285
neutral1: "#F8F8F8"

src/qml/pages/node/NodeRunner.qml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ Page {
1818

1919
Component.onCompleted: nodeModel.startNodeInitializionThread();
2020

21-
BlockClock {
21+
ColumnLayout {
22+
spacing: 30
2223
anchors.centerIn: parent
24+
BlockClock {
25+
Layout.alignment: Qt.AlignCenter
26+
}
27+
NetworkIndicator {
28+
Layout.alignment: Qt.AlignCenter
29+
}
2330
}
2431
}

0 commit comments

Comments
 (0)