From 8817535b104e9edee0c2a19e3af33c9fb1a4f274 Mon Sep 17 00:00:00 2001 From: SoftFever Date: Sun, 22 Sep 2024 14:35:31 +0800 Subject: [PATCH] handle bambustudioopen on Mac by default --- cmake/modules/MacOSXBundleInfo.plist.in | 8 ++++++++ src/libslic3r/Utils.hpp | 2 +- src/platform/osx/Info.plist.in | 1 + src/slic3r/GUI/Downloader.cpp | 3 ++- src/slic3r/GUI/InstanceCheck.cpp | 3 ++- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cmake/modules/MacOSXBundleInfo.plist.in b/cmake/modules/MacOSXBundleInfo.plist.in index 2f010c8a822..3de0ec036c1 100644 --- a/cmake/modules/MacOSXBundleInfo.plist.in +++ b/cmake/modules/MacOSXBundleInfo.plist.in @@ -37,6 +37,14 @@ orcaslicer + + + CFBundleURLName + BambuStudio Downloads + CFBundleURLSchemes + + bambustudioopen + CFBundleDocumentTypes diff --git a/src/libslic3r/Utils.hpp b/src/libslic3r/Utils.hpp index 9f249246f43..e9408e1a022 100644 --- a/src/libslic3r/Utils.hpp +++ b/src/libslic3r/Utils.hpp @@ -219,7 +219,7 @@ extern bool is_json_file(const std::string& path); // Orca: custom protocal support utils inline bool is_orca_open(const std::string& url) { return boost::starts_with(url, "orcaslicer://open"); } inline bool is_prusaslicer_open(const std::string& url) { return boost::starts_with(url, "prusaslicer://open"); } -inline bool is_bambustudio_open(const std::string& url) { return boost::starts_with(url, "bambustudio://open"); } +inline bool is_bambustudio_open(const std::string& url) { return boost::starts_with(url, "bambustudio://open") || boost::starts_with(url, "bambustudioopen://"); } inline bool is_cura_open(const std::string& url) { return boost::starts_with(url, "cura://open"); } inline bool is_supported_open_protocol(const std::string& url) { return is_orca_open(url) || is_prusaslicer_open(url) || is_bambustudio_open(url) || is_cura_open(url); } inline bool is_printables_link(const std::string& url) { diff --git a/src/platform/osx/Info.plist.in b/src/platform/osx/Info.plist.in index a2621d25211..629dc870fed 100644 --- a/src/platform/osx/Info.plist.in +++ b/src/platform/osx/Info.plist.in @@ -33,6 +33,7 @@ orcasliceropen orcaslicer + bambustudioopen diff --git a/src/slic3r/GUI/Downloader.cpp b/src/slic3r/GUI/Downloader.cpp index 25e160f24d9..7757ca3ad67 100644 --- a/src/slic3r/GUI/Downloader.cpp +++ b/src/slic3r/GUI/Downloader.cpp @@ -145,9 +145,10 @@ void Downloader::start_download(const std::string& full_url) // Orca: Replace PS workaround for "mysterious slash" with a more dynamic approach // Windows seems to have fixed the issue and this provides backwards compatability for those it still affects boost::regex re(R"(^(orcaslicer|prusaslicer|bambustudio|cura):\/\/open[\/]?\?file=)", boost::regbase::icase); + boost::regex re2(R"(^(bambustudioopen):\/\/)", boost::regex::icase); boost::smatch results; - if (!boost::regex_search(full_url, results, re)) { + if (!boost::regex_search(full_url, results, re) && !boost::regex_search(full_url, results, re2)) { BOOST_LOG_TRIVIAL(error) << "Could not start download due to wrong URL: " << full_url; // Orca: show error NotificationManager* ntf_mngr = wxGetApp().notification_manager(); diff --git a/src/slic3r/GUI/InstanceCheck.cpp b/src/slic3r/GUI/InstanceCheck.cpp index 360a952c1b0..09d4da31c59 100644 --- a/src/slic3r/GUI/InstanceCheck.cpp +++ b/src/slic3r/GUI/InstanceCheck.cpp @@ -502,6 +502,7 @@ void OtherInstanceMessageHandler::handle_message(const std::string& message) std::vector paths; std::vector downloads; boost::regex re(R"(^(orcaslicer|prusaslicer|cura|bambustudio):\/\/open[\/]?\?file=)", boost::regbase::icase); + boost::regex re2(R"(^(bambustudioopen):\/\/)", boost::regex::icase); boost::smatch results; // Skip the first argument, it is the path to the slicer executable. @@ -510,7 +511,7 @@ void OtherInstanceMessageHandler::handle_message(const std::string& message) boost::filesystem::path p = MessageHandlerInternal::get_path(*it); if (! p.string().empty()) paths.emplace_back(p); - else if (boost::regex_search(*it, results, re)) + else if (boost::regex_search(*it, results, re) || boost::regex_search(*it, results, re2)) downloads.emplace_back(*it); } if (! paths.empty()) {