From 0bec080221e1002ef30b01215f7cdafd552c08f2 Mon Sep 17 00:00:00 2001 From: gwigz Date: Tue, 8 Oct 2024 18:48:54 +0100 Subject: Minimal favorite folder inventory feature Utilizes the recent-ish "open in new window" functionality from `LLPanelMainInventory::newFolderWindow` --- indra/newview/app_settings/commands.xml | 8 +++ .../newview/app_settings/settings_per_account.xml | 11 ++++ indra/newview/llinventorybridge.cpp | 2 + indra/newview/llinventorygallerymenu.cpp | 25 +++++++++ indra/newview/llinventorygallerymenu.h | 3 ++ indra/newview/llinventorypanel.cpp | 6 +++ indra/newview/llinventorypanel.h | 1 + indra/newview/llviewermenu.cpp | 57 +++++++++++++++++++++ indra/newview/skins/default/textures/textures.xml | 1 + .../textures/toolbar_icons/favorite_folder.png | Bin 0 -> 572 bytes .../default/xui/en/menu_gallery_inventory.xml | 10 ++++ .../skins/default/xui/en/menu_inventory.xml | 7 +++ indra/newview/skins/default/xui/en/menu_viewer.xml | 7 +++ .../newview/skins/default/xui/en/notifications.xml | 12 +++++ indra/newview/skins/default/xui/en/strings.xml | 2 + 15 files changed, 152 insertions(+) create mode 100644 indra/newview/skins/default/textures/toolbar_icons/favorite_folder.png (limited to 'indra') diff --git a/indra/newview/app_settings/commands.xml b/indra/newview/app_settings/commands.xml index b47ceff446..f2ab740646 100644 --- a/indra/newview/app_settings/commands.xml +++ b/indra/newview/app_settings/commands.xml @@ -295,4 +295,12 @@ is_running_function="Floater.IsOpen" is_running_parameters="performance" /> + diff --git a/indra/newview/app_settings/settings_per_account.xml b/indra/newview/app_settings/settings_per_account.xml index 6b788dd78f..80a4bec57f 100644 --- a/indra/newview/app_settings/settings_per_account.xml +++ b/indra/newview/app_settings/settings_per_account.xml @@ -458,5 +458,16 @@ Value 2 + FavoriteFolder + + Comment + Favorite inventory folder (UUID) + Persist + 1 + Type + String + Value + + diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index ca84c30b66..5ed79a6493 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -4413,6 +4413,8 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items { mWearables=true; } + + items.push_back(std::string("Set favorite folder")); } else { diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index dbf4821ca1..0c35a7f695 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -92,6 +92,7 @@ LLContextMenu* LLInventoryGalleryContextMenu::createMenu() registrar.add("Inventory.DoToSelected", boost::bind(&LLInventoryGalleryContextMenu::doToSelected, this, _2)); registrar.add("Inventory.FileUploadLocation", boost::bind(&LLInventoryGalleryContextMenu::fileUploadLocation, this, _2)); + registrar.add("Inventory.SetFavoriteFolder", boost::bind(&LLInventoryGalleryContextMenu::setFavoriteFolder, this)); registrar.add("Inventory.EmptyTrash", boost::bind(&LLInventoryModel::emptyFolderType, &gInventory, "ConfirmEmptyTrash", LLFolderType::FT_TRASH)); registrar.add("Inventory.EmptyLostAndFound", boost::bind(&LLInventoryModel::emptyFolderType, &gInventory, "ConfirmEmptyLostAndFound", LLFolderType::FT_LOST_AND_FOUND)); registrar.add("Inventory.DoCreate", [this](LLUICtrl*, const LLSD& data) @@ -110,6 +111,7 @@ LLContextMenu* LLInventoryGalleryContextMenu::createMenu() registrar.add("Inventory.Share", boost::bind(&LLAvatarActions::shareWithAvatars, uuids, gFloaterView->getParentFloater(mGallery))); enable_registrar.add("Inventory.CanSetUploadLocation", boost::bind(&LLInventoryGalleryContextMenu::canSetUploadLocation, this, _2)); + enable_registrar.add("Inventory.CanSetFavoriteFolder", boost::bind(&LLInventoryGalleryContextMenu::canSetFavoriteFolder, this)); enable_registrar.add("Inventory.EnvironmentEnabled", [](LLUICtrl*, const LLSD&) { @@ -504,6 +506,25 @@ bool LLInventoryGalleryContextMenu::canSetUploadLocation(const LLSD& userdata) return true; } +void LLInventoryGalleryContextMenu::setFavoriteFolder() +{ + gSavedPerAccountSettings.setString("FavoriteFolder", mUUIDs.front().asString()); +} + +bool LLInventoryGalleryContextMenu::canSetFavoriteFolder() +{ + if (mUUIDs.size() != 1) + { + return false; + } + LLInventoryCategory* cat = gInventory.getCategory(mUUIDs.front()); + if (!cat) + { + return false; + } + return true; +} + bool is_inbox_folder(LLUUID item_id) { const LLUUID inbox_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_INBOX); @@ -769,6 +790,8 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men items.push_back(std::string("upload_def")); } + items.push_back(std::string("Set favorite folder")); + if(is_outfits && !isRootFolder()) { items.push_back(std::string("New Outfit")); @@ -843,6 +866,8 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men { disabled_items.push_back(std::string("Copy")); } + + disabled_items.push_back(std::string("Set favorite folder")); } if((obj->getType() == LLAssetType::AT_SETTINGS) || ((obj->getType() <= LLAssetType::AT_GESTURE) diff --git a/indra/newview/llinventorygallerymenu.h b/indra/newview/llinventorygallerymenu.h index 7c3545432b..7f6598e171 100644 --- a/indra/newview/llinventorygallerymenu.h +++ b/indra/newview/llinventorygallerymenu.h @@ -49,6 +49,9 @@ protected: void fileUploadLocation(const LLSD& userdata); bool canSetUploadLocation(const LLSD& userdata); + void setFavoriteFolder(); + bool canSetFavoriteFolder(); + static void onRename(const LLSD& notification, const LLSD& response); private: diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 6d42145f6b..c7bd1d943a 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -185,6 +185,7 @@ LLInventoryPanel::LLInventoryPanel(const LLInventoryPanel::Params& p) : mCommitCallbackRegistrar.add("Inventory.BeginIMSession", boost::bind(&LLInventoryPanel::beginIMSession, this)); mCommitCallbackRegistrar.add("Inventory.Share", boost::bind(&LLAvatarActions::shareWithAvatars, this)); mCommitCallbackRegistrar.add("Inventory.FileUploadLocation", boost::bind(&LLInventoryPanel::fileUploadLocation, this, _2)); + mCommitCallbackRegistrar.add("Inventory.SetFavoriteFolder", boost::bind(&LLInventoryPanel::setFavoriteFolder, this)); mCommitCallbackRegistrar.add("Inventory.OpenNewFolderWindow", boost::bind(&LLInventoryPanel::openSingleViewInventory, this, LLUUID())); } @@ -1757,6 +1758,11 @@ void LLInventoryPanel::fileUploadLocation(const LLSD& userdata) } } +void LLInventoryPanel::setFavoriteFolder() +{ + gSavedPerAccountSettings.setString("FavoriteFolder", LLFolderBridge::sSelf.get()->getUUID().asString()); +} + void LLInventoryPanel::openSingleViewInventory(LLUUID folder_id) { LLPanelMainInventory::newFolderWindow(folder_id.isNull() ? LLFolderBridge::sSelf.get()->getUUID() : folder_id); diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h index 56909c8d98..ab17196e5f 100644 --- a/indra/newview/llinventorypanel.h +++ b/indra/newview/llinventorypanel.h @@ -225,6 +225,7 @@ public: void doCreate(const LLSD& userdata); bool beginIMSession(); void fileUploadLocation(const LLSD& userdata); + void setFavoriteFolder(); void openSingleViewInventory(LLUUID folder_id = LLUUID()); void purgeSelectedItems(); bool attachObject(const LLSD& userdata); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 58019d2e87..418c24a25e 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -39,6 +39,7 @@ #include "llfloaterreg.h" #include "llfloatersidepanelcontainer.h" #include "llinventorypanel.h" +#include "llsidepanelinventory.h" #include "llnotifications.h" #include "llnotificationsutil.h" #include "llviewereventrecorder.h" @@ -6913,6 +6914,59 @@ void handle_give_money_dialog() } } +LLFloaterSidePanelContainer* get_favorite_inventory_folder() +{ + LLUUID folder_id = LLUUID(gSavedPerAccountSettings.getString("FavoriteFolder")); + if (!folder_id.isNull()) + { + LLFloaterReg::const_instance_list_t& inst_list = LLFloaterReg::getFloaterList("inventory"); + for (LLFloaterReg::const_instance_list_t::const_iterator iter = inst_list.begin(); iter != inst_list.end();) + { + LLFloaterSidePanelContainer* inventory_container = dynamic_cast(*iter++); + if (inventory_container) + { + LLSidepanelInventory* sidepanel_inventory = dynamic_cast(inventory_container->findChild("main_panel", true)); + if (sidepanel_inventory) + { + LLPanelMainInventory* main_inventory = sidepanel_inventory->getMainInventoryPanel(); + if (main_inventory && main_inventory->isSingleFolderMode() + && (main_inventory->getCurrentSFVRoot() == folder_id)) + { + return inventory_container; + } + } + } + } + } + + return NULL; +} + +void toggle_favorite_inventory_folder() +{ + LLUUID folder_id = LLUUID(gSavedPerAccountSettings.getString("FavoriteFolder")); + if ((folder_id.isNull()) || (!gInventory.getCategory(folder_id))) + { + LLNotificationsUtil::add("MissingFavoriteFolder"); + return; + } + + LLFloaterSidePanelContainer* inventory_container = get_favorite_inventory_folder(); + if (inventory_container) + { + inventory_container->closeFloater(); + } + else + { + LLPanelMainInventory::newFolderWindow(folder_id); + } +} + +bool favorite_inventory_folder_visible() +{ + return (get_favorite_inventory_folder() != NULL); +} + bool enable_pay_avatar() { LLViewerObject* obj = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject(); @@ -10243,6 +10297,9 @@ void initialize_menus() commit.add("Inventory.NewWindow", boost::bind(&LLPanelMainInventory::newWindow)); + commit.add("Inventory.OpenFavoriteFolder", boost::bind(&toggle_favorite_inventory_folder)); + enable.add("Inventory.IsFavoriteFolderOpen", boost::bind(&favorite_inventory_folder_visible)); + enable.add("EnablePayObject", boost::bind(&enable_pay_object)); enable.add("EnablePayAvatar", boost::bind(&enable_pay_avatar)); enable.add("EnableEdit", boost::bind(&enable_object_edit)); diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index 11eafcb45d..4763396d50 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -162,6 +162,7 @@ with the same filename but different name + diff --git a/indra/newview/skins/default/textures/toolbar_icons/favorite_folder.png b/indra/newview/skins/default/textures/toolbar_icons/favorite_folder.png new file mode 100644 index 0000000000..811efffc0b Binary files /dev/null and b/indra/newview/skins/default/textures/toolbar_icons/favorite_folder.png differ diff --git a/indra/newview/skins/default/xui/en/menu_gallery_inventory.xml b/indra/newview/skins/default/xui/en/menu_gallery_inventory.xml index 16907d3577..99f84fe808 100644 --- a/indra/newview/skins/default/xui/en/menu_gallery_inventory.xml +++ b/indra/newview/skins/default/xui/en/menu_gallery_inventory.xml @@ -715,6 +715,16 @@ function="Inventory.CanSetUploadLocation" /> + + + + diff --git a/indra/newview/skins/default/xui/en/menu_inventory.xml b/indra/newview/skins/default/xui/en/menu_inventory.xml index d8aac71dd5..a72f610abb 100644 --- a/indra/newview/skins/default/xui/en/menu_inventory.xml +++ b/indra/newview/skins/default/xui/en/menu_inventory.xml @@ -996,6 +996,13 @@ parameter="pbr_material" /> + + + diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 911f61f346..5789b113c1 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -36,6 +36,13 @@ function="Inventory.NewWindow" parameter="" /> + + + + +Favorite folder is missing. + +Select the "use as favorite folder" from a folder's menu to set it as the favorite folder. + fail + + diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 232586636b..25779ca2c6 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -4212,6 +4212,7 @@ name="Command_360_Capture_Label">360 snapshot Speak Camera controls Voice settings + Favorite folder Capture a 360 equirectangular image @@ -4245,6 +4246,7 @@ name="Command_360_Capture_Tooltip">Capture a 360 equirectangular image Speak with people nearby using your microphone Changing camera angle Volume controls for calls and people near you in world + Open your favorite inventory folder currently in your bottom toolbar currently in your left toolbar -- cgit v1.2.3