Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Qt] Re-work settings restart and saving flow #1113

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/qt/pivx/qtutils.h
Expand Up @@ -19,6 +19,15 @@
#include <initializer_list>
#include "qt/pivx/pivxgui.h"

// Repair parameters
const QString SALVAGEWALLET("-salvagewallet");
const QString RESCAN("-rescan");
const QString ZAPTXES1("-zapwallettxes=1");
const QString ZAPTXES2("-zapwallettxes=2");
const QString UPGRADEWALLET("-upgradewallet");
const QString REINDEX("-reindex");
const QString RESYNC("-resync");

extern Qt::Modifier SHORT_KEY;

bool openDialog(QDialog *widget, QWidget *gui);
Expand Down
9 changes: 0 additions & 9 deletions src/qt/pivx/settings/settingswalletrepairwidget.cpp
Expand Up @@ -6,15 +6,6 @@
#include "qt/pivx/settings/forms/ui_settingswalletrepairwidget.h"
#include "qt/pivx/qtutils.h"

// Repair parameters
const QString SALVAGEWALLET("-salvagewallet");
const QString RESCAN("-rescan");
const QString ZAPTXES1("-zapwallettxes=1");
const QString ZAPTXES2("-zapwallettxes=2");
const QString UPGRADEWALLET("-upgradewallet");
const QString REINDEX("-reindex");
const QString RESYNC("-resync");

SettingsWalletRepairWidget::SettingsWalletRepairWidget(PIVXGUI* _window, QWidget *parent) :
PWidget(_window, parent),
ui(new Ui::SettingsWalletRepairWidget)
Expand Down
24 changes: 21 additions & 3 deletions src/qt/pivx/settings/settingswidget.cpp
Expand Up @@ -206,8 +206,25 @@ void SettingsWidget::onSaveOptionsClicked(){
if(mapper->submit()) {
pwalletMain->MarkDirty();
if (this->clientModel->getOptionsModel()->isRestartRequired()) {
openStandardDialog(tr("Restart required"), tr("You wallet will be restarted to apply the changes\n"), tr("OK"));
emit handleRestart(QStringList());
bool fAcceptRestart = openStandardDialog(tr("Restart required"), tr("Your wallet needs to be restarted to apply the changes\n"), tr("Restart Now"), tr("Restart Later"));

if (fAcceptRestart) {
// Get command-line arguments and remove the application name
QStringList args = QApplication::arguments();
args.removeFirst();

// Remove existing repair-options
args.removeAll(SALVAGEWALLET);
args.removeAll(RESCAN);
args.removeAll(ZAPTXES1);
args.removeAll(ZAPTXES2);
args.removeAll(UPGRADEWALLET);
args.removeAll(REINDEX);

emit handleRestart(args);
} else {
inform(tr("Options will be applied on next wallet restart"));
}
} else {
inform(tr("Options stored"));
}
Expand Down Expand Up @@ -393,13 +410,14 @@ void SettingsWidget::setMapper(){
settingsDisplayOptionsWidget->setMapper(mapper);
}

void SettingsWidget::openStandardDialog(QString title, QString body, QString okBtn, QString cancelBtn){
bool SettingsWidget::openStandardDialog(QString title, QString body, QString okBtn, QString cancelBtn){
showHideOp(true);
DefaultDialog *confirmDialog = new DefaultDialog(window);
confirmDialog->setText(title, body, okBtn, cancelBtn);
confirmDialog->adjustSize();
openDialogWithOpaqueBackground(confirmDialog, window);
confirmDialog->deleteLater();
return confirmDialog->isOk;
}

SettingsWidget::~SettingsWidget(){
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/settings/settingswidget.h
Expand Up @@ -95,7 +95,7 @@ private slots:
QList<QPushButton*> options;

void selectOption(QPushButton* option);
void openStandardDialog(QString title = "", QString body = "", QString okBtn = "OK", QString cancelBtn = "");
bool openStandardDialog(QString title = "", QString body = "", QString okBtn = "OK", QString cancelBtn = "");
};

#endif // SETTINGSWIDGET_H