From 3fc6b82ac0fbac47e5923bbb1c317cb0393fa062 Mon Sep 17 00:00:00 2001 From: Tha_14 Date: Fri, 17 May 2024 17:12:14 -0700 Subject: [PATCH] I'm out of jokes --- .gitignore | 3 ++- src/message_n10n.cpp | 53 +++++++++++++++++++++++++++----------------- src/message_n10n.hpp | 6 ++--- 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index d2cb415..cfa7815 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,5 @@ CMakeCache.txt imgui.ini /out CMakePresets.json -CMakeUserPresets.json \ No newline at end of file +CMakeUserPresets.json +CMakeSettings.json \ No newline at end of file diff --git a/src/message_n10n.cpp b/src/message_n10n.cpp index c146b72..ab9db5d 100644 --- a/src/message_n10n.cpp +++ b/src/message_n10n.cpp @@ -2,6 +2,32 @@ #include +#include + +#include +#include + +class OurHandler : public WinToastLib::IWinToastHandler { + public: + virtual ~OurHandler(void) { + } + + protected: // wintoast + void toastActivated(void) const override { + std::cout << "action called\n"; + } + + void toastActivated(int actionIndex) const override { + std::cout << "action called\n"; + } + + void toastDismissed(WinToastDismissalReason state) const override { + } + + void toastFailed(void) const override { + } +}; + MessageN10n::MessageN10n(RegistryMessageModel& rmm) : _rmm(rmm) { // Register WinToast App User Model @@ -23,37 +49,24 @@ MessageN10n::~MessageN10n(void) { bool MessageN10n::onEvent(const Message::Events::MessageConstruct& e) { std::cout << "message constructed called\n"; - /* if (!e.e.all_of()) { return false; } - */ auto templ = WinToastLib::WinToastTemplate(WinToastLib::WinToastTemplate::Text02); templ.setTextField(L"title", WinToastLib::WinToastTemplate::FirstLine); - templ.setTextField(L"subtitle", WinToastLib::WinToastTemplate::SecondLine); + templ.setTextField( + std::wstring_convert>{}.from_bytes( + e.e.get().text + ), + WinToastLib::WinToastTemplate::SecondLine + ); WinToastLib::WinToast::WinToastError error; - const auto toast_id = WinToastLib::WinToast::instance()->showToast(templ, this, &error); + const auto toast_id = WinToastLib::WinToast::instance()->showToast(templ, new OurHandler, &error); if (toast_id < 0) { std::wcout << L"Error: Could not launch your toast notification! " << error << std::endl; } return false; } - -void MessageN10n::toastActivated(void) const { - // action - std::cout << "action called\n"; -} - -void MessageN10n::toastActivated(int actionIndex) const { - // action - std::cout << "action called\n"; -} - -void MessageN10n::toastDismissed(WinToastDismissalReason) const { -} - -void MessageN10n::toastFailed(void) const { -} \ No newline at end of file diff --git a/src/message_n10n.hpp b/src/message_n10n.hpp index 1ed7c7a..cf19b21 100644 --- a/src/message_n10n.hpp +++ b/src/message_n10n.hpp @@ -2,9 +2,7 @@ #include -#include - -class MessageN10n : public RegistryMessageModelEventI, public WinToastLib::IWinToastHandler { +class MessageN10n : public RegistryMessageModelEventI {//, public WinToastLib::IWinToastHandler { RegistryMessageModel& _rmm; public: @@ -14,9 +12,11 @@ class MessageN10n : public RegistryMessageModelEventI, public WinToastLib::IWinT protected: // rmm bool onEvent(const Message::Events::MessageConstruct& e) override; +/* protected: // wintoast void toastActivated(void) const override; void toastActivated(int actionIndex) const override; void toastDismissed(WinToastDismissalReason state) const override; void toastFailed(void) const override; + */ };