Skip to content

Commit

Permalink
GUI: Re-work port mapping saving
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuzzbawls committed Jun 14, 2021
1 parent fc0452c commit fc52bd3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "checkpoints.h"
#include "clientversion.h"
#include "interfaces/handler.h"
#include "mapport.h"
#include "masternodeman.h"
#include "net.h"
#include "netbase.h"
Expand Down Expand Up @@ -347,6 +348,10 @@ void ClientModel::unsubscribeFromCoreSignals()
m_handler_notify_block_tip->disconnect();
}

void ClientModel::mapPort(bool use_upnp, bool use_natpmp) {
StartMapPort(use_upnp, use_natpmp);
}

bool ClientModel::getTorInfo(std::string& ip_port) const
{
proxyType onion;
Expand Down
4 changes: 2 additions & 2 deletions src/qt/clientmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include "uint256.h"
#include "chain.h"
#include "mapport.h"

#include <QObject>
#include <QDateTime>
Expand Down Expand Up @@ -96,7 +95,8 @@ class ClientModel : public QObject

bool getTorInfo(std::string& ip_port) const;

static void mapPort(bool use_upnp, bool use_natpmp) { StartMapPort(use_upnp, use_natpmp); }
//! Set the automatic port mapping options
static void mapPort(bool use_upnp, bool use_natpmp);

// Start/Stop the masternode polling timer
void startMasternodesTimer();
Expand Down
10 changes: 6 additions & 4 deletions src/qt/pivx/settings/settingswalletoptionswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,14 @@ SettingsWalletOptionsWidget::SettingsWalletOptionsWidget(PIVXGUI* _window, QWidg
connect(ui->pushButtonSave, &QPushButton::clicked, [this] { Q_EMIT saveSettings(); });
connect(ui->pushButtonReset, &QPushButton::clicked, this, &SettingsWalletOptionsWidget::onResetClicked);
connect(ui->pushButtonClean, &QPushButton::clicked, [this] { Q_EMIT discardSettings(); });

connect(ui->pushButtonSave, &QPushButton::clicked, [this](){
ClientModel::mapPort(ui->mapPortUpnp->isChecked(), ui->mapPortNatpmp->isChecked());
});
}

void SettingsWalletOptionsWidget::onResetClicked()
{
QSettings settings;
walletModel->resetWalletOptions(settings);
clientModel->getOptionsModel()->setNetworkDefaultOptions(settings, true);
saveMapPortOptions();
inform(tr("Options reset succeed"));
}

Expand Down Expand Up @@ -130,6 +127,11 @@ void SettingsWalletOptionsWidget::discardWalletOnlyOptions()
reloadWalletOptions();
}

void SettingsWalletOptionsWidget::saveMapPortOptions()
{
clientModel->mapPort(ui->mapPortUpnp->isChecked(), ui->mapPortNatpmp->isChecked());
}

SettingsWalletOptionsWidget::~SettingsWalletOptionsWidget(){
delete ui;
}
2 changes: 2 additions & 0 deletions src/qt/pivx/settings/settingswalletoptionswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class SettingsWalletOptionsWidget : public PWidget
void discardWalletOnlyOptions();
bool saveWalletOnlyOptions();

void saveMapPortOptions();

Q_SIGNALS:
void saveSettings();
void discardSettings();
Expand Down
3 changes: 3 additions & 0 deletions src/qt/pivx/settings/settingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ void SettingsWidget::onSaveOptionsClicked()
return;
}

// Save port mapping settings
settingsWalletOptionsWidget->saveMapPortOptions();

if (mapper->submit()) {
OptionsModel* optionsModel = this->clientModel->getOptionsModel();
if (optionsModel->isRestartRequired()) {
Expand Down

0 comments on commit fc52bd3

Please sign in to comment.