Skip to content

Commit f8f995d

Browse files
committed
qml: When multipleRecipients is disabled, clearToFront of the list
1 parent 5893fd5 commit f8f995d

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

src/qml/models/sendrecipientslistmodel.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,28 @@ void SendRecipientsListModel::clear()
144144
Q_EMIT currentRecipientChanged();
145145
Q_EMIT currentIndexChanged();
146146
}
147+
148+
void SendRecipientsListModel::clearToFront()
149+
{
150+
bool count_changed = false;
151+
while (m_recipients.size() > 1) {
152+
delete m_recipients.at(1);
153+
m_recipients.removeAt(1);
154+
count_changed = true;
155+
}
156+
157+
if (count_changed) {
158+
Q_EMIT countChanged();
159+
}
160+
161+
if (m_totalAmount != m_recipients[0]->amount()->satoshi()) {
162+
m_totalAmount = m_recipients[0]->amount()->satoshi();
163+
Q_EMIT totalAmountChanged();
164+
}
165+
166+
if (m_current != 0) {
167+
m_current = 0;
168+
Q_EMIT currentRecipientChanged();
169+
Q_EMIT currentIndexChanged();
170+
}
171+
}

src/qml/models/sendrecipientslistmodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class SendRecipientsListModel : public QAbstractListModel
3838
Q_INVOKABLE void prev();
3939
Q_INVOKABLE void remove();
4040
Q_INVOKABLE void clear();
41+
Q_INVOKABLE void clearToFront();
4142

4243
int currentIndex() const { return m_current + 1; }
4344
void setCurrentIndex(int row);

src/qml/pages/wallet/Send.qml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ PageStack {
3434
id: settings
3535
property alias coinControlEnabled: sendOptionsPopup.coinControlEnabled
3636
property alias multipleRecipientsEnabled: sendOptionsPopup.multipleRecipientsEnabled
37+
38+
onMultipleRecipientsEnabledChanged: {
39+
if (!multipleRecipientsEnabled) {
40+
root.wallet.recipients.clearToFront()
41+
}
42+
}
3743
}
3844

3945
ScrollView {

0 commit comments

Comments
 (0)