Change structure.
This commit is contained in:
parent
16e7f5003c
commit
6339fd78a2
|
@ -39,7 +39,7 @@ class NotificationsManager : public QObject {
|
||||||
|
|
||||||
// these slots are platform specific (D-Bus only)
|
// these slots are platform specific (D-Bus only)
|
||||||
// but Qt slot declarations can not be inside an ifdef!
|
// but Qt slot declarations can not be inside an ifdef!
|
||||||
private slots:
|
public slots:
|
||||||
void actionInvoked(uint id, QString action);
|
void actionInvoked(uint id, QString action);
|
||||||
void notificationClosed(uint id, uint reason);
|
void notificationClosed(uint id, uint reason);
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,23 +3,26 @@
|
||||||
|
|
||||||
using namespace WinToastLib;
|
using namespace WinToastLib;
|
||||||
|
|
||||||
class CustomHandler : public QObject, public IWinToastHandler {
|
class CustomHandler : public IWinToastHandler {
|
||||||
Q_OBJECT
|
|
||||||
public:
|
public:
|
||||||
void toastActivated() { emit activated(notificationID); }
|
CustomHandler(NotificationsManager* parent) : notificationsManager(parent) {}
|
||||||
void toastActivated(int) { emit activated(notificationID); }
|
void toastActivated() {
|
||||||
|
notificationsManager->actionInvoked(notificationID, "");
|
||||||
|
}
|
||||||
|
void toastActivated(int) {
|
||||||
|
notificationsManager->actionInvoked(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) {
|
void toastDismissed(WinToastDismissalReason) {
|
||||||
emit dismissed(notificationID);
|
notificationsManager->notificationClosed(notificationID, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint notificationID;
|
uint notificationID;
|
||||||
|
|
||||||
signals:
|
private:
|
||||||
void activated(uint id);
|
NotificationsManager* notificationsManager;
|
||||||
void dismissed(uint id);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -61,14 +64,10 @@ 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(this);
|
||||||
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) { this->actionInvoked(id, ""); });
|
|
||||||
connect(customHandler, &CustomHandler::dismissed, this,
|
|
||||||
[=](uint id) { this->notificationClosed(id, 0); });
|
|
||||||
|
|
||||||
WinToast::instance()->showToast(templ, customHandler);
|
WinToast::instance()->showToast(templ, customHandler);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue