UI: Update tray icons to use masks on macOS

master
PatTheMav 2020-11-12 23:39:32 +01:00
parent 3e7e99e0f3
commit 35e6f5e17a
No known key found for this signature in database
GPG Key ID: CEFD5D83C12A66B3
5 changed files with 78 additions and 22 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -11,8 +11,11 @@
<file>images/down.svg</file>
<file>images/up.svg</file>
<file>images/obs.png</file>
<file>images/obs_macos.png</file>
<file>images/obs_paused.png</file>
<file>images/obs_paused_macos.png</file>
<file>images/tray_active.png</file>
<file>images/tray_active_macos.png</file>
<file>images/expand.svg</file>
<file>images/unlocked.svg</file>
<file>images/locked.svg</file>

View File

@ -5619,10 +5619,19 @@ inline void OBSBasic::OnActivate()
App()->IncrementSleepInhibition();
UpdateProcessPriority();
if (trayIcon && trayIcon->isVisible())
if (trayIcon && trayIcon->isVisible()) {
#ifdef __APPLE__
QIcon trayMask =
QIcon(":/res/images/tray_active_macos.png");
trayMask.setIsMask(true);
trayIcon->setIcon(
QIcon::fromTheme("obs-tray", trayMask));
#else
trayIcon->setIcon(QIcon::fromTheme(
"obs-tray-active",
QIcon(":/res/images/tray_active.png")));
#endif
}
}
}
@ -5637,19 +5646,42 @@ inline void OBSBasic::OnDeactivate()
App()->DecrementSleepInhibition();
ClearProcessPriority();
if (trayIcon && trayIcon->isVisible())
trayIcon->setIcon(QIcon::fromTheme(
"obs-tray", QIcon(":/res/images/obs.png")));
if (trayIcon && trayIcon->isVisible()) {
#ifdef __APPLE__
QIcon trayIconFile =
QIcon(":/res/images/obs_macos.png");
trayIconFile.setIsMask(true);
#else
QIcon trayIconFile = QIcon(":/res/images/obs.png");
#endif
trayIcon->setIcon(
QIcon::fromTheme("obs-tray", trayIconFile));
}
} else if (outputHandler->Active() && trayIcon &&
trayIcon->isVisible()) {
if (os_atomic_load_bool(&recording_paused))
trayIcon->setIcon(QIcon::fromTheme(
"obs-tray-paused",
QIcon(":/res/images/obs_paused.png")));
else
trayIcon->setIcon(QIcon::fromTheme(
"obs-tray-active",
QIcon(":/res/images/tray_active.png")));
if (os_atomic_load_bool(&recording_paused)) {
#ifdef __APPLE__
QIcon trayIconFile =
QIcon(":/res/images/obs_paused_macos.png");
trayIconFile.setIsMask(true);
#else
QIcon trayIconFile =
QIcon(":/res/images/obs_paused.png");
#endif
trayIcon->setIcon(QIcon::fromTheme("obs-tray-paused",
trayIconFile));
} else {
#ifdef __APPLE__
QIcon trayIconFile =
QIcon(":/res/images/tray_active_macos.png");
trayIconFile.setIsMask(true);
#else
QIcon trayIconFile =
QIcon(":/res/images/tray_active.png");
#endif
trayIcon->setIcon(QIcon::fromTheme("obs-tray-active",
trayIconFile));
}
}
}
@ -7536,9 +7568,14 @@ void OBSBasic::ToggleShowHide()
void OBSBasic::SystemTrayInit()
{
#ifdef __APPLE__
QIcon trayIconFile = QIcon(":/res/images/obs_macos.png");
trayIconFile.setIsMask(true);
#else
QIcon trayIconFile = QIcon(":/res/images/obs.png");
#endif
trayIcon.reset(new QSystemTrayIcon(
QIcon::fromTheme("obs-tray", QIcon(":/res/images/obs.png")),
this));
QIcon::fromTheme("obs-tray", trayIconFile), this));
trayIcon->setToolTip("OBS Studio");
showHide = new QAction(QTStr("Basic.SystemTray.Show"), trayIcon.data());
@ -8114,10 +8151,18 @@ void OBSBasic::PauseRecording()
ui->statusbar->RecordingPaused();
if (trayIcon && trayIcon->isVisible())
trayIcon->setIcon(QIcon::fromTheme(
"obs-tray-paused",
QIcon(":/res/images/obs_paused.png")));
if (trayIcon && trayIcon->isVisible()) {
#ifdef __APPLE__
QIcon trayIconFile =
QIcon(":/res/images/obs_paused_macos.png");
trayIconFile.setIsMask(true);
#else
QIcon trayIconFile =
QIcon(":/res/images/obs_paused.png");
#endif
trayIcon->setIcon(QIcon::fromTheme("obs-tray-paused",
trayIconFile));
}
os_atomic_set_bool(&recording_paused, true);
@ -8145,10 +8190,18 @@ void OBSBasic::UnpauseRecording()
ui->statusbar->RecordingUnpaused();
if (trayIcon && trayIcon->isVisible())
trayIcon->setIcon(QIcon::fromTheme(
"obs-tray-active",
QIcon(":/res/images/tray_active.png")));
if (trayIcon && trayIcon->isVisible()) {
#ifdef __APPLE__
QIcon trayIconFile =
QIcon(":/res/images/tray_active_macos.png");
trayIconFile.setIsMask(true);
#else
QIcon trayIconFile =
QIcon(":/res/images/tray_active.png");
#endif
trayIcon->setIcon(QIcon::fromTheme("obs-tray-active",
trayIconFile));
}
os_atomic_set_bool(&recording_paused, false);