UI: Fix show/hide toggle with minimize to taskbar

If the user would minimize to tray instead of taskbar, the
window would flash when clicking show in the tray menu, and
the preview would be disabled. This would only happen on Linux.
This commit is contained in:
cg2121 2022-03-01 05:14:47 -06:00 committed by Matt Gajownik
parent 14b1d34a06
commit 02aa833950

View File

@ -4759,6 +4759,7 @@ void OBSBasic::changeEvent(QEvent *event)
if (trayIcon && trayIcon->isVisible() &&
sysTrayMinimizeToTray()) {
ToggleShowHide();
return;
}
if (previewEnabled)
@ -8988,9 +8989,10 @@ void OBSBasic::SetShowing(bool showing)
if (showHide)
showHide->setText(QTStr("Basic.SystemTray.Show"));
QTimer::singleShot(250, this, SLOT(hide()));
QTimer::singleShot(0, this, SLOT(hide()));
setVisible(false);
if (previewEnabled)
EnablePreviewDisplay(false);
#ifdef __APPLE__
EnableOSXDockIcon(false);
@ -8999,9 +9001,10 @@ void OBSBasic::SetShowing(bool showing)
} else if (showing && !isVisible()) {
if (showHide)
showHide->setText(QTStr("Basic.SystemTray.Hide"));
QTimer::singleShot(250, this, SLOT(show()));
QTimer::singleShot(0, this, SLOT(show()));
setVisible(true);
if (previewEnabled)
EnablePreviewDisplay(true);
#ifdef __APPLE__
EnableOSXDockIcon(true);