[vlc-devel] commit: Fix drop MimeData on Windows... Close #1911 (Jean-Baptiste Kempf )
git version control
git at videolan.org
Wed Sep 10 08:39:00 CEST 2008
vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Tue Sep 9 23:21:22 2008 -0700| [f4f357d27e36425875bfb02c1164e6f837724cbf] | committer: Jean-Baptiste Kempf
Fix drop MimeData on Windows... Close #1911
In fact Qt uses always / as a separator, so introduce a function named toNativeSeparator (inspired from QDir) to fix this on Win$uck$
(cherry picked from commit de25484831fc71e0a8e24dd859e2186c77e7d5b2)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f4f357d27e36425875bfb02c1164e6f837724cbf
---
modules/gui/qt4/dialogs/playlist.cpp | 2 +-
modules/gui/qt4/main_interface.cpp | 6 ++++--
modules/gui/qt4/qt4.hpp | 15 +++++++++++++++
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/modules/gui/qt4/dialogs/playlist.cpp b/modules/gui/qt4/dialogs/playlist.cpp
index 289db4f..b8d4ead 100644
--- a/modules/gui/qt4/dialogs/playlist.cpp
+++ b/modules/gui/qt4/dialogs/playlist.cpp
@@ -71,7 +71,7 @@ void PlaylistDialog::dropEvent( QDropEvent *event )
{
const QMimeData *mimeData = event->mimeData();
foreach( QUrl url, mimeData->urls() ) {
- QString s = url.toString();
+ QString s = toNativeSeparators( url.toString() );
if( s.length() > 0 ) {
playlist_Add( THEPL, qtu(s), NULL,
PLAYLIST_APPEND, PLAYLIST_END, true, false );
diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index a7b2faf..608ff52 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -1082,7 +1082,8 @@ void MainInterface::dropEvent(QDropEvent *event)
if( THEMIM->getIM()->hasInput() )
{
if( input_AddSubtitles( THEMIM->getInput(),
- qtu( mimeData->urls()[0].toString() ),
+ qtu( toNativeSeparators(
+ mimeData->urls()[0].toLocalFile() ) ),
true ) )
{
event->acceptProposedAction();
@@ -1093,7 +1094,8 @@ void MainInterface::dropEvent(QDropEvent *event)
bool first = true;
foreach( QUrl url, mimeData->urls() )
{
- QString s = url.toLocalFile();
+ QString s = toNativeSeparators( url.toLocalFile() );
+
if( s.length() > 0 ) {
playlist_Add( THEPL, qtu(s), NULL,
PLAYLIST_APPEND | (first ? PLAYLIST_GO:0),
diff --git a/modules/gui/qt4/qt4.hpp b/modules/gui/qt4/qt4.hpp
index ef19b84..6b8c113 100644
--- a/modules/gui/qt4/qt4.hpp
+++ b/modules/gui/qt4/qt4.hpp
@@ -117,6 +117,21 @@ enum {
PLEventType = 200
};
+
+#include <QString>
+/* Replace separators on Windows because Qt is always using / */
+static inline QString toNativeSeparators( QString s )
+{
+#ifdef WIN32
+ for (int i=0; i<(int)s.length(); i++)
+ {
+ if (s[i] == QLatin1Char('/'))
+ s[i] = QLatin1Char('\\');
+ }
+#endif
+ return s;
+}
+
static const int DialogEvent_Type = QEvent::User + DialogEventType + 1;
//static const int PLUndockEvent_Type = QEvent::User + DialogEventType + 2;
//static const int PLDockEvent_Type = QEvent::User + DialogEventType + 3;
More information about the vlc-devel
mailing list