diff --git a/src/downloader/Download.hpp b/src/downloader/Download.hpp index 31762b5685..2b5da07357 100644 --- a/src/downloader/Download.hpp +++ b/src/downloader/Download.hpp @@ -14,7 +14,8 @@ enum DownloadState DownloadStopped, DownloadDone, DownloadError, - DownloadPaused + DownloadPaused, + DownloadStateUnknown }; class Download { diff --git a/src/downloader/DownloaderApp.cpp b/src/downloader/DownloaderApp.cpp index bdcc743afa..68e09b82b9 100644 --- a/src/downloader/DownloaderApp.cpp +++ b/src/downloader/DownloaderApp.cpp @@ -77,7 +77,8 @@ bool DownloadApp::OnInit() } m_frame = new DownloadFrame("Downloader", wxPoint(50, 50), wxSize(450, 340)); m_frame->Show(true); - + +#ifdef _WIN32 wxWindow::MSWRegisterMessageHandler(WM_COPYDATA, [](wxWindow* win, WXUINT /* nMsg */, WXWPARAM wParam, WXLPARAM lParam) { auto frame = dynamic_cast(win); COPYDATASTRUCT* copy_data_structure = { 0 }; @@ -88,6 +89,7 @@ bool DownloadApp::OnInit() } return true; }); +#endif return wxApp::OnInit(); } @@ -400,6 +402,7 @@ DownloadState DownloadFrame::get_download_state(int id) const return m_downloads[i]->get_state(); } } + return DownloadState::DownloadStateUnknown; } bool DownloadFrame::is_in_state(int id, DownloadState state) const @@ -409,6 +412,7 @@ bool DownloadFrame::is_in_state(int id, DownloadState state) const return m_downloads[i]->get_state() == state; } } + return false; } bool DownloadFrame::cancel_download(int id) @@ -471,6 +475,7 @@ wxString DownloadFrame::get_path_of(int id) const return m_downloads[i]->get_final_path().string(); } } + return wxString(); } wxString DownloadFrame::get_folder_path_of(int id) const @@ -480,6 +485,7 @@ wxString DownloadFrame::get_folder_path_of(int id) const return m_downloads[i]->get_final_path().parent_path().string(); } } + return wxString(); } void DownloadFrame::handle_message(const wxString& msg) diff --git a/src/downloader/InstanceSend.cpp b/src/downloader/InstanceSend.cpp index b93490fe3f..7ecab44457 100644 --- a/src/downloader/InstanceSend.cpp +++ b/src/downloader/InstanceSend.cpp @@ -217,22 +217,31 @@ bool execute_command(const wxString& command) bool SlicerSend::get_instance_exists() const { +#ifdef _WIN32 return !EnumWindows(EnumWindowsProcSlicer, 0); +#endif + return false; } bool SlicerSend::send_path(const wxString& path) const { +#ifdef _WIN32 std::string escaped = escape_strings_cstyle({ "prusa-downloader", boost::nowide::narrow(path) }); return send_message_slicer(boost::nowide::widen(escaped)); +#endif + return false; } bool SlicerSend::start_with_path(const wxString& path) const { +#ifdef _WIN32 // "C:\\Users\\User\\Downloads\\PrusaSlicer-2.4.2+win64-202204251110\\prusa-slicer.exe " std::string escaped = escape_strings_cstyle({ boost::nowide::narrow(path) }); //return execute_command(boost::nowide::widen(escaped)); std::string binary = (boost::dll::program_location().parent_path() / "prusa-slicer.exe").string() + " "; //return execute_command("C:\\Users\\User\\Downloads\\PrusaSlicer-2.4.2+win64-202204251110\\prusa-slicer.exe " + boost::nowide::widen(escaped)); return execute_command(boost::nowide::widen(binary) + boost::nowide::widen(escaped)); +#endif + return false; } bool SlicerSend::start_or_send(const wxString& path) const @@ -248,12 +257,18 @@ bool SlicerSend::start_or_send(const wxString& path) const bool DownloaderSend::get_instance_exists() const { +#ifdef _WIN32 return !EnumWindows(EnumWindowsProcDownloader, 0); +#endif + return false; } bool DownloaderSend::send_url(const wxString& url) const { +#ifdef _WIN32 //std::string escaped = escape_strings_cstyle({ boost::nowide::narrow(url) }); return send_message_downloader(url); +#endif + return false; } diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index 6954ce4621..f56e59e00a 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -1248,8 +1248,7 @@ PageUpdate::PageUpdate(ConfigWizard *parent) box_presets->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &event) { this->preset_update = event.IsChecked(); }); box_registry->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) { - //if(!event.IsChecked()) - // return; +#ifdef _WIN32 // Registry key creation for "prusaslicer://" URL boost::filesystem::path binary_path(resources_dir()); @@ -1272,7 +1271,7 @@ PageUpdate::PageUpdate(ConfigWizard *parent) } //key_full = "\"C:\\Program Files\\Prusa3D\\PrusaSlicer\\prusa-slicer-console.exe\" \"%1\""; key_full = key_string; - +#endif }); } diff --git a/src/slic3r/GUI/DesktopIntegrationDialog.cpp b/src/slic3r/GUI/DesktopIntegrationDialog.cpp index 7f99a505c6..9348c759ae 100644 --- a/src/slic3r/GUI/DesktopIntegrationDialog.cpp +++ b/src/slic3r/GUI/DesktopIntegrationDialog.cpp @@ -420,6 +420,34 @@ void DesktopIntegrationDialog::perform_desktop_integration() show_error(nullptr, _L("Performing desktop integration failed - could not create Gcodeviewer desktop file. PrusaSlicer desktop file was probably created successfully.")); } } + bool url_destop_file = true; + if (url_destop_file) + { + // no need for icon right? + std::string desktop_file = GUI::format( + "[Desktop Entry]\n" + "Name=PrusaSlicer URL Protocol%1%\n" + "Exec=\"%3%\" %%u\n" + "Terminal=false\n" + "Type=Application\n" + "MimeType=x-scheme-handler/prusaslicer;\n" + "StartupNotify=false\n" + , name_suffix, version_suffix, excutable_path); + + std::string desktop_path = GUI::format("%1%/applications/PrusaSlicerURLProtocol%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); + std::string command = GUI::format("xdg-mime default PrusaSlicerURLProtocol%1%.desktop x-scheme-handler/prusaslicer", version_suffix); + //std::string command = GUI::format("xdg-mime default PrusaSlicer%1%.desktop x-scheme-handler/prusaslicer", version_suffix); + BOOST_LOG_TRIVIAL(debug) << "system command: " << command; + int r = system(command.c_str()); + BOOST_LOG_TRIVIAL(debug) << "system result: " << r; + } else { + BOOST_LOG_TRIVIAL(error) << "Performing desktop integration failed - could not create URL Protocol desktop file"; + show_error(nullptr, _L("Performing desktop integration failed - could not create RL Protocol desktop file. PrusaSlicer desktop file was probably created successfully.")); + } + } wxGetApp().plater()->get_notification_manager()->push_notification(NotificationType::DesktopIntegrationSuccess); } diff --git a/src/slic3r/GUI/FileArchiveDialog.cpp b/src/slic3r/GUI/FileArchiveDialog.cpp index 522e83daed..31a085b8e7 100644 --- a/src/slic3r/GUI/FileArchiveDialog.cpp +++ b/src/slic3r/GUI/FileArchiveDialog.cpp @@ -201,7 +201,8 @@ FileArchiveDialog::FileArchiveDialog( mz_zip_archive* archive, std::vector&)> adjust_stack = [&adjust_stack, &reduce_stack, &avc = m_avc](boost::filesystem::path& file, std::vector& stack)->size_t { + std::function&)> adjust_stack = [&adjust_stack, &reduce_stack, &avc = m_avc](const boost::filesystem::path& const_file, std::vector& stack)->size_t { + boost::filesystem::path file(const_file); size_t struct_size = file.has_parent_path() ? adjust_stack(file.parent_path(), stack) : 0; if (stack.size() > struct_size && (file.has_extension() || file.filename().string() != stack[struct_size]->get_name())) @@ -209,7 +210,7 @@ FileArchiveDialog::FileArchiveDialog( mz_zip_archive* archive, std::vectorget_model()->AddFile(stack.empty() ? nullptr : stack.back(), boost::nowide::widen(file.filename().string()))); + stack.push_back(avc->get_model()->AddFile(stack.empty() ? nullptr : stack.back(), file.filename().string())); // filename string to wstring? return struct_size + 1; }; @@ -230,7 +231,7 @@ FileArchiveDialog::FileArchiveDialog( mz_zip_archive* archive, std::vectorget_model()->AddFile(parent, boost::nowide::widen(path.filename().string()))->set_fullpath(std::move(path)); + m_avc->get_model()->AddFile(parent, path.filename().string())->set_fullpath(std::move(path)); // filename string to wstring? } } diff --git a/src/slic3r/GUI/FileArchiveDialog.hpp b/src/slic3r/GUI/FileArchiveDialog.hpp index 70c507c94a..3404042930 100644 --- a/src/slic3r/GUI/FileArchiveDialog.hpp +++ b/src/slic3r/GUI/FileArchiveDialog.hpp @@ -4,8 +4,10 @@ #include "GUI_Utils.hpp" #include "libslic3r/miniz_extension.hpp" +#include #include - +#include +#include "wxExtensions.hpp" namespace Slic3r { namespace GUI {