fixed Drag & Drop on Windows

This commit is contained in:
Martchus 2015-09-01 20:20:02 +02:00
parent 80128db440
commit 5a93c6186c
2 changed files with 34 additions and 0 deletions

View File

@ -234,7 +234,24 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
if(url.scheme() == QLatin1String("file")) {
event->accept();
if(event->type() == QEvent::Drop) {
#ifdef Q_OS_WIN32
// remove leading slash
QString path = url.path();
int index = 0;
for(const auto &c : path) {
if(c == QChar('/')) {
++index;
} else {
break;
}
}
if(index) {
path = path.mid(index);
}
startParsing(path, true);
#else
startParsing(url.path(), true);
#endif
}
return true;
}

View File

@ -455,7 +455,24 @@ void PicturePreviewSelection::dropEvent(QDropEvent *event)
if(mimeData->hasUrls()) {
for(const auto &url : mimeData->urls()) {
if(url.scheme() == QLatin1String("file")) {
#ifdef Q_OS_WIN32
// remove leading slash
QString path = url.path();
int index = 0;
for(const auto &c : path) {
if(c == QChar('/')) {
++index;
} else {
break;
}
}
if(index) {
path = path.mid(index);
}
addOfSelectedType(path);
#else
addOfSelectedType(url.path());
#endif
event->accept();
return;
}