hrev50395 adds 2 changesets to branch 'master'
old head: 7a137e0f0cca591f595401309ed388a4d726acaa
new head: a784c3ad73a1ebad77c409775ade956e748ad93e
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=a784c3ad73a1+%5E7a137e0f0cca
----------------------------------------------------------------------------
778b5d524b1b: MediaPlayer: Fetch the clipboard for an url
* This avoid the user to paste in the BTextControl.
* Done also when the window is activated.
a784c3ad73a1: MediaPlayer: Handle B_ENTER in network window
[ Dario Casalinuovo <b.vitruvio@xxxxxxxxx> ]
----------------------------------------------------------------------------
2 files changed, 61 insertions(+)
src/apps/mediaplayer/NetworkStreamWin.cpp | 58 +++++++++++++++++++++++++++
src/apps/mediaplayer/NetworkStreamWin.h | 3 ++
############################################################################
Commit: 778b5d524b1bfc02fc04b6bb48fe92fe6abb4e8e
URL: http://cgit.haiku-os.org/haiku/commit/?id=778b5d524b1b
Author: Dario Casalinuovo <b.vitruvio@xxxxxxxxx>
Date: Fri Jul 8 11:49:54 2016 UTC
MediaPlayer: Fetch the clipboard for an url
* This avoid the user to paste in the BTextControl.
* Done also when the window is activated.
----------------------------------------------------------------------------
diff --git a/src/apps/mediaplayer/NetworkStreamWin.cpp
b/src/apps/mediaplayer/NetworkStreamWin.cpp
index b1351f6..f7a02c7 100644
--- a/src/apps/mediaplayer/NetworkStreamWin.cpp
+++ b/src/apps/mediaplayer/NetworkStreamWin.cpp
@@ -10,6 +10,7 @@
#include <Alert.h>
#include <Button.h>
#include <Catalog.h>
+#include <Clipboard.h>
#include <LayoutBuilder.h>
#include "MainApp.h"
@@ -43,6 +44,8 @@ NetworkStreamWin::NetworkStreamWin(BMessenger target)
.End()
.End();
+ _LookIntoClipboardForUrl();
+
CenterOnScreen();
}
@@ -86,3 +89,48 @@ NetworkStreamWin::MessageReceived(BMessage* message)
BWindow::MessageReceived(message);
}
}
+
+
+void
+NetworkStreamWin::WindowActivated(bool active)
+{
+ if (active)
+ _LookIntoClipboardForUrl();
+}
+
+
+void
+NetworkStreamWin::_LookIntoClipboardForUrl()
+{
+ // Don't do anything if we already have something
+ // set to avoid annoying the user.
+ if (fTextControl->TextView()->TextLength() > 0)
+ return;
+
+ // Let's see if we already have an url in the clipboard
+ // in that case avoid the user to paste it.
+ if (be_clipboard->Lock()) {
+ char* text = NULL;
+ int32 textLen = 0;
+
+ BMessage* data = be_clipboard->Data();
+ if (data->FindData("text/plain", B_MIME_TYPE,
+ (const void **)&text, &textLen) == B_OK) {
+
+ // NOTE: This is done because urls copied
+ // from WebPositive have the mime string at
+ // the end.
+ // TODO: Looks like a problem in Web+, should
+ // be fixed.
+ text[textLen] = '\0';
+
+ // Before to set the text let's see if it's really
+ // a valid URL.
+ BUrl url(text);
+ if (url.IsValid())
+ fTextControl->SetText(text);
+ }
+
+ be_clipboard->Unlock();
+ }
+}
diff --git a/src/apps/mediaplayer/NetworkStreamWin.h
b/src/apps/mediaplayer/NetworkStreamWin.h
index b88f629..c3d0311 100644
--- a/src/apps/mediaplayer/NetworkStreamWin.h
+++ b/src/apps/mediaplayer/NetworkStreamWin.h
@@ -20,7 +20,10 @@ public:
virtual void MessageReceived(BMessage*
message);
+ virtual void WindowActivated(bool active);
private:
+ void
_LookIntoClipboardForUrl();
+
BMessenger fTarget;
BTextControl* fTextControl;
};
############################################################################
Revision: hrev50395
Commit: a784c3ad73a1ebad77c409775ade956e748ad93e
URL: http://cgit.haiku-os.org/haiku/commit/?id=a784c3ad73a1
Author: Dario Casalinuovo <b.vitruvio@xxxxxxxxx>
Date: Fri Jul 8 11:50:47 2016 UTC
MediaPlayer: Handle B_ENTER in network window
----------------------------------------------------------------------------
diff --git a/src/apps/mediaplayer/NetworkStreamWin.cpp
b/src/apps/mediaplayer/NetworkStreamWin.cpp
index f7a02c7..2a3e0db 100644
--- a/src/apps/mediaplayer/NetworkStreamWin.cpp
+++ b/src/apps/mediaplayer/NetworkStreamWin.cpp
@@ -85,6 +85,16 @@ NetworkStreamWin::MessageReceived(BMessage* message)
Quit();
break;
+ case B_KEY_DOWN:
+ {
+ int8 key;
+ if (message->FindInt8("byte", &key) == B_OK
+ && key == B_ENTER) {
+ PostMessage(M_OPEN_URL);
+ break;
+ }
+ }
+
default:
BWindow::MessageReceived(message);
}