mirror of https://github.com/vitalif/openscad
Clifford Wolf:
Added support for dropping files git-svn-id: http://svn.clifford.at/openscad/trunk@125 b57f626f-c46c-0410-a088-ec61d464b74cstl_dim
parent
0cd451bbf9
commit
1b2caba2f5
33
mainwin.cc
33
mainwin.cc
|
@ -34,6 +34,9 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
|
#include <QDropEvent>
|
||||||
|
#include <QMimeData>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
//for chdir
|
//for chdir
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -252,6 +255,7 @@ MainWindow::MainWindow(const char *filename)
|
||||||
#endif
|
#endif
|
||||||
viewPerspective();
|
viewPerspective();
|
||||||
|
|
||||||
|
setAcceptDrops(true);
|
||||||
current_win = NULL;
|
current_win = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1303,3 +1307,32 @@ void MainWindow::viewOrthogonal()
|
||||||
screen->updateGL();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -808,6 +808,8 @@ public slots:
|
||||||
void viewPerspective();
|
void viewPerspective();
|
||||||
void viewOrthogonal();
|
void viewOrthogonal();
|
||||||
void animateUpdate();
|
void animateUpdate();
|
||||||
|
void dragEnterEvent(QDragEnterEvent *event);
|
||||||
|
void dropEvent(QDropEvent *event);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern AbstractModule *parse(const char *text, int debug);
|
extern AbstractModule *parse(const char *text, int debug);
|
||||||
|
|
Loading…
Reference in New Issue