Commit 9505a0b2 authored by Pierre Kim's avatar Pierre Kim

Add Wallet Reset GUI

parent 0a6d80b8
......@@ -191,6 +191,21 @@ void WalletAdapter::backup(const QString& _file) {
}
}
void WalletAdapter::reset() {
Q_CHECK_PTR(m_wallet);
save(false, false);
lock();
m_wallet->removeObserver(this);
m_isSynchronized = false;
m_newTransactionsNotificationTimer.stop();
m_lastWalletTransactionId = std::numeric_limits<quint64>::max();
Q_EMIT walletCloseCompletedSignal();
QCoreApplication::processEvents();
delete m_wallet;
m_wallet = nullptr;
unlock();
}
quint64 WalletAdapter::getTransactionCount() const {
Q_CHECK_PTR(m_wallet);
try {
......
......@@ -26,6 +26,7 @@ public:
void close();
bool save(bool _details, bool _cache);
void backup(const QString& _file);
void reset();
QString getAddress() const;
quint64 getActualBalance() const;
......
......@@ -260,6 +260,15 @@ void MainWindow::backupWallet() {
}
}
void MainWindow::resetWallet() {
Q_ASSERT(WalletAdapter::instance().isOpen());
if (QMessageBox::warning(this, tr("Warning"), tr("Your wallet will be reset and restored from blockchain.\n"
"Are you sure?"), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) {
WalletAdapter::instance().reset();
WalletAdapter::instance().open("");
}
}
void MainWindow::encryptWallet() {
if (Settings::instance().isEncrypted()) {
bool error = false;
......@@ -372,6 +381,7 @@ void MainWindow::walletOpened(bool _error, const QString& _error_text) {
m_encryptionStateIconLabel->show();
m_synchronizationStateIconLabel->show();
m_ui->m_backupWalletAction->setEnabled(true);
m_ui->m_resetWalletAction->setEnabled(true);
encryptedFlagChanged(Settings::instance().isEncrypted());
QList<QAction*> tabActions = m_tabActionGroup->actions();
......@@ -388,6 +398,7 @@ void MainWindow::walletOpened(bool _error, const QString& _error_text) {
void MainWindow::walletClosed() {
m_ui->m_backupWalletAction->setEnabled(false);
m_ui->m_resetWalletAction->setEnabled(false);
m_ui->m_encryptWalletAction->setEnabled(false);
m_ui->m_changePasswordAction->setEnabled(false);
m_ui->m_overviewFrame->hide();
......
......@@ -61,6 +61,7 @@ private:
Q_SLOT void createWallet();
Q_SLOT void openWallet();
Q_SLOT void backupWallet();
Q_SLOT void resetWallet();
Q_SLOT void encryptWallet();
Q_SLOT void aboutQt();
Q_SLOT void about();
......
......@@ -120,6 +120,7 @@
<addaction name="m_createWalletAction"/>
<addaction name="m_openWalletAction"/>
<addaction name="m_backupWalletAction"/>
<addaction name="m_resetWalletAction"/>
<addaction name="m_exitAction"/>
</widget>
<widget class="QMenu" name="menuSettings">
......@@ -312,6 +313,14 @@
<string>Backup wallet</string>
</property>
</action>
<action name="m_resetWalletAction">
<property name="text">
<string>Reset wallet</string>
</property>
<property name="toolTip">
<string>Reset wallet</string>
</property>
</action>
<action name="m_startOnLoginAction">
<property name="checkable">
<bool>true</bool>
......@@ -549,6 +558,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>m_resetWalletAction</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>resetWallet()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>449</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_aboutCryptonoteAction</sender>
<signal>triggered()</signal>
......@@ -620,6 +645,7 @@
<slot>encryptWallet()</slot>
<slot>aboutQt()</slot>
<slot>backupWallet()</slot>
<slot>resetWallet()</slot>
<slot>about()</slot>
<slot>setStartOnLogin(bool)</slot>
<slot>setMinimizeToTray(bool)</slot>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment