Make sure we don't lock the database while a dialog is open.

This can happen when
- the user is picking out a file to save the database as
- a dialog asking the user to save/discard/cancel the current database
  changes is active

It is dangerous to lock the databases while these actions are still
in progress.

Closes #208
This commit is contained in:
Felix Geyer 2015-07-13 21:17:11 +02:00
parent c6105a08ab
commit 721bec9794
2 changed files with 12 additions and 1 deletions

View File

@ -72,7 +72,7 @@ MainWindow::MainWindow()
m_inactivityTimer = new InactivityTimer(this); m_inactivityTimer = new InactivityTimer(this);
connect(m_inactivityTimer, SIGNAL(inactivityDetected()), connect(m_inactivityTimer, SIGNAL(inactivityDetected()),
m_ui->tabWidget, SLOT(lockDatabases())); this, SLOT(lockDatabasesAfterInactivity()));
applySettingsChanges(); applySettingsChanges();
setShortcut(m_ui->actionDatabaseOpen, QKeySequence::Open, Qt::CTRL + Qt::Key_O); setShortcut(m_ui->actionDatabaseOpen, QKeySequence::Open, Qt::CTRL + Qt::Key_O);
@ -579,6 +579,16 @@ void MainWindow::toggleWindow()
} }
} }
void MainWindow::lockDatabasesAfterInactivity()
{
// ignore event if a modal dialog is open (such as a message box or file dialog)
if (QApplication::activeModalWidget()) {
return;
}
m_ui->tabWidget->lockDatabases();
}
bool MainWindow::isTrayIconEnabled() const bool MainWindow::isTrayIconEnabled() const
{ {
return config()->get("GUI/ShowTrayIcon").toBool() return config()->get("GUI/ShowTrayIcon").toBool()

View File

@ -65,6 +65,7 @@ private Q_SLOTS:
void applySettingsChanges(); void applySettingsChanges();
void trayIconTriggered(QSystemTrayIcon::ActivationReason reason); void trayIconTriggered(QSystemTrayIcon::ActivationReason reason);
void toggleWindow(); void toggleWindow();
void lockDatabasesAfterInactivity();
private: private:
static void setShortcut(QAction* action, QKeySequence::StandardKey standard, int fallback = 0); static void setShortcut(QAction* action, QKeySequence::StandardKey standard, int fallback = 0);