diff --git a/src/notifications/manager.h b/src/notifications/manager.h index bdc06d4..653a0e6 100644 --- a/src/notifications/manager.h +++ b/src/notifications/manager.h @@ -39,7 +39,7 @@ class NotificationsManager : public QObject { // these slots are platform specific (D-Bus only) // but Qt slot declarations can not be inside an ifdef! - private slots: + public slots: void actionInvoked(uint id, QString action); void notificationClosed(uint id, uint reason); }; diff --git a/src/notifications/managerwin.cpp b/src/notifications/managerwin.cpp index 87b8bd2..2c98694 100644 --- a/src/notifications/managerwin.cpp +++ b/src/notifications/managerwin.cpp @@ -3,23 +3,26 @@ using namespace WinToastLib; -class CustomHandler : public QObject, public IWinToastHandler { - Q_OBJECT +class CustomHandler : public IWinToastHandler { public: - void toastActivated() { emit activated(notificationID); } - void toastActivated(int) { emit activated(notificationID); } + CustomHandler(NotificationsManager* parent) : notificationsManager(parent) {} + void toastActivated() { + notificationsManager->actionInvoked(notificationID, ""); + } + void toastActivated(int) { + notificationsManager->actionInvoked(notificationID, ""); + } void toastFailed() { std::wcout << L"Error showing current toast" << std::endl; } void toastDismissed(WinToastDismissalReason) { - emit dismissed(notificationID); + notificationsManager->notificationClosed(notificationID, 0); } uint notificationID; - signals: - void activated(uint id); - void dismissed(uint id); +private: + NotificationsManager* notificationsManager; }; namespace { @@ -61,14 +64,10 @@ void NotificationsManager::postNotification( // TODO: implement room or user avatar // templ.setImagePath(L"C:/example.png"); - CustomHandler *customHandler = new CustomHandler(); + CustomHandler *customHandler = new CustomHandler(this); count++; customHandler->notificationID = count; notificationIds[count] = roomEventId{room_id, event_id}; - connect(customHandler, &CustomHandler::activated, this, - [=](uint id) { this->actionInvoked(id, ""); }); - connect(customHandler, &CustomHandler::dismissed, this, - [=](uint id) { this->notificationClosed(id, 0); }); WinToast::instance()->showToast(templ, customHandler); }