Utils: Add platform util to send tray notification

This commit is contained in:
tt2468 2021-06-13 03:17:11 -07:00
parent 57794a2bf5
commit 0de3f304f0
2 changed files with 14 additions and 2 deletions

View File

@ -3,12 +3,12 @@
#include <QNetworkInterface> #include <QNetworkInterface>
#include <QHostAddress> #include <QHostAddress>
#include <obs-frontend-api.h>
#include "Utils.h" #include "Utils.h"
#include "../plugin-macros.generated.h" #include "../plugin-macros.generated.h"
#include <QDebug>
std::string Utils::Platform::GetLocalAddress() std::string Utils::Platform::GetLocalAddress()
{ {
std::vector<QString> validAddresses; std::vector<QString> validAddresses;
@ -77,3 +77,13 @@ bool Utils::Platform::GetCommandLineFlagSet(QString arg)
return parser.isSet(cmdlineOption); return parser.isSet(cmdlineOption);
} }
void Utils::Platform::SendTrayNotification(QSystemTrayIcon::MessageIcon icon, QString title, QString body)
{
if (!QSystemTrayIcon::isSystemTrayAvailable() || !QSystemTrayIcon::supportsMessages())
return;
void *systemTrayPtr = obs_frontend_get_system_tray();
auto systemTray = reinterpret_cast<QSystemTrayIcon*>(systemTrayPtr);
systemTray->showMessage(title, body, icon);
}

View File

@ -3,6 +3,7 @@
#include <obs.hpp> #include <obs.hpp>
#include <string> #include <string>
#include <QString> #include <QString>
#include <QSystemTrayIcon>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using json = nlohmann::json;
@ -25,6 +26,7 @@ namespace Utils {
std::string GetLocalAddress(); std::string GetLocalAddress();
QString GetCommandLineArgument(QString arg); QString GetCommandLineArgument(QString arg);
bool GetCommandLineFlagSet(QString arg); bool GetCommandLineFlagSet(QString arg);
void SendTrayNotification(QSystemTrayIcon::MessageIcon icon, QString title, QString body);
} }
namespace Obs { namespace Obs {