diff --git a/include/system.hpp b/include/system.hpp index a57651a2..8b05853b 100644 --- a/include/system.hpp +++ b/include/system.hpp @@ -36,6 +36,7 @@ Shell injection is possible, so make sure the URL is trusted or hard coded. May block, so open in a new thread. */ void openBrowser(const std::string &url); +void openFolder(const std::string &path); } // namespace system diff --git a/src/app/ModuleWidget.cpp b/src/app/ModuleWidget.cpp index b193afee..0f2f2c0f 100644 --- a/src/app/ModuleWidget.cpp +++ b/src/app/ModuleWidget.cpp @@ -29,6 +29,16 @@ struct ModuleUrlItem : ui::MenuItem { } }; + +struct ModuleFolderItem : ui::MenuItem { + std::string path; + void onAction(const event::Action &e) override { + std::thread t(system::openFolder, path); + t.detach(); + } +}; + + struct ModulePluginItem : ui::MenuItem { plugin::Plugin *plugin; ui::Menu *createChildMenu() override { @@ -80,11 +90,10 @@ struct ModulePluginItem : ui::MenuItem { menu->addChild(donateItem); } - // TODO open folder location with file explorer instead of browser if (!plugin->path.empty()) { - ModuleUrlItem *pathItem = new ModuleUrlItem; - pathItem->text = "Open folder"; - pathItem->url = plugin->path; + ModuleFolderItem *pathItem = new ModuleFolderItem; + pathItem->text = "Open plugin folder"; + pathItem->path = plugin->path; menu->addChild(pathItem); } @@ -92,6 +101,7 @@ struct ModulePluginItem : ui::MenuItem { } }; + struct ModuleDisconnectItem : ui::MenuItem { ModuleWidget *moduleWidget; void onAction(const event::Action &e) override { @@ -99,6 +109,7 @@ struct ModuleDisconnectItem : ui::MenuItem { } }; + struct ModuleResetItem : ui::MenuItem { ModuleWidget *moduleWidget; void onAction(const event::Action &e) override { @@ -106,6 +117,7 @@ struct ModuleResetItem : ui::MenuItem { } }; + struct ModuleRandomizeItem : ui::MenuItem { ModuleWidget *moduleWidget; void onAction(const event::Action &e) override { @@ -113,6 +125,7 @@ struct ModuleRandomizeItem : ui::MenuItem { } }; + struct ModuleCopyItem : ui::MenuItem { ModuleWidget *moduleWidget; void onAction(const event::Action &e) override { @@ -120,6 +133,7 @@ struct ModuleCopyItem : ui::MenuItem { } }; + struct ModulePasteItem : ui::MenuItem { ModuleWidget *moduleWidget; void onAction(const event::Action &e) override { @@ -127,6 +141,7 @@ struct ModulePasteItem : ui::MenuItem { } }; + struct ModuleSaveItem : ui::MenuItem { ModuleWidget *moduleWidget; void onAction(const event::Action &e) override { @@ -134,6 +149,7 @@ struct ModuleSaveItem : ui::MenuItem { } }; + struct ModuleLoadItem : ui::MenuItem { ModuleWidget *moduleWidget; void onAction(const event::Action &e) override { @@ -141,6 +157,7 @@ struct ModuleLoadItem : ui::MenuItem { } }; + struct ModulePresetItem : ui::MenuItem { ModuleWidget *moduleWidget; std::string presetPath; @@ -149,6 +166,7 @@ struct ModulePresetItem : ui::MenuItem { } }; + struct ModuleListPresetsItem : ui::MenuItem { ModuleWidget *moduleWidget; ui::Menu *createChildMenu() override { @@ -167,6 +185,7 @@ struct ModuleListPresetsItem : ui::MenuItem { } }; + struct ModuleCloneItem : ui::MenuItem { ModuleWidget *moduleWidget; void onAction(const event::Action &e) override { @@ -174,6 +193,7 @@ struct ModuleCloneItem : ui::MenuItem { } }; + struct ModuleBypassItem : ui::MenuItem { ModuleWidget *moduleWidget; void onAction(const event::Action &e) override { @@ -181,6 +201,7 @@ struct ModuleBypassItem : ui::MenuItem { } }; + struct ModuleDeleteItem : ui::MenuItem { ModuleWidget *moduleWidget; void onAction(const event::Action &e) override { diff --git a/src/app/Toolbar.cpp b/src/app/Toolbar.cpp index 5bf4509c..e5b257fc 100644 --- a/src/app/Toolbar.cpp +++ b/src/app/Toolbar.cpp @@ -577,9 +577,7 @@ struct PluginsButton : MenuButton { struct ManualItem : ui::MenuItem { void onAction(const event::Action &e) override { - std::thread t([&]() { - system::openBrowser("https://vcvrack.com/manual/"); - }); + std::thread t(system::openBrowser, "https://vcvrack.com/manual/"); t.detach(); } }; @@ -587,9 +585,7 @@ struct ManualItem : ui::MenuItem { struct WebsiteItem : ui::MenuItem { void onAction(const event::Action &e) override { - std::thread t([&]() { - system::openBrowser("https://vcvrack.com/"); - }); + std::thread t(system::openBrowser, "https://vcvrack.com/"); t.detach(); } }; @@ -602,6 +598,14 @@ struct CheckVersionItem : ui::MenuItem { }; +struct UserFolderItem : ui::MenuItem { + void onAction(const event::Action &e) override { + std::thread t(system::openFolder, asset::user("")); + t.detach(); + } +}; + + struct HelpButton : MenuButton { void onAction(const event::Action &e) override { ui::Menu *menu = createMenu(); @@ -621,6 +625,10 @@ struct HelpButton : MenuButton { checkVersionItem->text = "Check version on launch"; checkVersionItem->rightText = CHECKMARK(settings.checkVersion); menu->addChild(checkVersionItem); + + UserFolderItem *folderItem = new UserFolderItem; + folderItem->text = "Open user folder"; + menu->addChild(folderItem); } }; diff --git a/src/system.cpp b/src/system.cpp index a2cd3742..54959d1f 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -9,6 +9,7 @@ #include #include #include // for backtrace and backtrace_symbols + #include // for execl #endif #if defined ARCH_WIN @@ -150,11 +151,11 @@ std::string getStackTrace() { void openBrowser(const std::string &url) { #if defined ARCH_LIN - std::string command = "xdg-open " + url; + std::string command = "xdg-open \"" + url + "\""; (void) std::system(command.c_str()); #endif #if defined ARCH_MAC - std::string command = "open " + url; + std::string command = "open \"" + url + "\""; std::system(command.c_str()); #endif #if defined ARCH_WIN @@ -162,6 +163,17 @@ void openBrowser(const std::string &url) { #endif } +void openFolder(const std::string &path) { +#if defined ARCH_LIN + std::string command = "xdg-open \"" + path + "\""; + (void) std::system(command.c_str()); +#endif +#if defined ARCH_WIN + ShellExecute(NULL, "explorer", path.c_str(), NULL, NULL, SW_SHOWNORMAL); +#endif +} + + } // namespace system } // namespace rack