mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	ENH: [STUDIO-2550] config auto sync system presets
Change-Id: I83f9baae5793b214f4d1c040f5819ad9a03cd47f (cherry picked from commit 40fe90e176fc001f54b22375ddb0dd035a6d84cd)
This commit is contained in:
		
							parent
							
								
									d776c7595e
								
							
						
					
					
						commit
						0ca3f27c54
					
				
					 4 changed files with 16 additions and 7 deletions
				
			
		|  | @ -293,6 +293,10 @@ void AppConfig::set_defaults() | |||
|         set_bool("staff_pick_switch", true); | ||||
|     } | ||||
| 
 | ||||
|     if (get("sync_system_preset").empty()) { | ||||
|         set_bool("sync_system_preset", true); | ||||
|     } | ||||
| 
 | ||||
|     if (get("backup_switch").empty()) { | ||||
|         set_bool("backup_switch", true); | ||||
|     } | ||||
|  |  | |||
|  | @ -1186,7 +1186,8 @@ void GUI_App::post_init() | |||
|             std::string http_url = get_http_url(app_config->get_country_code()); | ||||
|             std::string language = GUI::into_u8(current_language_code()); | ||||
|             std::string network_ver = Slic3r::NetworkAgent::get_version(); | ||||
|             this->preset_updater->sync(http_url, language, network_ver, preset_bundle); | ||||
|             bool        sys_preset  = app_config->get("sync_system_preset") == "true"; | ||||
|             this->preset_updater->sync(http_url, language, network_ver, sys_preset ? preset_bundle : nullptr); | ||||
| 
 | ||||
|             //BBS: check new version
 | ||||
