From d5fe509c154913d76673d60ab153297a357466bb Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 15 Jan 2015 17:50:40 +0200 Subject: MAINT-4777 FIXED Confusing 'Save changes?' dialog when hitting the Delete button in notecard edit floater --- indra/newview/llpreviewnotecard.cpp | 62 ++++++++++++++-------- indra/newview/llpreviewnotecard.h | 1 + .../newview/skins/default/xui/en/notifications.xml | 12 +++++ 3 files changed, 53 insertions(+), 22 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp index 307fd55875..1308d1e9a7 100755 --- a/indra/newview/llpreviewnotecard.cpp +++ b/indra/newview/llpreviewnotecard.cpp @@ -500,28 +500,7 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem) void LLPreviewNotecard::deleteNotecard() { - if (mObjectUUID.isNull()) - { - LLViewerInventoryItem* item = gInventory.getItem(mItemUUID); - if (item != NULL) - { - const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH); - gInventory.changeItemParent(item, trash_id, FALSE); - } - } - else - { - LLViewerObject* object = gObjectList.findObject(mObjectUUID); - if(object) - { - LLViewerInventoryItem* item = dynamic_cast(object->getInventoryObject(mItemUUID)); - if (item != NULL) - { - object->removeInventory(mItemUUID); - } - } - } - closeFloater(); + LLNotificationsUtil::add("DeleteNotecard", LLSD(), LLSD(), boost::bind(&LLPreviewNotecard::handleConfirmDeleteDialog,this, _1, _2)); } // static @@ -627,4 +606,43 @@ bool LLPreviewNotecard::handleSaveChangesDialog(const LLSD& notification, const return false; } +bool LLPreviewNotecard::handleConfirmDeleteDialog(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (option != 0) + { + // canceled + return false; + } + + if (mObjectUUID.isNull()) + { + // move item from agent's inventory into trash + LLViewerInventoryItem* item = gInventory.getItem(mItemUUID); + if (item != NULL) + { + const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH); + gInventory.changeItemParent(item, trash_id, FALSE); + } + } + else + { + // delete item from inventory of in-world object + LLViewerObject* object = gObjectList.findObject(mObjectUUID); + if(object) + { + LLViewerInventoryItem* item = dynamic_cast(object->getInventoryObject(mItemUUID)); + if (item != NULL) + { + object->removeInventory(mItemUUID); + } + } + } + + // close floater, ignore unsaved changes + mForceClose = TRUE; + closeFloater(); + return false; +} + // EOF diff --git a/indra/newview/llpreviewnotecard.h b/indra/newview/llpreviewnotecard.h index b53c0da6be..1cf08dedd6 100755 --- a/indra/newview/llpreviewnotecard.h +++ b/indra/newview/llpreviewnotecard.h @@ -93,6 +93,7 @@ protected: S32 status, LLExtStat ext_status); bool handleSaveChangesDialog(const LLSD& notification, const LLSD& response); + bool handleConfirmDeleteDialog(const LLSD& notification, const LLSD& response); protected: LLViewerTextEditor* mEditor; diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index b4d8046d18..1f816dc806 100755 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -1195,6 +1195,18 @@ Save Changes? yestext="Save"/> + +Delete Notecard? + confirm + + +