Windows: Prevent white flicker when showing main window (#9637)

* Fixes #9603
This commit is contained in:
Jonathan White 2023-07-19 16:12:11 -04:00
parent 2fe647fd7a
commit a81771207f
No known key found for this signature in database
GPG key ID: 440FC65F2E0C6E01
3 changed files with 32 additions and 7 deletions

View file

@ -707,13 +707,6 @@ MainWindow::~MainWindow()
*/
void MainWindow::restoreConfigState()
{
// start minimized if configured
if (config()->get(Config::GUI_MinimizeOnStartup).toBool()) {
hideWindow();
} else {
bringToFront();
}
if (config()->get(Config::OpenPreviousDatabasesOnStartup).toBool()) {
const QStringList fileNames = config()->get(Config::LastOpenedDatabases).toStringList();
for (const QString& filename : fileNames) {
@ -1370,6 +1363,24 @@ void MainWindow::databaseTabChanged(int tabIndex)
updateEntryCountLabel();
}
void MainWindow::showEvent(QShowEvent* event)
{
Q_UNUSED(event)
#ifdef Q_OS_WIN
// Qt Hack - Prevent white flicker when showing window
QTimer::singleShot(50, this, [=] { setProperty("windowOpacity", 1.0); });
#endif
}
void MainWindow::hideEvent(QHideEvent* event)
{
Q_UNUSED(event)
#ifdef Q_OS_WIN
// Qt Hack - Prevent white flicker when showing window
setProperty("windowOpacity", 0.0);
#endif
}
void MainWindow::closeEvent(QCloseEvent* event)
{
if (m_appExiting) {