UI: Add option to always minimize to tray

Closes jp9000/obs-studio#737
This commit is contained in:
SuslikV
2017-01-24 23:01:24 -08:00
committed by jp9000
parent cdf8a40bf1
commit abe4bfd96e
5 changed files with 53 additions and 4 deletions

View File

@@ -2787,8 +2787,13 @@ void OBSBasic::closeEvent(QCloseEvent *event)
void OBSBasic::changeEvent(QEvent *event)
{
/* TODO */
UNUSED_PARAMETER(event);
if (event->type() == QEvent::WindowStateChange &&
isMinimized() &&
trayIcon->isVisible() &&
sysTrayMinimizeToTray()) {
ToggleShowHide();
}
}
void OBSBasic::on_actionShow_Recordings_triggered()
@@ -4906,6 +4911,15 @@ void OBSBasic::SetShowing(bool showing)
EnablePreviewDisplay(true);
setVisible(true);
/* Unminimize window if it was hidden to tray instead of task
* bar. */
if (sysTrayMinimizeToTray()) {
Qt::WindowStates state;
state = windowState() & ~Qt::WindowMinimized;
state |= Qt::WindowActive;
setWindowState(state);
}
}
}
@@ -5003,3 +5017,9 @@ void OBSBasic::SystemTray(bool firstStarted)
else
showHide->setText(QTStr("Basic.SystemTray.Show"));
}
bool OBSBasic::sysTrayMinimizeToTray()
{
return config_get_bool(GetGlobalConfig(),
"BasicWindow", "SysTrayMinimizeToTray");
}