relock database after successful autotype

This commit is contained in:
thez3ro 2018-02-05 13:25:16 +01:00
parent 4206fd94e3
commit b33259b1f2
No known key found for this signature in database
GPG key ID: F628F9E41DD7C073
8 changed files with 63 additions and 2 deletions

View file

@ -143,6 +143,8 @@ QStringList AutoType::windowTitles()
void AutoType::resetInAutoType()
{
m_inAutoType.unlock();
emit autotypeRejected();
}
void AutoType::raiseWindow()
@ -199,6 +201,7 @@ void AutoType::executeAutoTypeActions(const Entry* entry, QWidget* hideWindow, c
{
// no edit to the sequence beyond this point
if (!verifyAutoTypeSyntax(sequence)) {
emit autotypeRejected();
return;
}
@ -206,6 +209,7 @@ void AutoType::executeAutoTypeActions(const Entry* entry, QWidget* hideWindow, c
ListDeleter<AutoTypeAction*> actionsDeleter(&actions);
if (!parseActions(sequence, entry, actions)) {
emit autotypeRejected();
return;
}
@ -228,12 +232,16 @@ void AutoType::executeAutoTypeActions(const Entry* entry, QWidget* hideWindow, c
for (AutoTypeAction* action : asConst(actions)) {
if (m_plugin->activeWindow() != window) {
qWarning("Active window changed, interrupting auto-type.");
break;
emit autotypeRejected();
return;
}
action->accept(m_executor);
QCoreApplication::processEvents(QEventLoop::AllEvents, 10);
}
// emit signal only if autotype performed correctly
emit autotypePerformed();
}
/**
@ -300,6 +308,8 @@ void AutoType::performGlobalAutoType(const QList<Database*>& dbList)
message.append("\n\n");
message.append(windowTitle);
MessageBox::information(nullptr, tr("Auto-Type - KeePassXC"), message);
emit autotypeRejected();
} else if ((matchList.size() == 1) && !config()->get("security/autotypeask").toBool()) {
executeAutoTypeActions(matchList.first().entry, nullptr, matchList.first().sequence);
m_inAutoType.unlock();

View file

@ -64,6 +64,8 @@ public slots:
signals:
void globalShortcutTriggered();
void autotypePerformed();
void autotypeRejected();
private slots:
void performAutoTypeFromGlobal(AutoTypeMatch match);

View file

@ -35,6 +35,7 @@ AutoTypeSelectDialog::AutoTypeSelectDialog(QWidget* parent)
: QDialog(parent)
, m_view(new AutoTypeSelectView(this))
, m_matchActivatedEmitted(false)
, m_rejected(false)
{
setAttribute(Qt::WA_DeleteOnClose);
// Places the window on the active (virtual) desktop instead of where the main window is.
@ -83,6 +84,13 @@ void AutoTypeSelectDialog::done(int r)
QDialog::done(r);
}
void AutoTypeSelectDialog::reject()
{
m_rejected = true;
QDialog::reject();
}
void AutoTypeSelectDialog::emitMatchActivated(const QModelIndex& index)
{
// make sure we don't emit the signal twice when both activated() and clicked() are triggered
@ -98,6 +106,10 @@ void AutoTypeSelectDialog::emitMatchActivated(const QModelIndex& index)
void AutoTypeSelectDialog::matchRemoved()
{
if (m_rejected) {
return;
}
if (m_view->model()->rowCount() == 0) {
reject();
}

View file

@ -39,6 +39,7 @@ signals:
public slots:
void done(int r) override;
void reject() override;
private slots:
void emitMatchActivated(const QModelIndex& index);
@ -47,6 +48,7 @@ private slots:
private:
AutoTypeSelectView* const m_view;
bool m_matchActivatedEmitted;
bool m_rejected;
};
#endif // KEEPASSX_AUTOTYPESELECTDIALOG_H