Skip to content

Commit

Permalink
Project: Enabled opening project by drag-n-drop
Browse files Browse the repository at this point in the history
Issue #1665
  • Loading branch information
bjorn committed Apr 21, 2020
1 parent 62e626d commit 923ecac
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/tiled/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -885,15 +885,23 @@ void MainWindow::keyReleaseEvent(QKeyEvent *event)
void MainWindow::dragEnterEvent(QDragEnterEvent *e)
{
const QList<QUrl> urls = e->mimeData()->urls();
if (!urls.isEmpty() && !urls.at(0).toLocalFile().isEmpty())
if (!urls.isEmpty() && !urls.first().toLocalFile().isEmpty())
e->accept();
}

void MainWindow::dropEvent(QDropEvent *e)
{
const auto urls = e->mimeData()->urls();
for (const QUrl &url : urls)
openFile(url.toLocalFile());
for (const QUrl &url : urls) {
const QString localFile = url.toLocalFile();
if (localFile.isEmpty())
continue;

if (localFile.endsWith(QLatin1String(".tiled-project")))
openProjectFile(localFile);
else
openFile(localFile);
}
}

void MainWindow::newMap()
Expand Down

0 comments on commit 923ecac

Please sign in to comment.