Skip to content

Commit

Permalink
notifications: check if system tray is available before notifying
Browse files Browse the repository at this point in the history
  • Loading branch information
Stéphane L committed Mar 14, 2018
1 parent 389ef2a commit e1ca9a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,19 @@ QString Utils::OBSVersionString() {

QSystemTrayIcon* Utils::GetTrayIcon() {
QMainWindow* main = (QMainWindow*)obs_frontend_get_main_window();
if (!main) return nullptr;

return main->findChildren<QSystemTrayIcon*>().first();
}

void Utils::SysTrayNotify(QString &text,
QSystemTrayIcon::MessageIcon icon, QString title) {
if (!Config::Current()->AlertsEnabled || !QSystemTrayIcon::supportsMessages())
if (!Config::Current()->AlertsEnabled ||
!QSystemTrayIcon::isSystemTrayAvailable() ||
!QSystemTrayIcon::supportsMessages())
{
return;
}

QSystemTrayIcon* trayIcon = GetTrayIcon();
if (trayIcon)
Expand Down
2 changes: 0 additions & 2 deletions src/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ class Utils {
static obs_data_array_t* GetScenes();
static obs_data_t* GetSceneData(obs_source_t* source);

static obs_data_array_t* GetProfiles();

static QSpinBox* GetTransitionDurationControl();
static int GetTransitionDuration();
static void SetTransitionDuration(int ms);
Expand Down

0 comments on commit e1ca9a8

Please sign in to comment.