fix - MacOS - no notification in tray on image upload, save to clipboard and other notifications

This commit is contained in:
Yuriy Puchkov
2020-12-17 15:02:22 +02:00
parent 1e5e257394
commit 6300672828
2 changed files with 15 additions and 17 deletions

View File

@@ -1,34 +1,30 @@
#include "systemnotification.h"
#include "src/core/controller.h"
#include "src/utils/confighandler.h"
#include <QApplication>
#include <QUrl>
#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 <QDBusConnection>
#include <QDBusInterface>
#include <QDBusMessage>
#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<QVariant> 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
}