Skip to content

Commit

Permalink
Triage Issue #49 Better inspection of media urls
Browse files Browse the repository at this point in the history
Part 1: Ability to copy urls from nearby media for inspection
  • Loading branch information
akleshchev committed Feb 9, 2024
1 parent 67876e6 commit c8ee05a
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 41 deletions.
12 changes: 6 additions & 6 deletions indra/newview/llconversationloglist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ BOOL LLConversationLogList::handleRightMouseDown(S32 x, S32 y, MASK mask)
BOOL handled = LLUICtrl::handleRightMouseDown(x, y, mask);

LLToggleableMenu* context_menu = mContextMenu.get();
{
context_menu->buildDrawLabels();
if (context_menu && size())
context_menu->updateParent(LLMenuGL::sMenuContainer);
LLMenuGL::showPopup(this, context_menu, x, y);
}
if (context_menu && size())
{
context_menu->buildDrawLabels();
context_menu->updateParent(LLMenuGL::sMenuContainer);
LLMenuGL::showPopup(this, context_menu, x, y);
}

return handled;
}
Expand Down
84 changes: 76 additions & 8 deletions indra/newview/llpanelnearbymedia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "llaudioengine.h"
#include "llcheckboxctrl.h"
#include "llclipboard.h"
#include "llcombobox.h"
#include "llresizebar.h"
#include "llresizehandle.h"
Expand All @@ -53,7 +54,9 @@
#include "llvovolume.h"
#include "llstatusbar.h"
#include "llsdutil.h"
#include "lltoggleablemenu.h"
#include "llvieweraudio.h"
#include "llviewermenu.h"

#include "llfloaterreg.h"
#include "llfloaterpreference.h" // for the gear icon
Expand All @@ -77,7 +80,8 @@ LLPanelNearByMedia::LLPanelNearByMedia()
mAllMediaDisabled(false),
mDebugInfoVisible(false),
mParcelMediaItem(NULL),
mParcelAudioItem(NULL)
mParcelAudioItem(NULL),
mMoreLessBtn(NULL)
{
// This is just an initial value, mParcelAudioAutoStart does not affect ParcelMediaAutoPlayEnable
mParcelAudioAutoStart = gSavedSettings.getS32("ParcelMediaAutoPlayEnable") != 0
Expand All @@ -96,7 +100,14 @@ LLPanelNearByMedia::LLPanelNearByMedia()
mCommitCallbackRegistrar.add("SelectedMediaCtrl.Volume", boost::bind(&LLPanelNearByMedia::onCommitSelectedMediaVolume, this));
mCommitCallbackRegistrar.add("SelectedMediaCtrl.Zoom", boost::bind(&LLPanelNearByMedia::onClickSelectedMediaZoom, this));
mCommitCallbackRegistrar.add("SelectedMediaCtrl.Unzoom", boost::bind(&LLPanelNearByMedia::onClickSelectedMediaUnzoom, this));


// Context menu handler.
mCommitCallbackRegistrar.add("SelectedMediaCtrl.Action",
[this](LLUICtrl* ctrl, const LLSD& data)
{
onMenuAction(data);
});

buildFromFile( "panel_nearby_media.xml");
}

Expand Down Expand Up @@ -147,7 +158,8 @@ BOOL LLPanelNearByMedia::postBuild()
mUnzoomCtrl = getChild<LLUICtrl>("unzoom");
mVolumeSlider = getChild<LLSlider>("volume_slider");
mMuteBtn = getChild<LLButton>("mute_btn");

mMoreLessBtn = getChild<LLButton>("more_btn");

mEmptyNameString = getString("empty_item_text");
mParcelMediaName = getString("parcel_media_name");
mParcelAudioName = getString("parcel_audio_name");
Expand All @@ -166,8 +178,13 @@ BOOL LLPanelNearByMedia::postBuild()
mLessRect = getRect();
mLessRect.mBottom = minimized_controls->getRect().mBottom;

getChild<LLUICtrl>("more_btn")->setVisible(false);
mMoreLessBtn->setVisible(false);
onMoreLess();

