Move Qt Toast Notifications from GraphCanvas into Framework
Move the existing Qt Toast Notification QWidgets, EBuses and logic from the GraphCanvas gem into AzQtComponents and AzToolsFramework so they can be re-used. Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com>
This commit is contained in:
@@ -19,6 +19,7 @@ AZ_POP_DISABLE_WARNING
|
||||
#include <AzCore/Serialization/IdUtils.h>
|
||||
#include <AzCore/Asset/AssetManagerBus.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
#include <AzQtComponents/Components/ToastNotification.h>
|
||||
#include <GraphCanvas/GraphCanvasBus.h>
|
||||
#include <GraphCanvas/Components/GridBus.h>
|
||||
#include <GraphCanvas/Components/Nodes/NodeBus.h>
|
||||
@@ -3310,7 +3311,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void Graph::OnToastInteraction()
|
||||
{
|
||||
const GraphCanvas::ToastId* toastId = GraphCanvas::ToastNotificationBus::GetCurrentBusId();
|
||||
const AzToolsFramework::ToastId* toastId = AzToolsFramework::ToastNotificationBus::GetCurrentBusId();
|
||||
|
||||
if (toastId)
|
||||
{
|
||||
@@ -3335,7 +3336,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void Graph::OnToastDismissed()
|
||||
{
|
||||
const GraphCanvas::ToastId* toastId = GraphCanvas::ToastNotificationBus::GetCurrentBusId();
|
||||
const AzToolsFramework::ToastId* toastId = AzToolsFramework::ToastNotificationBus::GetCurrentBusId();
|
||||
|
||||
if (toastId)
|
||||
{
|
||||
@@ -3358,25 +3359,21 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void Graph::ReportError(const ScriptCanvas::Node& node, const AZStd::string& errorSource, const AZStd::string& errorMessage)
|
||||
{
|
||||
GraphCanvas::ToastConfiguration toastConfiguration(GraphCanvas::ToastType::Error, errorSource, errorMessage);
|
||||
|
||||
toastConfiguration.SetCloseOnClick(true);
|
||||
toastConfiguration.SetDuration(AZStd::chrono::milliseconds(5000));
|
||||
AzQtComponents::ToastConfiguration toastConfiguration(AzQtComponents::ToastType::Error, errorSource.c_str(), errorMessage.c_str());
|
||||
|
||||
GraphCanvas::ViewId viewId;
|
||||
GraphCanvas::SceneRequestBus::EventResult(viewId, GetGraphCanvasGraphId(), &GraphCanvas::SceneRequests::GetViewId);
|
||||
|
||||
GraphCanvas::ToastId toastId;
|
||||
|
||||
AzToolsFramework::ToastId toastId;
|
||||
GraphCanvas::ViewRequestBus::EventResult(toastId, viewId, &GraphCanvas::ViewRequests::ShowToastNotification, toastConfiguration);
|
||||
|
||||
GraphCanvas::ToastNotificationBus::MultiHandler::BusConnect(toastId);
|
||||
AzToolsFramework::ToastNotificationBus::MultiHandler::BusConnect(toastId);
|
||||
m_toastNodeIds[toastId] = node.GetEntityId();
|
||||
}
|
||||
|
||||
void Graph::UnregisterToast(const GraphCanvas::ToastId& toastId)
|
||||
void Graph::UnregisterToast(const AzToolsFramework::ToastId& toastId)
|
||||
{
|
||||
GraphCanvas::ToastNotificationBus::MultiHandler::BusDisconnect(toastId);
|
||||
AzToolsFramework::ToastNotificationBus::MultiHandler::BusDisconnect(toastId);
|
||||
m_toastNodeIds.erase(toastId);
|
||||
}
|
||||
|
||||
@@ -3408,10 +3405,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
m_updateStrings.clear();
|
||||
|
||||
GraphCanvas::ToastConfiguration toastConfiguration(GraphCanvas::ToastType::Information, "Nodes Updates", displayString);
|
||||
toastConfiguration.SetCloseOnClick(true);
|
||||
toastConfiguration.SetDuration(AZStd::chrono::milliseconds(5000));
|
||||
|
||||
AzQtComponents::ToastConfiguration toastConfiguration(AzQtComponents::ToastType::Information, "Nodes Updates", displayString.c_str());
|
||||
GraphCanvas::ViewRequestBus::Event(viewId, &GraphCanvas::ViewRequests::ShowToastNotification, toastConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user