Merge: Snapmaker Orca 2.1.2

This commit is contained in:
xiaoyeliu
2025-11-17 10:04:25 +08:00
parent 737948be1f
commit e89263e51a
1147 changed files with 668188 additions and 15290 deletions

View File

@@ -209,7 +209,7 @@ bool DesktopIntegrationDialog::is_integrated()
if (path.empty())
return false;
// confirmation that OrcaSlicer.desktop exists
// confirmation that Snapmaker_Orca.desktop exists
struct stat buffer;
return (stat (path.c_str(), &buffer) == 0);
}
@@ -290,11 +290,11 @@ void DesktopIntegrationDialog::perform_desktop_integration()
// slicer icon
// iterate thru target_candidates to find icons folder
for (size_t i = 0; i < target_candidates.size(); ++i) {
// Copy icon OrcaSlicer.png from resources_dir()/icons to target_dir_icons/icons/
// Copy icon Snapmaker_Orca.png from resources_dir()/icons to target_dir_icons/icons/
if (contains_path_dir(target_candidates[i], "images")) {
target_dir_icons = target_candidates[i];
std::string icon_path = GUI::format("%1%/images/OrcaSlicer.png",resources_dir());
std::string dest_path = GUI::format("%1%/images/%2%OrcaSlicer%3%.png", target_dir_icons, icon_theme_path, version_suffix);
std::string icon_path = GUI::format("%1%/images/Snapmaker_Orca.png",resources_dir());
std::string dest_path = GUI::format("%1%/images/%2%Snapmaker_Orca%3%.png", target_dir_icons, icon_theme_path, version_suffix);
if (copy_icon(icon_path, dest_path))
break; // success
else
@@ -305,8 +305,8 @@ void DesktopIntegrationDialog::perform_desktop_integration()
create_path(into_u8(wxFileName::GetHomeDir()), ".local/share/icons" + icon_theme_dirs);
// copy icon
target_dir_icons = GUI::format("%1%/.local/share",wxFileName::GetHomeDir());
std::string icon_path = GUI::format("%1%/images/OrcaSlicer.png",resources_dir());
std::string dest_path = GUI::format("%1%/images/%2%OrcaSlicer%3%.png", target_dir_icons, icon_theme_path, version_suffix);
std::string icon_path = GUI::format("%1%/images/Snapmaker_Orca.png",resources_dir());
std::string dest_path = GUI::format("%1%/images/%2%Snapmaker_Orca%3%.png", target_dir_icons, icon_theme_path, version_suffix);
if (!contains_path_dir(target_dir_icons, "images")
|| !copy_icon(icon_path, dest_path)) {
// every attempt failed - icon wont be present
@@ -316,10 +316,10 @@ void DesktopIntegrationDialog::perform_desktop_integration()
}
}
if(target_dir_icons.empty()) {
BOOST_LOG_TRIVIAL(error) << "Copying OrcaSlicer icon to icons directory failed.";
BOOST_LOG_TRIVIAL(error) << "Copying Snapmaker_Orca icon to icons directory failed.";
} else
// save path to icon
app_config->set("desktop_integration_icon_slicer_path", GUI::format("%1%/images/%2%OrcaSlicer%3%.png", target_dir_icons, icon_theme_path, version_suffix));
app_config->set("desktop_integration_icon_slicer_path", GUI::format("%1%/images/%2%Snapmaker_Orca%3%.png", target_dir_icons, icon_theme_path, version_suffix));
// desktop file
// iterate thru target_candidates to find applications folder
@@ -330,9 +330,9 @@ void DesktopIntegrationDialog::perform_desktop_integration()
// Write slicer desktop file
std::string desktop_file = GUI::format(
"[Desktop Entry]\n"
"Name=OrcaSlicer%1%\n"
"Name=Snapmaker_Orca%1%\n"
"GenericName=3D Printing Software\n"
"Icon=OrcaSlicer%2%\n"
"Icon=Snapmaker_Orca%2%\n"
"Exec=\"%3%\" %%F\n"
"Terminal=false\n"
"Type=Application\n"
@@ -340,24 +340,24 @@ void DesktopIntegrationDialog::perform_desktop_integration()
"Categories=Graphics;3DGraphics;Engineering;\n"
"Keywords=3D;Printing;Slicer;slice;3D;printer;convert;gcode;stl;obj;amf;SLA\n"
"StartupNotify=false\n"
"StartupWMClass=orca-slicer\n", name_suffix, version_suffix, excutable_path);
"StartupWMClass=snapmaker-orca\n", name_suffix, version_suffix, excutable_path);
std::string path = GUI::format("%1%/applications/OrcaSlicer%2%.desktop", target_dir_desktop, version_suffix);
std::string path = GUI::format("%1%/applications/Snapmaker_Orca%2%.desktop", target_dir_desktop, version_suffix);
if (create_desktop_file(path, desktop_file)){
BOOST_LOG_TRIVIAL(debug) << "OrcaSlicer.desktop file installation success.";
BOOST_LOG_TRIVIAL(debug) << "Snapmaker_Orca.desktop file installation success.";
break;
} else {
// write failed - try another path
BOOST_LOG_TRIVIAL(debug) << "Attempt to OrcaSlicer.desktop file installation failed. failed path: " << target_candidates[i];
BOOST_LOG_TRIVIAL(debug) << "Attempt to Snapmaker_Orca.desktop file installation failed. failed path: " << target_candidates[i];
target_dir_desktop.clear();
}
// if all failed - try creating default home folder
if (i == target_candidates.size() - 1) {
// create $HOME/.local/share
create_path(into_u8(wxFileName::GetHomeDir()), ".local/share/applications");
create_path(boost::nowide::narrow(wxFileName::GetHomeDir()), ".local/share/applications");
// create desktop file
target_dir_desktop = GUI::format("%1%/.local/share",wxFileName::GetHomeDir());
std::string path = GUI::format("%1%/applications/OrcaSlicer%2%.desktop", target_dir_desktop, version_suffix);
std::string path = GUI::format("%1%/applications/Snapmaker_Orca%2%.desktop", target_dir_desktop, version_suffix);
if (contains_path_dir(target_dir_desktop, "applications")) {
if (!create_desktop_file(path, desktop_file)) {
// Desktop file not written - end desktop integration
@@ -379,7 +379,7 @@ void DesktopIntegrationDialog::perform_desktop_integration()
return;
}
// save path to desktop file
app_config->set("desktop_integration_app_path", GUI::format("%1%/applications/OrcaSlicer%2%.desktop", target_dir_desktop, version_suffix));
app_config->set("desktop_integration_app_path", GUI::format("%1%/applications/Snapmaker_Orca%2%.desktop", target_dir_desktop, version_suffix));
// Repeat for Gcode viewer - use same paths as for slicer files
// Do NOT add gcode viewer desktop file on ChromeOS
@@ -387,8 +387,8 @@ void DesktopIntegrationDialog::perform_desktop_integration()
// Icon
if (!target_dir_icons.empty())
{
std::string icon_path = GUI::format("%1%/images/OrcaSlicer-gcodeviewer_192px.png",resources_dir());
std::string dest_path = GUI::format("%1%/images/%2%OrcaSlicer-gcodeviewer%3%.png", target_dir_icons, icon_theme_path, version_suffix);
std::string icon_path = GUI::format("%1%/images/Snapmaker_Orca-gcodeviewer_192px.png",resources_dir());
std::string dest_path = GUI::format("%1%/images/%2%Snapmaker_Orca-gcodeviewer%3%.png", target_dir_icons, icon_theme_path, version_suffix);
if (copy_icon(icon_path, dest_path))
// save path to icon
app_config->set("desktop_integration_icon_viewer_path", dest_path);
@@ -401,7 +401,7 @@ void DesktopIntegrationDialog::perform_desktop_integration()
"[Desktop Entry]\n"
"Name=Bambu Gcode Viewer%1%\n"
"GenericName=3D Printing Software\n"
"Icon=OrcaSlicer-gcodeviewer%2%\n"
"Icon=Snapmaker_Orca-gcodeviewer%2%\n"
"Exec=\"%3%\" --gcodeviewer %%F\n"
"Terminal=false\n"
"Type=Application\n"
@@ -410,13 +410,13 @@ void DesktopIntegrationDialog::perform_desktop_integration()
"Keywords=3D;Printing;Slicer;\n"
"StartupNotify=false\n", name_suffix, version_suffix, excutable_path);
std::string desktop_path = GUI::format("%1%/applications/OrcaSlicerGcodeViewer%2%.desktop", target_dir_desktop, version_suffix);
std::string desktop_path = GUI::format("%1%/applications/Snapmaker_OrcaGcodeViewer%2%.desktop", target_dir_desktop, version_suffix);
if (create_desktop_file(desktop_path, desktop_file))
// save path to desktop file
app_config->set("desktop_integration_app_viewer_path", desktop_path);
else {
BOOST_LOG_TRIVIAL(error) << "Performing desktop integration failed - could not create Gcodeviewer desktop file";
show_error(nullptr, _L("Performing desktop integration failed - could not create Gcodeviewer desktop file. OrcaSlicer desktop file was probably created successfully."));
show_error(nullptr, _L("Performing desktop integration failed - could not create Gcodeviewer desktop file. Snapmaker Orca desktop file was probably created successfully."));
}
}
@@ -531,7 +531,7 @@ void DesktopIntegrationDialog::perform_downloader_desktop_integration(std::strin
std::string desktop_file_downloader = GUI::format(
"[Desktop Entry]\n"
"Name=OrcaSlicer URL Protocol %1% %2%\n"
"Name=Snapmaker_Orca URL Protocol %1% %2%\n"
"Exec=%3% %%u\n"
"Terminal=false\n"
"Type=Application\n"
@@ -545,16 +545,16 @@ void DesktopIntegrationDialog::perform_downloader_desktop_integration(std::strin
if (contains_path_dir(target_candidates[i], "applications")) {
target_dir_desktop = target_candidates[i];
// Write slicer desktop file
std::string path = GUI::format("%1%/applications/OrcaSlicerURLProtocol-%2%%3%.desktop", target_dir_desktop, url_prefix, version_suffix);
std::string path = GUI::format("%1%/applications/Snapmaker_OrcaURLProtocol-%2%%3%.desktop", target_dir_desktop, url_prefix, version_suffix);
if (create_desktop_file(path, desktop_file_downloader)) {
app_config->set("desktop_integration_URL_path", path);
candidate_found = true;
BOOST_LOG_TRIVIAL(debug) << "OrcaSlicerURLProtocol.desktop file installation success.";
BOOST_LOG_TRIVIAL(debug) << "Snapmaker_OrcaURLProtocol.desktop file installation success.";
break;
}
else {
// write failed - try another path
BOOST_LOG_TRIVIAL(debug) << "Attempt to OrcaSlicerURLProtocol.desktop file installation failed. failed path: " << target_candidates[i];
BOOST_LOG_TRIVIAL(debug) << "Attempt to Snapmaker_OrcaURLProtocol.desktop file installation failed. failed path: " << target_candidates[i];
target_dir_desktop.clear();
}
}
@@ -562,10 +562,10 @@ void DesktopIntegrationDialog::perform_downloader_desktop_integration(std::strin
// if all failed - try creating default home folder
if (!candidate_found) {
// create $HOME/.local/share
create_path(into_u8(wxFileName::GetHomeDir()), ".local/share/applications");
create_path(boost::nowide::narrow(wxFileName::GetHomeDir()), ".local/share/applications");
// create desktop file
target_dir_desktop = GUI::format("%1%/.local/share", wxFileName::GetHomeDir());
std::string path = GUI::format("%1%/applications/OrcaSlicerURLProtocol-%2%%3%.desktop", target_dir_desktop, url_prefix, version_suffix);
std::string path = GUI::format("%1%/applications/Snapmaker_OrcaURLProtocol-%2%%3%.desktop", target_dir_desktop, url_prefix, version_suffix);
if (contains_path_dir(target_dir_desktop, "applications")) {
if (!create_desktop_file(path, desktop_file_downloader)) {
// Desktop file not written - end desktop integration
@@ -589,19 +589,19 @@ void DesktopIntegrationDialog::perform_downloader_desktop_integration(std::strin
}
// desktop file for downloader as part of main app
std::string desktop_path = GUI::format("%1%/applications/OrcaSlicerURLProtocol-%2%%3%.desktop", target_dir_desktop, url_prefix, version_suffix);
std::string desktop_path = GUI::format("%1%/applications/Snapmaker_OrcaURLProtocol-%2%%3%.desktop", target_dir_desktop, url_prefix, version_suffix);
if (create_desktop_file(desktop_path, desktop_file_downloader)) {
// save path to desktop file
app_config->set("desktop_integration_URL_path", desktop_path);
// finish registration on mime type
std::string command = GUI::format("xdg-mime default OrcaSlicerURLProtocol-%1%%2%.desktop x-scheme-handler/%1%", url_prefix, version_suffix);
std::string command = GUI::format("xdg-mime default Snapmaker_OrcaURLProtocol-%1%%2%.desktop x-scheme-handler/%1%", url_prefix, version_suffix);
BOOST_LOG_TRIVIAL(debug) << "system command: " << command;
int r = system(command.c_str());
BOOST_LOG_TRIVIAL(debug) << "system result: " << r;
}
// finish registration on mime type
std::string command = GUI::format("xdg-mime default OrcaSlicerURLProtocol-%1%%2%.desktop x-scheme-handler/%1%", url_prefix, version_suffix);
std::string command = GUI::format("xdg-mime default Snapmaker_OrcaURLProtocol-%1%%2%.desktop x-scheme-handler/%1%", url_prefix, version_suffix);
BOOST_LOG_TRIVIAL(debug) << "system command: " << command;
int r = system(command.c_str());
BOOST_LOG_TRIVIAL(debug) << "system result: " << r;