Simplified "Save/Rename Preset" dialog when only one preset is saved/renamed.
This commit is contained in:
parent
0eb2a2cf04
commit
3ad5f52b00
4 changed files with 31 additions and 40 deletions
|
@ -85,18 +85,17 @@ void SavePresetDialog::Item::init_input_name_ctrl(wxBoxSizer *input_name_sizer,
|
|||
}
|
||||
}
|
||||
|
||||
wxString SavePresetDialog::Item::get_top_label_text() const
|
||||
static std::map<Preset::Type, std::string> TOP_LABELS =
|
||||
{
|
||||
const std::string label_str = m_use_text_ctrl ?
|
||||
// TRN %1% = "Preset"
|
||||
L("Rename %1% to") :
|
||||
// TRN %1% = "Preset"
|
||||
L("Save %1% as");
|
||||
Tab* tab = wxGetApp().get_tab(m_type);
|
||||
return format_wxstr(_(label_str) + ":", tab->title());
|
||||
}
|
||||
// type Save settings
|
||||
{ Preset::Type::TYPE_PRINT, L("Save print settings as") },
|
||||
{ Preset::Type::TYPE_SLA_PRINT, L("Save print settings as") },
|
||||
{ Preset::Type::TYPE_FILAMENT, L("Save filament settings as")},
|
||||
{ Preset::Type::TYPE_SLA_MATERIAL, L("Save material settings as")},
|
||||
{ Preset::Type::TYPE_PRINTER, L("Save printer settings as") },
|
||||
};
|
||||
|
||||
SavePresetDialog::Item::Item(Preset::Type type, const std::string& suffix, wxBoxSizer* sizer, SavePresetDialog* parent):
|
||||
SavePresetDialog::Item::Item(Preset::Type type, const std::string& suffix, wxBoxSizer* sizer, SavePresetDialog* parent, bool is_for_multiple_save):
|
||||
m_type(type),
|
||||
m_use_text_ctrl(parent->is_for_rename()),
|
||||
m_parent(parent),
|
||||
|
@ -105,14 +104,15 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string& suffix, wxBox
|
|||
{
|
||||
m_valid_label->SetFont(wxGetApp().bold_font());
|
||||
|
||||
wxStaticText* label_top = new wxStaticText(m_parent, wxID_ANY, get_top_label_text());
|
||||
wxStaticText* label_top = is_for_multiple_save ? new wxStaticText(m_parent, wxID_ANY, _(TOP_LABELS.at(m_type)) + ":") : nullptr;
|
||||
|
||||
wxBoxSizer* input_name_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
input_name_sizer->Add(m_valid_bmp, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, BORDER_W);
|
||||
init_input_name_ctrl(input_name_sizer, get_init_preset_name(suffix));
|
||||
|
||||
sizer->Add(label_top, 0, wxEXPAND | wxTOP| wxBOTTOM, BORDER_W);
|
||||
sizer->Add(input_name_sizer,0, wxEXPAND | wxBOTTOM, BORDER_W);
|
||||
if (label_top)
|
||||
sizer->Add(label_top, 0, wxEXPAND | wxTOP| wxBOTTOM, BORDER_W);
|
||||
sizer->Add(input_name_sizer,0, wxEXPAND | (label_top ? 0 : wxTOP) | wxBOTTOM, BORDER_W);
|
||||
sizer->Add(m_valid_label, 0, wxEXPAND | wxLEFT, 3*BORDER_W);
|
||||
|
||||
if (m_type == Preset::TYPE_PRINTER)
|
||||
|
@ -205,8 +205,6 @@ void SavePresetDialog::Item::update()
|
|||
if ((!m_use_text_ctrl && m_presets->get_edited_preset().is_dirty) ||
|
||||
(dlg && dlg->get_preset_bundle())) // means that we save modifications from the DiffDialog
|
||||
info_line = _L("Save preset modifications to existing user profile");
|
||||
else
|
||||
info_line = _L("Nothing changed");
|
||||
m_valid_type = ValidationType::Valid;
|
||||
}
|
||||
else {
|
||||
|
@ -266,8 +264,8 @@ void SavePresetDialog::Item::update()
|
|||
|
||||
void SavePresetDialog::Item::update_valid_bmp()
|
||||
{
|
||||
std::string bmp_name = m_valid_type == ValidationType::Warning ? "exclamation" :
|
||||
m_valid_type == ValidationType::NoValid ? "cross" : "tick_mark" ;
|
||||
std::string bmp_name = m_valid_type == ValidationType::Warning ? "exclamation_manifold" :
|
||||
m_valid_type == ValidationType::NoValid ? "exclamation" : "tick_mark" ;
|
||||
m_valid_bmp->SetBitmap(*get_bmp_bundle(bmp_name));
|
||||
}
|
||||
|
||||
|
@ -289,22 +287,17 @@ void SavePresetDialog::Item::Enable(bool enable /*= true*/)
|
|||
// SavePresetDialog
|
||||
//-----------------------------------------------
|
||||
|
||||
SavePresetDialog::SavePresetDialog(wxWindow* parent, Preset::Type type, std::string suffix, bool template_filament)
|
||||
: DPIDialog(parent, wxID_ANY, _L("Save preset"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), 5 * wxGetApp().em_unit()), wxDEFAULT_DIALOG_STYLE | wxICON_WARNING | wxRESIZE_BORDER)
|
||||
{
|
||||
build(std::vector<Preset::Type>{type}, suffix, template_filament);
|
||||
}
|
||||
|
||||
SavePresetDialog::SavePresetDialog(wxWindow* parent, std::vector<Preset::Type> types, std::string suffix, bool template_filament/* =false*/, PresetBundle* preset_bundle/* = nullptr*/)
|
||||
: DPIDialog(parent, wxID_ANY, _L("Save presets"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), 5 * wxGetApp().em_unit()), wxDEFAULT_DIALOG_STYLE | wxICON_WARNING | wxRESIZE_BORDER),
|
||||
: DPIDialog(parent, wxID_ANY, types.size() == 1 ? _L("Save preset") : _L("Save presets"),
|
||||
wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), 5 * wxGetApp().em_unit()), wxDEFAULT_DIALOG_STYLE | wxICON_WARNING),
|
||||
m_preset_bundle(preset_bundle)
|
||||
{
|
||||
build(types, suffix, template_filament);
|
||||
}
|
||||
|
||||
SavePresetDialog::SavePresetDialog(wxWindow* parent, Preset::Type type, bool rename, const wxString& info_line_extention)
|
||||
: DPIDialog(parent, wxID_ANY, _L("Rename preset"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), 5 * wxGetApp().em_unit()), wxDEFAULT_DIALOG_STYLE | wxICON_WARNING | wxRESIZE_BORDER),
|
||||
m_use_for_rename(rename),
|
||||
SavePresetDialog::SavePresetDialog(wxWindow* parent, Preset::Type type, const wxString& info_line_extention)
|
||||
: DPIDialog(parent, wxID_ANY, _L("Rename preset"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), 5 * wxGetApp().em_unit()), wxDEFAULT_DIALOG_STYLE | wxICON_WARNING),
|
||||
m_use_for_rename(true),
|
||||
m_info_line_extention(info_line_extention)
|
||||
{
|
||||
build(std::vector<Preset::Type>{type});
|
||||
|
@ -335,9 +328,9 @@ void SavePresetDialog::build(std::vector<Preset::Type> types, std::string suffix
|
|||
|
||||
m_presets_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
// Add first item
|
||||
for (Preset::Type type : types)
|
||||
AddItem(type, suffix);
|
||||
const bool is_for_multiple_save = types.size() > 1;
|
||||
for (const Preset::Type& type : types)
|
||||
AddItem(type, suffix, is_for_multiple_save);
|
||||
|
||||
// Add dialog's buttons
|
||||
wxStdDialogButtonSizer* btns = this->CreateStdDialogButtonSizer(wxOK | wxCANCEL);
|
||||
|
@ -367,9 +360,9 @@ void SavePresetDialog::build(std::vector<Preset::Type> types, std::string suffix
|
|||
#endif
|
||||
}
|
||||
|
||||
void SavePresetDialog::AddItem(Preset::Type type, const std::string& suffix)
|
||||
void SavePresetDialog::AddItem(Preset::Type type, const std::string& suffix, bool is_for_multiple_save)
|
||||
{
|
||||
m_items.emplace_back(new Item{type, suffix, m_presets_sizer, this});
|
||||
m_items.emplace_back(new Item{type, suffix, m_presets_sizer, this, is_for_multiple_save});
|
||||
}
|
||||
|
||||
std::string SavePresetDialog::get_name()
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
Warning
|
||||
};
|
||||
|
||||
Item(Preset::Type type, const std::string& suffix, wxBoxSizer* sizer, SavePresetDialog* parent);
|
||||
Item(Preset::Type type, const std::string& suffix, wxBoxSizer* sizer, SavePresetDialog* parent, bool is_for_multiple_save);
|
||||
Item(wxWindow* parent, wxBoxSizer* sizer, const std::string& def_name, PrinterTechnology pt = ptFFF);
|
||||
|
||||
void update_valid_bmp();
|
||||
|
@ -65,7 +65,6 @@ public:
|
|||
std::string get_init_preset_name(const std::string &suffix);
|
||||
void init_input_name_ctrl(wxBoxSizer *input_name_sizer, std::string preset_name);
|
||||
const Preset* get_existing_preset() const ;
|
||||
wxString get_top_label_text() const ;
|
||||
|
||||
void update();
|
||||
};
|
||||
|
@ -89,12 +88,11 @@ public:
|
|||
|
||||
const wxString& get_info_line_extention() { return m_info_line_extention; }
|
||||
|
||||
SavePresetDialog(wxWindow* parent, Preset::Type type, std::string suffix = "", bool template_filament = false);
|
||||
SavePresetDialog(wxWindow* parent, std::vector<Preset::Type> types, std::string suffix = "", bool template_filament = false, PresetBundle* preset_bundle = nullptr);
|
||||
SavePresetDialog(wxWindow* parent, Preset::Type type, bool rename, const wxString& info_line_extention);
|
||||
SavePresetDialog(wxWindow* parent, Preset::Type type, const wxString& info_line_extention);
|
||||
~SavePresetDialog() override;
|
||||
|
||||
void AddItem(Preset::Type type, const std::string& suffix);
|
||||
void AddItem(Preset::Type type, const std::string& suffix, bool is_for_multiple_save);
|
||||
|
||||
PresetBundle* get_preset_bundle() const { return m_preset_bundle; }
|
||||
std::string get_name();
|
||||
|
|
|
@ -3820,7 +3820,7 @@ void Tab::save_preset(std::string name /*= ""*/, bool detach)
|
|||
}
|
||||
|
||||
if (name.empty()) {
|
||||
SavePresetDialog dlg(m_parent, m_type, detach ? _u8L("Detached") : "", from_template);
|
||||
SavePresetDialog dlg(m_parent, { m_type }, detach ? _u8L("Detached") : "", from_template);
|
||||
if (dlg.ShowModal() != wxID_OK)
|
||||
return;
|
||||
name = dlg.get_name();
|
||||
|
@ -3931,7 +3931,7 @@ void Tab::rename_preset()
|
|||
|
||||
// get new name
|
||||
|
||||
SavePresetDialog dlg(m_parent, m_type, true, msg);
|
||||
SavePresetDialog dlg(m_parent, m_type, msg);
|
||||
if (dlg.ShowModal() != wxID_OK)
|
||||
return;
|
||||
|
||||
|
|
|
@ -1012,7 +1012,7 @@ bool UnsavedChangesDialog::save(PresetCollection* dependent_presets, bool show_s
|
|||
|
||||
// for system/default/external presets we should take an edited name
|
||||
if (preset.is_system || preset.is_default || preset.is_external) {
|
||||
SavePresetDialog save_dlg(this, preset.type);
|
||||
SavePresetDialog save_dlg(this, { preset.type });
|
||||
if (save_dlg.ShowModal() != wxID_OK) {
|
||||
m_exit_action = Action::Discard;
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue