Skip to content

Commit c9bf7ae

Browse files
committed
qml: Don't allow Coin selection if there are none available
1 parent c31ac8c commit c9bf7ae

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

src/qml/controls/LabeledCoinControlButton.qml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import QtQuick.Layouts 1.15
88

99
Item {
1010
property int coinsSelected: 0
11+
property int coinCount: 0
1112

1213
signal openCoinControl
1314

@@ -32,7 +33,9 @@ Item {
3233
color: Theme.color.orangeLight1
3334
font.pixelSize: 18
3435
text: {
35-
if (coinsSelected === 0) {
36+
if (coinCount === 0) {
37+
qsTr("No coins available")
38+
} else if (coinsSelected === 0) {
3639
qsTr("Select")
3740
} else {
3841
qsTr("%1 input%2 selected")
@@ -43,7 +46,11 @@ Item {
4346

4447
MouseArea {
4548
anchors.fill: parent
46-
onClicked: root.openCoinControl()
49+
onClicked: {
50+
if (coinCount > 0) {
51+
root.openCoinControl()
52+
}
53+
}
4754
cursorShape: Qt.PointingHandCursor
4855
}
4956
}

src/qml/models/coinslistmodel.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
CoinsListModel::CoinsListModel(WalletQmlModel* parent)
1616
: QAbstractListModel(parent), m_wallet_model(parent), m_sort_by("amount"), m_total_amount(0)
1717
{
18+
update();
1819
}
1920

2021
CoinsListModel::~CoinsListModel() = default;
@@ -73,6 +74,7 @@ void CoinsListModel::update()
7374
}
7475
}
7576
endResetModel();
77+
Q_EMIT coinCountChanged();
7678
}
7779

7880
void CoinsListModel::setSortBy(const QString& roleName)
@@ -129,3 +131,8 @@ bool CoinsListModel::overRequiredAmount() const
129131
{
130132
return m_total_amount > m_wallet_model->sendRecipient()->cAmount();
131133
}
134+
135+
int CoinsListModel::coinCount() const
136+
{
137+
return m_coins.size();
138+
}

src/qml/models/coinslistmodel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class CoinsListModel : public QAbstractListModel
2020
Q_OBJECT
2121
Q_PROPERTY(int lockedCoinsCount READ lockedCoinsCount NOTIFY lockedCoinsCountChanged)
2222
Q_PROPERTY(int selectedCoinsCount READ selectedCoinsCount NOTIFY selectedCoinsCountChanged)
23+
Q_PROPERTY(int coinCount READ coinCount NOTIFY coinCountChanged)
2324
Q_PROPERTY(QString totalSelected READ totalSelected NOTIFY selectedCoinsCountChanged)
2425
Q_PROPERTY(QString changeAmount READ changeAmount NOTIFY selectedCoinsCountChanged)
2526
Q_PROPERTY(bool overRequiredAmount READ overRequiredAmount NOTIFY selectedCoinsCountChanged)
@@ -50,11 +51,13 @@ public Q_SLOTS:
5051
QString totalSelected() const;
5152
QString changeAmount() const;
5253
bool overRequiredAmount() const;
54+
int coinCount() const;
5355

5456
Q_SIGNALS:
5557
void sortByChanged(const QString& roleName);
5658
void lockedCoinsCountChanged();
5759
void selectedCoinsCountChanged();
60+
void coinCountChanged();
5861

5962
private:
6063
WalletQmlModel* m_wallet_model;

src/qml/pages/wallet/Send.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ PageStack {
185185
visible: settings.coinControlEnabled
186186
Layout.fillWidth: true
187187
coinsSelected: wallet.coinsListModel.selectedCoinsCount
188+
coinCount: wallet.coinsListModel.coinCount
188189
onOpenCoinControl: {
189190
root.wallet.coinsListModel.update()
190191
root.push(coinSelectionPage)

0 commit comments

Comments
 (0)