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