Merge pull request #25 from namecheap/bugfix/RND-729-flameshot-macos-no-notification-in-tray-on-image-upload

fix - MacOS - no notification in tray on image upload, save to clipboard and other notifications
This commit is contained in:
Yurii Puchkov
2020-12-17 15:18:26 +02:00
committed by GitHub
2 changed files with 15 additions and 17 deletions

View File

@@ -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 |
* ------------*/

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
}