Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
|
5a38a2db97 | ||
|
d9301bbba0 |
3 changed files with 24 additions and 1 deletions
|
@ -8,6 +8,9 @@ App::App(int argc, char *argv[]) :
|
|||
QApplication(argc, argv), window(new Window())
|
||||
{
|
||||
window->show();
|
||||
if (argc > 1)
|
||||
window->load_stl(argv[1]);
|
||||
else
|
||||
window->load_stl(":gl/sphere.stl");
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ Window::Window(QWidget *parent) :
|
|||
|
||||
{
|
||||
setWindowTitle("fstl");
|
||||
setAcceptDrops(true);
|
||||
|
||||
QFile styleFile(":/qt/style.qss");
|
||||
styleFile.open( QFile::ReadOnly );
|
||||
|
@ -128,3 +129,18 @@ bool Window::load_stl(const QString& filename)
|
|||
loader->start();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Window::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
if (event->mimeData()->hasUrls())
|
||||
{
|
||||
auto urls = event->mimeData()->urls();
|
||||
if (urls.size() == 1 && urls.front().path().endsWith(".stl"))
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
}
|
||||
|
||||
void Window::dropEvent(QDropEvent *event)
|
||||
{
|
||||
load_stl(event->mimeData()->urls().front().toLocalFile());
|
||||
}
|
||||
|
|
|
@ -12,6 +12,10 @@ public:
|
|||
explicit Window(QWidget* parent=0);
|
||||
bool load_stl(const QString& filename);
|
||||
|
||||
protected:
|
||||
void dragEnterEvent(QDragEnterEvent* event);
|
||||
void dropEvent(QDropEvent* event);
|
||||
|
||||
public slots:
|
||||
void on_open();
|
||||
void on_about();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue