From dcc040a119a377351e8a07bc9704ff3140f358a3 Mon Sep 17 00:00:00 2001 From: xiphon Date: Mon, 20 Jul 2020 14:47:13 +0000 Subject: [PATCH] WalletManager: instantiable QML type --- main.qml | 5 +++++ src/libwalletqt/WalletManager.cpp | 11 ----------- src/libwalletqt/WalletManager.h | 7 +++---- src/main/main.cpp | 8 +------- 4 files changed, 9 insertions(+), 22 deletions(-) diff --git a/main.qml b/main.qml index 4d49e8a9..ae6d96de 100644 --- a/main.qml +++ b/main.qml @@ -34,6 +34,7 @@ import QtQuick.Dialogs 1.2 import QtGraphicalEffects 1.0 import moneroComponents.Wallet 1.0 +import moneroComponents.WalletManager 1.0 import moneroComponents.PendingTransaction 1.0 import moneroComponents.NetworkType 1.0 import moneroComponents.Settings 1.0 @@ -2235,4 +2236,8 @@ ApplicationWindow { id: languageSidebar dragMargin: 0 } + + WalletManager { + id: walletManager + } } diff --git a/src/libwalletqt/WalletManager.cpp b/src/libwalletqt/WalletManager.cpp index bae16c46..6ce771ae 100644 --- a/src/libwalletqt/WalletManager.cpp +++ b/src/libwalletqt/WalletManager.cpp @@ -85,17 +85,6 @@ private: 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, const QString &language, NetworkType::Type nettype, quint64 kdfRounds) { diff --git a/src/libwalletqt/WalletManager.h b/src/libwalletqt/WalletManager.h index 013846fa..5a901ba3 100644 --- a/src/libwalletqt/WalletManager.h +++ b/src/libwalletqt/WalletManager.h @@ -51,6 +51,9 @@ class WalletManager : public QObject, public PassprasePrompter Q_PROPERTY(bool connected READ connected) public: + explicit WalletManager(QObject *parent = 0); + ~WalletManager(); + enum LogLevel { LogLevel_Silent = Monero::WalletManagerFactory::LogLevel_Silent, LogLevel_0 = Monero::WalletManagerFactory::LogLevel_0, @@ -62,7 +65,6 @@ public: LogLevel_Max = Monero::WalletManagerFactory::LogLevel_Max, }; - static WalletManager * instance(); // wizard: createWallet path; Q_INVOKABLE Wallet * createWallet(const QString &path, const QString &password, const QString &language, NetworkType::Type nettype = NetworkType::MAINNET, quint64 kdfRounds = 1); @@ -208,9 +210,6 @@ public slots: private: friend class WalletPassphraseListenerImpl; - explicit WalletManager(QObject *parent = 0); - ~WalletManager(); - bool isMining() const; static WalletManager * m_instance; diff --git a/src/main/main.cpp b/src/main/main.cpp index 3aeb2ded..f5423940 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -358,6 +358,7 @@ Verify update binary using 'shasum'-compatible (SHA256 algo) output signed by tw qmlRegisterType("moneroComponents.Clipboard", 1, 0, "Clipboard"); qmlRegisterType("moneroComponents.Downloader", 1, 0, "Downloader"); qmlRegisterType("moneroComponents.WalletKeysFilesModel", 1, 0, "WalletKeysFilesModel"); + qmlRegisterType("moneroComponents.WalletManager", 1, 0, "WalletManager"); // Temporary Qt.labs.settings replacement qmlRegisterType("moneroComponents.Settings", 1, 0, "MoneroSettings"); @@ -371,9 +372,6 @@ Verify update binary using 'shasum'-compatible (SHA256 algo) output signed by tw qmlRegisterUncreatableType("moneroComponents.UnsignedTransaction", 1, 0, "UnsignedTransaction", "UnsignedTransaction can't be instantiated directly"); - qmlRegisterUncreatableType("moneroComponents.WalletManager", 1, 0, "WalletManager", - "WalletManager can't be instantiated directly"); - qmlRegisterUncreatableType("moneroComponents.TranslationManager", 1, 0, "TranslationManager", "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); - WalletManager *walletManager = WalletManager::instance(); - - engine.rootContext()->setContextProperty("walletManager", walletManager); - engine.rootContext()->setContextProperty("translationManager", TranslationManager::instance()); engine.addImageProvider(QLatin1String("qrcode"), new QRCodeImageProvider());