File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -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
7172QString 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
9192QString 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+ }
Original file line number Diff line number Diff line change @@ -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
2121public:
@@ -36,6 +36,10 @@ class BitcoinAmount : public QObject
3636 qint64 satoshi () const ;
3737 void setSatoshi (qint64 new_amount);
3838
39+ bool isSet () const { return m_isSet; }
40+
41+ Q_INVOKABLE void format ();
42+
3943 static QString satsToBtcString (qint64 sat);
4044
4145public Q_SLOTS:
@@ -45,6 +49,7 @@ public Q_SLOTS:
4549Q_SIGNALS:
4650 void unitChanged ();
4751 void amountChanged ();
52+ void displayChanged ();
4853
4954private:
5055 QString sanitize (const QString& text);
Original file line number Diff line number Diff line change @@ -194,7 +194,8 @@ PageStack {
194194 placeholderText: " 0.00000000"
195195 selectByMouse: true
196196 text: root .recipient .amount .display
197- onEditingFinished: root .recipient .amount .display = text
197+ onTextEdited: root .recipient .amount .display = text
198+ onEditingFinished: root .recipient .amount .format ()
198199 onActiveFocusChanged: {
199200 if (! activeFocus) {
200201 root .recipient .amount .display = text
You can’t perform that action at this time.
0 commit comments