mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-04 15:39:34 +01:00
Correctly restore window geometry when minimised to tray on startup
Fixes #10537 Fixes #11982
This commit is contained in:
committed by
Janek Bevendorff
parent
4a2f64ed4d
commit
d92f9b1f49
@@ -188,9 +188,6 @@ MainWindow::MainWindow()
|
||||
databaseLockButton->setPopupMode(QToolButton::MenuButtonPopup);
|
||||
}
|
||||
|
||||
restoreGeometry(config()->get(Config::GUI_MainWindowGeometry).toByteArray());
|
||||
restoreState(config()->get(Config::GUI_MainWindowState).toByteArray());
|
||||
|
||||
connect(m_ui->tabWidget, &DatabaseTabWidget::databaseLocked, this, &MainWindow::databaseLocked);
|
||||
connect(m_ui->tabWidget, &DatabaseTabWidget::databaseUnlocked, this, &MainWindow::databaseUnlocked);
|
||||
connect(m_ui->tabWidget, &DatabaseTabWidget::activeDatabaseChanged, this, &MainWindow::activeDatabaseChanged);
|
||||
@@ -1387,6 +1384,12 @@ void MainWindow::showEvent(QShowEvent* event)
|
||||
// Qt Hack - Prevent white flicker when showing window
|
||||
QTimer::singleShot(50, this, [=] { setProperty("windowOpacity", 1.0); });
|
||||
#endif
|
||||
|
||||
// Restore geometry and window state only on the first showEvent to prevent issues with minimized tray startup
|
||||
if (!m_windowInformationRestored) {
|
||||
restoreWindowInformation();
|
||||
m_windowInformationRestored = true;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::hideEvent(QHideEvent* event)
|
||||
@@ -1532,6 +1535,12 @@ void MainWindow::saveWindowInformation()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::restoreWindowInformation()
|
||||
{
|
||||
restoreGeometry(config()->get(Config::GUI_MainWindowGeometry).toByteArray());
|
||||
restoreState(config()->get(Config::GUI_MainWindowState).toByteArray());
|
||||
}
|
||||
|
||||
bool MainWindow::saveLastDatabases()
|
||||
{
|
||||
if (config()->get(Config::OpenPreviousDatabasesOnStartup).toBool()) {
|
||||
|
||||
@@ -159,6 +159,7 @@ private:
|
||||
static const QString BaseWindowTitle;
|
||||
|
||||
void saveWindowInformation();
|
||||
void restoreWindowInformation();
|
||||
bool saveLastDatabases();
|
||||
bool isTrayIconEnabled() const;
|
||||
void customOpenUrl(QString url);
|
||||
@@ -190,6 +191,7 @@ private:
|
||||
|
||||
Q_DISABLE_COPY(MainWindow)
|
||||
|
||||
bool m_windowInformationRestored = false;
|
||||
bool m_appExitCalled = false;
|
||||
bool m_appExiting = false;
|
||||
bool m_restartRequested = false;
|
||||
|
||||
Reference in New Issue
Block a user