@@ -33,6 +33,33 @@ void MainWindow::on_imagePathSelector_clicked()
33
33
34
34
}
35
35
36
+ class CustomHandler : public IWinToastHandler {
37
+ public:
38
+ void toastActivated () const {
39
+ std::wcout << L" The user clicked in this toast" << std::endl;
40
+ }
41
+
42
+ void toastFailed () const {
43
+ std::wcout << L" Error showing current toast" << std::endl;
44
+ }
45
+ void toastDismissed (WinToastDismissalReason state) const {
46
+ switch (state) {
47
+ case UserCanceled:
48
+ std::wcout << L" The user dismissed this toast" << std::endl;
49
+ break ;
50
+ case ApplicationHidden:
51
+ std::wcout << L" The application hid the toast using ToastNotifier.hide()" << std::endl;
52
+ break ;
53
+ case TimedOut:
54
+ std::wcout << L" The toast has timed out" << std::endl;
55
+ break ;
56
+ default :
57
+ std::wcout << L" Toast not activated" << std::endl;
58
+ break ;
59
+ }
60
+ }
61
+ };
62
+
36
63
void MainWindow::on_showToast_clicked ()
37
64
{
38
65
WinToastTemplate templ = WinToastTemplate (WinToastTemplate::ImageAndText04);
@@ -41,7 +68,9 @@ void MainWindow::on_showToast_clicked()
41
68
templ.setTextField (ui->secondLine ->text ().toStdWString (), WinToastTemplate::SecondLine);
42
69
templ.setTextField (ui->secondLine ->text ().toStdWString (), WinToastTemplate::ThirdLine);
43
70
44
- /* if (!WinToast::instance()->showToast(templ, new IWinToastHandler)) {
71
+
72
+
73
+ if (!WinToast::instance ()->showToast (templ, new CustomHandler ())) {
45
74
QMessageBox::warning (this , " Error" , " Could not launch your toast notification!" );
46
- }*/
75
+ }
47
76
}
0 commit comments