Fabcoin Core  0.16.2
P2P Digital Currency
restoredialog.cpp
Go to the documentation of this file.
1 #include <restoredialog.h>
2 #include <ui_restoredialog.h>
3 #include <guiutil.h>
4 #include <walletmodel.h>
5 #include <QMessageBox>
6 #include <QFile>
7 #include <styleSheet.h>
8 
9 RestoreDialog::RestoreDialog(QWidget *parent) :
10  QDialog(parent),
11  ui(new Ui::RestoreDialog),
12  model(0)
13 {
14  ui->setupUi(this);
15  SetObjectStyleSheet(ui->btnReset, StyleSheetNames::ButtonWhite);
16 }
17 
19 {
20  delete ui;
21 }
22 
24 {
25  return ui->rbReindex->isChecked() ? "-reindex" : "-salvagewallet";
26 }
27 
29 {
30  return ui->txtWalletPath->text();
31 }
32 
34 {
35  this->model = model;
36 }
37 
39 {
40  ui->txtWalletPath->setText("");
41  ui->rbReindex->setChecked(true);
42 }
43 
45 {
46  QString filename = getFileName();
47  QString param = getParam();
48  if(model && QFile::exists(filename))
49  {
50  QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm wallet restoration"),
51  tr("Warning: The wallet will be restored from location <b>%1</b> and restarted with parameter <b>%2</b>.").arg(filename, param)
52  + tr("<br><br>Are you sure you wish to restore your wallet?"),
53  QMessageBox::Yes|QMessageBox::Cancel,
54  QMessageBox::Cancel);
55  if(retval == QMessageBox::Yes)
56  {
58  {
59  QApplication::quit();
60  }
61  }
62  }
63  accept();
64 }
65 
67 {
68  reject();
69 }
70 
72 {
73  QString filename = GUIUtil::getOpenFileName(this,
74  tr("Restore Wallet"), QString(),
75  tr("Wallet Data (*.dat)"), NULL);
76 
77  if (filename.isEmpty())
78  return;
79 
80  ui->txtWalletPath->setText(filename);
81 }
#define SetObjectStyleSheet(object, name)
Definition: styleSheet.h:10
QPushButton * btnReset
void on_toolWalletPath_clicked()
on_toolWalletPath_clicked Choose wallet button path slot
QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedSuffixOut)
Get open filename, convenience wrapper for QFileDialog::getOpenFileName.
Definition: guiutil.cpp:359
QLineEdit * txtWalletPath
Ui::RestoreDialog * ui
Definition: restoredialog.h:72
void on_btnReset_clicked()
on_btnReset_clicked Reset button click slot
WalletModel * model
Definition: restoredialog.h:73
RestoreDialog(QWidget *parent=0)
RestoreDialog Constructor.
~RestoreDialog()
~RestoreDialog Destructor
void setModel(WalletModel *model)
setModel Set wallet model
void on_btnBoxRestore_accepted()
on_btnBoxRestore_accepted Ok button click slot
QString getParam()
getParam Get the command line param for restart of the wallet
QString getFileName()
getFileName Get the restore wallet name
The RestoreDialog class Restore dialog class.
Definition: restoredialog.h:15
bool restoreWallet(const QString &filename, const QString &param)
Interface to Fabcoin wallet from Qt view code.
Definition: walletmodel.h:103
void on_btnBoxRestore_rejected()
on_btnBoxRestore_rejected Cancel button click slot
QRadioButton * rbReindex
void setupUi(QDialog *RestoreDialog)