Something working I guess?
This commit is contained in:
parent
b1ea3f88c2
commit
801693867a
3
.gitignore
vendored
3
.gitignore
vendored
@ -24,3 +24,6 @@ CMakeCache.txt
|
||||
|
||||
*.tox
|
||||
imgui.ini
|
||||
/out
|
||||
CMakePresets.json
|
||||
CMakeUserPresets.json
|
7
external/CMakeLists.txt
vendored
7
external/CMakeLists.txt
vendored
@ -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()
|
@ -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
|
||||
)
|
||||
|
||||
########################################
|
||||
|
@ -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 {
|
||||
}
|
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user