-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
qml: Introduce WalletModel and loadWallet functionality
When a user selects a wallet from the WalletSelect menu the wallet controller can now load the wallet data in and the name and balance will appear in the WalletBadge
- Loading branch information
Showing
13 changed files
with
216 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) 2024 The Bitcoin Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#include <qml/models/walletqmlmodel.h> | ||
|
||
#include <qt/bitcoinunits.h> | ||
|
||
#include <QTimer> | ||
|
||
WalletQmlModel::WalletQmlModel(std::unique_ptr<interfaces::Wallet> wallet, QObject *parent) | ||
: QObject(parent) | ||
{ | ||
m_wallet = std::move(wallet); | ||
} | ||
|
||
WalletQmlModel::WalletQmlModel(QObject *parent) | ||
: QObject(parent) | ||
{ | ||
} | ||
|
||
QString WalletQmlModel::balance() const | ||
{ | ||
if (!m_wallet) { | ||
return "0"; | ||
} | ||
return BitcoinUnits::format(BitcoinUnits::Unit::BTC, m_wallet->getBalance()); | ||
} | ||
|
||
QString WalletQmlModel::name() const | ||
{ | ||
if (!m_wallet) { | ||
return QString(); | ||
} | ||
return QString::fromStdString(m_wallet->getWalletName()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) 2024 The Bitcoin Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef BITCOIN_QML_MODELS_WALLETQMLMODEL_H | ||
#define BITCOIN_QML_MODELS_WALLETQMLMODEL_H | ||
|
||
#include <interfaces/wallet.h> | ||
|
||
#include <QObject> | ||
|
||
class WalletQmlModel : public QObject | ||
{ | ||
Q_OBJECT | ||
Q_PROPERTY(QString name READ name NOTIFY nameChanged) | ||
Q_PROPERTY(QString balance READ balance NOTIFY balanceChanged) | ||
|
||
public: | ||
WalletQmlModel(std::unique_ptr<interfaces::Wallet> wallet, QObject *parent = nullptr); | ||
WalletQmlModel(QObject *parent = nullptr); | ||
~WalletQmlModel() = default; | ||
|
||
QString name() const; | ||
QString balance() const; | ||
|
||
Q_SIGNALS: | ||
void nameChanged(); | ||
void balanceChanged(); | ||
|
||
private: | ||
std::unique_ptr<interfaces::Wallet> m_wallet; | ||
}; | ||
|
||
#endif // BITCOIN_QML_MODELS_WALLETQMLMODEL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.