mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-24 17:26:47 +00:00
Merge branch 'main' into feat/plugin-lifecycle-evts
This commit is contained in:
+29
-234
@@ -3,14 +3,24 @@
|
||||
#include "libslic3r/Technologies.hpp"
|
||||
#include "libslic3r/Platform.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "BindDialog.hpp"
|
||||
#include "DeviceManager.hpp"
|
||||
#include "HMS.hpp"
|
||||
#include "PresetBundleDialog.hpp"
|
||||
#include "WebUserLoginDialog.hpp"
|
||||
#include "WebViewDialog.hpp"
|
||||
#include "slic3r/Utils/BBLCloudServiceAgent.hpp"
|
||||
#include "slic3r/Utils/NetworkAgent.hpp"
|
||||
#include "GUI_Init.hpp"
|
||||
#include "GUI_ObjectList.hpp"
|
||||
#include "slic3r/GUI/UserManager.hpp"
|
||||
#include "slic3r/GUI/TaskManager.hpp"
|
||||
#include "format.hpp"
|
||||
#include "libslic3r_version.h"
|
||||
#include "BuildCommit.hpp"
|
||||
#include "Downloader.hpp"
|
||||
#include <boost/chrono/duration.hpp>
|
||||
#include <boost/locale/encoding_utf.hpp>
|
||||
#include <boost/log/detail/native_typeof.hpp>
|
||||
#include <libslic3r/Config.hpp>
|
||||
#include <mutex>
|
||||
@@ -596,7 +606,7 @@ wxString file_wildcards(FileType file_type, const std::string &custom_extension)
|
||||
static std::string libslic3r_translate_callback(const char *s) { return wxGetTranslation(wxString(s, wxConvUTF8)).utf8_str().data(); }
|
||||
|
||||
#ifdef WIN32
|
||||
static GUID GUID_DEVINTERFACE_HID = { 0x4D1E55B2, 0xF16F, 0x11CF, 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 };
|
||||
static GUID GUID_DEVINTERFACE_HID = { 0x4D1E55B2, 0xF16F, 0x11CF, { 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 } };
|
||||
|
||||
static void register_win32_device_notification_event()
|
||||
{
|
||||
@@ -2602,7 +2612,7 @@ void GUI_App::init_app_config()
|
||||
set_log_path_and_level(log_filename, 3);
|
||||
#endif
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("gui mode, Current OrcaSlicer Version %1% build %2%") % SoftFever_VERSION % GIT_COMMIT_HASH;
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("gui mode, Current OrcaSlicer Version %1% build %2%") % SoftFever_VERSION % build_commit_label;
|
||||
|
||||
//BBS: remove GCodeViewer as seperate APP logic
|
||||
if (!app_config)
|
||||
@@ -2663,7 +2673,7 @@ std::string GUI_App::get_bbl_client_version()
|
||||
void GUI_App::on_start_subscribe_again(std::string dev_id)
|
||||
{
|
||||
auto start_subscribe_timer = new wxTimer(this, wxID_ANY);
|
||||
Bind(wxEVT_TIMER, [this, start_subscribe_timer, dev_id](auto& e) {
|
||||
Bind(wxEVT_TIMER, [start_subscribe_timer, dev_id](auto& e) {
|
||||
start_subscribe_timer->Stop();
|
||||
Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) return;
|
||||
@@ -3253,7 +3263,7 @@ bool GUI_App::on_init_inner()
|
||||
}
|
||||
});
|
||||
|
||||
Bind(EVT_SHOW_NO_NEW_VERSION, [this](const wxCommandEvent& evt) {
|
||||
Bind(EVT_SHOW_NO_NEW_VERSION, [](const wxCommandEvent& evt) {
|
||||
wxString msg = _L("This is the newest version.");
|
||||
InfoDialog dlg(nullptr, _L("Info"), msg);
|
||||
dlg.ShowModal();
|
||||
@@ -5278,7 +5288,7 @@ std::string GUI_App::handle_web_request(std::string cmd)
|
||||
}
|
||||
}
|
||||
else if (command_str.compare("begin_network_plugin_download") == 0) {
|
||||
CallAfter([this] { wxGetApp().ShowDownNetPluginDlg(); });
|
||||
CallAfter([] { wxGetApp().ShowDownNetPluginDlg(); });
|
||||
}
|
||||
else if (command_str.compare("get_web_shortcut") == 0) {
|
||||
if (root.get_child_optional("key_event") != boost::none) {
|
||||
@@ -6828,7 +6838,7 @@ bool GUI_App::check_preset_parent_available(const std::pair<std::string, std::ma
|
||||
|
||||
void GUI_App::add_pending_vendor_preset(const std::pair<std::string, std::map<std::string, std::string>>& preset_data)
|
||||
{
|
||||
Preset::Type type;
|
||||
Preset::Type type = Preset::Type::TYPE_INVALID;
|
||||
if (preset_data.second.at(BBL_JSON_KEY_TYPE) == PRESET_IOT_PRINT_TYPE)
|
||||
type = Preset::Type::TYPE_PRINT;
|
||||
else if (preset_data.second.at(BBL_JSON_KEY_TYPE) == PRESET_IOT_PRINTER_TYPE)
|
||||
@@ -7789,21 +7799,6 @@ void GUI_App::stop_http_server()
|
||||
m_http_server.stop();
|
||||
}
|
||||
|
||||
void GUI_App::switch_staff_pick(bool on)
|
||||
{
|
||||
mainframe->m_webview->SendDesignStaffpick(on);
|
||||
}
|
||||
|
||||
bool GUI_App::switch_language()
|
||||
{
|
||||
if (select_language()) {
|
||||
recreate_GUI(_L("Switching application language") + dots);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
static const wxLanguageInfo* linux_get_existing_locale_language(const wxLanguageInfo* language,
|
||||
const wxLanguageInfo* system_language)
|
||||
@@ -7898,72 +7893,6 @@ int GUI_App::GetSingleChoiceIndex(const wxString& message,
|
||||
#endif
|
||||
}
|
||||
|
||||
// select language from the list of installed languages
|
||||
bool GUI_App::select_language()
|
||||
{
|
||||
wxArrayString translations = wxTranslations::Get()->GetAvailableTranslations(SLIC3R_APP_KEY);
|
||||
std::vector<const wxLanguageInfo*> language_infos;
|
||||
language_infos.emplace_back(wxLocale::GetLanguageInfo(wxLANGUAGE_ENGLISH));
|
||||
for (size_t i = 0; i < translations.GetCount(); ++ i) {
|
||||
const wxLanguageInfo *langinfo = wxLocale::FindLanguageInfo(translations[i]);
|
||||
if (langinfo != nullptr)
|
||||
language_infos.emplace_back(langinfo);
|
||||
}
|
||||
sort_remove_duplicates(language_infos);
|
||||
std::sort(language_infos.begin(), language_infos.end(), [](const wxLanguageInfo* l, const wxLanguageInfo* r) { return l->Description < r->Description; });
|
||||
|
||||
wxArrayString names;
|
||||
names.Alloc(language_infos.size());
|
||||
|
||||
// Some valid language should be selected since the application start up.
|
||||
const wxString active_language_code = current_language_code();
|
||||
const wxLanguageInfo* active_language_info = wxLocale::FindLanguageInfo(active_language_code);
|
||||
const wxLanguage current_language = active_language_info != nullptr ? wxLanguage(active_language_info->Language) : wxLanguage(m_wxLocale->GetLanguage());
|
||||
const wxString active_lang_prefix = active_language_code.BeforeFirst('_');
|
||||
int init_selection = -1;
|
||||
int init_selection_alt = -1;
|
||||
int init_selection_default = -1;
|
||||
for (size_t i = 0; i < language_infos.size(); ++ i) {
|
||||
if (wxLanguage(language_infos[i]->Language) == current_language)
|
||||
// The dictionary matches the active language and country.
|
||||
init_selection = i;
|
||||
else if ((language_infos[i]->CanonicalName.BeforeFirst('_') == active_lang_prefix) ||
|
||||
// if the active language is Slovak, mark the Czech language as active.
|
||||
(language_infos[i]->CanonicalName.BeforeFirst('_') == "cs" && active_lang_prefix == "sk"))
|
||||
// The dictionary matches the active language, it does not necessarily match the country.
|
||||
init_selection_alt = i;
|
||||
if (language_infos[i]->CanonicalName.BeforeFirst('_') == "en")
|
||||
// This will be the default selection if the active language does not match any dictionary.
|
||||
init_selection_default = i;
|
||||
names.Add(language_infos[i]->Description);
|
||||
}
|
||||
if (init_selection == -1)
|
||||
// This is the dictionary matching the active language.
|
||||
init_selection = init_selection_alt;
|
||||
if (init_selection != -1)
|
||||
// This is the language to highlight in the choice dialog initially.
|
||||
init_selection_default = init_selection;
|
||||
|
||||
const long index = GetSingleChoiceIndex(_L("Select the language"), _L("Language"), names, init_selection_default);
|
||||
// Try to load a new language.
|
||||
if (index != -1 && (init_selection == -1 || init_selection != index)) {
|
||||
const wxLanguageInfo *new_language_info = language_infos[index];
|
||||
if (this->load_language(new_language_info->CanonicalName, false)) {
|
||||
// Save language at application config.
|
||||
// Which language to save as the selected dictionary language?
|
||||
// 1) Hopefully the language set to wxTranslations by this->load_language(), but that API is weird and we don't want to rely on its
|
||||
// stability in the future:
|
||||
// wxTranslations::Get()->GetBestTranslation(SLIC3R_APP_KEY, wxLANGUAGE_ENGLISH);
|
||||
// 2) Current locale language may not match the dictionary name, see GH issue #3901
|
||||
// m_wxLocale->GetCanonicalName()
|
||||
// 3) new_language_info->CanonicalName is a safe bet. It points to a valid dictionary name.
|
||||
app_config->set("language", new_language_info->CanonicalName.ToUTF8().data());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Load gettext translation files and activate them at the start of the application,
|
||||
// based on the "language" key stored in the application config.
|
||||
@@ -8319,7 +8248,7 @@ bool GUI_App::show_modal_ip_address_enter_dialog(bool input_sn, wxString title)
|
||||
dlg.set_machine_obj(obj);
|
||||
if (!title.empty()) dlg.update_title(title);
|
||||
|
||||
dlg.Bind(EVT_ENTER_IP_ADDRESS, [this, obj](wxCommandEvent& e) {
|
||||
dlg.Bind(EVT_ENTER_IP_ADDRESS, [obj](wxCommandEvent& e) {
|
||||
auto selection_data_arr = wxSplit(e.GetString().ToStdString(), '|');
|
||||
|
||||
if (selection_data_arr.size() == 2) {
|
||||
@@ -8350,146 +8279,6 @@ void GUI_App::show_ip_address_enter_dialog_handler(wxCommandEvent& evt)
|
||||
show_modal_ip_address_enter_dialog(mode == -1?false:true, title);
|
||||
}
|
||||
|
||||
//void GUI_App::add_config_menu(wxMenuBar *menu)
|
||||
//void GUI_App::add_config_menu(wxMenu *menu)
|
||||
//{
|
||||
// auto local_menu = new wxMenu();
|
||||
// wxWindowID config_id_base = wxWindow::NewControlId(int(ConfigMenuCnt));
|
||||
//
|
||||
// const auto config_wizard_name = _(ConfigWizard::name(true));
|
||||
// const auto config_wizard_tooltip = from_u8((boost::format(_utf8(L("Open %s"))) % config_wizard_name).str());
|
||||
// // Cmd+, is standard on OS X - what about other operating systems?
|
||||
// if (is_editor()) {
|
||||
// local_menu->Append(config_id_base + ConfigMenuWizard, config_wizard_name + dots, config_wizard_tooltip);
|
||||
// local_menu->Append(config_id_base + ConfigMenuUpdate, _L("Check for Configuration Updates"), _L("Check for configuration updates"));
|
||||
// local_menu->AppendSeparator();
|
||||
// }
|
||||
// local_menu->Append(config_id_base + ConfigMenuPreferences, _L("Preferences") + dots +
|
||||
//#ifdef __APPLE__
|
||||
// "\tCtrl+,",
|
||||
//#else
|
||||
// "\tCtrl+P",
|
||||
//#endif
|
||||
// _L("Application preferences"));
|
||||
// wxMenu* mode_menu = nullptr;
|
||||
// if (is_editor()) {
|
||||
// local_menu->AppendSeparator();
|
||||
// mode_menu = new wxMenu();
|
||||
// mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeSimple, _L("Simple"), _L("Simple Mode"));
|
||||
// mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeAdvanced, _L("Advanced"), _L("Advanced Mode"));
|
||||
// Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if (get_mode() == comSimple) evt.Check(true); }, config_id_base + ConfigMenuModeSimple);
|
||||
// Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if (get_mode() == comAdvanced) evt.Check(true); }, config_id_base + ConfigMenuModeAdvanced);
|
||||
//
|
||||
// local_menu->AppendSubMenu(mode_menu, _L("Mode"), wxString::Format(_L("%s Mode"), SLIC3R_APP_NAME));
|
||||
// }
|
||||
// local_menu->AppendSeparator();
|
||||
// local_menu->Append(config_id_base + ConfigMenuLanguage, _L("Language"));
|
||||
// if (is_editor()) {
|
||||
// local_menu->AppendSeparator();
|
||||
// }
|
||||
//
|
||||
// local_menu->Bind(wxEVT_MENU, [this, config_id_base](wxEvent &event) {
|
||||
// switch (event.GetId() - config_id_base) {
|
||||
// case ConfigMenuWizard:
|
||||
// run_wizard(ConfigWizard::RR_USER);
|
||||
// break;
|
||||
// case ConfigMenuUpdate:
|
||||
// check_updates(true);
|
||||
// break;
|
||||
//#ifdef __linux__
|
||||
// case ConfigMenuDesktopIntegration:
|
||||
// show_desktop_integration_dialog();
|
||||
// break;
|
||||
//#endif
|
||||
// case ConfigMenuSnapshots:
|
||||
// //BBS do not support task snapshot
|
||||
// break;
|
||||
// case ConfigMenuPreferences:
|
||||
// {
|
||||
// //BBS GUI refactor: remove unuse layout logic
|
||||
// //bool app_layout_changed = false;
|
||||
// {
|
||||
// // the dialog needs to be destroyed before the call to recreate_GUI()
|
||||
// // or sometimes the application crashes into wxDialogBase() destructor
|
||||
// // so we put it into an inner scope
|
||||
// PreferencesDialog dlg(mainframe);
|
||||
// dlg.ShowModal();
|
||||
// //BBS GUI refactor: remove unuse layout logic
|
||||
// //app_layout_changed = dlg.settings_layout_changed();
|
||||
// if (dlg.seq_top_layer_only_changed())
|
||||
// this->plater_->refresh_print();
|
||||
//
|
||||
// if (dlg.recreate_GUI()) {
|
||||
// recreate_GUI(_L("Restart application") + dots);
|
||||
// return;
|
||||
// }
|
||||
//#ifdef _WIN32
|
||||
// if (is_editor()) {
|
||||
// if (app_config->get("associate_3mf") == "true")
|
||||
// associate_3mf_files();
|
||||
// if (app_config->get("associate_stl") == "true")
|
||||
// associate_stl_files();
|
||||
// }
|
||||
// else {
|
||||
// if (app_config->get("associate_gcode") == "true")
|
||||
// associate_gcode_files();
|
||||
// }
|
||||
//#endif // _WIN32
|
||||
// }
|
||||
// //BBS GUI refactor: remove unuse layout logic
|
||||
// /*if (app_layout_changed) {
|
||||
// // hide full main_sizer for mainFrame
|
||||
// mainframe->GetSizer()->Show(false);
|
||||
// mainframe->update_layout();
|
||||
// mainframe->select_tab(size_t(0));
|
||||
// }*/
|
||||
// break;
|
||||
// }
|
||||
// case ConfigMenuLanguage:
|
||||
// {
|
||||
// /* Before change application language, let's check unsaved changes on 3D-Scene
|
||||
// * and draw user's attention to the application restarting after a language change
|
||||
// */
|
||||
// {
|
||||
// // the dialog needs to be destroyed before the call to switch_language()
|
||||
// // or sometimes the application crashes into wxDialogBase() destructor
|
||||
// // so we put it into an inner scope
|
||||
// wxString title = is_editor() ? wxString(SLIC3R_APP_NAME) : wxString(GCODEVIEWER_APP_NAME);
|
||||
// title += " - " + _L("Choose language");
|
||||
// //wxMessageDialog dialog(nullptr,
|
||||
// MessageDialog dialog(nullptr,
|
||||
// _L("Switching the language requires application restart.\n") + "\n\n" +
|
||||
// _L("Do you want to continue?"),
|
||||
// title,
|
||||
// wxICON_QUESTION | wxOK | wxCANCEL);
|
||||
// if (dialog.ShowModal() == wxID_CANCEL)
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// switch_language();
|
||||
// break;
|
||||
// }
|
||||
// case ConfigMenuFlashFirmware:
|
||||
// //BBS FirmwareDialog::run(mainframe);
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// using std::placeholders::_1;
|
||||
//
|
||||
// if (mode_menu != nullptr) {
|
||||
// auto modfn = [this](int mode, wxCommandEvent&) { if (get_mode() != mode) save_mode(mode); };
|
||||
// mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comSimple, _1), config_id_base + ConfigMenuModeSimple);
|
||||
// mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comAdvanced, _1), config_id_base + ConfigMenuModeAdvanced);
|
||||
// }
|
||||
//
|
||||
// // BBS
|
||||
// //menu->Append(local_menu, _L("Configuration"));
|
||||
// menu->AppendSubMenu(local_menu, _L("Configuration"));
|
||||
//}
|
||||
|
||||
void GUI_App::open_presetbundledialog(size_t open_on_tab, const std::string& highlight_option)
|
||||
{
|
||||
bool app_layout_changed = false;
|
||||
@@ -8799,7 +8588,7 @@ bool GUI_App::check_and_keep_current_preset_changes(const wxString& caption, con
|
||||
if (!no_need_change && dlg.ShowModal() == wxID_CANCEL)
|
||||
return false;
|
||||
|
||||
auto reset_modifications = [this, is_called_from_configwizard]() {
|
||||
auto reset_modifications = [this]() {
|
||||
//if (is_called_from_configwizard)
|
||||
// return; // no need to discared changes. It will be done fromConfigWizard closing
|
||||
|
||||
@@ -8928,10 +8717,16 @@ void GUI_App::load_current_presets(bool active_preset_combox/*= false*/, bool ch
|
||||
auto* nozzle_diameter = edited_printer_preset.config.option<ConfigOptionFloats>("nozzle_diameter");
|
||||
if (nozzle_diameter) {
|
||||
// Mixed-color slots are virtual filaments kept at the tail of the list, so they have no
|
||||
// nozzle of their own. Sizing to the nozzle count alone would silently drop the mixes of
|
||||
// a just-loaded project, and update_extruder_count() would then strip the facets painted
|
||||
// with them.
|
||||
preset_bundle->set_num_filaments(nozzle_diameter->values.size() + preset_bundle->num_mixed_filaments());
|
||||
// nozzle of their own and the count has to allow for them. Only ever grow: this sizes
|
||||
// the list so the combo boxes have something to bind to, and set_num_filaments() trims
|
||||
// at the raw tail, so shrinking here would eat the mixes rather than the surplus
|
||||
// physical slots. A list longer than the nozzle count is a state the app reaches
|
||||
// legitimately - raising the extruder count and not saving the printer preset leaves
|
||||
// exactly that on the next start - and losing the project's mixes to it is worse than
|
||||
// carrying a filament the printer has no nozzle for until the count is next changed.
|
||||
const size_t target = nozzle_diameter->values.size() + preset_bundle->num_mixed_filaments();
|
||||
if (target > preset_bundle->filament_presets.size())
|
||||
preset_bundle->set_num_filaments(target);
|
||||
}
|
||||
}
|
||||
this->plater()->set_printer_technology(printer_technology);
|
||||
@@ -9432,7 +9227,7 @@ int GUI_App::filaments_cnt() const
|
||||
PrintSequence GUI_App::global_print_sequence() const
|
||||
{
|
||||
PrintSequence global_print_seq = PrintSequence::ByDefault;
|
||||
auto curr_preset_config = preset_bundle->prints.get_edited_preset().config;
|
||||
const auto &curr_preset_config = preset_bundle->prints.get_edited_preset().config;
|
||||
if (curr_preset_config.has("print_sequence"))
|
||||
global_print_seq = curr_preset_config.option<ConfigOptionEnum<PrintSequence>>("print_sequence")->value;
|
||||
return global_print_seq;
|
||||
|
||||
Reference in New Issue
Block a user