Skip to content

Commit db30717

Browse files
committed
Merge remote-tracking branch 'fork/recipients'
2 parents 9c963df + 5642319 commit db30717

File tree

12 files changed

+331
-300
lines changed

12 files changed

+331
-300
lines changed

src/qml/bitcoinamount.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2024 The Bitcoin Core developers
1+
// Copyright (c) 2024-2025 The Bitcoin Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

@@ -66,6 +66,7 @@ void BitcoinAmount::setUnit(const Unit unit)
6666
{
6767
m_unit = unit;
6868
Q_EMIT unitChanged();
69+
Q_EMIT displayChanged();
6970
}
7071

7172
QString BitcoinAmount::unitLabel() const
@@ -85,7 +86,7 @@ void BitcoinAmount::flipUnit()
8586
m_unit = Unit::BTC;
8687
}
8788
Q_EMIT unitChanged();
88-
Q_EMIT amountChanged();
89+
Q_EMIT displayChanged();
8990
}
9091

9192
QString BitcoinAmount::satsToBtcString(qint64 sat)
@@ -151,3 +152,8 @@ void BitcoinAmount::fromDisplay(const QString& text)
151152
}
152153
setSatoshi(newSat);
153154
}
155+
156+
void BitcoinAmount::format()
157+
{
158+
Q_EMIT displayChanged();
159+
}

src/qml/bitcoinamount.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2024 The Bitcoin Core developers
1+
// Copyright (c) 2024-2025 The Bitcoin Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

@@ -15,7 +15,7 @@ class BitcoinAmount : public QObject
1515
Q_OBJECT
1616
Q_PROPERTY(Unit unit READ unit WRITE setUnit NOTIFY unitChanged)
1717
Q_PROPERTY(QString unitLabel READ unitLabel NOTIFY unitChanged)
18-
Q_PROPERTY(QString display READ toDisplay WRITE fromDisplay NOTIFY amountChanged)
18+
Q_PROPERTY(QString display READ toDisplay WRITE fromDisplay NOTIFY displayChanged)
1919
Q_PROPERTY(qint64 satoshi READ satoshi WRITE setSatoshi NOTIFY amountChanged)
2020

2121
public:
@@ -38,6 +38,8 @@ class BitcoinAmount : public QObject
3838

3939
bool isSet() const { return m_isSet; }
4040

41+
Q_INVOKABLE void format();
42+
4143
static QString satsToBtcString(qint64 sat);
4244

4345
public Q_SLOTS:
@@ -47,6 +49,7 @@ public Q_SLOTS:
4749
Q_SIGNALS:
4850
void unitChanged();
4951
void amountChanged();
52+
void displayChanged();
5053

5154
private:
5255
QString sanitize(const QString& text);

src/qml/controls/IconButton.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Button {
6565
},
6666
State {
6767
name: "DISABLED"; when: !root.enabled
68-
PropertyChanges { target: icon; color: Theme.color.neutral2 }
68+
PropertyChanges { target: icon; color: Theme.color.neutral4 }
6969
PropertyChanges { target: bg; color: Theme.color.background }
7070
}
7171
]

src/qml/models/sendrecipient.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class SendRecipient : public QObject
3838
BitcoinAmount* amount() const;
3939
QString amountError() const;
4040
void setAmountError(const QString& error);
41+
void setAmount(const QString& amount);
4142

4243
QString message() const;
4344
void setMessage(const QString& message);

src/qml/models/sendrecipientslistmodel.cpp

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
#include <qml/models/sendrecipient.h>
65
#include <qml/models/sendrecipientslistmodel.h>
6+
7+
#include <qml/models/sendrecipient.h>
78
#include <qml/models/walletqmlmodel.h>
89

910
SendRecipientsListModel::SendRecipientsListModel(QObject* parent)
@@ -54,9 +55,13 @@ void SendRecipientsListModel::add()
5455
auto* recipient = new SendRecipient(m_wallet, this);
5556
connect(recipient->amount(), &BitcoinAmount::amountChanged,
5657
this, &SendRecipientsListModel::updateTotalAmount);
58+
if (m_recipients.size() > 0) {
59+
recipient->amount()->setUnit(m_recipients[m_current]->amount()->unit());
60+
}
5761
m_recipients.append(recipient);
62+
5863
endInsertRows();
59-
Q_EMIT countChanged();
64+
Q_EMIT countChanged();
6065
setCurrentIndex(row);
6166
}
6267

