Better handling of "Lock on Minimize" setting

* Fix #1090 - delay locking databases after minimize to allow for clipboard use, Auto-Type use, and browser integration use.

* Fix #6757 - prevent setting both minimize on unlock and lock on minimize settings at the same time.
This commit is contained in:
Jonathan White 2022-06-27 23:21:40 -04:00
parent 0cbfbc08f3
commit e245701533
7 changed files with 57 additions and 12 deletions

View file

@ -76,14 +76,21 @@ void Clipboard::setText(const QString& text, bool clear)
if (config()->get(Config::Security_ClearClipboard).toBool()) {
int timeout = config()->get(Config::Security_ClearClipboardTimeout).toInt();
if (timeout > 0) {
m_secondsElapsed = -1;
countdownTick();
m_secondsToClear = timeout;
sendCountdownStatus();
m_timer->start(1000);
} else {
clearCopiedText();
}
}
}
}
int Clipboard::secondsToClear()
{
return m_secondsToClear;
}
void Clipboard::clearCopiedText()
{
m_timer->stop();
@ -105,17 +112,20 @@ void Clipboard::clearCopiedText()
void Clipboard::countdownTick()
{
m_secondsElapsed++;
int timeout = config()->get(Config::Security_ClearClipboardTimeout).toInt();
int timeLeft = timeout - m_secondsElapsed;
if (timeLeft <= 0) {
if (--m_secondsToClear <= 0) {
clearCopiedText();
} else {
emit updateCountdown(100 * timeLeft / timeout,
QObject::tr("Clearing the clipboard in %1 second(s)…", "", timeLeft).arg(timeLeft));
sendCountdownStatus();
}
}
void Clipboard::sendCountdownStatus()
{
emit updateCountdown(
100 * m_secondsToClear / config()->get(Config::Security_ClearClipboardTimeout).toInt(),
QObject::tr("Clearing the clipboard in %1 second(s)…", "", m_secondsToClear).arg(m_secondsToClear));
}
Clipboard* Clipboard::instance()
{
if (!m_instance) {