mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-22 14:50:59 +00:00
Ask Before Migrating User Filament Presets to Their Legacy Printers
Instead of giving user presets their parent's 2.4.2 printers in memory, detect the user presets that inherit their parent's compatible_printers and are missing printers from the legacy map, and offer to migrate them at startup or from Help > Migrate Filament Presets. Migrating first backs up the user folder to filament_preset_migration_<datetime>_backup.zip in the configuration folder, and migrates nothing if that fails. It then writes the printers into each preset's compatible_printers, patching only that key so the preset keeps the parent name it was saved with and older releases can still resolve it. Cloud-synced presets are marked for upload. No asks again at the next launch; "Don't remind me again" stops the startup prompt.
This commit is contained in:
1 parent
e55ac357b5
commit
65e97cddd2
15 files changed
+430
-90
No files matched your search
@@ -12,6 +12,7 @@
|
||||
#include "DeviceManager.hpp"
|
||||
#include "HMS.hpp"
|
||||
#include "PresetBundleDialog.hpp"
|
||||
#include "LegacyPrinterMigrationDialog.hpp"
|
||||
#include "WebUserLoginDialog.hpp"
|
||||
#include "WebViewDialog.hpp"
|
||||
#include "slic3r/Utils/BBLCloudServiceAgent.hpp"
|
||||
@@ -1109,6 +1110,8 @@ void GUI_App::post_init()
|
||||
}
|
||||
|
||||
this->check_new_version_sf();
|
||||
if (!cw_showed)
|
||||
this->check_legacy_printer_migration(false);
|
||||
const auto cloud_provider = get_printer_cloud_provider();
|
||||
if (is_user_login(cloud_provider) && !app_config->get_stealth_mode()) {
|
||||
// this->check_privacy_version(0);
|
||||
@@ -6822,6 +6825,50 @@ void GUI_App::reload_settings()
|
||||
}
|
||||
}
|
||||
|
||||
void GUI_App::check_legacy_printer_migration(bool by_user)
|
||||
{
|
||||
const std::vector<LegacyPrinterMigration> migrations = preset_bundle->legacy_printer_migrations();
|
||||
if (migrations.empty()) {
|
||||
if (by_user)
|
||||
MessageDialog(mainframe, _L("All your filament presets are available on the printers they were made for."),
|
||||
_L("Migrate Filament Presets"), wxOK | wxICON_INFORMATION).ShowModal();
|
||||
return;
|
||||
}
|
||||
if (!by_user && app_config->get_bool("legacy_printer_migration_dont_remind"))
|
||||
return;
|
||||
|
||||
LegacyPrinterMigrationDialog dlg(mainframe, migrations, !by_user);
|
||||
const bool migrate = dlg.ShowModal() == wxID_YES;
|
||||
if (dlg.dont_remind())
|
||||
app_config->set_bool("legacy_printer_migration_dont_remind", true);
|
||||
if (!migrate)
|
||||
return;
|
||||
|
||||
std::vector<std::string> failed;
|
||||
const std::string backup = preset_bundle->migrate_legacy_printers(migrations, failed);
|
||||
if (backup.empty()) {
|
||||
show_error(mainframe, _L("Your presets could not be backed up, so they were not migrated."));
|
||||
return;
|
||||
}
|
||||
preset_bundle->update_compatible(PresetSelectCompatibleType::Never);
|
||||
mainframe->update_side_preset_ui();
|
||||
for (auto tab : tabs_list) {
|
||||
tab->reload_config();
|
||||
tab->update_changed_ui();
|
||||
}
|
||||
if (plater_)
|
||||
plater_->sidebar().update_all_preset_comboboxes();
|
||||
|
||||
wxString message = format_wxstr(_L("Your filament presets were migrated. Select them again in the filament list where you used them.\n\n"
|
||||
"A backup of your presets was saved to:\n%1%"), backup);
|
||||
if (!failed.empty()) {
|
||||
message += "\n\n" + _L("These presets could not be migrated:");
|
||||
for (const std::string &name : failed)
|
||||
message += "\n" + from_u8(name);
|
||||
}
|
||||
MessageDialog(mainframe, message, _L("Migrate Filament Presets"), wxOK | (failed.empty() ? wxICON_INFORMATION : wxICON_WARNING)).ShowModal();
|
||||
}
|
||||
|
||||
//BBS reload when logout
|
||||
void GUI_App::remove_user_presets()
|
||||
{
|
||||
|
||||
@@ -568,6 +568,10 @@ public:
|
||||
void check_update(bool show_tips, int by_user);
|
||||
void check_new_version(bool show_tips = false, int by_user = 0);
|
||||
void check_new_version_sf(bool show_tips = false, int by_user = 0);
|
||||
// Offers to migrate user filament presets that lost printers their parent listed in an older release.
|
||||
// At startup it asks once per release unless the user chose not to be reminded; by_user also reports
|
||||
// when there is nothing to migrate.
|
||||
void check_legacy_printer_migration(bool by_user);
|
||||
bool process_network_msg(std::string dev_id, std::string msg);
|
||||
void request_new_version(int by_user);
|
||||
void enter_force_upgrade();
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
#include "LegacyPrinterMigrationDialog.hpp"
|
||||
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI_Utils.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "MainFrame.hpp"
|
||||
#include "format.hpp"
|
||||
#include "libslic3r/Preset.hpp"
|
||||
#include "Widgets/Button.hpp"
|
||||
#include "Widgets/CheckBox.hpp"
|
||||
#include "Widgets/DialogButtons.hpp"
|
||||
#include "Widgets/Label.hpp"
|
||||
|
||||
#include <wx/event.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/toplevel.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
LegacyPrinterMigrationDialog::LegacyPrinterMigrationDialog(wxWindow *parent, const std::vector<LegacyPrinterMigration> &migrations,
|
||||
bool offer_dont_remind)
|
||||
: DPIDialog(parent ? parent : static_cast<wxWindow *>(wxGetApp().mainframe), wxID_ANY, _L("Migrate Filament Presets"),
|
||||
wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
|
||||
{
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
SetFont(Label::Body_14);
|
||||
|
||||
auto *sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
auto *message = new Label(this,
|
||||
_L("Since OrcaSlicer 2.5.0, filament presets have been restructured to support more features. Some of your "
|
||||
"presets need to be migrated to the new structure, or they will no longer be available for some of your "
|
||||
"printers.\n\n"
|
||||
"Would you like to migrate them now? Your presets will be backed up first, and this only needs to be done "
|
||||
"once. You can also do it later from Help > Migrate Filament Presets."),
|
||||
0);
|
||||
message->Wrap(FromDIP(520));
|
||||
sizer->Add(message, 0, wxEXPAND | wxALL, FromDIP(15));
|
||||
|
||||
sizer->Add(new Label(this, _L("Affected presets:")), 0, wxLEFT | wxRIGHT, FromDIP(15));
|
||||
sizer->AddSpacer(FromDIP(5));
|
||||
|
||||
wxString details;
|
||||
for (const LegacyPrinterMigration &migration : migrations) {
|
||||
details += format_wxstr(_L("%1% (based on %2%)"), migration.preset, migration.parent) + "\n";
|
||||
for (const std::string &printer : migration.printers)
|
||||
details += " " + from_u8(printer) + "\n";
|
||||
}
|
||||
auto *list = new wxTextCtrl(this, wxID_ANY, details, wxDefaultPosition, wxSize(-1, FromDIP(220)),
|
||||
wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP);
|
||||
sizer->Add(list, 1, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(15));
|
||||
|
||||
if (offer_dont_remind) {
|
||||
auto *dont_remind_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
m_dont_remind = new ::CheckBox(this);
|
||||
auto *dont_remind_label = new Label(this, _L("Don't remind me again"));
|
||||
dont_remind_label->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) {
|
||||
m_dont_remind->SetValue(!m_dont_remind->GetValue());
|
||||
e.Skip();
|
||||
});
|
||||
dont_remind_sizer->Add(m_dont_remind, 0, wxALIGN_CENTER_VERTICAL);
|
||||
dont_remind_sizer->Add(dont_remind_label, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(6));
|
||||
sizer->Add(dont_remind_sizer, 0, wxLEFT | wxRIGHT | wxTOP, FromDIP(15));
|
||||
}
|
||||
|
||||
auto *buttons = new DialogButtons(this, {"Yes", "No"}, "Yes");
|
||||
buttons->GetYES()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) { EndModal(wxID_YES); });
|
||||
buttons->GetNO()->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) { EndModal(wxID_NO); });
|
||||
sizer->Add(buttons, 0, wxEXPAND);
|
||||
|
||||
SetSizerAndFit(sizer);
|
||||
CenterOnParent();
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
}
|
||||
|
||||
bool LegacyPrinterMigrationDialog::dont_remind() const
|
||||
{
|
||||
return m_dont_remind != nullptr && m_dont_remind->GetValue();
|
||||
}
|
||||
|
||||
void LegacyPrinterMigrationDialog::on_dpi_changed(const wxRect &)
|
||||
{
|
||||
if (m_dont_remind != nullptr)
|
||||
m_dont_remind->Rescale();
|
||||
GetSizer()->SetSizeHints(this);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "GUI_Utils.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class CheckBox;
|
||||
class wxWindow;
|
||||
class wxRect;
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
struct LegacyPrinterMigration;
|
||||
|
||||
namespace GUI {
|
||||
|
||||
// Lists the user filament presets that no longer show on printers their parent listed in an older
|
||||
// release, and asks whether to migrate them. ShowModal() returns wxID_YES to migrate. With
|
||||
// offer_dont_remind it also offers to stop the startup reminder for good.
|
||||
class LegacyPrinterMigrationDialog : public DPIDialog
|
||||
{
|
||||
public:
|
||||
LegacyPrinterMigrationDialog(wxWindow *parent, const std::vector<LegacyPrinterMigration> &migrations, bool offer_dont_remind);
|
||||
|
||||
bool dont_remind() const;
|
||||
|
||||
protected:
|
||||
void on_dpi_changed(const wxRect &suggested_rect) override;
|
||||
|
||||
private:
|
||||
::CheckBox *m_dont_remind{nullptr};
|
||||
};
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
@@ -2827,6 +2827,10 @@ wxMenu* MainFrame::generate_help_menu()
|
||||
append_menu_item(helpMenu, wxID_ANY, _L("Show Configuration Folder"), _L("Show Configuration Folder"),
|
||||
[](wxCommandEvent&) { Slic3r::GUI::desktop_open_datadir_folder(); });
|
||||
|
||||
append_menu_item(helpMenu, wxID_ANY, _L("Migrate Filament Presets"),
|
||||
_L("Bring back filament presets that a profile update removed from printers they were made for"),
|
||||
[](wxCommandEvent&) { wxGetApp().check_legacy_printer_migration(true); });
|
||||
|
||||
helpMenu->AppendSeparator();
|
||||
|
||||
// Troubleshoot center
|
||||
|
||||
@@ -589,6 +589,10 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
Slic3r::GUI::desktop_open_datadir_folder();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("help_migrate_filament_presets", L("Migrate Filament Presets"), L("Help"), [](const std::string&) {
|
||||
wxGetApp().check_legacy_printer_migration(true);
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("help_troubleshoot", L("Troubleshoot Center"), L("Help"), [](const std::string&) {
|
||||
wxGetApp().troubleshoot();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
|
||||
Reference in new issue
Block a user