0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-19 20:32:15 +02:00

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

@ -414,6 +414,7 @@ Basic.Settings.General.RecordWhenStreaming="Automatically record when streaming"
Basic.Settings.General.KeepRecordingWhenStreamStops="Keep recording when stream stops"
Basic.Settings.General.SysTrayEnabled="Enable system tray icon"
Basic.Settings.General.SysTrayWhenStarted="Minimize to system tray when started"
Basic.Settings.General.SystemTrayHideMinimize="Hide to system tray instead of minimize to task bar"
# basic mode 'stream' settings
Basic.Settings.Stream="Stream"

View File

@ -209,14 +209,24 @@
</property>
</widget>
</item>
<item row="11" column="0" colspan="2">
<item row="11" column="1">
<widget class="QCheckBox" name="systemTrayAlways">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Basic.Settings.General.SystemTrayHideMinimize</string>
</property>
</widget>
</item>
<item row="12" column="0" colspan="2">
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="12" column="0" colspan="2">
<item row="13" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_10">
<property name="enabled">
<bool>true</bool>
@ -4189,5 +4199,11 @@
</hint>
</hints>
</connection>
<connection>
<sender>systemTrayEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>systemTrayAlways</receiver>
<slot>setEnabled(bool)</slot>
</connection>
</connections>
</ui>

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");
}

View File

@ -321,6 +321,8 @@ private:
void ReplayBufferClicked();
bool sysTrayMinimizeToTray();
public slots:
void StartStreaming();
void StopStreaming();

View File

@ -281,6 +281,7 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
HookWidget(ui->keepRecordStreamStops,CHECK_CHANGED, GENERAL_CHANGED);
HookWidget(ui->systemTrayEnabled, CHECK_CHANGED, GENERAL_CHANGED);
HookWidget(ui->systemTrayWhenStarted,CHECK_CHANGED, GENERAL_CHANGED);
HookWidget(ui->systemTrayAlways, CHECK_CHANGED, GENERAL_CHANGED);
HookWidget(ui->snappingEnabled, CHECK_CHANGED, GENERAL_CHANGED);
HookWidget(ui->screenSnapping, CHECK_CHANGED, GENERAL_CHANGED);
HookWidget(ui->centerSnapping, CHECK_CHANGED, GENERAL_CHANGED);
@ -891,6 +892,10 @@ void OBSBasicSettings::LoadGeneralSettings()
"BasicWindow", "SysTrayWhenStarted");
ui->systemTrayWhenStarted->setChecked(systemTrayWhenStarted);
bool systemTrayAlways = config_get_bool(GetGlobalConfig(),
"BasicWindow", "SysTrayMinimizeToTray");
ui->systemTrayAlways->setChecked(systemTrayAlways);
bool snappingEnabled = config_get_bool(GetGlobalConfig(),
"BasicWindow", "SnappingEnabled");
ui->snappingEnabled->setChecked(snappingEnabled);
@ -2341,6 +2346,11 @@ void OBSBasicSettings::SaveGeneralSettings()
config_set_bool(GetGlobalConfig(), "BasicWindow",
"SysTrayWhenStarted",
ui->systemTrayWhenStarted->isChecked());
if (WidgetChanged(ui->systemTrayAlways))
config_set_bool(GetGlobalConfig(),
"BasicWindow", "SysTrayMinimizeToTray",
ui->systemTrayAlways->isChecked());
}
void OBSBasicSettings::SaveStream1Settings()