mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-05-28 11:02:10 -04:00
Merge pull request #1458 from keepassxreboot/feature/relock-after-autotype
Relock database after successful autotype
This commit is contained in:
commit
61a3d5ffda
8 changed files with 63 additions and 2 deletions
|
@ -143,6 +143,8 @@ QStringList AutoType::windowTitles()
|
||||||
void AutoType::resetInAutoType()
|
void AutoType::resetInAutoType()
|
||||||
{
|
{
|
||||||
m_inAutoType.unlock();
|
m_inAutoType.unlock();
|
||||||
|
|
||||||
|
emit autotypeRejected();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoType::raiseWindow()
|
void AutoType::raiseWindow()
|
||||||
|
@ -199,6 +201,7 @@ void AutoType::executeAutoTypeActions(const Entry* entry, QWidget* hideWindow, c
|
||||||
{
|
{
|
||||||
// no edit to the sequence beyond this point
|
// no edit to the sequence beyond this point
|
||||||
if (!verifyAutoTypeSyntax(sequence)) {
|
if (!verifyAutoTypeSyntax(sequence)) {
|
||||||
|
emit autotypeRejected();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,6 +209,7 @@ void AutoType::executeAutoTypeActions(const Entry* entry, QWidget* hideWindow, c
|
||||||
ListDeleter<AutoTypeAction*> actionsDeleter(&actions);
|
ListDeleter<AutoTypeAction*> actionsDeleter(&actions);
|
||||||
|
|
||||||
if (!parseActions(sequence, entry, actions)) {
|
if (!parseActions(sequence, entry, actions)) {
|
||||||
|
emit autotypeRejected();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,12 +232,16 @@ void AutoType::executeAutoTypeActions(const Entry* entry, QWidget* hideWindow, c
|
||||||
for (AutoTypeAction* action : asConst(actions)) {
|
for (AutoTypeAction* action : asConst(actions)) {
|
||||||
if (m_plugin->activeWindow() != window) {
|
if (m_plugin->activeWindow() != window) {
|
||||||
qWarning("Active window changed, interrupting auto-type.");
|
qWarning("Active window changed, interrupting auto-type.");
|
||||||
break;
|
emit autotypeRejected();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
action->accept(m_executor);
|
action->accept(m_executor);
|
||||||
QCoreApplication::processEvents(QEventLoop::AllEvents, 10);
|
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("\n\n");
|
||||||
message.append(windowTitle);
|
message.append(windowTitle);
|
||||||
MessageBox::information(nullptr, tr("Auto-Type - KeePassXC"), message);
|
MessageBox::information(nullptr, tr("Auto-Type - KeePassXC"), message);
|
||||||
|
|
||||||
|
emit autotypeRejected();
|
||||||
} else if ((matchList.size() == 1) && !config()->get("security/autotypeask").toBool()) {
|
} else if ((matchList.size() == 1) && !config()->get("security/autotypeask").toBool()) {
|
||||||
executeAutoTypeActions(matchList.first().entry, nullptr, matchList.first().sequence);
|
executeAutoTypeActions(matchList.first().entry, nullptr, matchList.first().sequence);
|
||||||
m_inAutoType.unlock();
|
m_inAutoType.unlock();
|
||||||
|
|
|
@ -64,6 +64,8 @@ public slots:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void globalShortcutTriggered();
|
void globalShortcutTriggered();
|
||||||
|
void autotypePerformed();
|
||||||
|
void autotypeRejected();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void performAutoTypeFromGlobal(AutoTypeMatch match);
|
void performAutoTypeFromGlobal(AutoTypeMatch match);
|
||||||
|
|
|
@ -35,6 +35,7 @@ AutoTypeSelectDialog::AutoTypeSelectDialog(QWidget* parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, m_view(new AutoTypeSelectView(this))
|
, m_view(new AutoTypeSelectView(this))
|
||||||
, m_matchActivatedEmitted(false)
|
, m_matchActivatedEmitted(false)
|
||||||
|
, m_rejected(false)
|
||||||
{
|
{
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
// Places the window on the active (virtual) desktop instead of where the main window is.
|
// 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);
|
QDialog::done(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AutoTypeSelectDialog::reject()
|
||||||
|
{
|
||||||
|
m_rejected = true;
|
||||||
|
|
||||||
|
QDialog::reject();
|
||||||
|
}
|
||||||
|
|
||||||
void AutoTypeSelectDialog::emitMatchActivated(const QModelIndex& index)
|
void AutoTypeSelectDialog::emitMatchActivated(const QModelIndex& index)
|
||||||
{
|
{
|
||||||
// make sure we don't emit the signal twice when both activated() and clicked() are triggered
|
// 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()
|
void AutoTypeSelectDialog::matchRemoved()
|
||||||
{
|
{
|
||||||
|
if (m_rejected) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_view->model()->rowCount() == 0) {
|
if (m_view->model()->rowCount() == 0) {
|
||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void done(int r) override;
|
void done(int r) override;
|
||||||
|
void reject() override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void emitMatchActivated(const QModelIndex& index);
|
void emitMatchActivated(const QModelIndex& index);
|
||||||
|
@ -47,6 +48,7 @@ private slots:
|
||||||
private:
|
private:
|
||||||
AutoTypeSelectView* const m_view;
|
AutoTypeSelectView* const m_view;
|
||||||
bool m_matchActivatedEmitted;
|
bool m_matchActivatedEmitted;
|
||||||
|
bool m_rejected;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSX_AUTOTYPESELECTDIALOG_H
|
#endif // KEEPASSX_AUTOTYPESELECTDIALOG_H
|
||||||
|
|
|
@ -54,6 +54,7 @@ const int DatabaseTabWidget::LastDatabasesCount = 5;
|
||||||
DatabaseTabWidget::DatabaseTabWidget(QWidget* parent)
|
DatabaseTabWidget::DatabaseTabWidget(QWidget* parent)
|
||||||
: QTabWidget(parent)
|
: QTabWidget(parent)
|
||||||
, m_dbWidgetStateSync(new DatabaseWidgetStateSync(this))
|
, m_dbWidgetStateSync(new DatabaseWidgetStateSync(this))
|
||||||
|
, m_dbPendingLock(nullptr)
|
||||||
{
|
{
|
||||||
DragTabBar* tabBar = new DragTabBar(this);
|
DragTabBar* tabBar = new DragTabBar(this);
|
||||||
setTabBar(tabBar);
|
setTabBar(tabBar);
|
||||||
|
@ -63,6 +64,7 @@ DatabaseTabWidget::DatabaseTabWidget(QWidget* parent)
|
||||||
connect(this, SIGNAL(currentChanged(int)), SLOT(emitActivateDatabaseChanged()));
|
connect(this, SIGNAL(currentChanged(int)), SLOT(emitActivateDatabaseChanged()));
|
||||||
connect(this, SIGNAL(activateDatabaseChanged(DatabaseWidget*)), m_dbWidgetStateSync, SLOT(setActive(DatabaseWidget*)));
|
connect(this, SIGNAL(activateDatabaseChanged(DatabaseWidget*)), m_dbWidgetStateSync, SLOT(setActive(DatabaseWidget*)));
|
||||||
connect(autoType(), SIGNAL(globalShortcutTriggered()), SLOT(performGlobalAutoType()));
|
connect(autoType(), SIGNAL(globalShortcutTriggered()), SLOT(performGlobalAutoType()));
|
||||||
|
connect(autoType(), SIGNAL(autotypePerformed()), SLOT(relockPendingDatabase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseTabWidget::~DatabaseTabWidget()
|
DatabaseTabWidget::~DatabaseTabWidget()
|
||||||
|
@ -737,6 +739,27 @@ void DatabaseTabWidget::lockDatabases()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function relock the pending database when autotype has been performed successfully
|
||||||
|
* A database is marked as pending when it's unlocked after a global Auto-Type invocation
|
||||||
|
*/
|
||||||
|
void DatabaseTabWidget::relockPendingDatabase()
|
||||||
|
{
|
||||||
|
if (!m_dbPendingLock || !config()->get("security/relockautotype").toBool()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_dbPendingLock->currentMode() == DatabaseWidget::LockedMode || !m_dbPendingLock->dbHasKey()) {
|
||||||
|
m_dbPendingLock = nullptr;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_dbPendingLock->lock();
|
||||||
|
|
||||||
|
emit databaseLocked(m_dbPendingLock);
|
||||||
|
m_dbPendingLock = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void DatabaseTabWidget::modified()
|
void DatabaseTabWidget::modified()
|
||||||
{
|
{
|
||||||
Q_ASSERT(qobject_cast<Database*>(sender()));
|
Q_ASSERT(qobject_cast<Database*>(sender()));
|
||||||
|
@ -827,6 +850,7 @@ void DatabaseTabWidget::performGlobalAutoType()
|
||||||
if (unlockedDatabases.size() > 0) {
|
if (unlockedDatabases.size() > 0) {
|
||||||
autoType()->performGlobalAutoType(unlockedDatabases);
|
autoType()->performGlobalAutoType(unlockedDatabases);
|
||||||
} else if (m_dbList.size() > 0){
|
} else if (m_dbList.size() > 0){
|
||||||
indexDatabaseManagerStruct(0).dbWidget->showUnlockDialog();
|
m_dbPendingLock = indexDatabaseManagerStruct(0).dbWidget;
|
||||||
|
m_dbPendingLock->showUnlockDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,7 @@ public slots:
|
||||||
bool isModified(int index = -1);
|
bool isModified(int index = -1);
|
||||||
void performGlobalAutoType();
|
void performGlobalAutoType();
|
||||||
void lockDatabases();
|
void lockDatabases();
|
||||||
|
void relockPendingDatabase();
|
||||||
QString databasePath(int index = -1);
|
QString databasePath(int index = -1);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -117,6 +118,7 @@ private:
|
||||||
|
|
||||||
QHash<Database*, DatabaseManagerStruct> m_dbList;
|
QHash<Database*, DatabaseManagerStruct> m_dbList;
|
||||||
QPointer<DatabaseWidgetStateSync> m_dbWidgetStateSync;
|
QPointer<DatabaseWidgetStateSync> m_dbWidgetStateSync;
|
||||||
|
QPointer<DatabaseWidget> m_dbPendingLock;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSX_DATABASETABWIDGET_H
|
#endif // KEEPASSX_DATABASETABWIDGET_H
|
||||||
|
|
|
@ -161,6 +161,7 @@ void SettingsWidget::loadSettings()
|
||||||
m_secUi->lockDatabaseIdleSpinBox->setValue(config()->get("security/lockdatabaseidlesec").toInt());
|
m_secUi->lockDatabaseIdleSpinBox->setValue(config()->get("security/lockdatabaseidlesec").toInt());
|
||||||
m_secUi->lockDatabaseMinimizeCheckBox->setChecked(config()->get("security/lockdatabaseminimize").toBool());
|
m_secUi->lockDatabaseMinimizeCheckBox->setChecked(config()->get("security/lockdatabaseminimize").toBool());
|
||||||
m_secUi->lockDatabaseOnScreenLockCheckBox->setChecked(config()->get("security/lockdatabasescreenlock").toBool());
|
m_secUi->lockDatabaseOnScreenLockCheckBox->setChecked(config()->get("security/lockdatabasescreenlock").toBool());
|
||||||
|
m_secUi->relockDatabaseAutoTypeCheckBox->setChecked(config()->get("security/relockautotype").toBool());
|
||||||
m_secUi->fallbackToGoogle->setChecked(config()->get("security/IconDownloadFallbackToGoogle").toBool());
|
m_secUi->fallbackToGoogle->setChecked(config()->get("security/IconDownloadFallbackToGoogle").toBool());
|
||||||
|
|
||||||
m_secUi->passwordCleartextCheckBox->setChecked(config()->get("security/passwordscleartext").toBool());
|
m_secUi->passwordCleartextCheckBox->setChecked(config()->get("security/passwordscleartext").toBool());
|
||||||
|
@ -233,6 +234,7 @@ void SettingsWidget::saveSettings()
|
||||||
config()->set("security/lockdatabaseidlesec", m_secUi->lockDatabaseIdleSpinBox->value());
|
config()->set("security/lockdatabaseidlesec", m_secUi->lockDatabaseIdleSpinBox->value());
|
||||||
config()->set("security/lockdatabaseminimize", m_secUi->lockDatabaseMinimizeCheckBox->isChecked());
|
config()->set("security/lockdatabaseminimize", m_secUi->lockDatabaseMinimizeCheckBox->isChecked());
|
||||||
config()->set("security/lockdatabasescreenlock", m_secUi->lockDatabaseOnScreenLockCheckBox->isChecked());
|
config()->set("security/lockdatabasescreenlock", m_secUi->lockDatabaseOnScreenLockCheckBox->isChecked());
|
||||||
|
config()->set("security/relockautotype", m_secUi->relockDatabaseAutoTypeCheckBox->isChecked());
|
||||||
config()->set("security/IconDownloadFallbackToGoogle", m_secUi->fallbackToGoogle->isChecked());
|
config()->set("security/IconDownloadFallbackToGoogle", m_secUi->fallbackToGoogle->isChecked());
|
||||||
|
|
||||||
config()->set("security/passwordscleartext", m_secUi->passwordCleartextCheckBox->isChecked());
|
config()->set("security/passwordscleartext", m_secUi->passwordCleartextCheckBox->isChecked());
|
||||||
|
|
|
@ -122,6 +122,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<widget class="QCheckBox" name="relockDatabaseAutoTypeCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Re-lock previously locked database after performing Auto-Type</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="passwordRepeatCheckBox">
|
<widget class="QCheckBox" name="passwordRepeatCheckBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue