fixed Drag & Drop on Windows
This commit is contained in:
parent
80128db440
commit
5a93c6186c
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue