Browse Source

Properly close app on welcome back cancel

pull/94/head
fekt 2 years ago
parent
commit
1f7b8186f0
  1. 25
      src/mainwindow.cpp

25
src/mainwindow.cpp

@ -388,11 +388,14 @@ void MainWindow::closeEvent(QCloseEvent* event) {
s.sync(); s.sync();
// Let the RPC know to shut down any running service. // Let the RPC know to shut down any running service.
if(rpc){
rpc->shutdownhushd(); rpc->shutdownhushd();
int passphraselenght = DataStore::getChatDataStore()->getPassword().length(); }
int passphraselength = DataStore::getChatDataStore()->getPassword().length();
// Check is encryption is ON for SDl // Check is encryption is ON for SDl
if(passphraselenght > 0) { if(passphraselength > 0) {
// delete old file before // delete old file before
//auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); //auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
@ -635,6 +638,10 @@ void MainWindow::removeWalletEncryptionStartUp() {
Ui_startup ed; Ui_startup ed;
ed.setupUi(&d); ed.setupUi(&d);
// Connect cancel button to close app on queued connection
QObject::connect(ed.buttonBox, &QDialogButtonBox::rejected, qApp, &QCoreApplication::quit, Qt::QueuedConnection);
// Connect new/restore button click
QObject::connect(ed.new_restore, &QPushButton::clicked, [&] { QObject::connect(ed.new_restore, &QPushButton::clicked, [&] {
d.close(); d.close();
@ -648,8 +655,7 @@ void MainWindow::removeWalletEncryptionStartUp() {
cl->loadConnection(); cl->loadConnection();
}); });
if (d.exec() == QDialog::Accepted) if (d.exec() == QDialog::Accepted){
{
QString passphraseBlank = ed.txtPassword->text(); // data comes from user inputs QString passphraseBlank = ed.txtPassword->text(); // data comes from user inputs
QString passphrase = QString("HUSH3") + passphraseBlank + QString("SDL"); QString passphrase = QString("HUSH3") + passphraseBlank + QString("SDL");
@ -666,12 +672,12 @@ void MainWindow::removeWalletEncryptionStartUp() {
sequence1 = new char[length+1]; sequence1 = new char[length+1];
strncpy(sequence1, passphraseHash.toUtf8(), length+1); strncpy(sequence1, passphraseHash.toUtf8(), length+1);
#define MESSAGE ((const unsigned char *) sequence) #define MESSAGE ((const unsigned char *) sequence)
#define MESSAGE_LEN length #define MESSAGE_LEN length
#define hash ((const unsigned char *) sequence1) #define hash ((const unsigned char *) sequence1)
#define PASSWORD sequence #define PASSWORD sequence
#define KEY_LEN crypto_box_SEEDBYTES #define KEY_LEN crypto_box_SEEDBYTES
unsigned char key[KEY_LEN]; unsigned char key[KEY_LEN];
@ -708,7 +714,6 @@ void MainWindow::removeWalletEncryptionStartUp() {
}else{ }else{
this->doClosePw(); this->doClosePw();
} }
} }
QString MainWindow::getPassword() QString MainWindow::getPassword()

Loading…
Cancel
Save