Properly active key association dialog and main window upon unlock request

This commit is contained in:
Janek Bevendorff 2018-01-15 01:15:39 +01:00
parent 48ac3790c2
commit 7665bc6c63

View File

@ -31,6 +31,7 @@
#include "core/Metadata.h" #include "core/Metadata.h"
#include "core/Uuid.h" #include "core/Uuid.h"
#include "core/PasswordGenerator.h" #include "core/PasswordGenerator.h"
#include "gui/MainWindow.h"
// de887cc3-0363-43b8-974b-5911b8816224 // de887cc3-0363-43b8-974b-5911b8816224
@ -60,11 +61,8 @@ bool BrowserService::isDatabaseOpened() const
return false; return false;
} }
if (dbWidget->currentMode() == DatabaseWidget::ViewMode || dbWidget->currentMode() == DatabaseWidget::EditMode) { return dbWidget->currentMode() == DatabaseWidget::ViewMode || dbWidget->currentMode() == DatabaseWidget::EditMode;
return true;
}
return false;
} }
bool BrowserService::openDatabase() bool BrowserService::openDatabase()
@ -82,7 +80,8 @@ bool BrowserService::openDatabase()
return true; return true;
} }
m_dbTabWidget->activateWindow(); KEEPASSXC_MAIN_WINDOW->bringToFront();
return false; return false;
} }
@ -181,15 +180,20 @@ QString BrowserService::storeKey(const QString& key)
QMessageBox::StandardButton dialogResult = QMessageBox::No; QMessageBox::StandardButton dialogResult = QMessageBox::No;
do { do {
bool ok = false; QInputDialog keyDialog;
id = QInputDialog::getText(nullptr, tr("KeePassXC: New key association request"), keyDialog.setWindowTitle(tr("KeePassXC: New key association request"));
tr("You have received an association " keyDialog.setLabelText(tr("You have received an association request for the above key.\n\n"
"request for the above key.\n" "If you would like to allow it access to your KeePassXC database,\n"
"If you would like to allow it access " "give it a unique name to identify and accept it."));
"to your KeePassXC database,\n" keyDialog.setOkButtonText(tr("Save and allow access"));
"give it a unique name to identify and accept it."), keyDialog.show();
QLineEdit::Normal, QString(), &ok); keyDialog.activateWindow();
if (!ok || id.isEmpty()) { keyDialog.raise();
auto ok = keyDialog.exec();
id = keyDialog.textValue();
if (ok != QDialog::Accepted || id.isEmpty()) {
return {}; return {};
} }