Check if system has system tray using QSystemTrayIcon::isSystemTrayAvailable()

This commit is contained in:
Jonas Kvinge
2018-09-30 15:33:27 +02:00
parent 6d888eb51a
commit 298dbe96c8
5 changed files with 79 additions and 55 deletions

View File

@@ -23,6 +23,7 @@
#include <cmath>
#include <QObject>
#include <QSystemTrayIcon>
#include <QPixmap>
#include <QPainter>
#include <QPoint>
@@ -105,10 +106,11 @@ void SystemTrayIcon::SetStopped() {
UpdateIcon();
}
SystemTrayIcon* SystemTrayIcon::CreateSystemTrayIcon(QObject *parent) {
SystemTrayIcon *SystemTrayIcon::CreateSystemTrayIcon(QObject *parent) {
#ifdef Q_OS_MACOS
return new MacSystemTrayIcon(parent);
#else
return new QtSystemTrayIcon(parent);
if (QSystemTrayIcon::isSystemTrayAvailable()) return new QtSystemTrayIcon(parent);
else return nullptr;
#endif
}