1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-10 22:31:40 +02:00

Drag and drop

This commit is contained in:
George King
2025-04-04 20:41:04 +02:00
committed by GitHub
parent e1be9af5e6
commit 6fba8a6a86

View File

@@ -157,6 +157,28 @@ void MainWindow::loadTranslation()
#endif
}
void MainWindow::dragEnterEvent(QDragEnterEvent* event)
{
if (event->mimeData()->hasUrls())
event->acceptProposedAction();
}
void MainWindow::dropEvent(QDropEvent* event)
{
if (!getAnswerAboutUnsavedChanges())
return;
for (const QUrl& url : event->mimeData()->urls())
{
QString path = url.toLocalFile();
if (path.endsWith(".h3m", Qt::CaseInsensitive) || path.endsWith(".vmap", Qt::CaseInsensitive))
{
openMap(path);
break;
}
}
}
MainWindow::MainWindow(QWidget* parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),