From 2a3fe4c6281f6fb7f221cd514bce58184f8a6a14 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Wed, 24 May 2023 17:47:45 +0200 Subject: [PATCH] Gui: Notifications Framework - accept more notifier types ========================================================= Extends notifier types to Gui::Document, App::Document, Gui::ViewProviderDocumentObject. This allows to pass these objects as notifiers, and the framework gets the right string from the Label or FullLabel as appropriate. --- src/Gui/Notifications.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/Gui/Notifications.h b/src/Gui/Notifications.h index b5fed13ead..a46452b4c1 100644 --- a/src/Gui/Notifications.h +++ b/src/Gui/Notifications.h @@ -166,6 +166,21 @@ inline void Gui::Notify(TNotifier && notifier, TCaption && caption, TMessage && Base::IntendedRecipient::Developer, Base::ContentType::Untranslated>(notifier->getFullLabel(), msg.c_str()); } + else if constexpr( std::is_base_of_v::type>> ) { + Base::Console().Send(notifier->getObject()->getFullLabel(), msg.c_str()); + } + else if constexpr( std::is_base_of_v::type>> ) { + Base::Console().Send(notifier->getDocument()->Label.getStrValue(), msg.c_str()); + } + else if constexpr( std::is_base_of_v::type>> ) { + Base::Console().Send(notifier->Label.getStrValue(), msg.c_str()); + } else { Base::Console().Send::type>> ) { Base::Console().Send(notifier->getFullLabel(), msg.toUtf8()); } + else if constexpr( std::is_base_of_v::type>> ) { + Base::Console().Send(notifier->getObject()->getFullLabel(), msg.toUtf8()); + } + else if constexpr( std::is_base_of_v::type>> ) { + Base::Console().Send(notifier->getDocument()->Label.getStrValue(), msg.toUtf8()); + } + else if constexpr( std::is_base_of_v::type>> ) { + Base::Console().Send(notifier->Label.getStrValue(), msg.toUtf8()); + } else { Base::Console().Send(notifier, msg.toUtf8()); } @@ -230,6 +254,15 @@ inline void Gui::Notify(TNotifier && notifier, TCaption && caption, TMessage && if constexpr( std::is_base_of_v::type>> ) { Base::Console().Send(notifier->getFullLabel(), msg.c_str()); } + else if constexpr( std::is_base_of_v::type>> ) { + Base::Console().Send(notifier->getObject()->getFullLabel(), msg.c_str()); + } + else if constexpr( std::is_base_of_v::type>> ) { + Base::Console().Send(notifier->getDocument()->Label.getStrValue(), msg.c_str()); + } + else if constexpr( std::is_base_of_v::type>> ) { + Base::Console().Send(notifier->Label.getStrValue(), msg.c_str()); + } else { Base::Console().Send(notifier, msg.c_str()); }