Add unlock dialog on Autotype and show default Autotype sequence (#89)

* Add unlockdialog on autotype. Fix #10
* Show default autotype sequence for existing entries
* NOTE: New entries/groups do not show the default autotype sequence
This commit is contained in:
TheZ3ro 2016-11-11 22:26:07 +01:00 committed by Jonathan White
parent 0657d343bf
commit 6927158daa
13 changed files with 202 additions and 11 deletions

View file

@ -43,6 +43,7 @@
#include "gui/KeePass1OpenWidget.h"
#include "gui/MessageBox.h"
#include "gui/UnlockDatabaseWidget.h"
#include "gui/UnlockDatabaseDialog.h"
#include "gui/entry/EditEntryWidget.h"
#include "gui/entry/EntryView.h"
#include "gui/group/EditGroupWidget.h"
@ -124,6 +125,8 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
m_keepass1OpenWidget->setObjectName("keepass1OpenWidget");
m_unlockDatabaseWidget = new UnlockDatabaseWidget();
m_unlockDatabaseWidget->setObjectName("unlockDatabaseWidget");
m_unlockDatabaseDialog = new UnlockDatabaseDialog();
m_unlockDatabaseDialog->setObjectName("unlockDatabaseDialog");
addWidget(m_mainWidget);
addWidget(m_editEntryWidget);
addWidget(m_editGroupWidget);
@ -153,6 +156,7 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
connect(m_databaseOpenMergeWidget, SIGNAL(editFinished(bool)), SLOT(mergeDatabase(bool)));
connect(m_keepass1OpenWidget, SIGNAL(editFinished(bool)), SLOT(openDatabase(bool)));
connect(m_unlockDatabaseWidget, SIGNAL(editFinished(bool)), SLOT(unlockDatabase(bool)));
connect(m_unlockDatabaseDialog, SIGNAL(unlockDone(bool)), SLOT(unlockDatabase(bool)));
connect(this, SIGNAL(currentChanged(int)), this, SLOT(emitCurrentModeChanged()));
m_searchCaseSensitive = false;
@ -173,7 +177,8 @@ DatabaseWidget::Mode DatabaseWidget::currentMode() const
else if (currentWidget() == m_mainWidget) {
return DatabaseWidget::ViewMode;
}
else if (currentWidget() == m_unlockDatabaseWidget) {
else if (currentWidget() == m_unlockDatabaseWidget ||
currentWidget() == m_databaseOpenWidget) {
return DatabaseWidget::LockedMode;
}
else {
@ -696,7 +701,14 @@ void DatabaseWidget::unlockDatabase(bool accepted)
return;
}
replaceDatabase(static_cast<DatabaseOpenWidget*>(sender())->database());
Database *db = Q_NULLPTR;
if (sender() == m_unlockDatabaseDialog) {
db = m_unlockDatabaseDialog->database();
} else if (sender() == m_unlockDatabaseWidget) {
db = m_unlockDatabaseWidget->database();
}
replaceDatabase(db);
const QList<Group*> groups = m_db->rootGroup()->groupsRecursive(true);
for (Group* group : groups) {
@ -710,6 +722,12 @@ void DatabaseWidget::unlockDatabase(bool accepted)
setCurrentWidget(m_mainWidget);
m_unlockDatabaseWidget->clearForms();
Q_EMIT unlockedDatabase();
if (sender() == m_unlockDatabaseDialog) {
QList<Database*> dbList;
dbList.append(m_db);
autoType()->performGlobalAutoType(dbList);
}
}
void DatabaseWidget::entryActivationSignalReceived(Entry* entry, EntryModel::ModelColumn column)
@ -1009,3 +1027,16 @@ GroupView* DatabaseWidget::groupView() {
EntryView* DatabaseWidget::entryView() {
return m_entryView;
}
void DatabaseWidget::showUnlockDialog()
{
m_unlockDatabaseDialog->clearForms();
m_unlockDatabaseDialog->setDBFilename(m_filename);
m_unlockDatabaseDialog->show();
m_unlockDatabaseDialog->activateWindow();
}
void DatabaseWidget::closeUnlockDialog()
{
m_unlockDatabaseDialog->close();
}