Skip to content

Commit 132e03f

Browse files
committed
qml: Add remove button to multiple recipients
1 parent c259984 commit 132e03f

File tree

5 files changed

+36
-19
lines changed

5 files changed

+36
-19
lines changed

src/qml/models/sendrecipientslistmodel.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

55
#include <qml/models/sendrecipientslistmodel.h>
6+
#include <qobjectdefs.h>
67

78
#include <qml/models/sendrecipient.h>
89

src/qml/models/sendrecipientslistmodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <QAbstractListModel>
1111
#include <QList>
12+
#include <qobjectdefs.h>
1213

1314
class SendRecipientsListModel : public QAbstractListModel
1415
{

src/qml/models/walletqmlmodel.cpp

Lines changed: 2 additions & 10 deletions
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.
@@ -6,6 +7,7 @@
67

78
#include <qml/models/activitylistmodel.h>
89
#include <qml/models/sendrecipient.h>
10+
#include <qml/models/sendrecipientslistmodel.h>
911
#include <qml/models/walletqmlmodeltransaction.h>
1012

1113
#include <consensus/amount.h>
@@ -208,13 +210,3 @@ std::vector<COutPoint> WalletQmlModel::listSelectedCoins() const
208210
{
209211
return m_coin_control.ListSelected();
210212
}
211-
212-
int WalletQmlModel::recipientIndex() const
213-
{
214-
return 1;
215-
}
216-
217-
int WalletQmlModel::recipientsCount() const
218-
{
219-
return 1;
220-
}

src/qml/models/walletqmlmodel.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ class WalletQmlModel : public QObject
3030
Q_PROPERTY(SendRecipient* sendRecipient READ sendRecipient CONSTANT)
3131
Q_PROPERTY(SendRecipientsListModel* recipients READ sendRecipientList CONSTANT)
3232
Q_PROPERTY(WalletQmlModelTransaction* currentTransaction READ currentTransaction NOTIFY currentTransactionChanged)
33-
Q_PROPERTY(int recipientIndex READ recipientIndex NOTIFY recipientIndexChanged)
34-
Q_PROPERTY(int recipientsCount READ recipientsCount NOTIFY recipientsCountChanged)
3533

3634
public:
3735
WalletQmlModel(std::unique_ptr<interfaces::Wallet> wallet, QObject* parent = nullptr);
@@ -68,15 +66,10 @@ class WalletQmlModel : public QObject
6866
bool isSelectedCoin(const COutPoint& output);
6967
std::vector<COutPoint> listSelectedCoins() const;
7068

71-
int recipientIndex() const;
72-
int recipientsCount() const;
73-
7469
Q_SIGNALS:
7570
void nameChanged();
7671
void balanceChanged();
7772
void currentTransactionChanged();
78-
void recipientIndexChanged();
79-
void recipientsCountChanged();
8073

8174
private:
8275
std::unique_ptr<interfaces::Wallet> m_wallet;

src/qml/pages/wallet/Send.qml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ PageStack {
1616
vertical: true
1717

1818
property WalletQmlModel wallet: walletController.selectedWallet
19-
property SendRecipient recipient: wallet.sendRecipient
19+
property SendRecipient recipient: wallet.recipients.current
2020

2121
signal transactionPrepared()
2222

@@ -97,6 +97,9 @@ PageStack {
9797
iconWidth: 30
9898
iconHeight: 30
9999
iconSource: "image://images/caret-left"
100+
onClicked: {
101+
wallet.recipients.prev()
102+
}
100103
}
101104

102105
NavButton {
@@ -105,14 +108,41 @@ PageStack {
105108
iconWidth: 30
106109
iconHeight: 30
107110
iconSource: "image://images/caret-right"
111+
onClicked: {
112+
wallet.recipients.next()
113+
}
108114
}
109115

110116
CoreText {
117+
Layout.fillWidth: true
118+
Layout.alignment: Qt.AlignLeft
111119
id: selectAndAddRecipientsLabel
112-
text: qsTr("Recipient %1 of %2").arg(wallet.recipientIndex).arg(wallet.recipientsCount)
120+
text: qsTr("Recipient %1 of %2").arg(wallet.recipients.currentIndex).arg(wallet.recipients.count)
113121
font.pixelSize: 18
114122
color: Theme.color.neutral9
115123
}
124+
125+
NavButton {
126+
Layout.preferredWidth: 30
127+
Layout.preferredHeight: 30
128+
iconWidth: 20
129+
iconHeight: 20
130+
iconSource: "image://images/plus"
131+
onClicked: {
132+
wallet.recipients.add()
133+
}
134+
}
135+
NavButton {
136+
Layout.preferredWidth: 30
137+
Layout.preferredHeight: 30
138+
iconWidth: 20
139+
iconHeight: 20
140+
iconSource: "image://images/minus"
141+
visible: wallet.recipients.count > 1
142+
onClicked: {
143+
wallet.recipients.remove()
144+
}
145+
}
116146
}
117147

118148
Separator {

0 commit comments

Comments
 (0)