From ace506cc8aec370b739b40ab2afa7c1fef4cc030 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 18 Jul 2024 07:38:36 +0300 Subject: viewer#1997 Warn user if closing appearance with unsaved changes --- indra/newview/llfloatersidepanelcontainer.cpp | 41 ++++++++++++++++++++++ indra/newview/llfloatersidepanelcontainer.h | 9 +++-- .../newview/skins/default/xui/en/notifications.xml | 14 ++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/indra/newview/llfloatersidepanelcontainer.cpp b/indra/newview/llfloatersidepanelcontainer.cpp index 48547852c4..6c5d2570f2 100644 --- a/indra/newview/llfloatersidepanelcontainer.cpp +++ b/indra/newview/llfloatersidepanelcontainer.cpp @@ -28,6 +28,7 @@ #include "llfloaterreg.h" #include "llfloatersidepanelcontainer.h" +#include "llnotificationsutil.h" #include "llpaneleditwearable.h" // newview includes @@ -90,6 +91,46 @@ void LLFloaterSidePanelContainer::closeFloater(bool app_quitting) } } +void LLFloaterSidePanelContainer::onClickCloseBtn(bool app_quitting) +{ + if (!app_quitting) + { + LLPanelOutfitEdit* panel_outfit_edit = + dynamic_cast(LLFloaterSidePanelContainer::findPanel("appearance", "panel_outfit_edit")); + if (panel_outfit_edit) + { + LLFloater* parent = gFloaterView->getParentFloater(panel_outfit_edit); + if (parent == this) + { + LLSidepanelAppearance* panel_appearance = dynamic_cast(getPanel("appearance")); + if (panel_appearance) + { + LLPanelEditWearable* edit_wearable_ptr = panel_appearance->getWearable(); + if (edit_wearable_ptr && edit_wearable_ptr->getVisible() && edit_wearable_ptr->isDirty()) + { + LLNotificationsUtil::add("UsavedWearableChanges", LLSD(), LLSD(), [this](const LLSD& notification, const LLSD& response) + { + onCloseMsgCallback(notification, response); + }); + return; + } + } + } + } + } + + closeFloater(); +} + +void LLFloaterSidePanelContainer::onCloseMsgCallback(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (0 == option) + { + closeFloater(); + } +} + LLFloater* LLFloaterSidePanelContainer::getTopmostInventoryFloater() { LLFloater* topmost_floater = NULL; diff --git a/indra/newview/llfloatersidepanelcontainer.h b/indra/newview/llfloatersidepanelcontainer.h index 19d6c747cb..d7f6c309c4 100644 --- a/indra/newview/llfloatersidepanelcontainer.h +++ b/indra/newview/llfloatersidepanelcontainer.h @@ -49,9 +49,11 @@ public: LLFloaterSidePanelContainer(const LLSD& key, const Params& params = getDefaultParams()); ~LLFloaterSidePanelContainer(); - /*virtual*/ void onOpen(const LLSD& key); + void onOpen(const LLSD& key) override; - /*virtual*/ void closeFloater(bool app_quitting = false); + void closeFloater(bool app_quitting = false) override; + + void onClickCloseBtn(bool app_qutting) override; void cleanup() { destroy(); } @@ -84,6 +86,9 @@ public: } return panel; } + +protected: + void onCloseMsgCallback(const LLSD& notification, const LLSD& response); }; #endif // LL_LLFLOATERSIDEPANELCONTAINER_H diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 3ba4f2f3e4..2c19a89fb2 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -4261,6 +4261,20 @@ Unable to add estate manager [AGENT] to banned list. Can't change appearance until clothing and shape are loaded. + +You have unsaved changes. + group + confirm + + +