Skip to content

Commit 7f81d42

Browse files
committed
Fixing example.
1 parent 77c42f5 commit 7f81d42

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

example/qt-gui-example/WinToastExample/mainwindow.cpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,33 @@ void MainWindow::on_imagePathSelector_clicked()
3333

3434
}
3535

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+
3663
void MainWindow::on_showToast_clicked()
3764
{
3865
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText04);
@@ -41,7 +68,9 @@ void MainWindow::on_showToast_clicked()
4168
templ.setTextField(ui->secondLine->text().toStdWString(), WinToastTemplate::SecondLine);
4269
templ.setTextField(ui->secondLine->text().toStdWString(), WinToastTemplate::ThirdLine);
4370

44-
/* if (!WinToast::instance()->showToast(templ, new IWinToastHandler)) {
71+
72+
73+
if (!WinToast::instance()->showToast(templ, new CustomHandler())) {
4574
QMessageBox::warning(this, "Error", "Could not launch your toast notification!");
46-
}*/
75+
}
4776
}

0 commit comments

Comments
 (0)