diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-02-09 01:31:05 +0200 |
---|---|---|
committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2024-02-10 00:27:28 +0200 |
commit | c8ee05a2712e56a7cdcb2b9e25c8b092c088d4d4 (patch) | |
tree | 1916e205a9c2d975b5012eeec3b989de9638fba6 | |
parent | 67876e6cb01871201048955868151971883aeaf4 (diff) |
Triage Issue #49 Better inspection of media urls
Part 1: Ability to copy urls from nearby media for inspection
-rw-r--r-- | indra/newview/llconversationloglist.cpp | 12 | ||||
-rw-r--r-- | indra/newview/llpanelnearbymedia.cpp | 84 | ||||
-rw-r--r-- | indra/newview/llpanelnearbymedia.h | 16 | ||||
-rw-r--r-- | indra/newview/llpanelpeople.cpp | 19 | ||||
-rw-r--r-- | indra/newview/llpanelpeople.h | 1 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_nearby_media.xml | 15 |
6 files changed, 106 insertions, 41 deletions
diff --git a/indra/newview/llconversationloglist.cpp b/indra/newview/llconversationloglist.cpp index 97b16a5e93..e6ebfc2f1b 100644 --- a/indra/newview/llconversationloglist.cpp +++ b/indra/newview/llconversationloglist.cpp @@ -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; } diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp index 3c3cd5d522..c911f102a1 100644 --- a/indra/newview/llpanelnearbymedia.cpp +++ b/indra/newview/llpanelnearbymedia.cpp @@ -30,6 +30,7 @@ #include "llaudioengine.h" #include "llcheckboxctrl.h" +#include "llclipboard.h" #include "llcombobox.h" #include "llresizebar.h" #include "llresizehandle.h" @@ -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 @@ -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 @@ -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"); } @@ -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"); @@ -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; } @@ -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(); } @@ -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; @@ -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 @@ -934,7 +970,7 @@ void LLPanelNearByMedia::onMoreLess() setShape(new_rect); - getChild<LLUICtrl>("more_btn")->setVisible(true); + mMoreLessBtn->setVisible(true); } void LLPanelNearByMedia::updateControls() @@ -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) diff --git a/indra/newview/llpanelnearbymedia.h b/indra/newview/llpanelnearbymedia.h index 2d898d0aa1..7239a80043 100644 --- a/indra/newview/llpanelnearbymedia.h +++ b/indra/newview/llpanelnearbymedia.h @@ -36,6 +36,7 @@ class LLSlider; class LLSliderCtrl; class LLCheckBoxCtrl; class LLTextBox; +class LLToggleableMenu; class LLComboBox; class LLViewerMediaImpl; @@ -43,10 +44,11 @@ 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* @@ -104,15 +106,12 @@ private: 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(); @@ -141,6 +140,7 @@ private: void onCommitSelectedMediaVolume(); void onClickSelectedMediaZoom(); void onClickSelectedMediaUnzoom(); + void onMenuAction(const LLSD& userdata); LLUICtrl* mNearbyMediaPanel; LLScrollListCtrl* mMediaList; @@ -158,6 +158,7 @@ private: LLUICtrl* mUnzoomCtrl; LLSlider* mVolumeSlider; LLButton* mMuteBtn; + LLButton* mMoreLessBtn; bool mAllMediaDisabled; bool mDebugInfoVisible; @@ -171,6 +172,7 @@ private: LLRect mLessRect; LLScrollListItem* mParcelMediaItem; LLScrollListItem* mParcelAudioItem; + LLToggleableMenu* mContextMenu; }; diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp index 13b52e97c5..b3224c2c1f 100644 --- a/indra/newview/llpanelpeople.cpp +++ b/indra/newview/llpanelpeople.cpp @@ -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) diff --git a/indra/newview/llpanelpeople.h b/indra/newview/llpanelpeople.h index 14205cebe2..25abebc576 100644 --- a/indra/newview/llpanelpeople.h +++ b/indra/newview/llpanelpeople.h @@ -87,7 +87,6 @@ private: 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 diff --git a/indra/newview/skins/default/xui/en/menu_nearby_media.xml b/indra/newview/skins/default/xui/en/menu_nearby_media.xml new file mode 100644 index 0000000000..11a5dfa5fa --- /dev/null +++ b/indra/newview/skins/default/xui/en/menu_nearby_media.xml @@ -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> |