Improve minimize to tray

This commit is contained in:
Janek Bevendorff 2017-02-08 15:37:13 +01:00 committed by Jonathan White
parent d1b403333c
commit 38d64a34a1

View File

@ -554,7 +554,7 @@ void MainWindow::closeEvent(QCloseEvent* event)
if (minimizeOnClose && !appExitCalled)
{
event->ignore();
hide();
toggleWindow();
if (config()->get("security/lockdatabaseminimize").toBool()) {
m_ui->tabWidget->lockDatabases();
@ -722,6 +722,7 @@ void MainWindow::trayIconTriggered(QSystemTrayIcon::ActivationReason reason)
void MainWindow::toggleWindow()
{
if ((QApplication::activeWindow() == this) && isVisible() && !isMinimized()) {
setWindowState(windowState() | Qt::WindowMinimized);
hide();
if (config()->get("security/lockdatabaseminimize").toBool()) {
@ -730,8 +731,8 @@ void MainWindow::toggleWindow()
}
else {
ensurePolished();
setWindowState(windowState() & ~Qt::WindowMinimized);
show();
setWindowState(windowState() & ~Qt::WindowMinimized);
raise();
activateWindow();
}