mContextMenu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>(
"menu_nearby_media.xml",
gMenuHolder,
LLViewerMenuHolderGL::child_registry_t::instance());

return TRUE;
}
Expand All @@ -193,8 +210,7 @@ void LLPanelNearByMedia::reshape(S32 width, S32 height, BOOL called_from_parent)
{
LLPanelPulldown::reshape(width, height, called_from_parent);

LLButton* more_btn = findChild<LLButton>("more_btn");
if (more_btn && more_btn->getValue().asBoolean())
if (mMoreLessBtn && mMoreLessBtn->getValue().asBoolean())
{
mMoreRect = getRect();
}
Expand Down Expand Up @@ -234,6 +250,26 @@ BOOL LLPanelNearByMedia::handleHover(S32 x, S32 y, MASK mask)
return true;
}

BOOL LLPanelNearByMedia::handleRightMouseDown(S32 x, S32 y, MASK mask)
{
S32 x_list, y_list;
localPointToOtherView(x, y, &x_list, &y_list, mMediaList);
if (mMoreLessBtn->getToggleState()
&& mMediaList->pointInView(x_list, y_list)
&& mMediaList->selectItemAt(x_list, y_list, mask))
{
if (mContextMenu)
{
mContextMenu->buildDrawLabels();
mContextMenu->updateParent(LLMenuGL::sMenuContainer);
LLMenuGL::showPopup(this, mContextMenu, x, y);
return TRUE;
}
}

return LLPanelPulldown::handleRightMouseDown(x, y, mask);
}

bool LLPanelNearByMedia::getParcelAudioAutoStart()
{
return mParcelAudioAutoStart;
Expand Down Expand Up @@ -923,7 +959,7 @@ void LLPanelNearByMedia::onAdvancedButtonClick()

void LLPanelNearByMedia::onMoreLess()
{
bool is_more = getChild<LLButton>("more_btn")->getToggleState();
bool is_more = mMoreLessBtn->getToggleState();
mNearbyMediaPanel->setVisible(is_more);

// enable resizing when expanded
Expand All @@ -934,7 +970,7 @@ void LLPanelNearByMedia::onMoreLess()

setShape(new_rect);

getChild<LLUICtrl>("more_btn")->setVisible(true);
mMoreLessBtn->setVisible(true);
}

void LLPanelNearByMedia::updateControls()
Expand Down Expand Up @@ -1174,6 +1210,38 @@ void LLPanelNearByMedia::onClickSelectedMediaUnzoom()
LLViewerMediaFocus::getInstance()->unZoom();
}

void LLPanelNearByMedia::onMenuAction(const LLSD& userdata)
{
const std::string command_name = userdata.asString();
if ("copy" == command_name)
{
LLClipboard::instance().reset();
LLUUID selected_media_id = mMediaList->getValue().asUUID();
std::string url;

if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID)
{
url = LLViewerMedia::getInstance()->getParcelAudioURL();
}
else if (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID)
{
url = LLViewerParcelMedia::getInstance()->getURL();
}
else
{
LLViewerMediaImpl* impl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(selected_media_id);
if (NULL != impl)
{
url = impl->getCurrentMediaURL();
}
}

if (!url.empty())
{
LLClipboard::instance().copyToClipboard(utf8str_to_wstring(url), 0, url.size());
}
}
}

// static
void LLPanelNearByMedia::getNameAndUrlHelper(LLViewerMediaImpl* impl, std::string& name, std::string & url, const std::string &defaultName)
Expand Down
16 changes: 9 additions & 7 deletions indra/newview/llpanelnearbymedia.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,19 @@ class LLSlider;
class LLSliderCtrl;
class LLCheckBoxCtrl;
class LLTextBox;
class LLToggleableMenu;
class LLComboBox;
class LLViewerMediaImpl;

