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 2, 2021
1 parent fc0452c commit 5876841
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
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 5876841

Please sign in to comment.