From 45c46fe24ae40b38cfd7260495bdf767c9b2891f Mon Sep 17 00:00:00 2001 From: Ford Smith Date: Tue, 25 Aug 2020 17:37:56 -0500 Subject: [PATCH] UI: Fix tray icon appearing when disabled in settings --- UI/window-basic-main.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 788721215..600009bdd 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -5547,7 +5547,7 @@ inline void OBSBasic::OnActivate() App()->IncrementSleepInhibition(); UpdateProcessPriority(); - if (trayIcon) + if (trayIcon && trayIcon->isVisible()) trayIcon->setIcon(QIcon::fromTheme( "obs-tray-active", QIcon(":/res/images/tray_active.png"))); @@ -5565,10 +5565,10 @@ inline void OBSBasic::OnDeactivate() App()->DecrementSleepInhibition(); ClearProcessPriority(); - if (trayIcon) + if (trayIcon && trayIcon->isVisible()) trayIcon->setIcon(QIcon::fromTheme( "obs-tray", QIcon(":/res/images/obs.png"))); - } else if (trayIcon) { + } else if (trayIcon && trayIcon->isVisible()) { if (os_atomic_load_bool(&recording_paused)) trayIcon->setIcon(QIcon(":/res/images/obs_paused.png")); else @@ -7543,7 +7543,8 @@ void OBSBasic::IconActivated(QSystemTrayIcon::ActivationReason reason) void OBSBasic::SysTrayNotify(const QString &text, QSystemTrayIcon::MessageIcon n) { - if (trayIcon && QSystemTrayIcon::supportsMessages()) { + if (trayIcon && trayIcon->isVisible() && + QSystemTrayIcon::supportsMessages()) { QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon(n); trayIcon->showMessage("OBS Studio", text, icon, 10000); @@ -8061,7 +8062,7 @@ void OBSBasic::PauseRecording() ui->statusbar->RecordingPaused(); - if (trayIcon) + if (trayIcon && trayIcon->isVisible()) trayIcon->setIcon(QIcon(":/res/images/obs_paused.png")); os_atomic_set_bool(&recording_paused, true); @@ -8090,7 +8091,7 @@ void OBSBasic::UnpauseRecording() ui->statusbar->RecordingUnpaused(); - if (trayIcon) + if (trayIcon && trayIcon->isVisible()) trayIcon->setIcon( QIcon(":/res/images/tray_active.png"));