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:
Alex Peterson
2021-10-20 11:15:24 -07:00
committed by GitHub
parent 67532ed18f
commit 7ddcdffed7
25 changed files with 514 additions and 381 deletions
@@ -13,6 +13,8 @@
#include <AzCore/Serialization/EditContext.h>
#include <AzQtComponents/Components/ToastNotification.h>
#include <Components/Connections/ConnectionComponent.h>
#include <Components/Connections/ConnectionLayerControllerComponent.h>
@@ -1117,10 +1119,8 @@ namespace GraphCanvas
QPointF globalConnectionPoint = ConversionUtils::AZToQPoint(globalConnectionVector);
QPointF anchorPoint(0.0f, 0.0f);
ToastConfiguration toastConfiguration(ToastType::Error, "Unable to connect to slot", m_validationResult.m_failureReason);
toastConfiguration.SetCloseOnClick(false);
AzQtComponents::ToastConfiguration toastConfiguration(AzQtComponents::ToastType::Error, "Unable to connect to slot", m_validationResult.m_failureReason.c_str());
toastConfiguration.m_closeOnClick = false;
m_toastId = viewHandler->ShowToastAtPoint(globalConnectionPoint.toPoint(), anchorPoint, toastConfiguration);
}
@@ -19,6 +19,7 @@ AZ_POP_DISABLE_WARNING
#include <AzCore/Component/EntityBus.h>
#include <AzCore/std/string/string.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/UI/Notifications/ToastBus.h>
#include <GraphCanvas/Components/Connections/ConnectionBus.h>
#include <GraphCanvas/Components/GeometryBus.h>
@@ -210,7 +211,7 @@ namespace GraphCanvas
ConnectionValidationTooltip m_validationResult;
Endpoint m_endpointTooltip;
ToastId m_toastId;
AzToolsFramework::ToastId m_toastId;
//! The Id of the graph this connection belongs to.
GraphId m_graphId;
@@ -12,6 +12,8 @@
#include <qsizepolicy.h>
#include <QGraphicsSceneDragDropEvent>
#include <AzQtComponents/Components/ToastNotification.h>
#include <Components/Slots/Data/DataSlotLayoutComponent.h>
#include <Components/Slots/Data/DataSlotConnectionPin.h>
@@ -157,8 +159,8 @@ namespace GraphCanvas
anchorPoint = QPointF(1.0f, 0.5f);
}
ToastConfiguration toastConfiguration(ToastType::Error, "Unable to drop onto to slot", error);
toastConfiguration.SetCloseOnClick(false);
AzQtComponents::ToastConfiguration toastConfiguration(AzQtComponents::ToastType::Error, "Unable to drop onto to slot", error.c_str());
toastConfiguration.m_closeOnClick = false;
m_toastId = viewHandler->ShowToastAtPoint(globalConnectionPoint.toPoint(), anchorPoint, toastConfiguration);
}
@@ -10,6 +10,7 @@
#include <QGraphicsLinearLayout>
#include <QTimer>
#include <AzToolsFramework/UI/Notifications/ToastBus.h>
#include <Components/Slots/SlotLayoutComponent.h>
#include <GraphCanvas/Components/SceneBus.h>
#include <GraphCanvas/Components/Slots/SlotBus.h>
@@ -58,7 +59,7 @@ namespace GraphCanvas
SlotId m_slotId;
ViewId m_viewId;
ToastId m_toastId;
AzToolsFramework::ToastId m_toastId;
};
class DoubleClickSceneEventFilter
@@ -1,29 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzCore/EBus/EBus.h>
#include <GraphCanvas/Editor/EditorTypes.h>
namespace GraphCanvas
{
class ToastNotifications
: public AZ::EBusTraits
{
public:
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
using BusIdType = ToastId;
virtual void OnToastInteraction() {}
virtual void OnToastDismissed() {}
};
using ToastNotificationBus = AZ::EBus<ToastNotifications>;
}
@@ -12,6 +12,7 @@
#include <AzCore/EBus/EBus.h>
#include <AzCore/Component/EntityId.h>
#include <AzCore/Math/Vector2.h>
#include <AzToolsFramework/UI/Notifications/ToastBus.h>
#include <GraphCanvas/Editor/EditorTypes.h>
@@ -139,11 +140,11 @@ namespace GraphCanvas
virtual void RefreshView() = 0;
//! Toast Notifications
virtual void HideToastNotification(const ToastId& toastId) = 0;
virtual void HideToastNotification(const AzToolsFramework::ToastId& toastId) = 0;
virtual ToastId ShowToastNotification(const ToastConfiguration& toastConfiguration) = 0;
virtual ToastId ShowToastAtCursor(const ToastConfiguration& toastConfiguration) = 0;
virtual ToastId ShowToastAtPoint(const QPoint& screenPosition, const QPointF& anchorPoint, const ToastConfiguration&) = 0;
virtual AzToolsFramework::ToastId ShowToastNotification(const AzQtComponents::ToastConfiguration& toastConfiguration) = 0;
virtual AzToolsFramework::ToastId ShowToastAtCursor(const AzQtComponents::ToastConfiguration& toastConfiguration) = 0;
virtual AzToolsFramework::ToastId ShowToastAtPoint(const QPoint& screenPosition, const QPointF& anchorPoint, const AzQtComponents::ToastConfiguration&) = 0;
virtual bool IsShowing() const = 0;
};
@@ -29,8 +29,6 @@ namespace GraphCanvas
typedef AZ::EntityId GraphicsEffectId;
typedef AZ::EntityId ToastId;
typedef AZ::Uuid PersistentGraphMemberId;
typedef AZ::Crc32 ExtenderId;
@@ -81,14 +79,6 @@ namespace GraphCanvas
Target
};
enum class ToastType
{
Information,
Warning,
Error,
Custom
};
enum class ListingType
{
Unknown,
@@ -116,88 +106,6 @@ namespace GraphCanvas
private:
};
class ToastConfiguration
{
public:
ToastConfiguration(ToastType toastType, const AZStd::string& titleLabel, const AZStd::string& descriptionLabel)
: m_toastType(toastType)
, m_titleLabel(titleLabel)
, m_descriptionLabel(descriptionLabel)
{
}
~ToastConfiguration() = default;
ToastType GetToastType() const
{
return m_toastType;
}
const AZStd::string& GetTitleLabel() const
{
return m_titleLabel;
}
const AZStd::string& GetDescriptionLabel() const
{
return m_descriptionLabel;
}
void SetCustomToastImage(const AZStd::string& toastImage)
{
AZ_Error("GraphCanvas", m_toastType == ToastType::Custom, "Setting a custom image on a non-custom Toast notification");
m_customToastImage = toastImage;
}
const AZStd::string& GetCustomToastImage() const
{
return m_customToastImage;
}
void SetDuration(AZStd::chrono::milliseconds duration)
{
m_duration = duration;
}
AZStd::chrono::milliseconds GetDuration() const
{
return m_duration;
}
void SetCloseOnClick(bool closeOnClick)
{
m_closeOnClick = closeOnClick;
}
bool GetCloseOnClick() const
{
return m_closeOnClick;
}
void SetFadeDuration(AZStd::chrono::milliseconds fadeDuration)
{
m_fadeDuration = fadeDuration;
}
AZStd::chrono::milliseconds GetFadeDuration() const
{
return m_fadeDuration;
}
private:
AZStd::chrono::milliseconds m_fadeDuration = AZStd::chrono::milliseconds(250);
AZStd::chrono::milliseconds m_duration;
bool m_closeOnClick;
AZStd::string m_customToastImage;
ToastType m_toastType;
AZStd::string m_titleLabel;
AZStd::string m_descriptionLabel;
};
struct ConnectionValidationTooltip
{
bool operator()() const
@@ -12,6 +12,7 @@
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzCore/Component/Entity.h>
#include <AzToolsFramework/UI/Notifications/ToastBus.h>
#include <GraphCanvas/Widgets/GraphCanvasGraphicsView/GraphCanvasGraphicsView.h>
@@ -46,6 +47,7 @@ namespace GraphCanvas
, m_queuedFocus(nullptr)
{
m_viewId = AZ::Entity::MakeId();
m_notificationsView = AZStd::make_unique<AzToolsFramework::ToastNotificationsView>(this, AZ_CRC(m_viewId.ToString()));
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@@ -603,8 +605,8 @@ namespace GraphCanvas
const int maxSize = 17500;
if (windowSize.width() > maxSize || windowSize.height() > maxSize)
{
ToastConfiguration toastConfiguration(ToastType::Information, "Screenshot", "Screenshot attempted to capture an area too large. Some down-ressing may occur.");
ShowToastNotification(toastConfiguration);
AzQtComponents::ToastConfiguration toastConfiguration(AzQtComponents::ToastType::Information, "Screenshot", "Screenshot attempted to capture an area too large. Some down-ressing may occur.");
m_notificationsView->ShowToastNotification(toastConfiguration);
if (windowSize.width() > maxSize)
{
@@ -825,64 +827,24 @@ namespace GraphCanvas
invalidateScene(GetViewableAreaInSceneCoordinates());
}
void GraphCanvasGraphicsView::HideToastNotification(const ToastId& toastId)
void GraphCanvasGraphicsView::HideToastNotification(const AzToolsFramework::ToastId& toastId)
{
auto notificationIter = m_notifications.find(toastId);
if (notificationIter != m_notifications.end())
{
auto queuedIter = AZStd::find(m_queuedNotifications.begin(), m_queuedNotifications.end(), toastId);
if (queuedIter != m_queuedNotifications.end())
{
m_queuedNotifications.erase(queuedIter);
}
notificationIter->second->reject();
}
m_notificationsView->HideToastNotification(toastId);
}
ToastId GraphCanvasGraphicsView::ShowToastNotification(const ToastConfiguration& toastConfiguration)
AzToolsFramework::ToastId GraphCanvasGraphicsView::ShowToastNotification(const AzQtComponents::ToastConfiguration& toastConfiguration)
{
ToastNotification* notification = aznew ToastNotification(this, toastConfiguration);
ToastId toastId = notification->GetToastId();
m_notifications[toastId] = notification;
m_queuedNotifications.emplace_back(toastId);
if (!m_activeNotification.IsValid())
{
DisplayQueuedNotification();
}
return toastId;
return m_notificationsView->ShowToastNotification(toastConfiguration);
}
ToastId GraphCanvasGraphicsView::ShowToastAtCursor(const ToastConfiguration& toastConfiguration)
AzToolsFramework::ToastId GraphCanvasGraphicsView::ShowToastAtCursor(const AzQtComponents::ToastConfiguration& toastConfiguration)
{
ToastNotification* notification = aznew ToastNotification(this, toastConfiguration);
notification->ShowToastAtCursor();
ToastId toastId = notification->GetToastId();
m_notifications[toastId] = notification;
return toastId;
return m_notificationsView->ShowToastAtCursor(toastConfiguration);
}
ToastId GraphCanvasGraphicsView::ShowToastAtPoint(const QPoint& screenPosition, const QPointF& anchorPoint, const ToastConfiguration& toastConfiguration)
AzToolsFramework::ToastId GraphCanvasGraphicsView::ShowToastAtPoint(const QPoint& screenPosition, const QPointF& anchorPoint, const AzQtComponents::ToastConfiguration& toastConfiguration)
{
ToastNotification* notification = aznew ToastNotification(this, toastConfiguration);
notification->ShowToastAtPoint(screenPosition, anchorPoint);
ToastId toastId = notification->GetToastId();
m_notifications[toastId] = notification;
return toastId;
return m_notificationsView->ShowToastAtPoint(screenPosition, anchorPoint, toastConfiguration);
}
bool GraphCanvasGraphicsView::IsShowing() const
@@ -1245,14 +1207,14 @@ namespace GraphCanvas
CalculateInternalRectangle();
UpdateToastPosition();
m_notificationsView->UpdateToastPosition();
}
void GraphCanvasGraphicsView::moveEvent(QMoveEvent* event)
{
QGraphicsView::moveEvent(event);
UpdateToastPosition();
m_notificationsView->UpdateToastPosition();
}
void GraphCanvasGraphicsView::scrollContentsBy(int dx, int dy)
@@ -1266,25 +1228,14 @@ namespace GraphCanvas
{
QGraphicsView::showEvent(showEvent);
if (m_activeNotification.IsValid())
{
DisplayQueuedNotification();
}
m_notificationsView->OnShow();
}
void GraphCanvasGraphicsView::hideEvent(QHideEvent* hideEvent)
{
QGraphicsView::hideEvent(hideEvent);
if (m_activeNotification.IsValid())
{
auto notificationIter = m_notifications.find(m_activeNotification);
if (notificationIter != m_notifications.end())
{
notificationIter->second->hide();
}
}
m_notificationsView->OnHide();
}
void GraphCanvasGraphicsView::OnSettingsChanged()
@@ -1378,25 +1329,6 @@ namespace GraphCanvas
BookmarkManagerRequestBus::Event(sceneId, &BookmarkManagerRequests::ActivateShortcut, bookmarkShortcut);
}
void GraphCanvasGraphicsView::UpdateToastPosition()
{
if (m_activeNotification.IsValid())
{
auto notificationIter = m_notifications.find(m_activeNotification);
if (notificationIter != m_notifications.end())
{
// Want this to be roughly in the top right corner of the graphics view.
QPoint globalPoint = mapToGlobal(QPoint(width() - 10, 10));
// Anchor point will be top right
QPointF anchorPoint = QPointF(1, 0);
notificationIter->second->UpdatePosition(globalPoint, anchorPoint);
}
}
}
void GraphCanvasGraphicsView::CenterOnSceneMembers(const AZStd::vector<AZ::EntityId>& memberIds)
{
QRectF boundingRect;
@@ -1642,48 +1574,4 @@ namespace GraphCanvas
AZ::TickBus::Handler::BusDisconnect();
}
}
void GraphCanvasGraphicsView::OnNotificationHidden()
{
m_activeNotification.SetInvalid();
if (!m_queuedNotifications.empty())
{
DisplayQueuedNotification();
}
}
void GraphCanvasGraphicsView::DisplayQueuedNotification()
{
if (m_queuedNotifications.empty() && isVisible())
{
return;
}
ToastId toastId = m_queuedNotifications.front();
m_queuedNotifications.erase(m_queuedNotifications.begin());
auto notificationIter = m_notifications.find(toastId);
if (notificationIter != m_notifications.end())
{
m_activeNotification = toastId;
// Want this to be roughly in the top right corner of the graphics view.
QPoint globalPoint = mapToGlobal(QPoint(width() - 10, 10));
// Anchor point will be top right
QPointF anchorPoint = QPointF(1, 0);
notificationIter->second->ShowToastAtPoint(globalPoint, anchorPoint);
QObject::connect(notificationIter->second, &ToastNotification::ToastNotificationHidden, this, &GraphCanvasGraphicsView::OnNotificationHidden);
}
// If we didn't actually show something, recurse to avoid things getting stuck in the queue.
if (!m_activeNotification.IsValid())
{
DisplayQueuedNotification();
}
}
}
@@ -27,11 +27,11 @@ AZ_POP_DISABLE_WARNING
#include <AzCore/Memory/SystemAllocator.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/UI/Notifications/ToastNotificationsView.h>
#include <GraphCanvas/Components/SceneBus.h>
#include <GraphCanvas/Components/ViewBus.h>
#include <GraphCanvas/Editor/AssetEditorBus.h>
#include <GraphCanvas/Widgets/ToastNotification/ToastNotification.h>
namespace GraphCanvas
{
@@ -123,11 +123,11 @@ namespace GraphCanvas
void RefreshView() override;
void HideToastNotification(const ToastId& toastId) override;
void HideToastNotification(const AzToolsFramework::ToastId& toastId) override;
ToastId ShowToastNotification(const ToastConfiguration& toastConfiguration) override;
ToastId ShowToastAtCursor(const ToastConfiguration& toastConfiguration) override;
ToastId ShowToastAtPoint(const QPoint& screenPosition, const QPointF& anchorPoint, const ToastConfiguration& toastConfiguration) override;
AzToolsFramework::ToastId ShowToastNotification(const AzQtComponents::ToastConfiguration& toastConfiguration) override;
AzToolsFramework::ToastId ShowToastAtCursor(const AzQtComponents::ToastConfiguration& toastConfiguration) override;
AzToolsFramework::ToastId ShowToastAtPoint(const QPoint& screenPosition, const QPointF& anchorPoint, const AzQtComponents::ToastConfiguration& toastConfiguration) override;
bool IsShowing() const override;
////
@@ -186,8 +186,6 @@ namespace GraphCanvas
private:
void UpdateToastPosition();
void CenterOnSceneMembers(const AZStd::vector<AZ::EntityId>& memberIds);
void ConnectBoundsSignals();
@@ -206,9 +204,6 @@ namespace GraphCanvas
void ManageTickState();
void OnNotificationHidden();
void DisplayQueuedNotification();
GraphCanvasGraphicsView(const GraphCanvasGraphicsView&) = delete;
ViewId m_viewId;
@@ -242,13 +237,7 @@ namespace GraphCanvas
AZStd::unique_ptr<FocusQueue> m_queuedFocus;
// These will display sequentially in a reserved part of the UI
ToastId m_activeNotification;
AZStd::vector< ToastId > m_queuedNotifications;
// There could be more then the queued list in terms of general notifications
// As some systems might want to re-use the systems for their own needs.
AZStd::unordered_map< ToastId, ToastNotification* > m_notifications;
AZStd::unique_ptr<AzToolsFramework::ToastNotificationsView> m_notificationsView;
bool m_isEditing;
@@ -1,209 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <QCursor>
#include <AzCore/Component/Entity.h>
#include <GraphCanvas/Widgets/ToastNotification/ToastNotification.h>
#include <StaticLib/GraphCanvas/Widgets/ToastNotification/ui_ToastNotification.h>
#include <GraphCanvas/Components/ToastBus.h>
namespace GraphCanvas
{
//////////////////////
// ToastNotification
//////////////////////
ToastNotification::ToastNotification(QWidget* parent, const ToastConfiguration& toastConfiguration)
: QDialog(parent, Qt::FramelessWindowHint)
, m_toastId(AZ::Entity::MakeId())
, m_closeOnClick(true)
, m_ui(new Ui::ToastNotification())
, m_fadeAnimation(nullptr)
{
setProperty("HasNoWindowDecorations", true);
setAttribute(Qt::WA_ShowWithoutActivating);
setAttribute(Qt::WA_DeleteOnClose);
m_ui->setupUi(this);
QIcon toastIcon;
switch (toastConfiguration.GetToastType())
{
case ToastType::Error:
toastIcon = QIcon(":/GraphCanvasEditorResources/toast_error_icon.png");
break;
case ToastType::Warning:
toastIcon = QIcon(":/GraphCanvasEditorResources/toast_warning_icon.png");
break;
case ToastType::Information:
toastIcon = QIcon(":/GraphCanvasEditorResources/toast_information_icon.png");
break;
case ToastType::Custom:
toastIcon = QIcon(toastConfiguration.GetCustomToastImage().c_str());
default:
break;
}
m_ui->iconLabel->setPixmap(toastIcon.pixmap(64, 64));
m_ui->titleLabel->setText(toastConfiguration.GetTitleLabel().c_str());
m_ui->mainLabel->setText(toastConfiguration.GetDescriptionLabel().c_str());
m_lifeSpan.setInterval(aznumeric_cast<int>(toastConfiguration.GetDuration().count()));
m_closeOnClick = toastConfiguration.GetCloseOnClick();
m_ui->closeButton->setVisible(m_closeOnClick);
QObject::connect(m_ui->closeButton, &QToolButton::clicked, this, &ToastNotification::accept);
m_fadeDuration = toastConfiguration.GetFadeDuration();
QObject::connect(&m_lifeSpan, &QTimer::timeout, this, &ToastNotification::FadeOut);
}
ToastNotification::~ToastNotification()
{
}
ToastId ToastNotification::GetToastId() const
{
return m_toastId;
}
void ToastNotification::ShowToastAtCursor()
{
QPoint globalCursorPos = QCursor::pos();
// Left/middle align it relative to the cursor.
QPointF anchorPoint(0, 0.5);
// Magic offset to try to get it to not hide under the cursor.
// No way to get this programatically from what I can tell.
globalCursorPos.setX(globalCursorPos.x() + 16);
ShowToastAtPoint(globalCursorPos, anchorPoint);
}
void ToastNotification::ShowToastAtPoint(const QPoint& screenPosition, const QPointF& anchorPoint)
{
show();
updateGeometry();
UpdatePosition(screenPosition, anchorPoint);
}
void ToastNotification::UpdatePosition(const QPoint& screenPosition, const QPointF& anchorPoint)
{
QRect dialogGeometry = geometry();
QPoint finalPosition;
finalPosition.setX(aznumeric_cast<int>(screenPosition.x() - dialogGeometry.width() * anchorPoint.x()));
finalPosition.setY(aznumeric_cast<int>(screenPosition.y() - dialogGeometry.height() * anchorPoint.y()));
move(finalPosition);
}
void ToastNotification::showEvent(QShowEvent* showEvent)
{
QDialog::showEvent(showEvent);
if (m_fadeDuration.count() > 0)
{
m_fadeAnimation = new QPropertyAnimation(this, "windowOpacity", this);
m_fadeAnimation->setKeyValueAt(0, 0);
m_fadeAnimation->setKeyValueAt(1, 1);
m_fadeAnimation->setDuration(static_cast<int>(m_fadeDuration.count()));
m_fadeAnimation->start();
QObject::connect(m_fadeAnimation, &QPropertyAnimation::finished, this, &ToastNotification::StartTimer);
}
else
{
StartTimer();
}
emit ToastNotificationShown();
}
void ToastNotification::hideEvent(QHideEvent* hideEvent)
{
QDialog::hideEvent(hideEvent);
m_lifeSpan.stop();
if (m_fadeAnimation)
{
m_fadeAnimation->stop();
delete m_fadeAnimation;
}
ToastNotificationBus::Event(GetToastId(), &ToastNotifications::OnToastDismissed);
emit ToastNotificationHidden();
}
void ToastNotification::mousePressEvent(QMouseEvent*)
{
if (m_closeOnClick)
{
ToastNotificationBus::Event(GetToastId(), &ToastNotifications::OnToastInteraction);
accept();
}
}
bool ToastNotification::eventFilter(QObject*, QEvent* event)
{
if (event->type() == QEvent::MouseButtonPress)
{
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
if (mouseEvent && mouseEvent->button() == Qt::MouseButton::LeftButton)
{
accept();
}
}
return false;
}
void ToastNotification::StartTimer()
{
delete m_fadeAnimation;
m_fadeAnimation = nullptr;
if (m_lifeSpan.interval() != 0)
{
m_lifeSpan.start();
}
}
void ToastNotification::FadeOut()
{
if (m_fadeDuration.count() > 0)
{
m_fadeAnimation = new QPropertyAnimation(this, "windowOpacity", this);
m_fadeAnimation->setKeyValueAt(0, windowOpacity());
m_fadeAnimation->setKeyValueAt(1, 0);
m_fadeAnimation->setDuration(static_cast<int>(m_fadeDuration.count()));
m_fadeAnimation->start();
QObject::connect(m_fadeAnimation, &QPropertyAnimation::finished, this, &ToastNotification::accept);
}
else
{
accept();
}
}
#include <StaticLib/GraphCanvas/Widgets/ToastNotification/moc_ToastNotification.cpp>
}
@@ -1,82 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include <QEvent>
#include <QDialog>
#include <QMouseEvent>
#include <QPropertyAnimation>
#include <QTimer>
#include <AzCore/Component/TickBus.h>
#include <AzCore/std/chrono/chrono.h>
#include <AzCore/std/smart_ptr/unique_ptr.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <GraphCanvas/Editor/EditorTypes.h>
#endif
namespace Ui
{
class ToastNotification;
}
namespace GraphCanvas
{
class ToastNotification
: public QDialog
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(ToastNotification, AZ::SystemAllocator, 0);
ToastNotification(QWidget* parent, const ToastConfiguration& configuration);
virtual ~ToastNotification();
ToastId GetToastId() const;
// Shows the toast notification relative to the current cursor.
void ShowToastAtCursor();
// Aligns the toast notification so that the specified anchor point on the notification lies on the specified screen position.
// i.e. anchor point of 0,0 will align the top left position of the dialog with the screen position
// anchor point of 1,1 will align the bottom right position of the dialog with the screen position
void ShowToastAtPoint(const QPoint& screenPosition, const QPointF& anchorPoint);
void UpdatePosition(const QPoint& screenPosition, const QPointF& anchorPoint);
// QDialog
void showEvent(QShowEvent* showEvent) override;
void hideEvent(QHideEvent* hideEvent) override;
void mousePressEvent(QMouseEvent* mouseEvent) override;
bool eventFilter(QObject* object, QEvent* event) override;
////
public slots:
void StartTimer();
void FadeOut();
signals:
void ToastNotificationShown();
void ToastNotificationHidden();
private:
QPropertyAnimation* m_fadeAnimation;
AZStd::chrono::milliseconds m_fadeDuration;
ToastId m_toastId;
bool m_closeOnClick;
QTimer m_lifeSpan;
AZStd::unique_ptr<Ui::ToastNotification> m_ui;
};
}
@@ -1,237 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ToastNotification</class>
<widget class="QDialog" name="ToastNotification">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>225</width>
<height>48</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>225</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="icon_frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgba(255, 255, 255, 20);</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="iconLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgba(255, 255, 255, 0);</string>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../Resources/GraphCanvasEditorResources.qrc">:/GraphCanvasEditorResources/toast_information_icon.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="text_frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QFrame" name="titleFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>5</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Invalid Connection</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="closeButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../Resources/GraphCanvasEditorResources.qrc">
<normaloff>:/GraphCanvasEditorResources/lineedit_clear.png</normaloff>:/GraphCanvasEditorResources/lineedit_clear.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="mainLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Types are not a match.</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../Resources/GraphCanvasEditorResources.qrc"/>
<include location="../Resources/GraphCanvasEditorResources.qrc"/>
</resources>
<connections/>
</ui>
@@ -30,7 +30,6 @@ set(FILES
StaticLib/GraphCanvas/Components/PersistentIdBus.h
StaticLib/GraphCanvas/Components/SceneBus.h
StaticLib/GraphCanvas/Components/StyleBus.h
StaticLib/GraphCanvas/Components/ToastBus.h
StaticLib/GraphCanvas/Components/ViewBus.h
StaticLib/GraphCanvas/Components/VisualBus.h
StaticLib/GraphCanvas/GraphicsItems/AnimatedPulse.cpp
@@ -222,9 +221,6 @@ set(FILES
StaticLib/GraphCanvas/Widgets/StyledItemDelegates/GenericComboBoxDelegate.h
StaticLib/GraphCanvas/Widgets/StyledItemDelegates/IconDecoratedNameDelegate.cpp
StaticLib/GraphCanvas/Widgets/StyledItemDelegates/IconDecoratedNameDelegate.h
StaticLib/GraphCanvas/Widgets/ToastNotification/ToastNotification.cpp
StaticLib/GraphCanvas/Widgets/ToastNotification/ToastNotification.h
StaticLib/GraphCanvas/Widgets/ToastNotification/ToastNotification.ui
StaticLib/GraphCanvas/Utils/ColorUtils.h
StaticLib/GraphCanvas/Utils/ConversionUtils.h
StaticLib/GraphCanvas/Utils/GraphUtils.cpp