From 969b359a92b4a0dfc86bb6dd100769d102dbf806 Mon Sep 17 00:00:00 2001 From: Black Hat Date: Sat, 20 Oct 2018 11:07:50 +0800 Subject: [PATCH] Fix Windows build. --- src/notifications/managerwin.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/notifications/managerwin.cpp b/src/notifications/managerwin.cpp index 27f019d..87b8bd2 100644 --- a/src/notifications/managerwin.cpp +++ b/src/notifications/managerwin.cpp @@ -4,17 +4,20 @@ using namespace WinToastLib; class CustomHandler : public QObject, public IWinToastHandler { + Q_OBJECT public: void toastActivated() { emit activated(notificationID); } void toastActivated(int) { emit activated(notificationID); } void toastFailed() { std::wcout << L"Error showing current toast" << std::endl; } - void toastDismissed(WinToastDismissalReason) { emit dismissed(notificationID); } + void toastDismissed(WinToastDismissalReason) { + emit dismissed(notificationID); + } uint notificationID; -signals: + signals: void activated(uint id); void dismissed(uint id); }; @@ -58,27 +61,25 @@ void NotificationsManager::postNotification( // TODO: implement room or user avatar // templ.setImagePath(L"C:/example.png"); - CustomHandler* customHandler = new CustomHandler(); + CustomHandler *customHandler = new CustomHandler(); 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); - }); + 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); } void NotificationsManager::actionInvoked(uint id, QString action) { - if (notificationIds.contains(id)) { - roomEventId idEntry = notificationIds[id]; - emit notificationClicked(idEntry.roomId, idEntry.eventId); - } + if (notificationIds.contains(id)) { + roomEventId idEntry = notificationIds[id]; + emit notificationClicked(idEntry.roomId, idEntry.eventId); + } } void NotificationsManager::notificationClosed(uint id, uint reason) { - notificationIds.remove(id); + notificationIds.remove(id); }