[vlc-commits] skins2: add support for subtitle drag'n'drop

Erwan Tulou git at videolan.org
Thu Oct 17 22:47:31 CEST 2013


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Thu Oct 17 21:28:20 2013 +0200| [c45edd56d3103dcf276e53ec42d56e7da856ab07] | committer: Erwan Tulou

skins2: add support for subtitle drag'n'drop

This patch copies the Qt interface implementation wrt file dropping, namely:
- first try it as a subtitle file if it is relevant
- second, try it as an item to be added to the playlist if not a subtitle

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c45edd56d3103dcf276e53ec42d56e7da856ab07
---

 modules/gui/skins2/src/top_window.cpp |   25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/modules/gui/skins2/src/top_window.cpp b/modules/gui/skins2/src/top_window.cpp
index b981128..1e88b9b 100644
--- a/modules/gui/skins2/src/top_window.cpp
+++ b/modules/gui/skins2/src/top_window.cpp
@@ -48,6 +48,8 @@
 #include "../utils/ustring.hpp"
 
 #include <vlc_keys.h>
+#include <vlc_input.h>
+#include <vlc_url.h>
 #include <list>
 
 
@@ -277,12 +279,27 @@ void TopWindow::processEvent( EvtDragDrop &rEvtDragDrop )
     }
     else
     {
+        input_thread_t *pInput = getIntf()->p_sys->p_input;
+        bool is_subtitle = false;
         list<string> files = rEvtDragDrop.getFiles();
-        list<string>::const_iterator it = files.begin();
-        for( bool first = true; it != files.end(); ++it, first = false )
+        if( files.size() == 1 && pInput != NULL )
         {
-            bool playOnDrop = m_playOnDrop && first;
-            CmdAddItem( getIntf(), it->c_str(), playOnDrop ).execute();
+            list<string>::const_iterator it = files.begin();
+            char* psz_file = make_path( it->c_str() );
+            if( psz_file )
+            {
+                is_subtitle = !input_AddSubtitle( pInput, psz_file, true );
+                free( psz_file );
+            }
+        }
+        if( !is_subtitle )
+        {
+            list<string>::const_iterator it = files.begin();
+            for( bool first = true; it != files.end(); ++it, first = false )
+            {
+                bool playOnDrop = m_playOnDrop && first;
+                CmdAddItem( getIntf(), it->c_str(), playOnDrop ).execute();
+            }
         }
     }
     m_pDragControl = NULL;



More information about the vlc-commits mailing list