From 13e4bcd50e324d5228ce920d1fc84aa3ba8d6e5e Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 21 May 2013 18:02:16 -0400 Subject: Added meny entry for disclosing the library path. Part of #125 diff --git a/openscad.pro b/openscad.pro index c36c37b..8bd24af 100644 --- a/openscad.pro +++ b/openscad.pro @@ -302,6 +302,7 @@ SOURCES += src/version_check.cc \ src/parsersettings.cc \ src/stl-utils.cc \ src/boost-utils.cc \ + src/PlatformUtils.cc \ \ src/nodedumper.cc \ src/traverser.cc \ @@ -385,7 +386,7 @@ macx { src/CocoaUtils.h SOURCES += src/AppleEvents.cc OBJECTIVE_SOURCES += src/CocoaUtils.mm \ - src/PlatformUtils.mm + src/PlatformUtils-mac.mm } unix:!macx { SOURCES += src/PlatformUtils-posix.cc diff --git a/src/MainWindow.h b/src/MainWindow.h index 378705e..bd32bdd 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -101,6 +101,7 @@ private slots: void actionSave(); void actionSaveAs(); void actionReload(); + void actionShowLibraryFolder(); private slots: void pasteViewportTranslation(); diff --git a/src/MainWindow.ui b/src/MainWindow.ui index 8e995cd..e9bd96e 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -137,6 +137,7 @@ + @@ -688,6 +689,11 @@ Check for Update.. + + + Show Library Folder... + + diff --git a/src/PlatformUtils-mac.mm b/src/PlatformUtils-mac.mm new file mode 100644 index 0000000..1e2ba43 --- /dev/null +++ b/src/PlatformUtils-mac.mm @@ -0,0 +1,7 @@ +#include "PlatformUtils.h" +#import + +std::string PlatformUtils::documentsPath() +{ + return std::string([[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] UTF8String]); +} diff --git a/src/PlatformUtils.cc b/src/PlatformUtils.cc new file mode 100644 index 0000000..cea449b --- /dev/null +++ b/src/PlatformUtils.cc @@ -0,0 +1,7 @@ +#include "PlatformUtils.h" +#include "boosty.h" + +std::string PlatformUtils::libraryPath() +{ + return boosty::stringy(fs::path(PlatformUtils::documentsPath()) / "OpenSCAD" / "libraries"); +} diff --git a/src/PlatformUtils.h b/src/PlatformUtils.h index 6448427..202abaa 100644 --- a/src/PlatformUtils.h +++ b/src/PlatformUtils.h @@ -6,6 +6,7 @@ namespace PlatformUtils { std::string documentsPath(); + std::string libraryPath(); } diff --git a/src/PlatformUtils.mm b/src/PlatformUtils.mm deleted file mode 100644 index 1e2ba43..0000000 --- a/src/PlatformUtils.mm +++ /dev/null @@ -1,7 +0,0 @@ -#include "PlatformUtils.h" -#import - -std::string PlatformUtils::documentsPath() -{ - return std::string([[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] UTF8String]); -} diff --git a/src/mainwin.cc b/src/mainwin.cc index da3501d..9b490c7 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -53,6 +53,7 @@ #ifdef Q_OS_MAC #include "CocoaUtils.h" #endif +#include "PlatformUtils.h" #include #include @@ -227,6 +228,7 @@ MainWindow::MainWindow(const QString &filename) connect(this->fileActionSaveAs, SIGNAL(triggered()), this, SLOT(actionSaveAs())); connect(this->fileActionReload, SIGNAL(triggered()), this, SLOT(actionReload())); connect(this->fileActionQuit, SIGNAL(triggered()), this, SLOT(quit())); + connect(this->fileShowLibraryFolder, SIGNAL(triggered()), this, SLOT(actionShowLibraryFolder())); #ifndef __APPLE__ QList shortcuts = this->fileActionSave->shortcuts(); shortcuts.push_back(QKeySequence(Qt::Key_F2)); @@ -951,6 +953,11 @@ void MainWindow::actionSaveAs() } } +void MainWindow::actionShowLibraryFolder() +{ + QDesktopServices::openUrl(QUrl::fromLocalFile(QString::fromStdString(PlatformUtils::libraryPath()))); +} + void MainWindow::actionReload() { if (checkEditorModified()) refreshDocument(); -- cgit v0.10.1