mirror of
https://github.com/wownero/wowlet.git
synced 2026-12-04 22:14:02 +01:00
refactor: remove appcontext, cleanup Wallet
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <QTableWidget>
|
||||
|
||||
#include "CCSProgressDelegate.h"
|
||||
#include "utils/Utils.h"
|
||||
|
||||
CCSWidget::CCSWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
@@ -37,8 +38,9 @@ void CCSWidget::linkClicked() {
|
||||
QModelIndex index = ui->tableView->currentIndex();
|
||||
auto entry = m_model->entry(index.row());
|
||||
|
||||
if (entry)
|
||||
if (entry) {
|
||||
Utils::externalLinkWarning(this, entry->url);
|
||||
}
|
||||
}
|
||||
|
||||
void CCSWidget::donateClicked() {
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <QProgressBar>
|
||||
#include <QWidget>
|
||||
|
||||
#include "appcontext.h"
|
||||
#include "model/CCSModel.h"
|
||||
#include "widgets/CCSEntry.h"
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
#include "utils/NetworkManager.h"
|
||||
#include "utils/WebsocketNotifier.h"
|
||||
|
||||
LocalMoneroWidget::LocalMoneroWidget(QWidget *parent, QSharedPointer<AppContext> ctx)
|
||||
LocalMoneroWidget::LocalMoneroWidget(QWidget *parent, Wallet *wallet)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::LocalMoneroWidget)
|
||||
, m_ctx(std::move(ctx))
|
||||
, m_wallet(wallet)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include <QWidget>
|
||||
|
||||
#include "api/LocalMoneroApi.h"
|
||||
#include "appcontext.h"
|
||||
#include "model/LocalMoneroModel.h"
|
||||
#include "libwalletqt/Wallet.h"
|
||||
|
||||
namespace Ui {
|
||||
class LocalMoneroWidget;
|
||||
@@ -19,7 +19,7 @@ class LocalMoneroWidget : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LocalMoneroWidget(QWidget *parent, QSharedPointer<AppContext> ctx);
|
||||
explicit LocalMoneroWidget(QWidget *parent, Wallet *wallet);
|
||||
~LocalMoneroWidget() override;
|
||||
|
||||
public slots:
|
||||
@@ -42,7 +42,7 @@ private:
|
||||
void updatePaymentMethods();
|
||||
|
||||
QScopedPointer<Ui::LocalMoneroWidget> ui;
|
||||
QSharedPointer<AppContext> m_ctx;
|
||||
Wallet *m_wallet;
|
||||
|
||||
int m_currentPage = 0;
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <QTreeView>
|
||||
#include <QWidget>
|
||||
|
||||
#include "appcontext.h"
|
||||
#include "model/NodeModel.h"
|
||||
#include "utils/nodes.h"
|
||||
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
|
||||
#include "constants.h"
|
||||
#include "utils/AppData.h"
|
||||
#include "utils/config.h"
|
||||
|
||||
TickerWidgetBase::TickerWidgetBase(QWidget *parent, QSharedPointer<AppContext> ctx)
|
||||
TickerWidgetBase::TickerWidgetBase(QWidget *parent, Wallet *wallet)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::TickerWidget)
|
||||
, m_ctx(std::move(ctx))
|
||||
, m_wallet(wallet)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -53,8 +54,8 @@ void TickerWidgetBase::setDisplayText(const QString &text) {
|
||||
}
|
||||
|
||||
// BalanceTickerWidget
|
||||
BalanceTickerWidget::BalanceTickerWidget(QWidget *parent, QSharedPointer<AppContext> ctx, bool totalBalance)
|
||||
: TickerWidgetBase(parent, std::move(ctx))
|
||||
BalanceTickerWidget::BalanceTickerWidget(QWidget *parent, Wallet *wallet, bool totalBalance)
|
||||
: TickerWidgetBase(parent, wallet)
|
||||
, m_totalBalance(totalBalance)
|
||||
{
|
||||
if (totalBalance)
|
||||
@@ -64,13 +65,13 @@ BalanceTickerWidget::BalanceTickerWidget(QWidget *parent, QSharedPointer<AppCont
|
||||
|
||||
this->setPercentageVisible(false);
|
||||
|
||||
connect(m_ctx.get(), &AppContext::balanceUpdated, this, &BalanceTickerWidget::updateDisplay);
|
||||
connect(m_wallet, &Wallet::balanceUpdated, this, &BalanceTickerWidget::updateDisplay);
|
||||
connect(&appData()->prices, &Prices::fiatPricesUpdated, this, &BalanceTickerWidget::updateDisplay);
|
||||
connect(&appData()->prices, &Prices::fiatPricesUpdated, this, &BalanceTickerWidget::updateDisplay);
|
||||
}
|
||||
|
||||
void BalanceTickerWidget::updateDisplay() {
|
||||
double balance = (m_totalBalance ? m_ctx->wallet->balanceAll() : m_ctx->wallet->balance()) / constants::cdiv;
|
||||
double balance = (m_totalBalance ? m_wallet->balanceAll() : m_wallet->balance()) / constants::cdiv;
|
||||
QString fiatCurrency = config()->get(Config::preferredFiatCurrency).toString();
|
||||
double balanceFiatAmount = appData()->prices.convert("XMR", fiatCurrency, balance);
|
||||
if (balanceFiatAmount < 0)
|
||||
@@ -79,8 +80,8 @@ void BalanceTickerWidget::updateDisplay() {
|
||||
}
|
||||
|
||||
// PriceTickerWidget
|
||||
PriceTickerWidget::PriceTickerWidget(QWidget *parent, QSharedPointer<AppContext> ctx, QString symbol)
|
||||
: TickerWidgetBase(parent, std::move(ctx))
|
||||
PriceTickerWidget::PriceTickerWidget(QWidget *parent, Wallet *wallet, QString symbol)
|
||||
: TickerWidgetBase(parent, wallet)
|
||||
, m_symbol(std::move(symbol))
|
||||
{
|
||||
this->setTitle(m_symbol);
|
||||
@@ -107,8 +108,8 @@ void PriceTickerWidget::updateDisplay() {
|
||||
}
|
||||
|
||||
//RatioTickerWidget
|
||||
RatioTickerWidget::RatioTickerWidget(QWidget *parent, QSharedPointer<AppContext> ctx, QString symbol1, QString symbol2)
|
||||
: TickerWidgetBase(parent, std::move(ctx))
|
||||
RatioTickerWidget::RatioTickerWidget(QWidget *parent, Wallet *wallet, QString symbol1, QString symbol2)
|
||||
: TickerWidgetBase(parent, wallet)
|
||||
, m_symbol1(std::move(symbol1))
|
||||
, m_symbol2(std::move(symbol2))
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "appcontext.h"
|
||||
#include "libwalletqt/Wallet.h"
|
||||
|
||||
namespace Ui {
|
||||
class TickerWidget;
|
||||
@@ -17,7 +17,7 @@ class TickerWidgetBase : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TickerWidgetBase(QWidget *parent, QSharedPointer<AppContext> ctx);
|
||||
explicit TickerWidgetBase(QWidget *parent, Wallet *wallet);
|
||||
~TickerWidgetBase() override;
|
||||
|
||||
void setTitle(const QString &title);
|
||||
@@ -34,7 +34,7 @@ private:
|
||||
QScopedPointer<Ui::TickerWidget> ui;
|
||||
|
||||
protected:
|
||||
QSharedPointer<AppContext> m_ctx;
|
||||
Wallet *m_wallet;
|
||||
};
|
||||
|
||||
class BalanceTickerWidget : public TickerWidgetBase
|
||||
@@ -42,7 +42,7 @@ class BalanceTickerWidget : public TickerWidgetBase
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BalanceTickerWidget(QWidget *parent, QSharedPointer<AppContext> ctx, bool totalBalance);
|
||||
explicit BalanceTickerWidget(QWidget *parent, Wallet *wallet, bool totalBalance);
|
||||
|
||||
public slots:
|
||||
void updateDisplay() override;
|
||||
@@ -56,7 +56,7 @@ class PriceTickerWidget : public TickerWidgetBase
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PriceTickerWidget(QWidget *parent, QSharedPointer<AppContext> ctx, QString symbol);
|
||||
explicit PriceTickerWidget(QWidget *parent, Wallet *wallet, QString symbol);
|
||||
|
||||
public slots:
|
||||
void updateDisplay() override;
|
||||
@@ -70,7 +70,7 @@ class RatioTickerWidget : public TickerWidgetBase
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RatioTickerWidget(QWidget *parent, QSharedPointer<AppContext> ctx, QString symbol1, QString symbol2);
|
||||
explicit RatioTickerWidget(QWidget *parent, Wallet *wallet, QString symbol1, QString symbol2);
|
||||
|
||||
public slots:
|
||||
void updateDisplay() override;
|
||||
|
||||
+12
-11
@@ -13,11 +13,12 @@
|
||||
#include <QTableWidget>
|
||||
|
||||
#include "utils/Icons.h"
|
||||
#include "utils/Utils.h"
|
||||
|
||||
XMRigWidget::XMRigWidget(QSharedPointer<AppContext> ctx, QWidget *parent)
|
||||
XMRigWidget::XMRigWidget(Wallet *wallet, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::XMRigWidget)
|
||||
, m_ctx(std::move(ctx))
|
||||
, m_wallet(wallet)
|
||||
, m_XMRig(new XmRig(Config::defaultConfigDir().path()))
|
||||
, m_model(new QStandardItemModel(this))
|
||||
, m_contextMenu(new QMenu(this))
|
||||
@@ -96,25 +97,25 @@ XMRigWidget::XMRigWidget(QSharedPointer<AppContext> ctx, QWidget *parent)
|
||||
ui->relayTor->setChecked(config()->get(Config::xmrigNetworkTor).toBool());
|
||||
|
||||
// Receiving address
|
||||
auto username = m_ctx->wallet->getCacheAttribute("feather.xmrig_username");
|
||||
auto username = m_wallet->getCacheAttribute("feather.xmrig_username");
|
||||
if (!username.isEmpty()) {
|
||||
ui->lineEdit_address->setText(username);
|
||||
}
|
||||
connect(ui->lineEdit_address, &QLineEdit::textChanged, [=]() {
|
||||
m_ctx->wallet->setCacheAttribute("feather.xmrig_username", ui->lineEdit_address->text());
|
||||
m_wallet->setCacheAttribute("feather.xmrig_username", ui->lineEdit_address->text());
|
||||
});
|
||||
connect(ui->btn_fillPrimaryAddress, &QPushButton::clicked, this, &XMRigWidget::onUsePrimaryAddressClicked);
|
||||
|
||||
// Password
|
||||
auto password = m_ctx->wallet->getCacheAttribute("feather.xmrig_password");
|
||||
auto password = m_wallet->getCacheAttribute("feather.xmrig_password");
|
||||
if (!password.isEmpty()) {
|
||||
ui->lineEdit_password->setText(password);
|
||||
} else {
|
||||
ui->lineEdit_password->setText("featherwallet");
|
||||
m_ctx->wallet->setCacheAttribute("feather.xmrig_password", ui->lineEdit_password->text());
|
||||
m_wallet->setCacheAttribute("feather.xmrig_password", ui->lineEdit_password->text());
|
||||
}
|
||||
connect(ui->lineEdit_password, &QLineEdit::textChanged, [=]() {
|
||||
m_ctx->wallet->setCacheAttribute("feather.xmrig_password", ui->lineEdit_password->text());
|
||||
m_wallet->setCacheAttribute("feather.xmrig_password", ui->lineEdit_password->text());
|
||||
});
|
||||
|
||||
// [Status] tab
|
||||
@@ -171,7 +172,7 @@ void XMRigWidget::onClearClicked() {
|
||||
}
|
||||
|
||||
void XMRigWidget::onUsePrimaryAddressClicked() {
|
||||
ui->lineEdit_address->setText(m_ctx->wallet->address(0, 0));
|
||||
ui->lineEdit_address->setText(m_wallet->address(0, 0));
|
||||
}
|
||||
|
||||
void XMRigWidget::onStartClicked() {
|
||||
@@ -193,8 +194,8 @@ void XMRigWidget::onStartClicked() {
|
||||
}
|
||||
|
||||
// username is receiving address usually
|
||||
auto username = m_ctx->wallet->getCacheAttribute("feather.xmrig_username");
|
||||
auto password = m_ctx->wallet->getCacheAttribute("feather.xmrig_password");
|
||||
auto username = m_wallet->getCacheAttribute("feather.xmrig_username");
|
||||
auto password = m_wallet->getCacheAttribute("feather.xmrig_password");
|
||||
|
||||
if (username.isEmpty()) {
|
||||
ui->console->appendPlainText("Please specify a receiving address on the Settings screen.");
|
||||
@@ -203,7 +204,7 @@ void XMRigWidget::onStartClicked() {
|
||||
|
||||
if (address.contains("cryptonote.social") && !username.contains(".")) {
|
||||
// cryptonote social requires <addr>.<username>, we'll just grab a few chars from primary addy
|
||||
username = QString("%1.%2").arg(username, m_ctx->wallet->address(0, 0).mid(0, 6));
|
||||
username = QString("%1.%2").arg(username, m_wallet->address(0, 0).mid(0, 6));
|
||||
}
|
||||
|
||||
int threads = ui->threadSlider->value();
|
||||
|
||||
@@ -7,10 +7,11 @@
|
||||
#include <QMenu>
|
||||
#include <QWidget>
|
||||
#include <QItemSelection>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#include "appcontext.h"
|
||||
#include "utils/xmrig.h"
|
||||
#include "utils/config.h"
|
||||
#include "libwalletqt/Wallet.h"
|
||||
|
||||
namespace Ui {
|
||||
class XMRigWidget;
|
||||
@@ -21,7 +22,7 @@ class XMRigWidget : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit XMRigWidget(QSharedPointer<AppContext> ctx, QWidget *parent = nullptr);
|
||||
explicit XMRigWidget(Wallet *wallet, QWidget *parent = nullptr);
|
||||
~XMRigWidget() override;
|
||||
QStandardItemModel *model();
|
||||
|
||||
@@ -63,7 +64,7 @@ private:
|
||||
bool checkXMRigPath();
|
||||
|
||||
QScopedPointer<Ui::XMRigWidget> ui;
|
||||
QSharedPointer<AppContext> m_ctx;
|
||||
Wallet *m_wallet;
|
||||
XmRig *m_XMRig;
|
||||
QStandardItemModel *m_model;
|
||||
QMenu *m_contextMenu;
|
||||
|
||||
Reference in New Issue
Block a user