]> git.sesse.net Git - vlc/commitdiff
Fix drop MimeData on Windows... Close #1911
authorJean-Baptiste Kempf <jb@videolan.org>
Wed, 10 Sep 2008 06:21:22 +0000 (23:21 -0700)
committerJean-Baptiste Kempf <jb@videolan.org>
Wed, 10 Sep 2008 06:32:27 +0000 (23:32 -0700)
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@videolan.org>
modules/gui/qt4/dialogs/playlist.cpp
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/qt4.hpp

index 289db4fcc45d3914d84da26548322845b7887762..b8d4eadc2f4f4752a998b4c984742b2e75228f4a 100644 (file)
@@ -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 );
index a7b2fafbc0b91fc6726c161dfe062d3a62da49b5..608ff5200a4fea4d93265b4b3557c582ee2d2745 100644 (file)
@@ -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),
index ef19b84d5d2bd48d90a7e10bc35ad4f4348ac9e7..6b8c1137b9b7f23117c74de824fe0527d4ce904a 100644 (file)
@@ -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;