Skip to content

Commit

Permalink
GUI: Implement and connect WalletModel::getWalletPath().
Browse files Browse the repository at this point in the history
  • Loading branch information
furszy committed Jul 21, 2021
1 parent c2d3a07 commit 23458ca
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/qt/pivx/settings/settingsinformationwidget.cpp
Expand Up @@ -91,7 +91,6 @@ SettingsInformationWidget::SettingsInformationWidget(PIVXGUI* _window,QWidget *p
#ifdef ENABLE_WALLET
// Wallet data -- remove it with if it's needed
ui->labelInfoBerkeley->setText(DbEnv::version(0, 0, 0));
ui->labelInfoDataDir->setText(QString::fromStdString(GetDataDir().string() + QDir::separator().toLatin1() + gArgs.GetArg("-wallet", DEFAULT_WALLET_DAT)));
#else
ui->labelInfoBerkeley->setText(tr("No information"));
#endif
Expand Down Expand Up @@ -127,6 +126,13 @@ void SettingsInformationWidget::loadClientModel()
}
}

void SettingsInformationWidget::loadWalletModel()
{
if (walletModel) {
ui->labelInfoDataDir->setText(walletModel->getWalletPath());
}
}

void SettingsInformationWidget::setNumConnections(int count)
{
if (!clientModel)
Expand Down
1 change: 1 addition & 0 deletions src/qt/pivx/settings/settingsinformationwidget.h
Expand Up @@ -22,6 +22,7 @@ class SettingsInformationWidget : public PWidget
~SettingsInformationWidget() override;

void loadClientModel() override;
void loadWalletModel() override;

void run(int type) override;
void onError(QString error, int type) override;
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/settings/settingswidget.cpp
Expand Up @@ -9,7 +9,6 @@
#include "optionsmodel.h"
#include "clientmodel.h"
#include "utilitydialog.h"
#include "wallet/wallet.h"
#include <QScrollBar>
#include <QDataWidgetMapper>

Expand Down Expand Up @@ -202,6 +201,7 @@ void SettingsWidget::loadWalletModel()
this->settingsBitToolWidget->setWalletModel(this->walletModel);
this->settingsDisplayOptionsWidget->setWalletModel(this->walletModel);
this->settingsWalletOptionsWidget->setWalletModel(this->walletModel);
this->settingsInformationWidget->setWalletModel(this->walletModel);
}

void SettingsWidget::onResetAction()
Expand Down
17 changes: 13 additions & 4 deletions src/qt/rpcconsole.cpp
Expand Up @@ -12,6 +12,7 @@
#include "guiutil.h"
#include "peertablemodel.h"
#include "qt/rpcexecutor.h"
#include "walletmodel.h"

#include "chainparams.h"
#include "netbase.h"
Expand Down Expand Up @@ -62,11 +63,12 @@ const struct {

RPCConsole::RPCConsole(QWidget* parent) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint),
ui(new Ui::RPCConsole),
clientModel(0),
clientModel(nullptr),
walletModel(nullptr),
historyPtr(0),
cachedNodeid(-1),
peersTableContextMenu(0),
banTableContextMenu(0)
peersTableContextMenu(nullptr),
banTableContextMenu(nullptr)
{
ui->setupUi(this);
GUIUtil::restoreWindowGeometry("nRPCConsoleWindow", this->size(), this);
Expand Down Expand Up @@ -94,7 +96,6 @@ RPCConsole::RPCConsole(QWidget* parent) : QDialog(parent, Qt::WindowSystemMenuHi
// set library version labels
#ifdef ENABLE_WALLET
ui->berkeleyDBVersion->setText(DbEnv::version(0, 0, 0));
ui->wallet_path->setText(QString::fromStdString(GetDataDir().string() + QDir::separator().toLatin1() + gArgs.GetArg("-wallet", DEFAULT_WALLET_DAT)));
#else

ui->label_berkeleyDBVersion->hide();
Expand Down Expand Up @@ -287,6 +288,14 @@ void RPCConsole::setClientModel(ClientModel* model)
}
}

void RPCConsole::setWalletModel(WalletModel* model)
{
walletModel = model;
if (walletModel) {
ui->wallet_path->setText(walletModel->getWalletPath());
}
}

/** Restart wallet with "-salvagewallet" */
void RPCConsole::walletSalvage()
{
Expand Down
3 changes: 3 additions & 0 deletions src/qt/rpcconsole.h
Expand Up @@ -16,6 +16,7 @@

class ClientModel;
class RPCTimerInterface;
class WalletModel;

namespace Ui
{
Expand All @@ -37,6 +38,7 @@ class RPCConsole : public QDialog
~RPCConsole();

void setClientModel(ClientModel* model);
void setWalletModel(WalletModel* model);

protected:
virtual bool eventFilter(QObject* obj, QEvent* event);
Expand Down Expand Up @@ -140,6 +142,7 @@ public Q_SLOTS:

Ui::RPCConsole* ui;
ClientModel* clientModel;
WalletModel* walletModel;
QStringList history;
int historyPtr;
NodeId cachedNodeid;
Expand Down
5 changes: 5 additions & 0 deletions src/qt/walletmodel.cpp
Expand Up @@ -120,6 +120,11 @@ bool WalletModel::upgradeWallet(std::string& upgradeError)
return wallet->Upgrade(upgradeError, prev_version);
}

QString WalletModel::getWalletPath()
{
return QString::fromStdString(GetDataDir().string() + QDir::separator().toLatin1() + wallet->GetName());
}

CAmount WalletModel::getBalance(const CCoinControl* coinControl, bool fIncludeDelegated, bool fUnlockedOnly, bool fIncludeShielded) const
{
if (coinControl) {
Expand Down
3 changes: 3 additions & 0 deletions src/qt/walletmodel.h
Expand Up @@ -161,6 +161,9 @@ class WalletModel : public QObject
bool isSaplingWalletEnabled() const;
bool upgradeWallet(std::string& upgradeError);

// Returns the path to the first wallet db (future: add multi-wallet support)
QString getWalletPath();

interfaces::WalletBalances GetWalletBalances() { return m_cached_balances; };

CAmount getBalance(const CCoinControl* coinControl = nullptr, bool fIncludeDelegated = true, bool fUnlockedOnly = false, bool fIncludeShielded = true) const;
Expand Down

0 comments on commit 23458ca

Please sign in to comment.