From d4bc01d46c246e18fe1f795edb4533e130f9116a Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 8 May 2013 00:00:09 +0200 Subject: New feature: Drag and drop stl, off or dxf files will create an import statement diff --git a/Info.plist b/Info.plist index 506bab7..84b270f 100644 --- a/Info.plist +++ b/Info.plist @@ -38,6 +38,36 @@ LSIsAppleDefaultForType + + CFBundleTypeExtensions + + stl + + CFBundleTypeName + STL 3D file + CFBundleTypeRole + Viewer + + + CFBundleTypeExtensions + + off + + CFBundleTypeName + OFF 3D file + CFBundleTypeRole + Viewer + + + CFBundleTypeExtensions + + dxf + + CFBundleTypeName + DXF file + CFBundleTypeRole + Viewer + NSAppleScriptEnabled diff --git a/src/mainwin.cc b/src/mainwin.cc index 027f72a..dc6d85c 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -488,17 +488,25 @@ void MainWindow::requestOpenFile(const QString &) void MainWindow::openFile(const QString &new_filename) { + QString actual_filename; #ifdef ENABLE_MDI if (!editor->toPlainText().isEmpty()) { - new MainWindow(new_filename); + QFileInfo fi(new_filename); + if (!fi.suffix().toLower().contains(QRegExp("^(stl|off|dxf)$"))) { + actual_filename = new_filename; + } + new MainWindow(actual_filename); clearCurrentOutput(); return; } #endif - setFileName(new_filename); + setFileName(actual_filename); refreshDocument(); updateRecentFiles(); + if (actual_filename.isEmpty()) { + this->editor->setPlainText(QString("import(\"%1\");\n").arg(new_filename)); + } } void -- cgit v0.10.1