Fix Windows build.
This commit is contained in:
parent
932f21e9bb
commit
969b359a92
|
@ -4,17 +4,20 @@
|
||||||
using namespace WinToastLib;
|
using namespace WinToastLib;
|
||||||
|
|
||||||
class CustomHandler : public QObject, public IWinToastHandler {
|
class CustomHandler : public QObject, public IWinToastHandler {
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
void toastActivated() { emit activated(notificationID); }
|
void toastActivated() { emit activated(notificationID); }
|
||||||
void toastActivated(int) { emit activated(notificationID); }
|
void toastActivated(int) { emit activated(notificationID); }
|
||||||
void toastFailed() {
|
void toastFailed() {
|
||||||
std::wcout << L"Error showing current toast" << std::endl;
|
std::wcout << L"Error showing current toast" << std::endl;
|
||||||
}
|
}
|
||||||
void toastDismissed(WinToastDismissalReason) { emit dismissed(notificationID); }
|
void toastDismissed(WinToastDismissalReason) {
|
||||||
|
emit dismissed(notificationID);
|
||||||
|
}
|
||||||
|
|
||||||
uint notificationID;
|
uint notificationID;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void activated(uint id);
|
void activated(uint id);
|
||||||
void dismissed(uint id);
|
void dismissed(uint id);
|
||||||
};
|
};
|
||||||
|
@ -58,27 +61,25 @@ void NotificationsManager::postNotification(
|
||||||
// TODO: implement room or user avatar
|
// TODO: implement room or user avatar
|
||||||
// templ.setImagePath(L"C:/example.png");
|
// templ.setImagePath(L"C:/example.png");
|
||||||
|
|
||||||
CustomHandler* customHandler = new CustomHandler();
|
CustomHandler *customHandler = new CustomHandler();
|
||||||
count++;
|
count++;
|
||||||
customHandler->notificationID = count;
|
customHandler->notificationID = count;
|
||||||
notificationIds[count] = roomEventId{room_id, event_id};
|
notificationIds[count] = roomEventId{room_id, event_id};
|
||||||
connect(customHandler, &CustomHandler::activated, this, [=](uint id) {
|
connect(customHandler, &CustomHandler::activated, this,
|
||||||
this->actionInvoked(id, "");
|
[=](uint id) { this->actionInvoked(id, ""); });
|
||||||
});
|
connect(customHandler, &CustomHandler::dismissed, this,
|
||||||
connect(customHandler, &CustomHandler::dismissed, this, [=](uint id) {
|
[=](uint id) { this->notificationClosed(id, 0); });
|
||||||
this->notificationClosed(id, 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
WinToast::instance()->showToast(templ, customHandler);
|
WinToast::instance()->showToast(templ, customHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationsManager::actionInvoked(uint id, QString action) {
|
void NotificationsManager::actionInvoked(uint id, QString action) {
|
||||||
if (notificationIds.contains(id)) {
|
if (notificationIds.contains(id)) {
|
||||||
roomEventId idEntry = notificationIds[id];
|
roomEventId idEntry = notificationIds[id];
|
||||||
emit notificationClicked(idEntry.roomId, idEntry.eventId);
|
emit notificationClicked(idEntry.roomId, idEntry.eventId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationsManager::notificationClosed(uint id, uint reason) {
|
void NotificationsManager::notificationClosed(uint id, uint reason) {
|
||||||
notificationIds.remove(id);
|
notificationIds.remove(id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue