mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-01 19:47:39 +03:00
Implement database closing question on escape
This commit is contained in:
parent
dff5f3bc13
commit
af2479da8d
3 changed files with 30 additions and 0 deletions
|
@ -1708,6 +1708,10 @@ Are you sure you want to continue with this file?.</source>
|
|||
<source>Hardware keys found, but no slots are configured.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Press ESC again to close this database</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DatabaseSettingWidgetMetaData</name>
|
||||
|
|
|
@ -159,6 +159,29 @@ void DatabaseOpenWidget::toggleHardwareKeyComponent(bool state)
|
|||
m_ui->useHardwareKeyCheckBox->setText(tr("Use hardware key"));
|
||||
}
|
||||
}
|
||||
void DatabaseOpenWidget::closeDatabase()
|
||||
{
|
||||
int closeWarningInterval = 3000;
|
||||
|
||||
if (!m_triedToQuit && window() == getMainWindow()) {
|
||||
m_triedToQuit = true;
|
||||
m_ui->messageWidget->showMessage(
|
||||
tr("Press ESC again to close this database"), MessageWidget::Warning, closeWarningInterval);
|
||||
|
||||
QTimer::singleShot(closeWarningInterval, this, [this]() { m_triedToQuit = false; });
|
||||
return;
|
||||
}
|
||||
reject();
|
||||
}
|
||||
|
||||
void DatabaseOpenWidget::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Escape) {
|
||||
closeDatabase();
|
||||
} else {
|
||||
DialogyWidget::keyPressEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
bool DatabaseOpenWidget::event(QEvent* event)
|
||||
{
|
||||
|
|
|
@ -66,6 +66,7 @@ signals:
|
|||
|
||||
protected:
|
||||
bool event(QEvent* event) override;
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
QSharedPointer<CompositeKey> buildDatabaseKey();
|
||||
void setUserInteractionLock(bool state);
|
||||
|
||||
|
@ -81,6 +82,7 @@ protected slots:
|
|||
private slots:
|
||||
bool browseKeyFile();
|
||||
void toggleHardwareKeyComponent(bool state);
|
||||
void closeDatabase();
|
||||
void pollHardwareKey(bool manualTrigger = false, int delay = 0);
|
||||
void hardwareKeyResponse(bool found);
|
||||
|
||||
|
@ -92,6 +94,7 @@ private:
|
|||
bool m_manualHardwareKeyRefresh = false;
|
||||
bool m_blockQuickUnlock = false;
|
||||
bool m_unlockingDatabase = false;
|
||||
bool m_triedToQuit = false;
|
||||
QTimer m_hideTimer;
|
||||
QTimer m_hideNoHardwareKeysFoundTimer;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue