SavePresetDialog: Improvements

This commit is contained in:
YuSanka 2020-07-29 16:05:30 +02:00
parent 3c3e463f50
commit 96a364c3e6
3 changed files with 229 additions and 140 deletions

View file

@ -14,6 +14,7 @@ class wxStaticText;
class ScalableButton;
class wxBoxSizer;
class wxComboBox;
class wxStaticBitmap;
namespace Slic3r {
@ -200,35 +201,70 @@ class SavePresetDialog : public DPIDialog
UndefAction
};
TabPresetComboBox* m_preset_cb {nullptr};
std::string m_preset_name;
wxComboBox* m_combo {nullptr};
wxStaticText* m_label {nullptr};
struct Item
{
enum ValidationType
{
Valid,
NoValid,
Warning
};
Item(Preset::Type type, const std::string& suffix, wxBoxSizer* sizer, SavePresetDialog* parent);
void accept();
bool is_valid() const { return m_valid_type != NoValid; }
Preset::Type type() const { return m_type; }
std::string preset_name() const { return m_preset_name; }
private:
Preset::Type m_type;
ValidationType m_valid_type;
std::string m_preset_name;
SavePresetDialog* m_parent {nullptr};
wxStaticBitmap* m_valid_bmp {nullptr};
wxComboBox* m_combo {nullptr};
wxStaticText* m_valid_label {nullptr};
PresetCollection* m_presets {nullptr};
void update();
};
std::vector<Item> m_items;
wxBoxSizer* m_presets_sizer {nullptr};
wxStaticText* m_label {nullptr};
wxRadioBox* m_action_radio_box {nullptr};
wxBoxSizer* m_radio_sizer {nullptr};
ActionType m_action {UndefAction};
std::string m_ph_printer_name;
std::string m_old_preset_name;
std::string m_ph_printer_name;
std::string m_old_preset_name;
public:
SavePresetDialog(TabPresetComboBox* preset_cb, const std::string& suffix);
SavePresetDialog(Preset::Type type, const std::string& suffix);
~SavePresetDialog() {}
std::string get_name() { return m_preset_name; }
void AddItem(Preset::Type type, const std::string& suffix);
std::string get_name();
std::string get_name(Preset::Type type);
bool enable_ok_btn() const;
void add_info_for_edit_ph_printer(wxBoxSizer *sizer);
void update_info_for_edit_ph_printer(const std::string &preset_name);
void layout();
protected:
void on_dpi_changed(const wxRect& suggested_rect) override;
void on_sys_color_changed() override {}
private:
void add_common_items(wxBoxSizer *sizer, const std::string &suffix);
void add_items_for_edit_ph_printer(wxBoxSizer *sizer);
void update(const std::string &preset_name);
bool preset_name_is_accepted();
bool preset_is_possible_to_save();
void update_physical_printers();
void update_physical_printers(const std::string& preset_name);
void accept();
};