From 54da8eca850dc101ec5ee36c1ffe1309f4c7b40b Mon Sep 17 00:00:00 2001 From: Nick Stockton Date: Thu, 4 Apr 2019 01:03:21 -0400 Subject: [PATCH] obs-frontend-api: Access system tray icon from API All UI elements are accessible through the obs frontend api via obs_frontend_api_get_main_window, except for the tray icon and its elements. This commit adds an obs_frontend_api_get_system_tray function which returns the pointer to the QSystemTrayIcon cast to void (much like the QMainWindow pointer for the main window). --- UI/api-interface.cpp | 5 +++++ UI/obs-frontend-api/obs-frontend-api.cpp | 7 +++++++ UI/obs-frontend-api/obs-frontend-api.h | 1 + UI/obs-frontend-api/obs-frontend-internal.hpp | 1 + 4 files changed, 14 insertions(+) diff --git a/UI/api-interface.cpp b/UI/api-interface.cpp index 705caaa4b..a933a945d 100644 --- a/UI/api-interface.cpp +++ b/UI/api-interface.cpp @@ -67,6 +67,11 @@ struct OBSStudioAPI : obs_frontend_callbacks { return (void*)main->winId(); } + void *obs_frontend_get_system_tray(void) override + { + return (void*)main->trayIcon.data(); + } + void obs_frontend_get_scenes( struct obs_frontend_source_list *sources) override { diff --git a/UI/obs-frontend-api/obs-frontend-api.cpp b/UI/obs-frontend-api/obs-frontend-api.cpp index c3c933ab8..f0b9022cf 100644 --- a/UI/obs-frontend-api/obs-frontend-api.cpp +++ b/UI/obs-frontend-api/obs-frontend-api.cpp @@ -71,6 +71,13 @@ void *obs_frontend_get_main_window_handle(void) : nullptr; } +void *obs_frontend_get_system_tray(void) +{ + return !!callbacks_valid() + ? c->obs_frontend_get_system_tray() + : nullptr; +} + char **obs_frontend_get_scene_names(void) { if (!callbacks_valid()) diff --git a/UI/obs-frontend-api/obs-frontend-api.h b/UI/obs-frontend-api/obs-frontend-api.h index ae674943a..86d53abdc 100644 --- a/UI/obs-frontend-api/obs-frontend-api.h +++ b/UI/obs-frontend-api/obs-frontend-api.h @@ -82,6 +82,7 @@ static inline void obs_frontend_source_list_free( EXPORT void *obs_frontend_get_main_window(void); EXPORT void *obs_frontend_get_main_window_handle(void); +EXPORT void *obs_frontend_get_system_tray(void); EXPORT char **obs_frontend_get_scene_names(void); EXPORT void obs_frontend_get_scenes(struct obs_frontend_source_list *sources); diff --git a/UI/obs-frontend-api/obs-frontend-internal.hpp b/UI/obs-frontend-api/obs-frontend-internal.hpp index b1a906418..331f509ab 100644 --- a/UI/obs-frontend-api/obs-frontend-internal.hpp +++ b/UI/obs-frontend-api/obs-frontend-internal.hpp @@ -9,6 +9,7 @@ struct obs_frontend_callbacks { virtual ~obs_frontend_callbacks() {} virtual void *obs_frontend_get_main_window(void)=0; virtual void *obs_frontend_get_main_window_handle(void)=0; + virtual void *obs_frontend_get_system_tray(void)=0; virtual void obs_frontend_get_scenes( struct obs_frontend_source_list *sources)=0; -- GitLab