Add Copy Page URL to media right click menu
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
#include "llviewermenu.h"
|
||||
|
||||
// linden library includes
|
||||
#include "llclipboard.h"
|
||||
#include "llfocusmgr.h"
|
||||
#include "llsdutil.h"
|
||||
#include "lltextbox.h"
|
||||
@@ -397,6 +398,7 @@ void LLMediaCtrl::onFocusLost()
|
||||
BOOL LLMediaCtrl::postBuild ()
|
||||
{
|
||||
/*LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registar;
|
||||
registar.add("Copy.PageURL", boost::bind(&LLMediaCtrl::onCopyURL, this));
|
||||
registar.add("Open.WebInspector", boost::bind(&LLMediaCtrl::onOpenWebInspector, this));
|
||||
registar.add("Open.ViewSource", boost::bind(&LLMediaCtrl::onShowSource, this));
|
||||
|
||||
@@ -414,6 +416,12 @@ BOOL LLMediaCtrl::postBuild ()
|
||||
return true;
|
||||
}
|
||||
|
||||
void LLMediaCtrl::onCopyURL() const
|
||||
{
|
||||
auto wurl = utf8str_to_wstring(mCurrentNavUrl);
|
||||
gClipboard.copyFromSubstring(wurl, 0, wurl.size());
|
||||
}
|
||||
|
||||
void LLMediaCtrl::onOpenWebInspector()
|
||||
{
|
||||
if (mMediaSource && mMediaSource->hasMedia())
|
||||
|
||||
@@ -168,6 +168,7 @@ public:
|
||||
// Incoming media event dispatcher
|
||||
void handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event) override;
|
||||
|
||||
void onCopyURL() const;
|
||||
// right click debugging item
|
||||
void onOpenWebInspector();
|
||||
void onShowSource();
|
||||
|
||||
@@ -9433,6 +9433,15 @@ LLMediaCtrl* get_focused_media_ctrl()
|
||||
return media_ctrl;
|
||||
}
|
||||
|
||||
class MediaCtrlCopyURL : public view_listener_t
|
||||
{
|
||||
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
|
||||
{
|
||||
get_focused_media_ctrl()->onCopyURL();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class MediaCtrlWebInspector : public view_listener_t
|
||||
{
|
||||
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
|
||||
@@ -9812,6 +9821,7 @@ void initialize_menus()
|
||||
LLTextEditor::addMenuListeners();
|
||||
|
||||
// Media Ctrl menus
|
||||
addMenu(new MediaCtrlCopyURL(), "Copy.PageURL");
|
||||
addMenu(new MediaCtrlWebInspector(), "Open.WebInspector");
|
||||
addMenu(new MediaCtrlViewSource(), "Open.ViewSource");
|
||||
|
||||
|
||||
@@ -22,6 +22,12 @@
|
||||
<menu_item_separator
|
||||
layout="topleft"
|
||||
name="undo_separator" />
|
||||
<menu_item_call
|
||||
label="Copy Page URL"
|
||||
name="copy_page_url">
|
||||
<menu_item_call.on_click
|
||||
function="Copy.PageURL" />
|
||||
</menu_item_call>
|
||||
<menu_item_call
|
||||
label="Cut"
|
||||
layout="topleft"
|
||||
|
||||
Reference in New Issue
Block a user