From a8b13398894813f69ca3c602bd5251f8f72708fb Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Fri, 17 Jul 2026 19:41:32 +0000 Subject: [PATCH 3/6] 0003-unbreak-objc --- src/gui/macOS/ScreenSaver.cpp | 7 +++++++ src/qmplay2/NotifiesMacOS.mm | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/gui/macOS/ScreenSaver.cpp b/src/gui/macOS/ScreenSaver.cpp index 07f9fb1e..36885a39 100644 --- a/src/gui/macOS/ScreenSaver.cpp +++ b/src/gui/macOS/ScreenSaver.cpp @@ -20,6 +20,13 @@ #include +#ifndef kIOPMAssertPreventUserIdleDisplaySleep +#define kIOPMAssertPreventUserIdleDisplaySleep CFSTR("PreventUserIdleDisplaySleep") +#endif +#ifndef kIOPMAssertPreventUserIdleSystemSleep +#define kIOPMAssertPreventUserIdleSystemSleep CFSTR("PreventUserIdleSystemSleep") +#endif + #define QMPLAY2_MEDIA_PLAYBACK CFSTR("QMPlay2 media playback") class ScreenSaverPriv diff --git a/src/qmplay2/NotifiesMacOS.mm b/src/qmplay2/NotifiesMacOS.mm index 54cd511e..39e0cda8 100644 --- a/src/qmplay2/NotifiesMacOS.mm +++ b/src/qmplay2/NotifiesMacOS.mm @@ -3,7 +3,12 @@ #import #include + +#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include +#endif + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 @interface QMPlay2NotificationItem : NSObject {} @@ -32,26 +37,41 @@ static inline void releaseNotification(NSUserNotification *notification) [notification release]; } +#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 + /**/ NotifiesMacOS::NotifiesMacOS() { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 QMPlay2NotificationItem *notificationItem = [QMPlay2NotificationItem alloc]; [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:notificationItem]; m_notificationItem = notificationItem; +#else + m_notificationItem = nullptr; +#endif } NotifiesMacOS::~NotifiesMacOS() { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:nil]; [(QMPlay2NotificationItem *)m_notificationItem release]; for (auto &¬ification : m_notifications) releaseNotification((NSUserNotification *)notification); +#endif } bool NotifiesMacOS::doNotify(const QString &title, const QString &message, const int ms, const QPixmap &pixmap, const int iconId) { Q_UNUSED(iconId) +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1080 + Q_UNUSED(title) + Q_UNUSED(message) + Q_UNUSED(ms) + Q_UNUSED(pixmap) + return false; +#else if (!m_notificationItem) return false; @@ -113,6 +133,7 @@ bool NotifiesMacOS::doNotify(const QString &title, const QString &message, const } return true; +#endif } bool NotifiesMacOS::doNotify(const QString &title, const QString &message, const int ms, const QImage &image, const int iconId) {