|             this->check_new_version(); | ||||
|  |  | |||
|  | @ -426,7 +426,7 @@ wxBoxSizer *PreferencesDialog::create_item_input(wxString title, wxString title2 | |||
| wxBoxSizer *PreferencesDialog::create_item_backup_input(wxString title, wxWindow *parent, wxString tooltip, std::string param) | ||||
| { | ||||
|     wxBoxSizer *m_sizer_input = new wxBoxSizer(wxHORIZONTAL); | ||||
|     auto input_title = new wxStaticText(parent, wxID_ANY, title, wxDefaultPosition, DESIGN_TITLE_SIZE, 0); | ||||
|     auto input_title = new wxStaticText(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, 0); | ||||
|     input_title->SetForegroundColour(DESIGN_GRAY900_COLOR); | ||||
|     input_title->SetFont(::Label::Body_13); | ||||
|     input_title->SetToolTip(tooltip); | ||||
|  | @ -591,7 +591,7 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa | |||
|     checkbox_title->SetFont(::Label::Body_13); | ||||
| 
 | ||||
|     auto size = checkbox_title->GetTextExtent(title); | ||||
|     checkbox_title->SetMinSize(wxSize(size.x + FromDIP(40), -1)); | ||||
|     checkbox_title->SetMinSize(wxSize(size.x + FromDIP(4), -1)); | ||||
|     checkbox_title->Wrap(-1); | ||||
|     m_sizer_checkbox->Add(checkbox_title, 0, wxALIGN_CENTER | wxALL, 3); | ||||
| 
 | ||||
|  | @ -691,6 +691,7 @@ wxBoxSizer *PreferencesDialog::create_item_button(wxString title, wxString title | |||
|     m_button_download->SetMinSize(wxSize(FromDIP(58), FromDIP(22))); | ||||
|     m_button_download->SetSize(wxSize(FromDIP(58), FromDIP(22))); | ||||
|     m_button_download->SetCornerRadius(FromDIP(12)); | ||||
|     m_button_download->SetToolTip(tooltip); | ||||
| 
 | ||||
|     m_button_download->Bind(wxEVT_BUTTON, [this, onclick](auto &e) { onclick(); }); | ||||
| 
 | ||||
|  | @ -917,6 +918,7 @@ wxWindow* PreferencesDialog::create_general_page() | |||
| 
 | ||||
|     auto title_presets = create_item_title(_L("Presets"), page, _L("Presets")); | ||||
|     auto item_user_sync        = create_item_checkbox(_L("Auto sync user presets(Printer/Filament/Process)"), page, _L("User Sync"), 50, "sync_user_preset"); | ||||
|     auto item_system_sync        = create_item_checkbox(_L("Auto sync system presets(Printer/Filament/Process)"), page, _L("System Sync"), 50, "sync_system_preset"); | ||||
|     auto item_save_presets = create_item_button(_L("Clear my choice on the unsaved presets."), _L("Clear"), page, _L("Clear my choice on the unsaved presets."), []() { | ||||
|         wxGetApp().app_config->set("save_preset_choise", ""); | ||||
|     }); | ||||
|  | @ -933,9 +935,9 @@ wxWindow* PreferencesDialog::create_general_page() | |||
|                                                          _L("If enabled, sets BambuStudio as default application to open .step files"), 50, "associate_step"); | ||||
| #endif // _WIN32
 | ||||
| 
 | ||||
|     auto title_modelmall = create_item_title(_L("Model Mall"), page, _L("Model Mall")); | ||||
|     auto title_modelmall = create_item_title(_L("Online Models"), page, _L("Online Models")); | ||||
|     // auto item_backup = create_item_switch(_L("Backup switch"), page, _L("Backup switch"), "units");
 | ||||
|     auto item_modelmall = create_item_checkbox(_L("Show staff-picks"), page, _L("Show staff-picks"), 50, "staff_pick_switch"); | ||||
|     auto item_modelmall = create_item_checkbox(_L("Show online staff-picked models on the home page"), page, _L("Show online staff-picked models on the home page"), 50, "staff_pick_switch"); | ||||
| 
 | ||||
| 
 | ||||
|     auto title_project = create_item_title(_L("Project"), page, ""); | ||||
|  | @ -969,6 +971,7 @@ wxWindow* PreferencesDialog::create_general_page() | |||
|     sizer_page->Add(item_hints, 0, wxTOP, FromDIP(3)); | ||||
|     sizer_page->Add(title_presets, 0, wxTOP | wxEXPAND, FromDIP(20)); | ||||
|     sizer_page->Add(item_user_sync, 0, wxTOP, FromDIP(3)); | ||||
|     sizer_page->Add(item_system_sync, 0, wxTOP, FromDIP(3)); | ||||
|     sizer_page->Add(item_save_presets, 0, wxTOP, FromDIP(3)); | ||||
| #ifdef _WIN32 | ||||
|     sizer_page->Add(title_associate_file, 0, wxTOP| wxEXPAND, FromDIP(20)); | ||||
|  |  | |||
|  | @ -1206,7 +1206,7 @@ void PresetUpdater::sync(std::string http_url, std::string language, std::string | |||
| 	// Copy the whole vendors data for use in the background thread
 | ||||
| 	// Unfortunatelly as of C++11, it needs to be copied again
 | ||||
| 	// into the closure (but perhaps the compiler can elide this).
 | ||||
| 	VendorMap vendors = preset_bundle->vendors; | ||||
|     VendorMap vendors = preset_bundle ? preset_bundle->vendors : VendorMap{}; | ||||
| 
 | ||||
| 	p->thread = std::thread([this, vendors, http_url, language, plugin_version]() { | ||||
| 		this->p->prune_tmps(); | ||||
|  | @ -1215,7 +1215,8 @@ void PresetUpdater::sync(std::string http_url, std::string language, std::string | |||
| 		this->p->sync_version(); | ||||
| 		if (p->cancel) | ||||
| 			return; | ||||
| 		this->p->sync_config(http_url, std::move(vendors)); | ||||
|         if (!vendors.empty()) | ||||
| 		    this->p->sync_config(http_url, std::move(vendors)); | ||||
| 		if (p->cancel) | ||||
| 			return; | ||||
| 		this->p->sync_plugins(http_url, plugin_version); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 chunmao.guo
						chunmao.guo