summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mainwin.cc33
-rw-r--r--openscad.h2
2 files changed, 35 insertions, 0 deletions
diff --git a/mainwin.cc b/mainwin.cc
index 08e1ce6..19f558a 100644
--- a/mainwin.cc
+++ b/mainwin.cc
@@ -34,6 +34,9 @@
#include <QLabel>
#include <QFileInfo>
#include <QStatusBar>
+#include <QDropEvent>
+#include <QMimeData>
+#include <QUrl>
//for chdir
#include <unistd.h>
@@ -252,6 +255,7 @@ MainWindow::MainWindow(const char *filename)
#endif
viewPerspective();
+ setAcceptDrops(true);
current_win = NULL;
}
@@ -1303,3 +1307,32 @@ void MainWindow::viewOrthogonal()
screen->updateGL();
}
+void MainWindow::dragEnterEvent(QDragEnterEvent *event)
+{
+ if (event->mimeData()->hasUrls())
+ event->acceptProposedAction();
+}
+
+void MainWindow::dropEvent(QDropEvent *event)
+{
+ current_win = this;
+ const QList<QUrl> urls = event->mimeData()->urls();
+ for (int i = 0; i < urls.size(); i++) {
+ if (urls[i].scheme() != "file")
+ continue;
+ QString fn = urls[i].path();
+#if ENABLE_MDI
+ if (!editor->toPlainText().isEmpty()) {
+ new MainWindow(fn.toAscii().data());
+ break;
+ }
+#endif
+ filename = fn;
+ setWindowTitle(filename);
+ maybe_change_dir();
+ load();
+ break;
+ }
+ current_win = NULL;
+}
+
diff --git a/openscad.h b/openscad.h
index 6682db8..65311b7 100644
--- a/openscad.h
+++ b/openscad.h
@@ -808,6 +808,8 @@ public slots:
void viewPerspective();
void viewOrthogonal();
void animateUpdate();
+ void dragEnterEvent(QDragEnterEvent *event);
+ void dropEvent(QDropEvent *event);
};
extern AbstractModule *parse(const char *text, int debug);
contact: Jan Huwald // Impressum