From 13e4bcd50e324d5228ce920d1fc84aa3ba8d6e5e Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 21 May 2013 18:02:16 -0400 Subject: [PATCH] Added meny entry for disclosing the library path. Part of #125 --- openscad.pro | 3 ++- src/MainWindow.h | 1 + src/MainWindow.ui | 6 ++++++ src/{PlatformUtils.mm => PlatformUtils-mac.mm} | 0 src/PlatformUtils.cc | 7 +++++++ src/PlatformUtils.h | 1 + src/mainwin.cc | 7 +++++++ 7 files changed, 24 insertions(+), 1 deletion(-) rename src/{PlatformUtils.mm => PlatformUtils-mac.mm} (100%) create mode 100644 src/PlatformUtils.cc diff --git a/openscad.pro b/openscad.pro index c36c37bd..8bd24afd 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 378705e4..bd32bdd5 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 8e995cdb..e9bd96e5 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.mm b/src/PlatformUtils-mac.mm similarity index 100% rename from src/PlatformUtils.mm rename to src/PlatformUtils-mac.mm diff --git a/src/PlatformUtils.cc b/src/PlatformUtils.cc new file mode 100644 index 00000000..cea449be --- /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 6448427c..202abaaa 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/mainwin.cc b/src/mainwin.cc index da3501d9..9b490c71 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();