mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-02 15:32:34 +02:00
Merge g152 via gui_notify_setup_bg
This commit is contained in:
commit
f81eeca008
@ -28,6 +28,18 @@
|
|||||||
#ifdef USE_DBUS
|
#ifdef USE_DBUS
|
||||||
// https://wiki.ubuntu.com/NotificationDevelopmentGuidelines recommends at least 128
|
// https://wiki.ubuntu.com/NotificationDevelopmentGuidelines recommends at least 128
|
||||||
const int FREEDESKTOP_NOTIFICATION_ICON_SIZE = 128;
|
const int FREEDESKTOP_NOTIFICATION_ICON_SIZE = 128;
|
||||||
|
|
||||||
|
void DBusInitThread::run() {
|
||||||
|
auto interface = new QDBusInterface("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications");
|
||||||
|
if (!interface->isValid()) {
|
||||||
|
delete interface;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
interface->moveToThread(m_notificator.thread());
|
||||||
|
m_notificator.interface = interface;
|
||||||
|
m_notificator.mode = Notificator::Freedesktop;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Notificator::Notificator(const QString &_programName, QSystemTrayIcon *_trayIcon, QWidget *_parent) :
|
Notificator::Notificator(const QString &_programName, QSystemTrayIcon *_trayIcon, QWidget *_parent) :
|
||||||
@ -41,12 +53,8 @@ Notificator::Notificator(const QString &_programName, QSystemTrayIcon *_trayIcon
|
|||||||
mode = QSystemTray;
|
mode = QSystemTray;
|
||||||
}
|
}
|
||||||
#ifdef USE_DBUS
|
#ifdef USE_DBUS
|
||||||
interface = new QDBusInterface("org.freedesktop.Notifications",
|
m_dbus_init_thread = new DBusInitThread(*this);
|
||||||
"/org/freedesktop/Notifications", "org.freedesktop.Notifications");
|
m_dbus_init_thread->start();
|
||||||
if(interface->isValid())
|
|
||||||
{
|
|
||||||
mode = Freedesktop;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
// check if users OS has support for NSUserNotification
|
// check if users OS has support for NSUserNotification
|
||||||
@ -59,6 +67,8 @@ Notificator::Notificator(const QString &_programName, QSystemTrayIcon *_trayIcon
|
|||||||
Notificator::~Notificator()
|
Notificator::~Notificator()
|
||||||
{
|
{
|
||||||
#ifdef USE_DBUS
|
#ifdef USE_DBUS
|
||||||
|
m_dbus_init_thread->wait();
|
||||||
|
delete m_dbus_init_thread;
|
||||||
delete interface;
|
delete interface;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -218,8 +228,7 @@ void Notificator::notifyMacUserNotificationCenter(const QString &title, const QS
|
|||||||
|
|
||||||
void Notificator::notify(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout)
|
void Notificator::notify(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout)
|
||||||
{
|
{
|
||||||
switch(mode)
|
switch (Mode(mode)) {
|
||||||
{
|
|
||||||
#ifdef USE_DBUS
|
#ifdef USE_DBUS
|
||||||
case Freedesktop:
|
case Freedesktop:
|
||||||
notifyDBus(cls, title, text, icon, millisTimeout);
|
notifyDBus(cls, title, text, icon, millisTimeout);
|
||||||
|
@ -9,6 +9,9 @@
|
|||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QSystemTrayIcon;
|
class QSystemTrayIcon;
|
||||||
@ -18,6 +21,23 @@ class QDBusInterface;
|
|||||||
#endif
|
#endif
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
class Notificator;
|
||||||
|
|
||||||
|
#ifdef USE_DBUS
|
||||||
|
class DBusInitThread : public QThread
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Notificator& m_notificator;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DBusInitThread(Notificator& notificator) : m_notificator(notificator) {};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void run() override;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Cross-platform desktop notification client. */
|
/** Cross-platform desktop notification client. */
|
||||||
class Notificator: public QObject
|
class Notificator: public QObject
|
||||||
{
|
{
|
||||||
@ -59,11 +79,15 @@ private:
|
|||||||
UserNotificationCenter /**< Use the 10.8+ User Notification Center (Mac only) */
|
UserNotificationCenter /**< Use the 10.8+ User Notification Center (Mac only) */
|
||||||
};
|
};
|
||||||
QString programName;
|
QString programName;
|
||||||
Mode mode{None};
|
std::atomic<Mode> mode{None};
|
||||||
QSystemTrayIcon *trayIcon;
|
QSystemTrayIcon *trayIcon;
|
||||||
#ifdef USE_DBUS
|
#ifdef USE_DBUS
|
||||||
|
QThread *m_dbus_init_thread{nullptr};
|
||||||
|
protected:
|
||||||
QDBusInterface* interface{nullptr};
|
QDBusInterface* interface{nullptr};
|
||||||
|
friend class DBusInitThread;
|
||||||
|
|
||||||
|
private:
|
||||||
void notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
|
void notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
|
||||||
#endif
|
#endif
|
||||||
void notifySystray(Class cls, const QString &title, const QString &text, int millisTimeout);
|
void notifySystray(Class cls, const QString &title, const QString &text, int millisTimeout);
|
||||||
|
Loading…
Reference in New Issue
Block a user