Commit de254848 authored by Jean-Baptiste Kempf's avatar 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$
parent 88565227
......@@ -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 );
......
......@@ -1091,7 +1091,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();
......@@ -1102,7 +1103,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),
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment