WalletManager: instantiable QML type

This commit is contained in:
xiphon 2020-07-20 14:47:13 +00:00
parent 63e32c4a83
commit dcc040a119
4 changed files with 9 additions and 22 deletions

View File

@ -34,6 +34,7 @@ import QtQuick.Dialogs 1.2
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import moneroComponents.Wallet 1.0 import moneroComponents.Wallet 1.0
import moneroComponents.WalletManager 1.0
import moneroComponents.PendingTransaction 1.0 import moneroComponents.PendingTransaction 1.0
import moneroComponents.NetworkType 1.0 import moneroComponents.NetworkType 1.0
import moneroComponents.Settings 1.0 import moneroComponents.Settings 1.0
@ -2235,4 +2236,8 @@ ApplicationWindow {
id: languageSidebar id: languageSidebar
dragMargin: 0 dragMargin: 0
} }
WalletManager {
id: walletManager
}
} }

View File

@ -85,17 +85,6 @@ private:
PassphraseHelper m_phelper; PassphraseHelper m_phelper;
}; };
WalletManager * WalletManager::m_instance = nullptr;
WalletManager *WalletManager::instance()
{
if (!m_instance) {
m_instance = new WalletManager;
}
return m_instance;
}
Wallet *WalletManager::createWallet(const QString &path, const QString &password, Wallet *WalletManager::createWallet(const QString &path, const QString &password,
const QString &language, NetworkType::Type nettype, quint64 kdfRounds) const QString &language, NetworkType::Type nettype, quint64 kdfRounds)
{ {

View File

@ -51,6 +51,9 @@ class WalletManager : public QObject, public PassprasePrompter
Q_PROPERTY(bool connected READ connected) Q_PROPERTY(bool connected READ connected)
public: public:
explicit WalletManager(QObject *parent = 0);
~WalletManager();
enum LogLevel { enum LogLevel {
LogLevel_Silent = Monero::WalletManagerFactory::LogLevel_Silent, LogLevel_Silent = Monero::WalletManagerFactory::LogLevel_Silent,
LogLevel_0 = Monero::WalletManagerFactory::LogLevel_0, LogLevel_0 = Monero::WalletManagerFactory::LogLevel_0,
@ -62,7 +65,6 @@ public:
LogLevel_Max = Monero::WalletManagerFactory::LogLevel_Max, LogLevel_Max = Monero::WalletManagerFactory::LogLevel_Max,
}; };
static WalletManager * instance();
// wizard: createWallet path; // wizard: createWallet path;
Q_INVOKABLE Wallet * createWallet(const QString &path, const QString &password, Q_INVOKABLE Wallet * createWallet(const QString &path, const QString &password,
const QString &language, NetworkType::Type nettype = NetworkType::MAINNET, quint64 kdfRounds = 1); const QString &language, NetworkType::Type nettype = NetworkType::MAINNET, quint64 kdfRounds = 1);
@ -208,9 +210,6 @@ public slots:
private: private:
friend class WalletPassphraseListenerImpl; friend class WalletPassphraseListenerImpl;
explicit WalletManager(QObject *parent = 0);
~WalletManager();
bool isMining() const; bool isMining() const;
static WalletManager * m_instance; static WalletManager * m_instance;

View File

@ -358,6 +358,7 @@ Verify update binary using 'shasum'-compatible (SHA256 algo) output signed by tw
qmlRegisterType<clipboardAdapter>("moneroComponents.Clipboard", 1, 0, "Clipboard"); qmlRegisterType<clipboardAdapter>("moneroComponents.Clipboard", 1, 0, "Clipboard");
qmlRegisterType<Downloader>("moneroComponents.Downloader", 1, 0, "Downloader"); qmlRegisterType<Downloader>("moneroComponents.Downloader", 1, 0, "Downloader");
qmlRegisterType<WalletKeysFilesModel>("moneroComponents.WalletKeysFilesModel", 1, 0, "WalletKeysFilesModel"); qmlRegisterType<WalletKeysFilesModel>("moneroComponents.WalletKeysFilesModel", 1, 0, "WalletKeysFilesModel");
qmlRegisterType<WalletManager>("moneroComponents.WalletManager", 1, 0, "WalletManager");
// Temporary Qt.labs.settings replacement // Temporary Qt.labs.settings replacement
qmlRegisterType<MoneroSettings>("moneroComponents.Settings", 1, 0, "MoneroSettings"); qmlRegisterType<MoneroSettings>("moneroComponents.Settings", 1, 0, "MoneroSettings");
@ -371,9 +372,6 @@ Verify update binary using 'shasum'-compatible (SHA256 algo) output signed by tw
qmlRegisterUncreatableType<UnsignedTransaction>("moneroComponents.UnsignedTransaction", 1, 0, "UnsignedTransaction", qmlRegisterUncreatableType<UnsignedTransaction>("moneroComponents.UnsignedTransaction", 1, 0, "UnsignedTransaction",
"UnsignedTransaction can't be instantiated directly"); "UnsignedTransaction can't be instantiated directly");
qmlRegisterUncreatableType<WalletManager>("moneroComponents.WalletManager", 1, 0, "WalletManager",
"WalletManager can't be instantiated directly");
qmlRegisterUncreatableType<TranslationManager>("moneroComponents.TranslationManager", 1, 0, "TranslationManager", qmlRegisterUncreatableType<TranslationManager>("moneroComponents.TranslationManager", 1, 0, "TranslationManager",
"TranslationManager can't be instantiated directly"); "TranslationManager can't be instantiated directly");
@ -435,10 +433,6 @@ Verify update binary using 'shasum'-compatible (SHA256 algo) output signed by tw
engine.rootContext()->setContextProperty("moneroAccountsDir", moneroAccountsDir); engine.rootContext()->setContextProperty("moneroAccountsDir", moneroAccountsDir);
WalletManager *walletManager = WalletManager::instance();
engine.rootContext()->setContextProperty("walletManager", walletManager);
engine.rootContext()->setContextProperty("translationManager", TranslationManager::instance()); engine.rootContext()->setContextProperty("translationManager", TranslationManager::instance());
engine.addImageProvider(QLatin1String("qrcode"), new QRCodeImageProvider()); engine.addImageProvider(QLatin1String("qrcode"), new QRCodeImageProvider());