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
Jonathan White
parent
a2e7132ead
commit
1a4e9ca4e2
@@ -194,9 +194,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);
|
||||
@@ -1383,6 +1380,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)
|
||||
@@ -1540,6 +1543,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()) {
|
||||
|
||||
@@ -160,6 +160,7 @@ private:
|
||||
static const QString BaseWindowTitle;
|
||||
|
||||
void saveWindowInformation();
|
||||
void restoreWindowInformation();
|
||||
bool saveLastDatabases();
|
||||
bool isTrayIconEnabled() const;
|
||||
void customOpenUrl(QString url);
|
||||
@@ -192,6 +193,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