Triage Issue #49 Better inspection of media urls

Part 1: Ability to copy urls from nearby media for inspection
master
Andrey Kleshchev 2024-02-09 01:31:05 +02:00 committed by Andrey Kleshchev
parent 67876e6cb0
commit c8ee05a271
6 changed files with 106 additions and 41 deletions

View File

@ -91,12 +91,12 @@ BOOL LLConversationLogList::handleRightMouseDown(S32 x, S32 y, MASK mask)
BOOL handled = LLUICtrl::handleRightMouseDown(x, y, mask); BOOL handled = LLUICtrl::handleRightMouseDown(x, y, mask);
LLToggleableMenu* context_menu = mContextMenu.get(); LLToggleableMenu* context_menu = mContextMenu.get();
{ if (context_menu && size())
context_menu->buildDrawLabels(); {
if (context_menu && size()) context_menu->buildDrawLabels();
context_menu->updateParent(LLMenuGL::sMenuContainer); context_menu->updateParent(LLMenuGL::sMenuContainer);
LLMenuGL::showPopup(this, context_menu, x, y); LLMenuGL::showPopup(this, context_menu, x, y);
} }
return handled; return handled;
} }

View File

@ -30,6 +30,7 @@
#include "llaudioengine.h" #include "llaudioengine.h"
#include "llcheckboxctrl.h" #include "llcheckboxctrl.h"
#include "llclipboard.h"
#include "llcombobox.h" #include "llcombobox.h"
#include "llresizebar.h" #include "llresizebar.h"
#include "llresizehandle.h" #include "llresizehandle.h"
@ -53,7 +54,9 @@
#include "llvovolume.h" #include "llvovolume.h"
#include "llstatusbar.h" #include "llstatusbar.h"
#include "llsdutil.h" #include "llsdutil.h"
#include "lltoggleablemenu.h"
#include "llvieweraudio.h" #include "llvieweraudio.h"
#include "llviewermenu.h"
#include "llfloaterreg.h" #include "llfloaterreg.h"
#include "llfloaterpreference.h" // for the gear icon #include "llfloaterpreference.h" // for the gear icon
@ -77,7 +80,8 @@ LLPanelNearByMedia::LLPanelNearByMedia()
mAllMediaDisabled(false), mAllMediaDisabled(false),
mDebugInfoVisible(false), mDebugInfoVisible(false),
mParcelMediaItem(NULL), mParcelMediaItem(NULL),
mParcelAudioItem(NULL) mParcelAudioItem(NULL),
mMoreLessBtn(NULL)
{ {
// This is just an initial value, mParcelAudioAutoStart does not affect ParcelMediaAutoPlayEnable // This is just an initial value, mParcelAudioAutoStart does not affect ParcelMediaAutoPlayEnable
mParcelAudioAutoStart = gSavedSettings.getS32("ParcelMediaAutoPlayEnable") != 0 mParcelAudioAutoStart = gSavedSettings.getS32("ParcelMediaAutoPlayEnable") != 0
@ -96,7 +100,14 @@ LLPanelNearByMedia::LLPanelNearByMedia()
mCommitCallbackRegistrar.add("SelectedMediaCtrl.Volume", boost::bind(&LLPanelNearByMedia::onCommitSelectedMediaVolume, this)); mCommitCallbackRegistrar.add("SelectedMediaCtrl.Volume", boost::bind(&LLPanelNearByMedia::onCommitSelectedMediaVolume, this));
mCommitCallbackRegistrar.add("SelectedMediaCtrl.Zoom", boost::bind(&LLPanelNearByMedia::onClickSelectedMediaZoom, this)); mCommitCallbackRegistrar.add("SelectedMediaCtrl.Zoom", boost::bind(&LLPanelNearByMedia::onClickSelectedMediaZoom, this));
mCommitCallbackRegistrar.add("SelectedMediaCtrl.Unzoom", boost::bind(&LLPanelNearByMedia::onClickSelectedMediaUnzoom, 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"); buildFromFile( "panel_nearby_media.xml");
} }
@ -147,7 +158,8 @@ BOOL LLPanelNearByMedia::postBuild()
mUnzoomCtrl = getChild<LLUICtrl>("unzoom"); mUnzoomCtrl = getChild<LLUICtrl>("unzoom");
mVolumeSlider = getChild<LLSlider>("volume_slider"); mVolumeSlider = getChild<LLSlider>("volume_slider");
mMuteBtn = getChild<LLButton>("mute_btn"); mMuteBtn = getChild<LLButton>("mute_btn");
mMoreLessBtn = getChild<LLButton>("more_btn");
mEmptyNameString = getString("empty_item_text"); mEmptyNameString = getString("empty_item_text");
mParcelMediaName = getString("parcel_media_name"); mParcelMediaName = getString("parcel_media_name");
mParcelAudioName = getString("parcel_audio_name"); mParcelAudioName = getString("parcel_audio_name");
@ -166,8 +178,13 @@ BOOL LLPanelNearByMedia::postBuild()
mLessRect = getRect(); mLessRect = getRect();
mLessRect.mBottom = minimized_controls->getRect().mBottom; mLessRect.mBottom = minimized_controls->getRect().mBottom;
getChild<LLUICtrl>("more_btn")->setVisible(false); mMoreLessBtn->setVisible(false);
onMoreLess(); onMoreLess();
mContextMenu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>(
"menu_nearby_media.xml",
gMenuHolder,
LLViewerMenuHolderGL::child_registry_t::instance());
return TRUE; return TRUE;
} }
@ -193,8 +210,7 @@ void LLPanelNearByMedia::reshape(S32 width, S32 height, BOOL called_from_parent)
{ {
LLPanelPulldown::reshape(width, height, called_from_parent); LLPanelPulldown::reshape(width, height, called_from_parent);
LLButton* more_btn = findChild<LLButton>("more_btn"); if (mMoreLessBtn && mMoreLessBtn->getValue().asBoolean())
if (more_btn && more_btn->getValue().asBoolean())
{ {
mMoreRect = getRect(); mMoreRect = getRect();
} }
@ -234,6 +250,26 @@ BOOL LLPanelNearByMedia::handleHover(S32 x, S32 y, MASK mask)
return true; 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() bool LLPanelNearByMedia::getParcelAudioAutoStart()
{ {
return mParcelAudioAutoStart; return mParcelAudioAutoStart;
@ -923,7 +959,7 @@ void LLPanelNearByMedia::onAdvancedButtonClick()
void LLPanelNearByMedia::onMoreLess() void LLPanelNearByMedia::onMoreLess()
{ {
bool is_more = getChild<LLButton>("more_btn")->getToggleState(); bool is_more = mMoreLessBtn->getToggleState();
mNearbyMediaPanel->setVisible(is_more); mNearbyMediaPanel->setVisible(is_more);
// enable resizing when expanded // enable resizing when expanded
@ -934,7 +970,7 @@ void LLPanelNearByMedia::onMoreLess()
setShape(new_rect); setShape(new_rect);
getChild<LLUICtrl>("more_btn")->setVisible(true); mMoreLessBtn->setVisible(true);
} }
void LLPanelNearByMedia::updateControls() void LLPanelNearByMedia::updateControls()
@ -1174,6 +1210,38 @@ void LLPanelNearByMedia::onClickSelectedMediaUnzoom()
LLViewerMediaFocus::getInstance()->unZoom(); 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 // static
void LLPanelNearByMedia::getNameAndUrlHelper(LLViewerMediaImpl* impl, std::string& name, std::string & url, const std::string &defaultName) void LLPanelNearByMedia::getNameAndUrlHelper(LLViewerMediaImpl* impl, std::string& name, std::string & url, const std::string &defaultName)

View File

@ -36,6 +36,7 @@ class LLSlider;
class LLSliderCtrl; class LLSliderCtrl;
class LLCheckBoxCtrl; class LLCheckBoxCtrl;
class LLTextBox; class LLTextBox;
class LLToggleableMenu;
class LLComboBox; class LLComboBox;
class LLViewerMediaImpl; class LLViewerMediaImpl;
@ -43,10 +44,11 @@ class LLPanelNearByMedia : public LLPanelPulldown
{ {
public: public:
/*virtual*/ BOOL postBuild(); BOOL postBuild() override;
/*virtual*/ void draw(); void draw() override;
/*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent); void reshape(S32 width, S32 height, BOOL called_from_parent) override;
/*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask); 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 // this is part of the nearby media *dialog* so we can track whether
// the user *implicitly* wants audio on or off via their *explicit* // the user *implicitly* wants audio on or off via their *explicit*
@ -104,15 +106,12 @@ private:
void onClickDisableAll(); void onClickDisableAll();
void onClickEnableParcelMedia(); void onClickEnableParcelMedia();
void onClickDisableParcelMedia(); void onClickDisableParcelMedia();
void onClickMuteParcelMedia();
void onParcelMediaVolumeSlider();
void onClickParcelMediaPlay(); void onClickParcelMediaPlay();
void onClickParcelMediaStop(); void onClickParcelMediaStop();
void onClickParcelMediaPause(); void onClickParcelMediaPause();
void onClickParcelAudioPlay(); void onClickParcelAudioPlay();
void onClickParcelAudioStop(); void onClickParcelAudioStop();
void onClickParcelAudioPause(); void onClickParcelAudioPause();
void onCheckAutoPlay();
void onAdvancedButtonClick(); void onAdvancedButtonClick();
void onMoreLess(); void onMoreLess();
@ -141,6 +140,7 @@ private:
void onCommitSelectedMediaVolume(); void onCommitSelectedMediaVolume();
void onClickSelectedMediaZoom(); void onClickSelectedMediaZoom();
void onClickSelectedMediaUnzoom(); void onClickSelectedMediaUnzoom();
void onMenuAction(const LLSD& userdata);
LLUICtrl* mNearbyMediaPanel; LLUICtrl* mNearbyMediaPanel;
LLScrollListCtrl* mMediaList; LLScrollListCtrl* mMediaList;
@ -158,6 +158,7 @@ private:
LLUICtrl* mUnzoomCtrl; LLUICtrl* mUnzoomCtrl;
LLSlider* mVolumeSlider; LLSlider* mVolumeSlider;
LLButton* mMuteBtn; LLButton* mMuteBtn;
LLButton* mMoreLessBtn;
bool mAllMediaDisabled; bool mAllMediaDisabled;
bool mDebugInfoVisible; bool mDebugInfoVisible;
@ -171,6 +172,7 @@ private:
LLRect mLessRect; LLRect mLessRect;
LLScrollListItem* mParcelMediaItem; LLScrollListItem* mParcelMediaItem;
LLScrollListItem* mParcelAudioItem; LLScrollListItem* mParcelAudioItem;
LLToggleableMenu* mContextMenu;
}; };

View File

@ -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) void LLPanelPeople::setSortOrder(LLAvatarList* list, ESortOrder order, bool save)
{ {
switch (order) switch (order)

View File

@ -87,7 +87,6 @@ private:
std::string getActiveTabName() const; std::string getActiveTabName() const;
LLUUID getCurrentItemID() const; LLUUID getCurrentItemID() const;
void getCurrentItemIDs(uuid_vec_t& selected_uuids) const; void getCurrentItemIDs(uuid_vec_t& selected_uuids) const;
void showGroupMenu(LLMenuGL* menu);
void setSortOrder(LLAvatarList* list, ESortOrder order, bool save = true); void setSortOrder(LLAvatarList* list, ESortOrder order, bool save = true);
// UI callbacks // UI callbacks

View File

@ -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>