class LLPanelNearByMedia : public LLPanelPulldown
{
public:

/*virtual*/ BOOL postBuild();
/*virtual*/ void draw();
/*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent);
/*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
BOOL postBuild() override;
void draw() override;
void reshape(S32 width, S32 height, BOOL called_from_parent) override;
BOOL handleHover(S32 x, S32 y, MASK mask) override;
BOOL handleRightMouseDown(S32 x, S32 y, MASK mask) override;

// this is part of the nearby media *dialog* so we can track whether
// the user *implicitly* wants audio on or off via their *explicit*
Expand Down Expand Up @@ -104,15 +106,12 @@ class LLPanelNearByMedia : public LLPanelPulldown
void onClickDisableAll();
void onClickEnableParcelMedia();
void onClickDisableParcelMedia();
void onClickMuteParcelMedia();
void onParcelMediaVolumeSlider();
void onClickParcelMediaPlay();
void onClickParcelMediaStop();
void onClickParcelMediaPause();
void onClickParcelAudioPlay();
void onClickParcelAudioStop();
void onClickParcelAudioPause();
void onCheckAutoPlay();
void onAdvancedButtonClick();
void onMoreLess();

Expand Down Expand Up @@ -141,6 +140,7 @@ class LLPanelNearByMedia : public LLPanelPulldown
void onCommitSelectedMediaVolume();
void onClickSelectedMediaZoom();
void onClickSelectedMediaUnzoom();
void onMenuAction(const LLSD& userdata);

LLUICtrl* mNearbyMediaPanel;
LLScrollListCtrl* mMediaList;
Expand All @@ -158,6 +158,7 @@ class LLPanelNearByMedia : public LLPanelPulldown
LLUICtrl* mUnzoomCtrl;
LLSlider* mVolumeSlider;
LLButton* mMuteBtn;
LLButton* mMoreLessBtn;

bool mAllMediaDisabled;
bool mDebugInfoVisible;
Expand All @@ -171,6 +172,7 @@ class LLPanelNearByMedia : public LLPanelPulldown
LLRect mLessRect;
LLScrollListItem* mParcelMediaItem;
LLScrollListItem* mParcelAudioItem;
LLToggleableMenu* mContextMenu;
};


Expand Down
19 changes: 0 additions & 19 deletions indra/newview/llpanelpeople.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,25 +961,6 @@ void LLPanelPeople::getCurrentItemIDs(uuid_vec_t& selected_uuids) const

}

void LLPanelPeople::showGroupMenu(LLMenuGL* menu)
{
// Shows the menu at the top of the button bar.

// Calculate its coordinates.
// (assumes that groups panel is the current tab)
LLPanel* bottom_panel = mTabContainer->getCurrentPanel()->getChild<LLPanel>("bottom_panel");
LLPanel* parent_panel = mTabContainer->getCurrentPanel();
menu->arrangeAndClear();
S32 menu_height = menu->getRect().getHeight();
S32 menu_x = -2; // *HACK: compensates HPAD in showPopup()
S32 menu_y = bottom_panel->getRect().mTop + menu_height;

// Actually show the menu.
menu->buildDrawLabels();
menu->updateParent(LLMenuGL::sMenuContainer);
LLMenuGL::showPopup(parent_panel, menu, menu_x, menu_y);
}

void LLPanelPeople::setSortOrder(LLAvatarList* list, ESortOrder order, bool save)
{
switch (order)
Expand Down
1 change: 0 additions & 1 deletion indra/newview/llpanelpeople.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class LLPanelPeople
std::string getActiveTabName() const;
LLUUID getCurrentItemID() const;
void getCurrentItemIDs(uuid_vec_t& selected_uuids) const;
void showGroupMenu(LLMenuGL* menu);
void setSortOrder(LLAvatarList* list, ESortOrder order, bool save = true);

// UI callbacks
Expand Down
15 changes: 15 additions & 0 deletions indra/newview/skins/default/xui/en/menu_nearby_media.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<toggleable_menu
name="menu_nearby_media"
left="0"
bottom="0"
visible="false"
mouse_opaque="false">
<menu_item_call
label="Copy Url"
name="copy">
<menu_item_call.on_click
function="SelectedMediaCtrl.Action"
parameter="copy" />
</menu_item_call>
</toggleable_menu>

0 comments on commit c8ee05a

Please # to comment.