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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <AzCore/std/containers/unordered_map.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzToolsFramework/UI/Notifications/ToastBus.h>
|
||||
#include <ScriptCanvas/Core/Graph.h>
|
||||
#include <ScriptCanvas/Bus/GraphBus.h>
|
||||
#include <ScriptCanvas/Bus/NodeIdPair.h>
|
||||
@@ -27,7 +28,6 @@
|
||||
#include <GraphCanvas/Components/Nodes/Wrapper/WrapperNodeBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/Slots/Data/DataSlotBus.h>
|
||||
#include <GraphCanvas/Components/ToastBus.h>
|
||||
#include <GraphCanvas/Types/GraphCanvasGraphSerialization.h>
|
||||
#include <GraphCanvas/Editor/GraphModelBus.h>
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace ScriptCanvasEditor
|
||||
, private GraphCanvas::GraphModelRequestBus::Handler
|
||||
, private GraphCanvas::SceneNotificationBus::Handler
|
||||
, private GraphItemCommandNotificationBus::Handler
|
||||
, private GraphCanvas::ToastNotificationBus::MultiHandler
|
||||
, private AzToolsFramework::ToastNotificationBus::MultiHandler
|
||||
, private GeneralEditorNotificationBus::Handler
|
||||
, private AZ::SystemTickBus::Handler
|
||||
{
|
||||
@@ -327,7 +327,7 @@ namespace ScriptCanvasEditor
|
||||
protected:
|
||||
void PostRestore(const UndoData& restoredData) override;
|
||||
|
||||
void UnregisterToast(const GraphCanvas::ToastId& toastId);
|
||||
void UnregisterToast(const AzToolsFramework::ToastId& toastId);
|
||||
|
||||
Graph(const Graph&) = delete;
|
||||
|
||||
@@ -350,7 +350,7 @@ namespace ScriptCanvasEditor
|
||||
void HandleQueuedUpdates();
|
||||
bool IsNodeVersionConverting(const AZ::EntityId& graphCanvasNodeId) const;
|
||||
|
||||
AZStd::unordered_map< GraphCanvas::ToastId, AZ::EntityId > m_toastNodeIds;
|
||||
AZStd::unordered_map< AzToolsFramework::ToastId, AZ::EntityId > m_toastNodeIds;
|
||||
|
||||
// Function Definition Node Extension
|
||||
void HandleFunctionDefinitionExtension(ScriptCanvas::Node* node, GraphCanvas::SlotId graphCanvasSlotId, const GraphCanvas::NodeId& nodeId);
|
||||
|
||||
+9
-11
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <QButtonGroup>
|
||||
|
||||
#include <AzQtComponents/Components/ToastNotification.h>
|
||||
#include <GraphCanvas/Components/Connections/ConnectionBus.h>
|
||||
#include <GraphCanvas/Components/GridBus.h>
|
||||
#include <GraphCanvas/Components/Nodes/NodeBus.h>
|
||||
@@ -1434,31 +1435,28 @@ namespace ScriptCanvasEditor
|
||||
GraphCanvas::ViewId viewId;
|
||||
GraphCanvas::SceneRequestBus::EventResult(viewId, m_graphCanvasId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
|
||||
GraphCanvas::ToastType toastType;
|
||||
AzQtComponents::ToastType toastType;
|
||||
AZStd::string titleLabel = "Validation Issue";
|
||||
AZStd::string description = "";
|
||||
|
||||
if (m_model->GetValidationResults().HasErrors())
|
||||
{
|
||||
toastType = GraphCanvas::ToastType::Error;
|
||||
toastType = AzQtComponents::ToastType::Error;
|
||||
description = AZStd::string::format("%i validation error(s) were found.", m_model->GetValidationResults().ErrorCount());
|
||||
}
|
||||
else
|
||||
{
|
||||
toastType = GraphCanvas::ToastType::Warning;
|
||||
toastType = AzQtComponents::ToastType::Warning;
|
||||
description = AZStd::string::format("%i validation warning(s) were found.", m_model->GetValidationResults().WarningCount());
|
||||
}
|
||||
|
||||
GraphCanvas::ToastConfiguration toastConfiguration(toastType, titleLabel, description);
|
||||
AzQtComponents::ToastConfiguration toastConfiguration(toastType, titleLabel.c_str(), description.c_str());
|
||||
|
||||
toastConfiguration.SetCloseOnClick(true);
|
||||
toastConfiguration.SetDuration(AZStd::chrono::milliseconds(5000));
|
||||
|
||||
GraphCanvas::ToastId validationToastId;
|
||||
AzToolsFramework::ToastId validationToastId;
|
||||
|
||||
GraphCanvas::ViewRequestBus::EventResult(validationToastId, viewId, &GraphCanvas::ViewRequests::ShowToastNotification, toastConfiguration);
|
||||
|
||||
GraphCanvas::ToastNotificationBus::MultiHandler::BusConnect(validationToastId);
|
||||
AzToolsFramework::ToastNotificationBus::MultiHandler::BusConnect(validationToastId);
|
||||
|
||||
}
|
||||
|
||||
@@ -1469,11 +1467,11 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void ValidationData::OnToastDismissed()
|
||||
{
|
||||
const GraphCanvas::ToastId* toastId = GraphCanvas::ToastNotificationBus::GetCurrentBusId();
|
||||
const AzToolsFramework::ToastId* toastId = AzToolsFramework::ToastNotificationBus::GetCurrentBusId();
|
||||
|
||||
if (toastId)
|
||||
{
|
||||
GraphCanvas::ToastNotificationBus::MultiHandler::BusDisconnect((*toastId));
|
||||
AzToolsFramework::ToastNotificationBus::MultiHandler::BusDisconnect((*toastId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -15,10 +15,10 @@
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
|
||||
#include <AzQtComponents/Components/StyledDockWidget.h>
|
||||
#include <AzToolsFramework/UI/Notifications/ToastBus.h>
|
||||
|
||||
#include <GraphCanvas/Editor/AssetEditorBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
#include <GraphCanvas/Components/ToastBus.h>
|
||||
|
||||
#include <ScriptCanvas/Debugger/ValidationEvents/ValidationEvent.h>
|
||||
#include <ScriptCanvas/Debugger/StatusBus.h>
|
||||
@@ -183,7 +183,7 @@ namespace ScriptCanvasEditor
|
||||
//! Owns the model for each currently opened graph
|
||||
class ValidationData
|
||||
: private ScriptCanvas::StatusRequestBus::Handler
|
||||
, private GraphCanvas::ToastNotificationBus::MultiHandler
|
||||
, private AzToolsFramework::ToastNotificationBus::MultiHandler
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(ValidationData, AZ::SystemAllocator, 0);
|
||||
@@ -227,7 +227,7 @@ namespace ScriptCanvasEditor
|
||||
: public AzQtComponents::StyledDockWidget
|
||||
, public GraphCanvas::AssetEditorNotificationBus::Handler
|
||||
, public GraphCanvas::SceneNotificationBus::Handler
|
||||
, public GraphCanvas::ToastNotificationBus::Handler
|
||||
, public AzToolsFramework::ToastNotificationBus::Handler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h>
|
||||
|
||||
#include <AzQtComponents/Components/WindowDecorationWrapper.h>
|
||||
#include <AzQtComponents/Components/ToastNotification.h>
|
||||
|
||||
#include <GraphCanvas/Components/Connections/ConnectionBus.h>
|
||||
#include <GraphCanvas/Components/SceneBus.h>
|
||||
@@ -124,7 +125,7 @@ namespace ScriptCanvasEditor
|
||||
public:
|
||||
OnSaveToast(AZStd::string_view tabName, AZ::EntityId graphCanvasGraphId, bool saveSuccessful)
|
||||
{
|
||||
GraphCanvas::ToastType toastType = GraphCanvas::ToastType::Information;
|
||||
AzQtComponents::ToastType toastType = AzQtComponents::ToastType::Information;
|
||||
AZStd::string titleLabel = "Notification";
|
||||
|
||||
AZStd::string description;
|
||||
@@ -136,15 +137,12 @@ namespace ScriptCanvasEditor
|
||||
else
|
||||
{
|
||||
description = AZStd::string::format("Failed to save %s", tabName.data());
|
||||
toastType = GraphCanvas::ToastType::Error;
|
||||
toastType = AzQtComponents::ToastType::Error;
|
||||
}
|
||||
|
||||
GraphCanvas::ToastConfiguration toastConfiguration(toastType, titleLabel, description);
|
||||
AzQtComponents::ToastConfiguration toastConfiguration(toastType, titleLabel.c_str(), description.c_str());
|
||||
|
||||
toastConfiguration.SetCloseOnClick(true);
|
||||
toastConfiguration.SetDuration(AZStd::chrono::milliseconds(5000));
|
||||
|
||||
GraphCanvas::ToastId validationToastId;
|
||||
AzToolsFramework::ToastId validationToastId;
|
||||
|
||||
GraphCanvas::ViewId viewId;
|
||||
GraphCanvas::SceneRequestBus::EventResult(viewId, graphCanvasGraphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
|
||||
Reference in New Issue
Block a user