Feature request: Add an option to open inventory folders in a new separate window

This commit is contained in:
Inusaito Sayori
2013-08-24 21:52:53 -04:00
parent c3b7c6999f
commit c9482ecac5
10 changed files with 168 additions and 0 deletions

View File

@@ -101,6 +101,7 @@ set(viewer_SOURCE_FILES
hippopanelgrids.cpp
importtracker.cpp
jcfloaterareasearch.cpp
lffloaterinvpanel.cpp
lfsimfeaturehandler.cpp
lggdicdownload.cpp
lgghunspell_wrapper.cpp
@@ -615,6 +616,7 @@ set(viewer_HEADER_FILES
hippopanelgrids.h
importtracker.h
jcfloaterareasearch.h
lffloaterinvpanel.h
lfsimfeaturehandler.h
lggdicdownload.h
lgghunspell_wrapper.h

View File

@@ -6828,6 +6828,22 @@ This should be as low as possible, but too low may break functionality</string>
<integer>0</integer>
</array>
</map>
<key>FloaterInvPanelRect</key>
<map>
<key>Comment</key>
<string>Rectangle for new inventory windows a folder is opened in</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Rect</string>
<key>Value</key>
<array>
<integer>0</integer>
<integer>400</integer>
<integer>300</integer>
<integer>0</integer>
</array>
</map>
<key>FloaterJoystickRect</key>
<map>
<key>Comment</key>

View File

@@ -0,0 +1,81 @@
/* @file lffloaterinvpanel.cpp
* @brief Simple floater displaying an inventory panel with any category as its root
*
* Copyright (C) 2013 Liru Færs
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA */
#include "llviewerprecompiledheaders.h"
#include "lffloaterinvpanel.h"
#include "llinventorypanel.h"
#include "lluictrlfactory.h"
LFFloaterInvPanel::LFFloaterInvPanel(const LLUUID& cat_id, LLInventoryModel* model, const std::string& name)
: LLInstanceTracker<LFFloaterInvPanel, LLUUID>(cat_id)
{
mCommitCallbackRegistrar.add("InvPanel.Search", boost::bind(&LFFloaterInvPanel::onSearch, this, _2));
LLUICtrlFactory::getInstance()->buildFloater(this, "floater_inv_panel.xml");
LLPanel* panel = getChild<LLPanel>("placeholder_panel");
mPanel = new LLInventoryPanel("inv_panel", LLInventoryPanel::DEFAULT_SORT_ORDER, cat_id.asString(), panel->getRect(), model, true);
mPanel->postBuild();
mPanel->setFollows(FOLLOWS_ALL);
mPanel->setEnabled(true);
addChild(mPanel);
removeChild(panel);
setTitle(name);
}
LFFloaterInvPanel::~LFFloaterInvPanel()
{
delete mPanel;
}
// static
void LFFloaterInvPanel::show(const LLUUID& cat_id, LLInventoryModel* model, const std::string& name)
{
LFFloaterInvPanel* floater = LFFloaterInvPanel::getInstance(cat_id);
if (!floater) floater = new LFFloaterInvPanel(cat_id, model, name);
floater->open();
}
// static
void LFFloaterInvPanel::closeAll()
{
for (instance_iter i = endInstances(); i >= beginInstances(); --i)
i->close();
}
// virtual
BOOL LFFloaterInvPanel::handleKeyHere(KEY key, MASK mask)
{
if (!mPanel->hasFocus() && mask == MASK_NONE && (key == KEY_RETURN || key == KEY_DOWN))
{
mPanel->setFocus(true);
if (LLFolderView* root = mPanel->getRootFolder())
root->scrollToShowSelection();
return true;
}
return LLFloater::handleKeyHere(key, mask);
}
void LFFloaterInvPanel::onSearch(const LLSD& val)
{
mPanel->setFilterSubString(val.asString());
}

View File

@@ -0,0 +1,44 @@
/* @file lffloaterinvpanel.h
* @brief Simple floater displaying an inventory panel with any category as its root
*
* Copyright (C) 2013 Liru Færs
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA */
#ifndef LFFLOATERINVPANEL_H
#define LFFLOATERINVPANEL_H
#include "llfloater.h"
#include "llinstancetracker.h"
class LFFloaterInvPanel : public LLFloater, public LLInstanceTracker<LFFloaterInvPanel, LLUUID>
{
LFFloaterInvPanel(const LLUUID& cat_id, class LLInventoryModel* model, const std::string& name);
~LFFloaterInvPanel();
public:
static void show(const LLUUID& cat_id, LLInventoryModel* model, const std::string& name); // Show the floater for cat_id (create with other params if necessary)
static void closeAll(); // Called when not allowed to have inventory open
/*virtual*/ BOOL handleKeyHere(KEY key, MASK mask);
void onSearch(const LLSD& val);
private:
class LLInventoryPanel* mPanel;
};
#endif //LFFLOATERINVPANEL_H

View File

@@ -34,6 +34,7 @@
#include "lluictrlfactory.h"
#include "lffloaterinvpanel.h"
#include "llagent.h"
#include "llagentcamera.h"
#include "llagentwearables.h"
@@ -2771,6 +2772,14 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action)
return;
}
else if ("open_in_new_window" == action)
{
LLInventoryModel* model = getInventoryModel();
LLViewerInventoryCategory* cat = getCategory();
if (!model || !cat) return;
LFFloaterInvPanel::show(mUUID, model, cat->getName());
return;
}
else if ("paste" == action)
{
pasteFromClipboard();
@@ -3371,6 +3380,8 @@ void LLFolderBridge::buildContextMenuFolderOptions(U32 flags)
if (!isAgentInventory()) return;
if (isOutboxFolder()) return;
mItems.push_back(std::string("Open Folder In New Window"));
LLFolderType::EType type = category->getPreferredType();
const bool is_system_folder = LLFolderType::lookupIsProtectedType(type);
// calling card related functionality for folders.

View File

@@ -174,6 +174,7 @@ void LLInventoryPanel::buildFolderView()
{
root_id = (preferred_type != LLFolderType::FT_NONE)
? gInventory.findCategoryUUIDForType(preferred_type, false, false)
: gInventory.getCategory(static_cast<LLUUID>(mStartFolder)) ? static_cast<LLUUID>(mStartFolder) // Singu Note: if start folder is an id of a folder, use it
: LLUUID::null;
}

View File

@@ -66,6 +66,7 @@ class LLInvPanelComplObserver;
class LLInventoryPanel : public LLPanel
{
protected:
friend class LFFloaterInvPanel;
LLInventoryPanel(const std::string& name,
const std::string& sort_order_setting,
const std::string& start_folder,

View File

@@ -29,6 +29,7 @@
#include "llvoavatar.h"
#include "roles_constants.h" // Group "powers"
#include "lffloaterinvpanel.h"
#include "llfloaterbeacons.h"
#include "llfloatertools.h"
#include "llfloaterenvsettings.h"
@@ -208,6 +209,7 @@ void RlvUIEnabler::onToggleShowInv(bool fQuitting)
if (!fEnable)
{
LLInventoryView::closeAll();
LFFloaterInvPanel::closeAll();
}
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<floater name="inventory panel floater" width="250" height="400" min_width="100" min_height="100" rect_control="FloaterInvPanelRect" can_close="true" can_minimize="true" can_resize="true">
<filter_editor bottom="-36" follows="left|right|top" height="18" left="4" mouse_opaque="true" right="-4" name="inventory search editor" label="Type here to search">
<filter_editor.commit_callback function="InvPanel.Search"/>
</filter_editor>
<panel name="placeholder_panel" follows="all" left="5" right="-5" bottom_delta="-360" height="358"/>
</floater>

View File

@@ -39,6 +39,9 @@
mouse_opaque="true" name="Empty Lost And Found" width="128">
<on_click filter="" function="Inventory.EmptyLostAndFound" userdata="rename" />
</menu_item_call>
<menu_item_call label="Open in New Window" name="Open Folder In New Window">
<on_click function="Inventory.DoToSelected" userdata="open_in_new_window"/>
</menu_item_call>
<menu_item_call bottom_delta="-18" height="18" label="New Folder" left="0" mouse_opaque="true"
name="New Folder" width="128">
<on_click filter="" function="Inventory.DoCreate" userdata="category" />