UI: Match Windows taskbar state to tray icon

This adds both a status icon, and changes the color
of the taskbar button itself.
This commit is contained in:
Matt Gajownik
2020-02-27 21:16:26 +11:00
parent c59ce6981b
commit d442fda3fc
7 changed files with 68 additions and 6 deletions

View File

@@ -1780,6 +1780,11 @@ void OBSBasic::OBSInit()
SystemTray(true);
#endif
#ifdef _WIN32
taskBtn->setWindow(windowHandle());
taskProg->setRange(0, 1);
#endif
bool has_last_version = config_has_user_value(App()->GlobalConfig(),
"General", "LastVersion");
bool first_run =
@@ -5292,6 +5297,13 @@ inline void OBSBasic::OnActivate()
App()->IncrementSleepInhibition();
UpdateProcessPriority();
#ifdef _WIN32
taskProg->show();
taskProg->resume();
taskProg->setValue(1);
taskBtn->setOverlayIcon(QIcon::fromTheme(
"obs-active", QIcon(":/res/images/active.png")));
#endif
if (trayIcon)
trayIcon->setIcon(QIcon::fromTheme(
"obs-tray-active",
@@ -5313,12 +5325,34 @@ inline void OBSBasic::OnDeactivate()
if (trayIcon)
trayIcon->setIcon(QIcon::fromTheme(
"obs-tray", QIcon(":/res/images/obs.png")));
} else if (trayIcon) {
if (os_atomic_load_bool(&recording_paused))
trayIcon->setIcon(QIcon(":/res/images/obs_paused.png"));
else
trayIcon->setIcon(
QIcon(":/res/images/tray_active.png"));
#ifdef _WIN32
taskProg->hide();
taskBtn->clearOverlayIcon();
#endif
} else {
if (os_atomic_load_bool(&recording_paused)) {
#ifdef _WIN32
taskProg->show();
taskProg->pause();
taskBtn->setOverlayIcon(QIcon::fromTheme(
"obs-paused",
QIcon(":/res/images/paused.png")));
#endif
if (trayIcon)
trayIcon->setIcon(
QIcon(":/res/images/obs_paused.png"));
} else {
#ifdef _WIN32
taskProg->show();
taskProg->resume();
taskBtn->setOverlayIcon(QIcon::fromTheme(
"obs-active",
QIcon(":/res/images/active.png")));
#endif
if (trayIcon)
trayIcon->setIcon(
QIcon(":/res/images/tray_active.png"));
}
}
}
@@ -7698,6 +7732,11 @@ void OBSBasic::PauseRecording()
ui->statusbar->RecordingPaused();
#ifdef _WIN32
taskProg->pause();
taskBtn->setOverlayIcon(QIcon::fromTheme(
"obs-paused", QIcon(":/res/images/paused.png")));
#endif
if (trayIcon)
trayIcon->setIcon(QIcon(":/res/images/obs_paused.png"));
@@ -7727,6 +7766,11 @@ void OBSBasic::UnpauseRecording()
ui->statusbar->RecordingUnpaused();
#ifdef _WIN32
taskProg->resume();
taskBtn->setOverlayIcon(QIcon::fromTheme(
"obs-active", QIcon(":/res/images/active.png")));
#endif
if (trayIcon)
trayIcon->setIcon(
QIcon(":/res/images/tray_active.png"));