diff --git a/src/main.cpp b/src/main.cpp index 2d44f540..deeb0363 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -76,7 +76,8 @@ int main(int argc, char* argv[]) app.setOrganizationName(QStringLiteral("flameshot")); auto c = Controller::getInstance(); -#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) +#if not(defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \ + defined(Q_OS_MACX) || defined(Q_OS_WIN)) new FlameshotDBusAdapter(c); QDBusConnection dbus = QDBusConnection::sessionBus(); if (!dbus.isConnected()) { @@ -92,7 +93,8 @@ int main(int argc, char* argv[]) return app.exec(); } -#ifndef Q_OS_WIN +#if not(defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \ + defined(Q_OS_MACX) || defined(Q_OS_WIN)) /*--------------| * CLI parsing | * ------------*/ diff --git a/src/utils/systemnotification.cpp b/src/utils/systemnotification.cpp index 3df103af..2e3e62c5 100644 --- a/src/utils/systemnotification.cpp +++ b/src/utils/systemnotification.cpp @@ -1,34 +1,30 @@ #include "systemnotification.h" +#include "src/core/controller.h" #include "src/utils/confighandler.h" #include #include -#ifndef Q_OS_WIN +#if not(defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \ + defined(Q_OS_MACX) || defined(Q_OS_WIN)) #include #include #include -#else #endif -#include "src/core/controller.h" -#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) SystemNotification::SystemNotification(QObject* parent) : QObject(parent) + , m_interface(nullptr) { +#if not(defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \ + defined(Q_OS_MACX) || defined(Q_OS_WIN)) m_interface = new QDBusInterface(QStringLiteral("org.freedesktop.Notifications"), QStringLiteral("/org/freedesktop/Notifications"), QStringLiteral("org.freedesktop.Notifications"), QDBusConnection::sessionBus(), this); -} -#else -SystemNotification::SystemNotification(QObject* parent) - : QObject(parent) -{ - m_interface = nullptr; -} #endif +} void SystemNotification::sendMessage(const QString& text, const QString& savePath) @@ -45,7 +41,10 @@ void SystemNotification::sendMessage(const QString& text, return; } -#ifndef Q_OS_WIN +#if defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \ + defined(Q_OS_MACX) || defined(Q_OS_WIN) + Controller::getInstance()->sendTrayNotification(text, title, timeout); +#else QList args; QVariantMap hintsMap; if (!savePath.isEmpty()) { @@ -64,8 +63,5 @@ void SystemNotification::sendMessage(const QString& text, << timeout; // timeout m_interface->callWithArgumentList( QDBus::AutoDetect, QStringLiteral("Notify"), args); -#else - auto c = Controller::getInstance(); - c->sendTrayNotification(text, title, timeout); #endif }