@@ -94,7 +99,7 @@ void SendRecipientsListModel::remove()
9499
endRemoveRows();
95100
Q_EMIT countChanged();
96101

97-
if (m_current > 1) {
102+
if (m_current > 0) {
98103
setCurrentIndex(m_current - 1);
99104
} else {
100105
Q_EMIT currentRecipientChanged();
@@ -144,4 +149,30 @@ void SendRecipientsListModel::clear()
144149
Q_EMIT totalAmountChanged();
145150
Q_EMIT currentRecipientChanged();
146151
Q_EMIT currentIndexChanged();
152+
Q_EMIT listCleared();
153+
}
154+
155+
void SendRecipientsListModel::clearToFront()
156+
{
157+
bool count_changed = false;
158+
while (m_recipients.size() > 1) {
159+
delete m_recipients.at(1);
160+
m_recipients.removeAt(1);
161+
count_changed = true;
162+
}
163+
164+
if (count_changed) {
165+
Q_EMIT countChanged();
166+
}
167+
168+
if (m_totalAmount != m_recipients[0]->amount()->satoshi()) {
169+
m_totalAmount = m_recipients[0]->amount()->satoshi();
170+
Q_EMIT totalAmountChanged();
171+
}
172+
173+
if (m_current != 0) {
174+
m_current = 0;
175+
Q_EMIT currentRecipientChanged();
176+
Q_EMIT currentIndexChanged();
177+
}
147178
}

src/qml/models/sendrecipientslistmodel.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
#ifndef BITCOIN_QML_MODELS_SENDRECIPIENTSLISTMODEL_H
66
#define BITCOIN_QML_MODELS_SENDRECIPIENTSLISTMODEL_H
77

8-
#include <QAbstractListModel>
8+
#include <qml/models/sendrecipient.h>
99

10-
class SendRecipient;
11-
class WalletQmlModel;
10+
#include <QAbstractListModel>
11+
#include <QList>
1212

1313
class SendRecipientsListModel : public QAbstractListModel
1414
{
@@ -37,8 +37,9 @@ class SendRecipientsListModel : public QAbstractListModel
3737
Q_INVOKABLE void prev();
3838
Q_INVOKABLE void remove();
3939
Q_INVOKABLE void clear();
40+
Q_INVOKABLE void clearToFront();
4041

41-
int currentIndex() const { return m_current+1; }
42+
int currentIndex() const { return m_current + 1; }
4243
void setCurrentIndex(int row);
4344
SendRecipient* currentRecipient() const;
4445
int count() const { return m_recipients.size(); }
@@ -51,6 +52,7 @@ class SendRecipientsListModel : public QAbstractListModel
5152
void currentRecipientChanged();
5253
void countChanged();
5354
void totalAmountChanged();
55+
void listCleared();
5456

5557
private:
5658
void updateTotalAmount();

src/qml/models/walletqmlmodel.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
// Copyright (c) 2024 The Bitcoin Core developers
23
// Distributed under the MIT software license, see the accompanying
34
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -144,7 +145,7 @@ bool WalletQmlModel::prepareTransaction()
144145

145146
std::vector<wallet::CRecipient> vecSend;
146147
CAmount total = 0;
147-
for (auto * recipient : m_send_recipients->recipients()) {
148+
for (auto* recipient : m_send_recipients->recipients()) {
148149
CScript scriptPubKey = GetScriptForDestination(DecodeDestination(recipient->address().toStdString()));
149150
wallet::CRecipient c_recipient = {scriptPubKey, recipient->cAmount(), recipient->subtractFeeFromAmount()};
150151
m_coin_control.m_feerate = CFeeRate(1000);

src/qml/pages/node/NodeSettings.qml

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,35 @@ import "../../controls"
99
import "../../components"
1010
import "../settings"
1111

12-
Item {
12+
PageStack {
1313
signal doneClicked
1414

1515
property alias showDoneButton: doneButton.visible
1616

1717
id: root
1818

19-
PageStack {
20-
id: nodeSettingsView
21-
anchors.fill: parent
22-
23-
initialItem: Page {
24-
id: node_settings
25-
background: null
26-
implicitWidth: 450
27-
leftPadding: 20
28-
rightPadding: 20
29-
topPadding: 30
30-
31-
header: NavigationBar2 {
32-
centerItem: Header {
33-
headerBold: true
34-
headerSize: 18
35-
header: "Settings"
36-
}
37-
rightItem: NavButton {
38-
id: doneButton
39-
text: qsTr("Done")
40-
onClicked: root.doneClicked()
41-
}
19+
initialItem: Page {
20+
background: null
21+
header: NavigationBar2 {
22+
centerItem: Header {
23+
headerBold: true
24+
headerSize: 18
25+
header: "Settings"
4226
}
27+
rightItem: NavButton {
28+
id: doneButton
29+
text: qsTr("Done")
30+
onClicked: root.doneClicked()
31+
}
32+
}
33+
contentItem: RowLayout {
4334
ColumnLayout {
35+
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
36+
Layout.fillHeight: false
37+
Layout.fillWidth: true
38+
Layout.margins: 20
39+
Layout.maximumWidth: 450
4440
spacing: 4
45-
width: Math.min(parent.width, 450)
46-
anchors.horizontalCenter: parent.horizontalCenter
4741
Setting {
4842
id: gotoAbout
4943
Layout.fillWidth: true
@@ -52,7 +46,7 @@ Item {
5246
color: gotoAbout.stateColor
5347
}
5448
onClicked: {
55-
nodeSettingsView.push(about_page)
49+
root.push(about_page)
5650
}
5751
}
5852
Separator { Layout.fillWidth: true }
@@ -64,7 +58,7 @@ Item {
6458
color: gotoDisplay.stateColor
6559
}
6660
onClicked: {
67-
nodeSettingsView.push(display_page)
61+
root.push(display_page)
6862
}
6963
}
7064
Separator { Layout.fillWidth: true }
@@ -76,7 +70,7 @@ Item {
7670
color: gotoStorage.stateColor
7771
}
7872
onClicked: {
79-
nodeSettingsView.push(storage_page)
73+
root.push(storage_page)
8074
}
8175
}
8276
Separator { Layout.fillWidth: true }
@@ -88,7 +82,7 @@ Item {
8882
color: gotoConnection.stateColor
8983
}
9084
onClicked: {
91-
nodeSettingsView.push(connection_page)
85+
root.push(connection_page)
9286
}
9387
}
9488
Separator { Layout.fillWidth: true }
@@ -101,7 +95,7 @@ Item {
10195
}
10296
onClicked: {
10397
peerTableModel.startAutoRefresh();
104-
nodeSettingsView.push(peers_page)
98+
root.push(peers_page)
10599
}
106100
}
107101
Separator { Layout.fillWidth: true }
@@ -113,63 +107,67 @@ Item {
113107
color: gotoNetworkTraffic.stateColor
114108
}
115109
onClicked: {
116-
nodeSettingsView.push(networktraffic_page)
110+
root.push(networktraffic_page)
117111
}
118112
}
113+
Item {
114+
Layout.fillHeight: true
115+
}
119116
}
120117
}
121118
}
119+
122120
Component {
123121
id: about_page
124122
SettingsAbout {
125-
onBack: nodeSettingsView.pop()
123+
onBack: root.pop()
126124
}
127125
}
128126
Component {
129127
id: display_page
130128
SettingsDisplay {
131129
onBack: {
132-
nodeSettingsView.pop()
130+
root.pop()
133131
}
134132
}
135133
}
136134
Component {
137135
id: storage_page
138136
SettingsStorage {
139-
onBack: nodeSettingsView.pop()
137+
onBack: root.pop()
140138
}
141139
}
142140
Component {
143141
id: connection_page
144142
SettingsConnection {
145-
onBack: nodeSettingsView.pop()
143+
onBack: root.pop()
146144
}
147145
}
148146
Component {
149147
id: peers_page
150148
Peers {
151149
onBack: {
152-
nodeSettingsView.pop()
150+
root.pop()
153151
peerTableModel.stopAutoRefresh();
154152
}
155153
onPeerSelected: (peerDetails) => {
156-
nodeSettingsView.push(peer_details, {"details": peerDetails})
154+
root.push(peer_details, {"details": peerDetails})
157155
}
158156
}
159157
}
160158
Component {
161159
id: peer_details
162160
PeerDetails {
163161
onBack: {
164-
nodeSettingsView.pop()
162+
root.pop()
165163
}
166164
}
167165
}
168166
Component {
169167
id: networktraffic_page
170168
NetworkTraffic {
171169
showHeader: false
172-
onBack: nodeSettingsView.pop()
170+
onBack: root.pop()
173171
}
174172
}
175173
}

0 commit comments

Comments
 (0)