diff options
author | clifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c> | 2009-10-28 21:08:25 (GMT) |
---|---|---|
committer | clifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c> | 2009-10-28 21:08:25 (GMT) |
commit | 1b2caba2f55b826d3efc849dead388956040c7d8 (patch) | |
tree | be836755f1d8640a65ecacc0efe153d6b58ba27d /mainwin.cc | |
parent | 0cd451bbf9ea2bf69a1ed7e15ba1814a196cb0c5 (diff) |
Clifford Wolf:
Added support for dropping files
git-svn-id: http://svn.clifford.at/openscad/trunk@125 b57f626f-c46c-0410-a088-ec61d464b74c
Diffstat (limited to 'mainwin.cc')
-rw-r--r-- | mainwin.cc | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -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; +} + |