Something working I guess?

This commit is contained in:
Tha_14 2024-05-17 15:33:31 -07:00
parent b1ea3f88c2
commit 801693867a
5 changed files with 57 additions and 2 deletions

3
.gitignore vendored
View File

@ -24,3 +24,6 @@ CMakeCache.txt
*.tox
imgui.ini
/out
CMakePresets.json
CMakeUserPresets.json

View File

@ -20,3 +20,10 @@ if (NOT TARGET solanaceae_plugin)
FetchContent_MakeAvailable(solanaceae_plugin)
endif()
if (NOT TARGET WinToast)
FetchContent_Declare(WinToast_ext
GIT_REPOSITORY https://github.com/mohabouje/WinToast.git
GIT_TAG master
)
FetchContent_MakeAvailable(WinToast_ext)
endif()

View File

@ -11,6 +11,7 @@ target_include_directories(solanaceae_message_n10n PUBLIC .)
target_compile_features(solanaceae_message_n10n PUBLIC cxx_std_17)
target_link_libraries(solanaceae_message_n10n PUBLIC
solanaceae_message3
WinToast
)
########################################

View File

@ -2,17 +2,54 @@
#include <solanaceae/message3/components.hpp>
MessageN10n::MessageN10n(RegistryMessageModel& rmm) : _rmm(rmm) {
// Register WinToast App User Model
WinToastLib::WinToast::instance()->setAppName(L"Tomato");
const auto aumi = WinToastLib::WinToast::configureAUMI(L"green", L"solanaceae", L"solanaceae_message_n10n", L"20240517");
WinToastLib::WinToast::instance()->setAppUserModelId(aumi);
// Initialize WinToast
if (!WinToastLib::WinToast::instance()->initialize()) {
std::wcout << L"Error, could not initialize the lib!" << std::endl;
} else {
_rmm.subscribe(this, RegistryMessageModel_Event::message_construct);
}
}
MessageN10n::~MessageN10n(void) {
}
bool MessageN10n::onEvent(const Message::Events::MessageConstruct& e) {
/*
if (!e.e.all_of<Message::Components::MessageText>()) {
return false;
}
*/
auto templ = WinToastLib::WinToastTemplate(WinToastLib::WinToastTemplate::Text02);
templ.setTextField(L"title", WinToastLib::WinToastTemplate::FirstLine);
templ.setTextField(L"subtitle", WinToastLib::WinToastTemplate::SecondLine);
WinToastLib::WinToast::WinToastError error;
const auto toast_id = WinToastLib::WinToast::instance()->showToast(templ, this, &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
}
void MessageN10n::toastActivated(int actionIndex) const {
// action
}
void MessageN10n::toastDismissed(WinToastDismissalReason) const {
}
void MessageN10n::toastFailed(void) const {
}

View File

@ -2,7 +2,9 @@
#include <solanaceae/message3/registry_message_model.hpp>
class MessageN10n : public RegistryMessageModelEventI {
#include <wintoastlib.h>
class MessageN10n : public RegistryMessageModelEventI, public WinToastLib::IWinToastHandler {
RegistryMessageModel& _rmm;
public:
@ -11,5 +13,10 @@ class MessageN10n : public RegistryMessageModelEventI {
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;
};