diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 0a07cb6f99..93e274d0d2 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -824,7 +824,7 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab #if ENABLE_ENVIRONMENT_MAP unsigned int environment_texture_id = GUI::wxGetApp().plater()->get_environment_texture_id(); - bool use_environment_texture = environment_texture_id > 0 && GUI::wxGetApp().app_config->get("use_environment_map") == "1"; + bool use_environment_texture = environment_texture_id > 0 && GUI::wxGetApp().app_config->get_bool("use_environment_map"); shader->set_uniform("use_environment_tex", use_environment_texture); if (use_environment_texture) glsafe(::glBindTexture(GL_TEXTURE_2D, environment_texture_id)); @@ -869,7 +869,7 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab shader->stop_using(); if (edges_shader != nullptr) { edges_shader->start_using(); - if (m_show_non_manifold_edges && GUI::wxGetApp().app_config->get("non_manifold_edges") == "1") { + if (m_show_non_manifold_edges && GUI::wxGetApp().app_config->get_bool("non_manifold_edges")) { for (GLVolumeWithIdAndZ& volume : to_render) { volume.first->render_non_manifold_edges(); } diff --git a/src/slic3r/GUI/Camera.cpp b/src/slic3r/GUI/Camera.cpp index 62b9729ec5..4152ca3585 100644 --- a/src/slic3r/GUI/Camera.cpp +++ b/src/slic3r/GUI/Camera.cpp @@ -283,7 +283,7 @@ void Camera::debug_render() const imgui.begin(std::string("Camera statistics"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse); std::string type = get_type_as_string(); - if (wxGetApp().plater()->get_mouse3d_controller().connected() || (wxGetApp().app_config->get("use_free_camera") == "1")) + if (wxGetApp().plater()->get_mouse3d_controller().connected() || (wxGetApp().app_config->get_bool("use_free_camera"))) type += "/free"; else type += "/constrained"; diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index be1e02b84b..2a17df8a13 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -1298,7 +1298,7 @@ PageUpdate::PageUpdate(ConfigWizard *parent) append_spacer(VERTICAL_SPACING); auto *box_presets = new wxCheckBox(this, wxID_ANY, _L("Update built-in Presets automatically")); - box_presets->SetValue(app_config->get("preset_update") == "1"); + box_presets->SetValue(app_config->get_bool("preset_update")); append(box_presets); append_text(wxString::Format(_L( "If enabled, %s downloads updates of built-in system presets in the background." @@ -1416,7 +1416,7 @@ PageDownloader::PageDownloader(ConfigWizard* parent) auto* box_allow_downloads = new wxCheckBox(this, wxID_ANY, _L("Allow build-in downloader")); // TODO: Do we want it like this? The downloader is allowed for very first time the wizard is run. - bool box_allow_value = (app_config->has("downloader_url_registered") ? app_config->get("downloader_url_registered") == "1" : true); + bool box_allow_value = (app_config->has("downloader_url_registered") ? app_config->get_bool("downloader_url_registered") : true); box_allow_downloads->SetValue(box_allow_value); append(box_allow_downloads); @@ -1517,7 +1517,7 @@ void DownloaderUtils::Worker::deregister() bool DownloaderUtils::Worker::on_finish() { AppConfig* app_config = wxGetApp().app_config; - bool ac_value = app_config->get("downloader_url_registered") == "1"; + bool ac_value = app_config->get_bool("downloader_url_registered"); BOOST_LOG_TRIVIAL(debug) << "PageDownloader::on_finish_downloader ac_value " << ac_value << " downloader_checked " << downloader_checked; if (ac_value && downloader_checked) { // already registered but we need to do it again @@ -1546,7 +1546,7 @@ PageReloadFromDisk::PageReloadFromDisk(ConfigWizard* parent) , full_pathnames(false) { auto* box_pathnames = new wxCheckBox(this, wxID_ANY, _L("Export full pathnames of models and parts sources into 3mf and amf files")); - box_pathnames->SetValue(wxGetApp().app_config->get("export_sources_full_pathnames") == "1"); + box_pathnames->SetValue(wxGetApp().app_config->get_bool("export_sources_full_pathnames")); append(box_pathnames); append_text(_L( "If enabled, allows the Reload from disk command to automatically find and load the files when invoked.\n" @@ -1595,7 +1595,7 @@ PageMode::PageMode(ConfigWizard *parent) append_text("\n" + _L("The size of the object can be specified in inches")); check_inch = new wxCheckBox(this, wxID_ANY, _L("Use inches")); - check_inch->SetValue(wxGetApp().app_config->get("use_inches") == "1"); + check_inch->SetValue(wxGetApp().app_config->get_bool("use_inches")); append(check_inch); on_activate(); diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index b6d4fb9859..186f1f4fff 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -2373,7 +2373,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool statistics->models_instances_size = 0; #endif // ENABLE_GCODE_VIEWER_STATISTICS - const bool top_layer_only = get_app_config()->get("seq_top_layer_only") == "1"; + const bool top_layer_only = get_app_config()->get_bool("seq_top_layer_only"); SequentialView::Endpoints global_endpoints = { m_moves_count , 0 }; SequentialView::Endpoints top_layer_endpoints = global_endpoints; @@ -3221,7 +3221,7 @@ void GCodeViewer::render_legend(float& legend_height) const float icon_size = ImGui::GetTextLineHeight(); const float percent_bar_size = 2.0f * ImGui::GetTextLineHeight(); - bool imperial_units = wxGetApp().app_config->get("use_inches") == "1"; + bool imperial_units = wxGetApp().app_config->get_bool("use_inches"); auto append_item = [icon_size, percent_bar_size, &imgui, imperial_units](EItemType type, const ColorRGBA& color, const std::string& label, bool visible = true, const std::string& time = "", float percent = 0.0f, float max_percent = 0.0f, const std::array& offsets = { 0.0f, 0.0f, 0.0f, 0.0f }, diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 8809624343..48e614a39f 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2308,7 +2308,7 @@ void GLCanvas3D::on_char(wxKeyEvent& evt) #endif /* __APPLE__ */ { #ifdef _WIN32 - if (wxGetApp().app_config->get("use_legacy_3DConnexion") == "1") { + if (wxGetApp().app_config->get_bool("use_legacy_3DConnexion")) { #endif //_WIN32 #ifdef __APPLE__ // On OSX use Cmd+Shift+M to "Show/Hide 3Dconnexion devices settings dialog" @@ -2783,7 +2783,7 @@ void GLCanvas3D::on_mouse_wheel(wxMouseEvent& evt) return; // Calculate the zoom delta and apply it to the current zoom factor - double direction_factor = (wxGetApp().app_config->get("reverse_mouse_wheel_zoom") == "1") ? -1.0 : 1.0; + double direction_factor = wxGetApp().app_config->get_bool("reverse_mouse_wheel_zoom") ? -1.0 : 1.0; _update_camera_zoom(direction_factor * (double)evt.GetWheelRotation() / (double)evt.GetWheelDelta()); } @@ -3212,7 +3212,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) if (!m_moving) { if ((any_gizmo_active || evt.CmdDown() || m_hover_volume_idxs.empty()) && m_mouse.is_start_position_3D_defined()) { const Vec3d rot = (Vec3d(pos.x(), pos.y(), 0.0) - m_mouse.drag.start_position_3D) * (PI * TRACKBALLSIZE / 180.0); - if (wxGetApp().app_config->get("use_free_camera") == "1") + if (wxGetApp().app_config->get_bool("use_free_camera")) // Virtual track ball (similar to the 3DConnexion mouse). wxGetApp().plater()->get_camera().rotate_local_around_target(Vec3d(rot.y(), rot.x(), 0.0)); else { @@ -3238,7 +3238,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) const Vec3d cur_pos = _mouse_to_3d(pos, &z); const Vec3d orig = _mouse_to_3d(m_mouse.drag.start_position_2D, &z); Camera& camera = wxGetApp().plater()->get_camera(); - if (wxGetApp().app_config->get("use_free_camera") != "1") + if (!wxGetApp().app_config->get_bool("use_free_camera")) // Forces camera right vector to be parallel to XY plane in case it has been misaligned using the 3D mouse free rotation. // It is cheaper to call this function right away instead of testing wxGetApp().plater()->get_mouse3d_controller().connected(), // which checks an atomics (flushes CPU caches). @@ -3806,7 +3806,7 @@ void GLCanvas3D::update_ui_from_settings() // Update OpenGL scaling on OSX after the user toggled the "use_retina_opengl" settings in Preferences dialog. const float orig_scaling = m_retina_helper->get_scale_factor(); - const bool use_retina = wxGetApp().app_config->get("use_retina_opengl") == "1"; + const bool use_retina = wxGetApp().app_config->get_bool("use_retina_opengl"); BOOST_LOG_TRIVIAL(debug) << "GLCanvas3D: Use Retina OpenGL: " << use_retina; m_retina_helper->set_use_retina(use_retina); const float new_scaling = m_retina_helper->get_scale_factor(); @@ -3821,7 +3821,7 @@ void GLCanvas3D::update_ui_from_settings() #endif // ENABLE_RETINA_GL if (wxGetApp().is_editor()) - wxGetApp().plater()->enable_collapse_toolbar(wxGetApp().app_config->get("show_collapse_button") == "1"); + wxGetApp().plater()->enable_collapse_toolbar(wxGetApp().app_config->get_bool("show_collapse_button")); } GLCanvas3D::WipeTowerInfo GLCanvas3D::get_wipe_tower_info() const @@ -4725,8 +4725,8 @@ bool GLCanvas3D::_init_main_toolbar() "\n" + "[" + GUI::shortkey_ctrl_prefix() + "4] - " + _u8L("Printer Settings Tab") ; item.sprite_id = 10; item.enabling_callback = GLToolbarItem::Default_Enabling_Callback; - item.visibility_callback = []() { return (wxGetApp().app_config->get("new_settings_layout_mode") == "1" || - wxGetApp().app_config->get("dlg_settings_layout_mode") == "1"); }; + item.visibility_callback = []() { return wxGetApp().app_config->get_bool("new_settings_layout_mode") || + wxGetApp().app_config->get_bool("dlg_settings_layout_mode"); }; item.left.action_callback = []() { wxGetApp().mainframe->select_tab(); }; if (!m_main_toolbar.add_item(item)) return false; diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 99a83cf42e..a4cfc0cb95 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1203,7 +1203,7 @@ bool GUI_App::on_init_inner() // Now this position is equal to the mainframe position wxPoint splashscreen_pos = wxDefaultPosition; bool default_splashscreen_pos = true; - if (app_config->has("window_mainframe") && app_config->get("restore_win_position") == "1") { + if (app_config->has("window_mainframe") && app_config->get_bool("restore_win_position")) { auto metrics = WindowMetrics::deserialize(app_config->get("window_mainframe")); default_splashscreen_pos = metrics == boost::none; if (!default_splashscreen_pos) @@ -1237,7 +1237,7 @@ bool GUI_App::on_init_inner() if (! older_data_dir_path.empty()) { preset_bundle->import_newer_configs(older_data_dir_path); - app_config->save(); + //app_config->save(); // It looks like redundant call of save. ysFIXME delete after testing } if (is_editor()) { @@ -1413,7 +1413,6 @@ bool GUI_App::on_init_inner() app_config->set("restore_win_position", "0"); else if (answer == wxID_NO) app_config->set("restore_win_position", "1"); - app_config->save(); } return true; @@ -2889,7 +2888,7 @@ void GUI_App::MacOpenFiles(const wxArrayString &fileNames) void GUI_App::MacOpenURL(const wxString& url) { - if (app_config && app_config->get("downloader_url_registered") != "1") + if (app_config && !app_config->get_bool("downloader_url_registered")) { BOOST_LOG_TRIVIAL(error) << "Recieved command to open URL, but it is not allowed in app configuration. URL: " << url; return; @@ -3167,6 +3166,9 @@ void GUI_App::window_pos_save(wxTopLevelWindow* window, const std::string &name) WindowMetrics metrics = WindowMetrics::from_window(window); app_config->set(config_key, metrics.serialize()); + // save changed app_config here, before all action related to a close of application is processed + if (app_config->dirty()) + app_config->save(); } void GUI_App::window_pos_restore(wxTopLevelWindow* window, const std::string &name, bool default_maximized) @@ -3187,7 +3189,7 @@ void GUI_App::window_pos_restore(wxTopLevelWindow* window, const std::string &na const wxRect& rect = metrics->get_rect(); - if (app_config->get("restore_win_position") == "1") { + if (app_config->get_bool("restore_win_position")) { // workaround for crash related to the positioning of the window on secondary monitor app_config->set("restore_win_position", (boost::format("crashed_at_%1%_pos") % name).str()); app_config->save(); @@ -3242,7 +3244,7 @@ bool GUI_App::config_wizard_startup() return true; } #ifndef __APPLE__ - else if (is_editor() && m_last_app_conf_lower_version && app_config->get("downloader_url_registered") == "1") { + else if (is_editor() && m_last_app_conf_lower_version && app_config->get_bool("downloader_url_registered")) { show_downloader_registration_dialog(); return true; } @@ -3302,11 +3304,11 @@ bool GUI_App::open_browser_with_warning_dialog(const wxString& url, wxWindow* pa } } if (launch) - launch = app_config->get(option_key) != "1"; + launch = !app_config->get_bool(option_key); } // warning dialog doesn't containe a "Remember my choice" checkbox // and will be shown only when "Suppress to open hyperlink in browser" is ON. - else if (app_config->get(option_key) == "1") { + else if (app_config->get_bool(option_key)) { MessageDialog dialog(parent, _L("Open hyperlink in default browser?"), _L("PrusaSlicer: Open hyperlink"), wxICON_QUESTION | wxYES_NO); launch = dialog.ShowModal() == wxID_YES; } diff --git a/src/slic3r/GUI/GUI_Init.cpp b/src/slic3r/GUI/GUI_Init.cpp index 882c288162..bf65ec8903 100644 --- a/src/slic3r/GUI/GUI_Init.cpp +++ b/src/slic3r/GUI/GUI_Init.cpp @@ -49,7 +49,7 @@ int GUI_Run(GUI_InitParams ¶ms) GUI::GUI_App* gui = new GUI::GUI_App(params.start_as_gcodeviewer ? GUI::GUI_App::EAppMode::GCodeViewer : GUI::GUI_App::EAppMode::Editor); if (gui->get_app_mode() != GUI::GUI_App::EAppMode::GCodeViewer) { // G-code viewer is currently not performing instance check, a new G-code viewer is started every time. - bool gui_single_instance_setting = gui->app_config->get("single_instance") == "1"; + bool gui_single_instance_setting = gui->app_config->get_bool("single_instance"); if (Slic3r::instance_check(params.argc, params.argv, gui_single_instance_setting)) { //TODO: do we have delete gui and other stuff? return -1; diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 81ec956eed..1906d2c307 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -1250,7 +1250,7 @@ bool ObjectList::can_drop(const wxDataViewItem& item) const if (dragged_item_v_type == item_v_type && dragged_item_v_type != ModelVolumeType::MODEL_PART) return true; - if ((wxGetApp().app_config->get("order_volumes") == "1" && dragged_item_v_type != item_v_type) || // we can't reorder volumes outside of types + if ((wxGetApp().app_config->get_bool("order_volumes") && dragged_item_v_type != item_v_type) || // we can't reorder volumes outside of types item_v_type >= ModelVolumeType::SUPPORT_BLOCKER) // support blockers/enforcers can't change its place return false; @@ -1855,7 +1855,7 @@ void ObjectList::load_mesh_object( new_object->add_instance(); // each object should have at list one instance ModelVolume* new_volume = new_object->add_volume(mesh); - new_object->sort_volumes(wxGetApp().app_config->get("order_volumes") == "1"); + new_object->sort_volumes(wxGetApp().app_config->get_bool("order_volumes")); new_volume->name = name; if (text_config) new_volume->text_configuration = *text_config; @@ -2327,7 +2327,7 @@ void ObjectList::merge(bool to_multipart_object) const Vec3d vol_offset = volume_offset_correction* new_volume->get_offset(); new_volume->set_offset(vol_offset); } - new_object->sort_volumes(wxGetApp().app_config->get("order_volumes") == "1"); + new_object->sort_volumes(wxGetApp().app_config->get_bool("order_volumes")); // merge settings auto new_opt_keys = config.keys(); @@ -4896,7 +4896,7 @@ void ObjectList::set_extruder_for_selected_items(const int extruder) const wxDataViewItemArray ObjectList::reorder_volumes_and_get_selection(size_t obj_idx, std::function add_to_selection/* = nullptr*/) { - (*m_objects)[obj_idx]->sort_volumes(wxGetApp().app_config->get("order_volumes") == "1"); + (*m_objects)[obj_idx]->sort_volumes(wxGetApp().app_config->get_bool("order_volumes")); wxDataViewItemArray items = add_volumes_to_object_in_list(obj_idx, std::move(add_to_selection)); @@ -4907,7 +4907,7 @@ wxDataViewItemArray ObjectList::reorder_volumes_and_get_selection(size_t obj_idx void ObjectList::apply_volumes_order() { - if (wxGetApp().app_config->get("order_volumes") != "1" || !m_objects) + if (!wxGetApp().app_config->get_bool("order_volumes") || !m_objects) return; for (size_t obj_idx = 0; obj_idx < m_objects->size(); obj_idx++) diff --git a/src/slic3r/GUI/GUI_ObjectManipulation.cpp b/src/slic3r/GUI/GUI_ObjectManipulation.cpp index c295eb8fb7..0375a3ce71 100644 --- a/src/slic3r/GUI/GUI_ObjectManipulation.cpp +++ b/src/slic3r/GUI/GUI_ObjectManipulation.cpp @@ -118,8 +118,8 @@ static const wxString axes_color_back[] = { "#f5dcdc", "#dcf5dc", "#dcdcf5" }; ObjectManipulation::ObjectManipulation(wxWindow* parent) : OG_Settings(parent, true) { - m_imperial_units = wxGetApp().app_config->get("use_inches") == "1"; - m_use_colors = wxGetApp().app_config->get("color_mapinulation_panel") == "1"; + m_imperial_units = wxGetApp().app_config->get_bool("use_inches"); + m_use_colors = wxGetApp().app_config->get_bool("color_mapinulation_panel"); m_manifold_warning_bmp = ScalableBitmap(parent, "exclamation"); @@ -642,8 +642,8 @@ void ObjectManipulation::DisableUnuniformScale() void ObjectManipulation::update_ui_from_settings() { - if (m_imperial_units != (wxGetApp().app_config->get("use_inches") == "1")) { - m_imperial_units = wxGetApp().app_config->get("use_inches") == "1"; + if (m_imperial_units != wxGetApp().app_config->get_bool("use_inches")) { + m_imperial_units = wxGetApp().app_config->get_bool("use_inches"); auto update_unit_text = [](const wxString& new_unit_text, wxStaticText* widget) { widget->SetLabel(new_unit_text); @@ -667,8 +667,8 @@ void ObjectManipulation::update_ui_from_settings() } m_check_inch->SetValue(m_imperial_units); - if (m_use_colors != (wxGetApp().app_config->get("color_mapinulation_panel") == "1")) { - m_use_colors = wxGetApp().app_config->get("color_mapinulation_panel") == "1"; + if (m_use_colors != wxGetApp().app_config->get_bool("color_mapinulation_panel")) { + m_use_colors = wxGetApp().app_config->get_bool("color_mapinulation_panel"); // update colors for edit-boxes int axis_id = 0; for (ManipulationEditor* editor : m_editors) { diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 7bfb252482..d9dfc7db22 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -537,7 +537,7 @@ void Preview::update_layers_slider(const std::vector& layers_z, bool kee // Suggest the auto color change, if model looks like sign if (!color_change_already_exists && - wxGetApp().app_config->get("allow_auto_color_change") == "1" && + wxGetApp().app_config->get_bool("allow_auto_color_change") && m_layers_slider->IsNewPrint()) { const Print& print = wxGetApp().plater()->fff_print(); diff --git a/src/slic3r/GUI/GUI_Utils.cpp b/src/slic3r/GUI/GUI_Utils.cpp index d9bffa3f45..fad47035b5 100644 --- a/src/slic3r/GUI/GUI_Utils.cpp +++ b/src/slic3r/GUI/GUI_Utils.cpp @@ -165,7 +165,7 @@ bool check_dark_mode() { #ifdef _WIN32 void update_dark_ui(wxWindow* window) { - bool is_dark = wxGetApp().app_config->get("dark_color_mode") == "1";// ? true : check_dark_mode();// #ysDarkMSW - Allow it when we deside to support the sustem colors for application + bool is_dark = wxGetApp().app_config->get_bool("dark_color_mode");// ? true : check_dark_mode();// #ysDarkMSW - Allow it when we deside to support the sustem colors for application window->SetBackgroundColour(is_dark ? wxColour(43, 43, 43) : wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); window->SetForegroundColour(is_dark ? wxColour(250, 250, 250) : wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp index 26a5a855dd..0798b61f49 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp @@ -1757,7 +1757,7 @@ void GLGizmoCut3D::validate_connector_settings() void GLGizmoCut3D::init_input_window_data(CutConnectors &connectors) { - m_imperial_units = wxGetApp().app_config->get("use_inches") == "1"; + m_imperial_units = wxGetApp().app_config->get_bool("use_inches"); m_label_width = m_imgui->get_font_size() * 6.f; m_control_width = m_imgui->get_font_size() * 9.f; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp index cebef8b42b..8ed451ae5b 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp @@ -2962,7 +2962,7 @@ void GLGizmoEmboss::draw_style_edit() { process(); } - bool use_inch = wxGetApp().app_config->get("use_inches") == "1"; + bool use_inch = wxGetApp().app_config->get_bool("use_inches"); draw_height(use_inch); draw_depth(use_inch); @@ -3299,7 +3299,7 @@ void GLGizmoEmboss::draw_advanced() &stored_style->prop.distance : nullptr; m_imgui->disabled_begin(!allowe_surface_distance); - bool use_inch = wxGetApp().app_config->get("use_inches") == "1"; + bool use_inch = wxGetApp().app_config->get_bool("use_inches"); const std::string undo_move_tooltip = _u8L("Undo translation"); const wxString move_tooltip = _L("Distance center of text from model surface"); bool is_moved = false; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp index fc99e52c08..ece59beca8 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp @@ -1205,7 +1205,7 @@ void GLGizmoMeasure::render_dimensioning() ss_to_ndc_matrix * Geometry::translation_transform(v2ss_3) * q12ss); m_dimensioning.triangle.render(); - const bool use_inches = wxGetApp().app_config->get("use_inches") == "1"; + const bool use_inches = wxGetApp().app_config->get_bool("use_inches"); const double curr_value = use_inches ? ObjectManipulation::mm_to_in * distance : distance; const std::string curr_value_str = format_double(curr_value); const std::string units = use_inches ? _u8L("in") : _u8L("mm"); @@ -1973,7 +1973,7 @@ void GLGizmoMeasure::on_render_input_window(float x, float y, float bottom_limit ImGui::EndTable(); } - const bool use_inches = wxGetApp().app_config->get("use_inches") == "1"; + const bool use_inches = wxGetApp().app_config->get_bool("use_inches"); const std::string units = use_inches ? " " + _u8L("in") : " " + _u8L("mm"); ImGui::Separator(); diff --git a/src/slic3r/GUI/HintNotification.cpp b/src/slic3r/GUI/HintNotification.cpp index df955fa93a..1f3d224919 100644 --- a/src/slic3r/GUI/HintNotification.cpp +++ b/src/slic3r/GUI/HintNotification.cpp @@ -883,7 +883,7 @@ void NotificationManager::HintNotification::render_close_button(ImGuiWrapper& im //render_right_arrow_button(imgui, win_size_x, win_size_y, win_pos_x, win_pos_y); render_logo(imgui, win_size_x, win_size_y, win_pos_x, win_pos_y); render_preferences_button(imgui, win_pos_x, win_pos_y); - if (!m_documentation_link.empty() && wxGetApp().app_config->get("suppress_hyperlinks") != "1") + if (!m_documentation_link.empty() && !wxGetApp().app_config->get_bool("suppress_hyperlinks")) { render_documentation_button(imgui, win_size_x, win_size_y, win_pos_x, win_pos_y); } diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 22c9256bd8..b656f056ae 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -272,7 +272,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S update_ui_from_settings(); // FIXME (?) if (m_plater != nullptr) { - m_plater->get_collapse_toolbar().set_enabled(wxGetApp().app_config->get("show_collapse_button") == "1"); + m_plater->get_collapse_toolbar().set_enabled(wxGetApp().app_config->get_bool("show_collapse_button")); m_plater->show_action_buttons(true); preferences_dialog = new PreferencesDialog(this); @@ -442,9 +442,9 @@ void MainFrame::update_layout() }; ESettingsLayout layout = wxGetApp().is_gcode_viewer() ? ESettingsLayout::GCodeViewer : - (wxGetApp().app_config->get("old_settings_layout_mode") == "1" ? ESettingsLayout::Old : - wxGetApp().app_config->get("new_settings_layout_mode") == "1" ? ( wxGetApp().tabs_as_menu() ? ESettingsLayout::Old : ESettingsLayout::New) : - wxGetApp().app_config->get("dlg_settings_layout_mode") == "1" ? ESettingsLayout::Dlg : ESettingsLayout::Old); + (wxGetApp().app_config->get_bool("old_settings_layout_mode") ? ESettingsLayout::Old : + wxGetApp().app_config->get_bool("new_settings_layout_mode") ? ( wxGetApp().tabs_as_menu() ? ESettingsLayout::Old : ESettingsLayout::New) : + wxGetApp().app_config->get_bool("dlg_settings_layout_mode") ? ESettingsLayout::Dlg : ESettingsLayout::Old); if (m_layout == layout) return; @@ -1001,7 +1001,7 @@ bool MainFrame::can_eject() const bool MainFrame::can_slice() const { - bool bg_proc = wxGetApp().app_config->get("background_processing") == "1"; + bool bg_proc = wxGetApp().app_config->get_bool("background_processing"); return (m_plater != nullptr) ? !m_plater->model().objects.empty() && !bg_proc : false; } @@ -1497,7 +1497,7 @@ void MainFrame::init_menubar_as_editor() windowMenu->AppendSeparator(); append_menu_item(windowMenu, wxID_ANY, _L("Open New Instance") + "\tCtrl+Shift+I", _L("Open a new PrusaSlicer instance"), - [](wxCommandEvent&) { start_new_slicer(); }, "", nullptr, [this]() {return m_plater != nullptr && wxGetApp().app_config->get("single_instance") != "1"; }, this); + [](wxCommandEvent&) { start_new_slicer(); }, "", nullptr, [this]() {return m_plater != nullptr && !wxGetApp().app_config->get_bool("single_instance"); }, this); windowMenu->AppendSeparator(); append_menu_item(windowMenu, wxID_ANY, _L("Compare Presets")/* + "\tCtrl+F"*/, _L("Compare presets"), @@ -2202,7 +2202,7 @@ void MainFrame::technology_changed() // Update the UI based on the current preferences. void MainFrame::update_ui_from_settings() { -// const bool bp_on = wxGetApp().app_config->get("background_processing") == "1"; +// const bool bp_on = wxGetApp().app_config->get_bool("background_processing"); // m_menu_item_reslice_now->Enable(!bp_on); // m_plater->sidebar().show_reslice(!bp_on); // m_plater->sidebar().show_export(bp_on); diff --git a/src/slic3r/GUI/OG_CustomCtrl.cpp b/src/slic3r/GUI/OG_CustomCtrl.cpp index 2f4f91302c..d18df6bb2d 100644 --- a/src/slic3r/GUI/OG_CustomCtrl.cpp +++ b/src/slic3r/GUI/OG_CustomCtrl.cpp @@ -246,7 +246,7 @@ void OG_CustomCtrl::OnMotion(wxMouseEvent& event) wxString language = wxGetApp().app_config->get("translation_language"); - bool suppress_hyperlinks = get_app_config()->get("suppress_hyperlinks") == "1"; + const bool suppress_hyperlinks = get_app_config()->get_bool("suppress_hyperlinks"); for (CtrlLine& line : ctrl_lines) { line.is_focused = is_point_in_rect(pos, line.rect_label); @@ -567,7 +567,7 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord v_pos) Field* field = ctrl->opt_group->get_field(og_line.get_options().front().opt_id); - bool suppress_hyperlinks = get_app_config()->get("suppress_hyperlinks") == "1"; + const bool suppress_hyperlinks = get_app_config()->get_bool("suppress_hyperlinks"); if (draw_just_act_buttons) { if (field) draw_act_bmps(dc, wxPoint(0, v_pos), field->undo_to_sys_bitmap(), field->undo_bitmap(), field->blink()); diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index 0ca0bf9db5..3659a08ccf 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -1052,7 +1052,7 @@ void ogStaticText::SetPathEnd(const std::string& link) event.Skip(); } ); Bind(wxEVT_ENTER_WINDOW, [this, link](wxMouseEvent& event) { - SetToolTip(OptionsGroup::get_url(get_app_config()->get("suppress_hyperlinks") != "1" ? link : std::string())); + SetToolTip(OptionsGroup::get_url(!get_app_config()->get_bool("suppress_hyperlinks") ? link : std::string())); FocusText(true); event.Skip(); }); @@ -1061,7 +1061,7 @@ void ogStaticText::SetPathEnd(const std::string& link) void ogStaticText::FocusText(bool focus) { - if (get_app_config()->get("suppress_hyperlinks") == "1") + if (get_app_config()->get_bool("suppress_hyperlinks")) return; SetFont(focus ? Slic3r::GUI::wxGetApp().link_font() : diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 7c91b7dac1..505c33a1cf 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1292,7 +1292,7 @@ void Sidebar::show_info_sizer() int inst_idx = selection.get_instance_idx(); assert(inst_idx >= 0); - bool imperial_units = wxGetApp().app_config->get("use_inches") == "1"; + bool imperial_units = wxGetApp().app_config->get_bool("use_inches"); double koef = imperial_units ? ObjectManipulation::mm_to_in : 1.0f; ModelVolume* vol = nullptr; @@ -1388,7 +1388,7 @@ void Sidebar::update_sliced_info_sizer() const PrintStatistics& ps = p->plater->fff_print().print_statistics(); const bool is_wipe_tower = ps.total_wipe_tower_filament > 0; - bool imperial_units = wxGetApp().app_config->get("use_inches") == "1"; + bool imperial_units = wxGetApp().app_config->get_bool("use_inches"); double koef = imperial_units ? ObjectManipulation::in_to_mm : 1000.0; wxString new_label = imperial_units ? _L("Used Filament (in)") : _L("Used Filament (m)"); @@ -1814,7 +1814,7 @@ struct Plater::priv void update_ui_from_settings(); void update_main_toolbar_tooltips(); // std::shared_ptr statusbar(); - std::string get_config(const std::string &key) const; + bool get_config_bool(const std::string &key) const; std::vector load_files(const std::vector& input_files, bool load_model, bool load_config, bool used_inches = false); std::vector load_model_objects(const ModelObjectPtrs& model_objects, bool allow_negative_z = false, bool call_selection_changed = true); @@ -1860,7 +1860,7 @@ struct Plater::priv void process_validation_warning(const std::string& warning) const; - bool background_processing_enabled() const { return this->get_config("background_processing") == "1"; } + bool background_processing_enabled() const { return this->get_config_bool("background_processing"); } void update_print_volume_state(); void schedule_background_process(); // Update background processing thread from the current config and Model. @@ -2179,7 +2179,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) // updates camera type from .ini file camera.enable_update_config_on_type_change(true); - camera.set_type(get_config("use_perspective_camera")); + camera.set_type(wxGetApp().app_config->get("use_perspective_camera")); // Load the 3DConnexion device database. mouse3d_controller.load_config(*wxGetApp().app_config); @@ -2266,7 +2266,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) // collapse sidebar according to saved value if (wxGetApp().is_editor()) { - bool is_collapsed = wxGetApp().app_config->get("collapsed_sidebar") == "1"; + bool is_collapsed = get_config_bool("collapsed_sidebar"); sidebar->collapse(is_collapsed); } } @@ -2283,7 +2283,7 @@ void Plater::priv::update(unsigned int flags) { // the following line, when enabled, causes flickering on NVIDIA graphics cards // wxWindowUpdateLocker freeze_guard(q); - if (get_config("autocenter") == "1") + if (get_config_bool("autocenter")) model.center_instances_around_point(this->bed.build_volume().bed_center()); unsigned int update_status = 0; @@ -2299,7 +2299,7 @@ void Plater::priv::update(unsigned int flags) else this->schedule_background_process(); - if (get_config("autocenter") == "1" && this->sidebar->obj_manipul()->IsShown()) + if (get_config_bool("autocenter") && this->sidebar->obj_manipul()->IsShown()) this->sidebar->obj_manipul()->UpdateAndShow(true); } @@ -2314,7 +2314,7 @@ void Plater::priv::select_view(const std::string& direction) void Plater::priv::apply_free_camera_correction(bool apply/* = true*/) { camera.set_type(wxGetApp().app_config->get("use_perspective_camera")); - if (apply && wxGetApp().app_config->get("use_free_camera") != "1") + if (apply && !wxGetApp().app_config->get_bool("use_free_camera")) camera.recover_from_free_camera(); } @@ -2382,9 +2382,9 @@ void Plater::priv::update_main_toolbar_tooltips() // return main_frame->m_statusbar; //} -std::string Plater::priv::get_config(const std::string &key) const +bool Plater::priv::get_config_bool(const std::string &key) const { - return wxGetApp().app_config->get(key); + return wxGetApp().app_config->get_bool(key); } // After loading of the presets from project, check if they are visible. @@ -2761,7 +2761,7 @@ std::vector Plater::priv::load_model_objects(const ModelObjectPtrs& mode #endif /* AUTOPLACEMENT_ON_LOAD */ for (ModelObject *model_object : model_objects) { auto *object = model.add_object(*model_object); - object->sort_volumes(wxGetApp().app_config->get("order_volumes") == "1"); + object->sort_volumes(get_config_bool("order_volumes")); std::string object_name = object->name.empty() ? fs::path(object->input_file).filename().string() : object->name; obj_idxs.push_back(obj_count++); @@ -3575,7 +3575,7 @@ bool Plater::priv::replace_volume_with_stl(int object_idx, int volume_idx, const old_model_object->delete_volume(old_model_object->volumes.size() - 1); if (!sinking) old_model_object->ensure_on_bed(); - old_model_object->sort_volumes(wxGetApp().app_config->get("order_volumes") == "1"); + old_model_object->sort_volumes(get_config_bool("order_volumes")); // if object has just one volume, rename object too if (old_model_object->volumes.size() == 1) @@ -3941,7 +3941,7 @@ void Plater::priv::reload_from_disk() old_model_object->delete_volume(old_model_object->volumes.size() - 1); if (!sinking) old_model_object->ensure_on_bed(); - old_model_object->sort_volumes(wxGetApp().app_config->get("order_volumes") == "1"); + old_model_object->sort_volumes(get_config_bool("order_volumes")); sla::reproject_points_and_holes(old_model_object); @@ -4021,7 +4021,7 @@ void Plater::priv::reload_from_disk() old_model_object->delete_volume(old_model_object->volumes.size() - 1); if (!sinking) old_model_object->ensure_on_bed(); - old_model_object->sort_volumes(wxGetApp().app_config->get("order_volumes") == "1"); + old_model_object->sort_volumes(get_config_bool("order_volumes")); sla::reproject_points_and_holes(old_model_object); } @@ -4275,7 +4275,7 @@ void Plater::priv::on_slicing_update(SlicingStatusEvent &evt) if ((evt.status.flags & PrintBase::SlicingStatus::UPDATE_PRINT_STEP_WARNINGS) && static_cast(evt.status.warning_step) == psAlertWhenSupportsNeeded && - get_app_config()->get("alert_when_supports_needed") != "1") { + !get_app_config()->get_bool("alert_when_supports_needed")) { // This alerts are from psAlertWhenSupportsNeeded and the respective app settings is not Enabled, so discard the alerts. } else if (evt.status.flags & (PrintBase::SlicingStatus::UPDATE_PRINT_STEP_WARNINGS | PrintBase::SlicingStatus::UPDATE_PRINT_OBJECT_STEP_WARNINGS)) { @@ -5054,7 +5054,7 @@ void Plater::priv::show_action_buttons(const bool ready_to_slice_) const const bool send_gcode_shown = print_host_opt != nullptr && !print_host_opt->value.empty(); // when a background processing is ON, export_btn and/or send_btn are showing - if (wxGetApp().app_config->get("background_processing") == "1") + if (get_config_bool("background_processing")) { RemovableDriveManager::RemovableDrivesStatus removable_media_status = wxGetApp().removable_drive_manager()->status(); if (sidebar->show_reslice(false) | @@ -5143,7 +5143,7 @@ void Plater::priv::take_snapshot(const std::string& snapshot_name, const UndoRed } const GLGizmosManager& gizmos = view3D->get_canvas3d()->get_gizmos_manager(); - if (snapshot_type == UndoRedo::SnapshotType::ProjectSeparator && wxGetApp().app_config->get("clear_undo_redo_stack_on_new_project") == "1") + if (snapshot_type == UndoRedo::SnapshotType::ProjectSeparator && get_config_bool("clear_undo_redo_stack_on_new_project")) this->undo_redo_stack().clear(); this->undo_redo_stack().take_snapshot(snapshot_name, model, view3D->get_canvas3d()->get_selection(), gizmos, snapshot_data); if (snapshot_type == UndoRedo::SnapshotType::LeavingGizmoWithAction) { @@ -5650,7 +5650,7 @@ LoadProjectsDialog::LoadProjectsDialog(const std::vector& paths) wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL); bool contains_projects = !paths.empty(); - bool instances_allowed = wxGetApp().app_config->get("single_instance") != "1"; + bool instances_allowed = !wxGetApp().app_config->get_bool("single_instance"); if (contains_projects) main_sizer->Add(new wxStaticText(this, wxID_ANY, get_wraped_wxString(_L("There are several files being loaded, including Project files.") + "\n" + _L("Select an action to apply to all files."))), 0, wxEXPAND | wxALL, 10); @@ -5895,7 +5895,7 @@ bool Plater::preview_zip_archive(const boost::filesystem::path& archive_path) return true; } // 1 model (or more and other instances are not allowed), 0 projects - open geometry - if (project_paths.empty() && (non_project_paths.size() == 1 || wxGetApp().app_config->get("single_instance") == "1")) + if (project_paths.empty() && (non_project_paths.size() == 1 || wxGetApp().app_config->get_bool("single_instance"))) { load_files(non_project_paths, true, false); boost::system::error_code ec; @@ -6036,7 +6036,7 @@ ProjectDropDialog::ProjectDropDialog(const std::string& filename) { SetFont(wxGetApp().normal_font()); - bool single_instance_only = wxGetApp().app_config->get("single_instance") == "1"; + bool single_instance_only = wxGetApp().app_config->get_bool("single_instance"); wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL); wxArrayString choices; choices.reserve(4); @@ -6144,7 +6144,7 @@ bool Plater::load_files(const wxArrayString& filenames, bool delete_after_load/* (boost::algorithm::iends_with(filename, ".amf") && !boost::algorithm::iends_with(filename, ".zip.amf"))) load_type = ProjectDropDialog::LoadType::LoadGeometry; else { - if (wxGetApp().app_config->get("show_drop_project_dialog") == "1") { + if (wxGetApp().app_config->get_bool("show_drop_project_dialog")) { ProjectDropDialog dlg(filename); if (dlg.ShowModal() == wxID_OK) { int choice = dlg.get_action(); @@ -6294,7 +6294,7 @@ void Plater::increase_instances(size_t num) // p->print.get_object(obj_idx)->add_copy(Slic3r::to_2d(offset_vec)); } - if (p->get_config("autocenter") == "1") + if (p->get_config_bool("autocenter")) arrange(); p->update(); @@ -6711,7 +6711,7 @@ void Plater::export_amf() wxBusyCursor wait; bool export_config = true; DynamicPrintConfig cfg = wxGetApp().preset_bundle->full_config_secure(); - bool full_pathnames = wxGetApp().app_config->get("export_sources_full_pathnames") == "1"; + bool full_pathnames = wxGetApp().app_config->get_bool("export_sources_full_pathnames"); if (Slic3r::store_amf(path_u8.c_str(), &p->model, export_config ? &cfg : nullptr, full_pathnames)) { // Success // p->statusbar()->set_status_text(format_wxstr(_L("AMF file exported to %s"), path)); @@ -6744,7 +6744,7 @@ bool Plater::export_3mf(const boost::filesystem::path& output_path) DynamicPrintConfig cfg = wxGetApp().preset_bundle->full_config_secure(); const std::string path_u8 = into_u8(path); wxBusyCursor wait; - bool full_pathnames = wxGetApp().app_config->get("export_sources_full_pathnames") == "1"; + bool full_pathnames = wxGetApp().app_config->get_bool("export_sources_full_pathnames"); ThumbnailData thumbnail_data; ThumbnailsParams thumbnail_params = { {}, false, true, true, true }; p->generate_thumbnail(thumbnail_data, THUMBNAIL_SIZE_3MF.first, THUMBNAIL_SIZE_3MF.second, thumbnail_params, Camera::EType::Ortho); diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 1895572ae2..40c5314ee4 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -87,7 +87,7 @@ void PreferencesDialog::show(const std::string& highlight_opt_key /*= std::strin // cache input values for custom toolbar size m_custom_toolbar_size = atoi(get_app_config()->get("custom_toolbar_size").c_str()); - m_use_custom_toolbar_size = get_app_config()->get("use_custom_toolbar_size") == "1"; + m_use_custom_toolbar_size = get_app_config()->get_bool("use_custom_toolbar_size"); // set Field for notify_release to its value if (m_optgroup_gui && m_optgroup_gui->get_field("notify_release") != nullptr) { @@ -100,10 +100,10 @@ void PreferencesDialog::show(const std::string& highlight_opt_key /*= std::strin auto app_config = get_app_config(); downloader->set_path_name(app_config->get("url_downloader_dest")); - downloader->allow(!app_config->has("downloader_url_registered") || app_config->get("downloader_url_registered") == "1"); + downloader->allow(!app_config->has("downloader_url_registered") || app_config->get_bool("downloader_url_registered")); for (const std::string& opt_key : {"suppress_hyperlinks", "downloader_url_registered"}) - m_optgroup_other->set_value(opt_key, app_config->get(opt_key) == "1"); + m_optgroup_other->set_value(opt_key, app_config->get_bool(opt_key)); // update colors for color pickers of the labels update_color(m_sys_colour, wxGetApp().get_label_clr_sys()); @@ -257,25 +257,25 @@ void PreferencesDialog::build() append_bool_option(m_optgroup_general, "remember_output_path", L("Remember output directory"), L("If this is enabled, Slic3r will prompt the last output directory instead of the one containing the input files."), - app_config->has("remember_output_path") ? app_config->get("remember_output_path") == "1" : true); + app_config->has("remember_output_path") ? app_config->get_bool("remember_output_path") : true); append_bool_option(m_optgroup_general, "autocenter", L("Auto-center parts"), L("If this is enabled, Slic3r will auto-center objects around the print bed center."), - app_config->get("autocenter") == "1"); + app_config->get_bool("autocenter")); append_bool_option(m_optgroup_general, "background_processing", L("Background processing"), L("If this is enabled, Slic3r will pre-process objects as soon " "as they\'re loaded in order to save time when exporting G-code."), - app_config->get("background_processing") == "1"); + app_config->get_bool("background_processing")); append_bool_option(m_optgroup_general, "alert_when_supports_needed", L("Alert when supports needed"), L("If this is enabled, Slic3r will raise alerts when it detects " "issues in the sliced object, that can be resolved with supports (and brim). " "Examples of such issues are floating object parts, unsupported extrusions and low bed adhesion."), - app_config->get("alert_when_supports_needed") == "1"); + app_config->get_bool("alert_when_supports_needed")); m_optgroup_general->append_separator(); @@ -284,19 +284,19 @@ void PreferencesDialog::build() append_bool_option(m_optgroup_general, "export_sources_full_pathnames", L("Export sources full pathnames to 3mf and amf"), L("If enabled, allows the Reload from disk command to automatically find and load the files when invoked."), - app_config->get("export_sources_full_pathnames") == "1"); + app_config->get_bool("export_sources_full_pathnames")); #ifdef _WIN32 // Please keep in sync with ConfigWizard append_bool_option(m_optgroup_general, "associate_3mf", L("Associate .3mf files to PrusaSlicer"), L("If enabled, sets PrusaSlicer as default application to open .3mf files."), - app_config->get("associate_3mf") == "1"); + app_config->get_bool("associate_3mf")); append_bool_option(m_optgroup_general, "associate_stl", L("Associate .stl files to PrusaSlicer"), L("If enabled, sets PrusaSlicer as default application to open .stl files."), - app_config->get("associate_stl") == "1"); + app_config->get_bool("associate_stl")); #endif // _WIN32 m_optgroup_general->append_separator(); @@ -306,23 +306,23 @@ void PreferencesDialog::build() L("Update built-in Presets automatically"), L("If enabled, Slic3r downloads updates of built-in system presets in the background. These updates are downloaded " "into a separate temporary location. When a new preset version becomes available it is offered at application startup."), - app_config->get("preset_update") == "1"); + app_config->get_bool("preset_update")); append_bool_option(m_optgroup_general, "no_defaults", L("Suppress \" - default - \" presets"), L("Suppress \" - default - \" presets in the Print / Filament / Printer selections once there are any other valid presets available."), - app_config->get("no_defaults") == "1"); + app_config->get_bool("no_defaults")); append_bool_option(m_optgroup_general, "no_templates", L("Suppress \" Template \" filament presets"), L("Suppress \" Template \" filament presets in configuration wizard and sidebar visibility."), - app_config->get("no_templates") == "1"); + app_config->get_bool("no_templates")); append_bool_option(m_optgroup_general, "show_incompatible_presets", L("Show incompatible print and filament presets"), L("When checked, the print and filament presets are shown in the preset editor " "even if they are marked as incompatible with the active printer"), - app_config->get("show_incompatible_presets") == "1"); + app_config->get_bool("show_incompatible_presets")); m_optgroup_general->append_separator(); @@ -335,7 +335,7 @@ void PreferencesDialog::build() L("Show drop project dialog"), L("When checked, whenever dragging and dropping a project file on the application, shows a dialog asking to select the action to take on the file to load."), #endif - app_config->get("show_drop_project_dialog") == "1"); + app_config->get_bool("show_drop_project_dialog")); append_bool_option(m_optgroup_general, "single_instance", #if __APPLE__ @@ -346,7 +346,7 @@ void PreferencesDialog::build() L("Allow just a single PrusaSlicer instance"), L("If this is enabled, when starting PrusaSlicer and another instance of the same PrusaSlicer is already running, that instance will be reactivated instead."), #endif - app_config->has("single_instance") ? app_config->get("single_instance") == "1" : false ); + app_config->has("single_instance") ? app_config->get_bool("single_instance") : false ); m_optgroup_general->append_separator(); @@ -381,7 +381,7 @@ void PreferencesDialog::build() append_bool_option(m_optgroup_general, "associate_gcode", L("Associate .gcode files to PrusaSlicer G-code Viewer"), L("If enabled, sets PrusaSlicer G-code Viewer as default application to open .gcode files."), - app_config->get("associate_gcode") == "1"); + app_config->get_bool("associate_gcode")); } #endif // _WIN32 @@ -390,7 +390,7 @@ void PreferencesDialog::build() L("Use Retina resolution for the 3D scene"), L("If enabled, the 3D scene will be rendered in Retina resolution. " "If you are experiencing 3D performance problems, disabling this option may help."), - app_config->get("use_retina_opengl") == "1"); + app_config->get_bool("use_retina_opengl")); #endif m_optgroup_general->append_separator(); @@ -399,24 +399,24 @@ void PreferencesDialog::build() append_bool_option(m_optgroup_general, "show_splash_screen", L("Show splash screen"), L("Show splash screen"), - app_config->get("show_splash_screen") == "1"); + app_config->get_bool("show_splash_screen")); append_bool_option(m_optgroup_general, "restore_win_position", L("Restore window position on start"), L("If enabled, PrusaSlicer will be open at the position it was closed"), - app_config->get("restore_win_position") == "1"); + app_config->get_bool("restore_win_position")); // Clear Undo / Redo stack on new project append_bool_option(m_optgroup_general, "clear_undo_redo_stack_on_new_project", L("Clear Undo / Redo stack on new project"), L("Clear Undo / Redo stack on new project or when an existing project is loaded."), - app_config->get("clear_undo_redo_stack_on_new_project") == "1"); + app_config->get_bool("clear_undo_redo_stack_on_new_project")); #if defined(_WIN32) || defined(__APPLE__) append_bool_option(m_optgroup_general, "use_legacy_3DConnexion", L("Enable support for legacy 3DConnexion devices"), L("If enabled, the legacy 3DConnexion devices settings dialog is available by pressing CTRL+M"), - app_config->get("use_legacy_3DConnexion") == "1"); + app_config->get_bool("use_legacy_3DConnexion")); #endif // _WIN32 || __APPLE__ activate_options_tab(m_optgroup_general); @@ -434,17 +434,17 @@ void PreferencesDialog::build() append_bool_option(m_optgroup_camera, "use_perspective_camera", L("Use perspective camera"), L("If enabled, use perspective camera. If not enabled, use orthographic camera."), - app_config->get("use_perspective_camera") == "1"); + app_config->get_bool("use_perspective_camera")); append_bool_option(m_optgroup_camera, "use_free_camera", L("Use free camera"), L("If enabled, use free camera. If not enabled, use constrained camera."), - app_config->get("use_free_camera") == "1"); + app_config->get_bool("use_free_camera")); append_bool_option(m_optgroup_camera, "reverse_mouse_wheel_zoom", L("Reverse direction of zoom with mouse wheel"), L("If enabled, reverses the direction of zoom with mouse wheel"), - app_config->get("reverse_mouse_wheel_zoom") == "1"); + app_config->get_bool("reverse_mouse_wheel_zoom")); activate_options_tab(m_optgroup_camera); @@ -492,48 +492,48 @@ void PreferencesDialog::build() L("Sequential slider applied only to top layer"), L("If enabled, changes made using the sequential slider, in preview, apply only to gcode top layer." "If disabled, changes made using the sequential slider, in preview, apply to the whole gcode."), - app_config->get("seq_top_layer_only") == "1"); + app_config->get_bool("seq_top_layer_only")); if (is_editor) { append_bool_option(m_optgroup_gui, "show_collapse_button", L("Show sidebar collapse/expand button"), L("If enabled, the button for the collapse sidebar will be appeared in top right corner of the 3D Scene"), - app_config->get("show_collapse_button") == "1"); + app_config->get_bool("show_collapse_button")); /* append_bool_option(m_optgroup_gui, "suppress_hyperlinks", L("Suppress to open hyperlink in browser"), L("If enabled, PrusaSlicer will not open a hyperlinks in your browser."), //L("If enabled, the descriptions of configuration parameters in settings tabs wouldn't work as hyperlinks. " // "If disabled, the descriptions of configuration parameters in settings tabs will work as hyperlinks."), - app_config->get("suppress_hyperlinks") == "1"); + app_config->get_bool("suppress_hyperlinks")); */ append_bool_option(m_optgroup_gui, "color_mapinulation_panel", L("Use colors for axes values in Manipulation panel"), L("If enabled, the axes names and axes values will be colorized according to the axes colors. " "If disabled, old UI will be used."), - app_config->get("color_mapinulation_panel") == "1"); + app_config->get_bool("color_mapinulation_panel")); append_bool_option(m_optgroup_gui, "order_volumes", L("Order object volumes by types"), L("If enabled, volumes will be always ordered inside the object. Correct order is Model Part, Negative Volume, Modifier, Support Blocker and Support Enforcer. " "If disabled, you can reorder Model Parts, Negative Volumes and Modifiers. But one of the model parts have to be on the first place."), - app_config->get("order_volumes") == "1"); + app_config->get_bool("order_volumes")); append_bool_option(m_optgroup_gui, "non_manifold_edges", L("Show non-manifold edges"), L("If enabled, shows non-manifold edges."), - app_config->get("non_manifold_edges") == "1"); + app_config->get_bool("non_manifold_edges")); append_bool_option(m_optgroup_gui, "allow_auto_color_change", L("Allow automatically color change"), L("If enabled, related notification will be shown, when sliced object looks like a logo or a sign."), - app_config->get("allow_auto_color_change") == "1"); + app_config->get_bool("allow_auto_color_change")); #ifdef _MSW_DARK_MODE append_bool_option(m_optgroup_gui, "tabs_as_menu", L("Set settings tabs as menu items (experimental)"), L("If enabled, Settings Tabs will be placed as menu items. If disabled, old UI will be used."), - app_config->get("tabs_as_menu") == "1"); + app_config->get_bool("tabs_as_menu")); #endif m_optgroup_gui->append_separator(); @@ -541,7 +541,7 @@ void PreferencesDialog::build() append_bool_option(m_optgroup_gui, "show_hints", L("Show \"Tip of the day\" notification after start"), L("If enabled, useful hints are displayed at startup."), - app_config->get("show_hints") == "1"); + app_config->get_bool("show_hints")); append_enum_option(m_optgroup_gui, "notify_release", L("Notify about new releases"), @@ -557,7 +557,7 @@ void PreferencesDialog::build() append_bool_option(m_optgroup_gui, "use_custom_toolbar_size", L("Use custom size for toolbar icons"), L("If enabled, you can change size of toolbar icons manually."), - app_config->get("use_custom_toolbar_size") == "1"); + app_config->get_bool("use_custom_toolbar_size")); } activate_options_tab(m_optgroup_gui); @@ -568,7 +568,7 @@ void PreferencesDialog::build() m_optgroup_gui->get_field("notify_release")->set_value(val, false); create_icon_size_slider(); - m_icon_size_sizer->ShowItems(app_config->get("use_custom_toolbar_size") == "1"); + m_icon_size_sizer->ShowItems(app_config->get_bool("use_custom_toolbar_size")); create_settings_mode_widget(); create_settings_text_color_widget(); @@ -594,12 +594,12 @@ void PreferencesDialog::build() L("If enabled, PrusaSlicer will not open a hyperlinks in your browser."), //L("If enabled, the descriptions of configuration parameters in settings tabs wouldn't work as hyperlinks. " // "If disabled, the descriptions of configuration parameters in settings tabs will work as hyperlinks."), - app_config->get("suppress_hyperlinks") == "1"); + app_config->get_bool("suppress_hyperlinks")); append_bool_option(m_optgroup_other, "downloader_url_registered", L("Allow downloads from Printables.com"), L("If enabled, PrusaSlicer will allow to download from Printables.com"), - app_config->get("downloader_url_registered") == "1"); + app_config->get_bool("downloader_url_registered")); activate_options_tab(m_optgroup_other); @@ -619,7 +619,7 @@ void PreferencesDialog::build() append_bool_option(m_optgroup_render, "use_environment_map", L("Use environment map"), L("If enabled, renders object using the environment map."), - app_config->get("use_environment_map") == "1"); + app_config->get_bool("use_environment_map")); activate_options_tab(m_optgroup_render); #endif // ENABLE_ENVIRONMENT_MAP @@ -638,7 +638,7 @@ void PreferencesDialog::build() append_bool_option(m_optgroup_dark_mode, "dark_color_mode", L("Enable dark mode"), L("If enabled, UI will use Dark mode colors. If disabled, old UI will be used."), - app_config->get("dark_color_mode") == "1"); + app_config->get_bool("dark_color_mode")); if (wxPlatformInfo::Get().GetOSMajorVersion() >= 10) // Use system menu just for Window newer then Windows 10 // Use menu with ownerdrawn items by default on systems older then Windows 10 @@ -647,7 +647,7 @@ void PreferencesDialog::build() L("Use system menu for application"), L("If enabled, application will use the standart Windows system menu,\n" "but on some combination od display scales it can look ugly. If disabled, old UI will be used."), - app_config->get("sys_menu_enabled") == "1"); + app_config->get_bool("sys_menu_enabled")); } activate_options_tab(m_optgroup_dark_mode); @@ -799,7 +799,7 @@ void PreferencesDialog::revert(wxEvent&) app_config->set("custom_toolbar_size", (boost::format("%d") % m_custom_toolbar_size).str()); m_icon_size_slider->SetValue(m_custom_toolbar_size); } - if (m_use_custom_toolbar_size != (get_app_config()->get("use_custom_toolbar_size") == "1")) { + if (m_use_custom_toolbar_size != (get_app_config()->get_bool("use_custom_toolbar_size"))) { app_config->set("use_custom_toolbar_size", m_use_custom_toolbar_size ? "1" : "0"); m_optgroup_gui->set_value("use_custom_toolbar_size", m_use_custom_toolbar_size); @@ -823,17 +823,17 @@ void PreferencesDialog::revert(wxEvent&) continue; } if (key == "old_settings_layout_mode") { - m_rb_old_settings_layout_mode->SetValue(app_config->get(key) == "1"); + m_rb_old_settings_layout_mode->SetValue(app_config->get_bool(key)); m_settings_layout_changed = false; continue; } if (key == "new_settings_layout_mode") { - m_rb_new_settings_layout_mode->SetValue(app_config->get(key) == "1"); + m_rb_new_settings_layout_mode->SetValue(app_config->get_bool(key)); m_settings_layout_changed = false; continue; } if (key == "dlg_settings_layout_mode") { - m_rb_dlg_settings_layout_mode->SetValue(app_config->get(key) == "1"); + m_rb_dlg_settings_layout_mode->SetValue(app_config->get_bool(key)); m_settings_layout_changed = false; continue; } @@ -846,11 +846,11 @@ void PreferencesDialog::revert(wxEvent&) , m_optgroup_render #endif // ENABLE_ENVIRONMENT_MAP }) { - if (opt_group->set_value(key, app_config->get(key) == "1")) + if (opt_group->set_value(key, app_config->get_bool(key))) break; } if (key == "tabs_as_menu") { - m_rb_new_settings_layout_mode->Show(app_config->get(key) != "1"); + m_rb_new_settings_layout_mode->Show(!app_config->get_bool(key)); refresh_og(m_optgroup_gui); continue; } @@ -993,12 +993,12 @@ void PreferencesDialog::create_settings_mode_widget() }); }; - add_radio(&m_rb_old_settings_layout_mode, ++id, app_config->get("old_settings_layout_mode") == "1"); - add_radio(&m_rb_new_settings_layout_mode, ++id, app_config->get("new_settings_layout_mode") == "1"); - add_radio(&m_rb_dlg_settings_layout_mode, ++id, app_config->get("dlg_settings_layout_mode") == "1"); + add_radio(&m_rb_old_settings_layout_mode, ++id, app_config->get_bool("old_settings_layout_mode")); + add_radio(&m_rb_new_settings_layout_mode, ++id, app_config->get_bool("new_settings_layout_mode")); + add_radio(&m_rb_dlg_settings_layout_mode, ++id, app_config->get_bool("dlg_settings_layout_mode")); #ifdef _MSW_DARK_MODE - if (app_config->get("tabs_as_menu") == "1") { + if (app_config->get_bool("tabs_as_menu")) { m_rb_new_settings_layout_mode->Hide(); if (m_rb_new_settings_layout_mode->GetValue()) { m_rb_new_settings_layout_mode->SetValue(false); diff --git a/src/slic3r/Utils/OctoPrint.cpp b/src/slic3r/Utils/OctoPrint.cpp index 501d61423c..568f9fe670 100644 --- a/src/slic3r/Utils/OctoPrint.cpp +++ b/src/slic3r/Utils/OctoPrint.cpp @@ -300,7 +300,7 @@ bool OctoPrint::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Erro boost::asio::ip::address host_ip = boost::asio::ip::make_address(host, ec); if (!ec) { resolved_addr.push_back(host_ip); - } else if ( GUI::get_app_config()->get("allow_ip_resolve") == "1" && boost::algorithm::ends_with(host, ".local")){ + } else if ( GUI::get_app_config()->get_bool("allow_ip_resolve") && boost::algorithm::ends_with(host, ".local")){ Bonjour("octoprint") .set_hostname(host) .set_retries(5) // number of rounds of queries send @@ -428,7 +428,7 @@ bool OctoPrint::upload_inner_with_host(PrintHostUpload upload_data, ProgressFn p #ifdef WIN32 // Workaround for Windows 10/11 mDNS resolve issue, where two mDNS resolves in succession fail. - if (m_host.find("https://") == 0 || test_msg_or_host_ip.empty() || GUI::get_app_config()->get("allow_ip_resolve") != "1") + if (m_host.find("https://") == 0 || test_msg_or_host_ip.empty() || !GUI::get_app_config()->get_bool("allow_ip_resolve")) #endif // _WIN32 { // If https is entered we assume signed ceritificate is being used @@ -972,7 +972,7 @@ bool PrusaLink::upload_inner_with_host(PrintHostUpload upload_data, ProgressFn p storage_path += (upload_data.storage.empty() ? "/local" : upload_data.storage); #ifdef WIN32 // Workaround for Windows 10/11 mDNS resolve issue, where two mDNS resolves in succession fail. - if (m_host.find("https://") == 0 || test_msg_or_host_ip.empty() || GUI::get_app_config()->get("allow_ip_resolve") != "1") + if (m_host.find("https://") == 0 || test_msg_or_host_ip.empty() || !GUI::get_app_config()->get_bool("allow_ip_resolve")) #endif // _WIN32 { // If https is entered we assume signed ceritificate is being used diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index cd3935ea00..2b69bff528 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -213,7 +213,7 @@ void PresetUpdater::priv::set_download_prefs(const AppConfig *app_config) { enabled_version_check = app_config->get("notify_release") != "none"; version_check_url = app_config->version_check_url(); - enabled_config_update = app_config->get("preset_update") == "1" && !app_config->legacy_datadir(); + enabled_config_update = app_config->get_bool("preset_update") && !app_config->legacy_datadir(); } // Downloads a file (http get operation). Cancels if the Updater is being destroyed.