mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-19 19:33:47 +00:00
added option to save a profile as detached(no inheritance)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,124 +1,135 @@
|
|||||||
#ifndef slic3r_SavePresetDialog_hpp_
|
#ifndef slic3r_SavePresetDialog_hpp_
|
||||||
#define slic3r_SavePresetDialog_hpp_
|
#define slic3r_SavePresetDialog_hpp_
|
||||||
|
|
||||||
//#include <wx/gdicmn.h>
|
//#include <wx/gdicmn.h>
|
||||||
|
|
||||||
#include "libslic3r/Preset.hpp"
|
#include "libslic3r/Preset.hpp"
|
||||||
#include "wxExtensions.hpp"
|
#include "wxExtensions.hpp"
|
||||||
#include "GUI_Utils.hpp"
|
#include "GUI_Utils.hpp"
|
||||||
#include "Widgets/RadioBox.hpp"
|
#include "Widgets/RadioBox.hpp"
|
||||||
#include "Widgets/Button.hpp"
|
#include "Widgets/Button.hpp"
|
||||||
#include "Widgets/RoundedRectangle.hpp"
|
#include "Widgets/RoundedRectangle.hpp"
|
||||||
#include "Widgets/Label.hpp"
|
#include "Widgets/Label.hpp"
|
||||||
#include "Widgets/TextInput.hpp"
|
#include "Widgets/TextInput.hpp"
|
||||||
|
|
||||||
class wxString;
|
class wxString;
|
||||||
class wxStaticText;
|
class wxStaticText;
|
||||||
class wxComboBox;
|
class wxComboBox;
|
||||||
class wxStaticBitmap;
|
class wxStaticBitmap;
|
||||||
|
|
||||||
#define SAVE_PRESET_DIALOG_DEF_COLOUR wxColour(255, 255, 255)
|
#define SAVE_PRESET_DIALOG_DEF_COLOUR wxColour(255, 255, 255)
|
||||||
#define SAVE_PRESET_DIALOG_INPUT_SIZE wxSize(FromDIP(360), FromDIP(24))
|
#define SAVE_PRESET_DIALOG_INPUT_SIZE wxSize(FromDIP(360), FromDIP(24))
|
||||||
#define SAVE_PRESET_DIALOG_BUTTON_SIZE wxSize(FromDIP(60), FromDIP(24))
|
#define SAVE_PRESET_DIALOG_BUTTON_SIZE wxSize(FromDIP(60), FromDIP(24))
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
class SavePresetDialog : public DPIDialog
|
class SavePresetDialog : public DPIDialog
|
||||||
{
|
{
|
||||||
enum ActionType
|
enum ActionType
|
||||||
{
|
{
|
||||||
ChangePreset,
|
ChangePreset,
|
||||||
AddPreset,
|
AddPreset,
|
||||||
Switch,
|
Switch,
|
||||||
UndefAction
|
UndefAction
|
||||||
};
|
};
|
||||||
|
|
||||||
class Item : public wxWindow
|
class Item : public wxWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum ValidationType
|
enum ValidationType
|
||||||
{
|
{
|
||||||
Valid,
|
Valid,
|
||||||
NoValid,
|
NoValid,
|
||||||
Warning
|
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);
|
||||||
|
|
||||||
void update_valid_bmp();
|
void update_valid_bmp();
|
||||||
void accept();
|
void accept();
|
||||||
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
|
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
|
||||||
|
|
||||||
bool is_valid() const { return m_valid_type != NoValid; }
|
bool is_valid() const { return m_valid_type != NoValid; }
|
||||||
Preset::Type type() const { return m_type; }
|
Preset::Type type() const { return m_type; }
|
||||||
std::string preset_name() const { return m_preset_name; }
|
std::string preset_name() const { return m_preset_name; }
|
||||||
//BBS: add project embedded preset relate logic
|
//BBS: add project embedded preset relate logic
|
||||||
bool save_to_project() const { return m_save_to_project; }
|
bool save_to_project() const { return m_save_to_project; }
|
||||||
|
|
||||||
Preset::Type m_type;
|
// Method to get detach state
|
||||||
ValidationType m_valid_type;
|
bool is_detached() const { return m_detach; }
|
||||||
std::string m_preset_name;
|
|
||||||
|
Preset::Type m_type;
|
||||||
SavePresetDialog* m_parent {nullptr};
|
ValidationType m_valid_type;
|
||||||
wxStaticBitmap* m_valid_bmp {nullptr};
|
std::string m_preset_name;
|
||||||
wxComboBox* m_combo {nullptr};
|
|
||||||
TextInput* m_input_ctrl {nullptr};
|
SavePresetDialog* m_parent {nullptr};
|
||||||
wxStaticText* m_valid_label {nullptr};
|
wxStaticBitmap* m_valid_bmp {nullptr};
|
||||||
|
wxComboBox* m_combo {nullptr};
|
||||||
PresetCollection* m_presets {nullptr};
|
TextInput* m_input_ctrl {nullptr};
|
||||||
|
wxStaticText* m_valid_label {nullptr};
|
||||||
//BBS: add project embedded preset relate logic
|
|
||||||
RadioBox * m_radio_user{nullptr};
|
PresetCollection* m_presets {nullptr};
|
||||||
RadioBox * m_radio_project{nullptr};
|
|
||||||
bool m_save_to_project {false};
|
//BBS: add project embedded preset relate logic
|
||||||
|
RadioBox * m_radio_user{nullptr};
|
||||||
void update();
|
RadioBox * m_radio_project{nullptr};
|
||||||
};
|
wxCheckBox* m_detach_checkbox{nullptr};
|
||||||
|
|
||||||
std::vector<Item*> m_items;
|
bool m_save_to_project {false};
|
||||||
|
bool m_detach{false};
|
||||||
Button* m_confirm {nullptr};
|
|
||||||
Button* m_cancel {nullptr};
|
void update();
|
||||||
wxBoxSizer* m_presets_sizer {nullptr};
|
};
|
||||||
wxStaticText* m_label {nullptr};
|
|
||||||
wxBoxSizer* m_radio_sizer {nullptr};
|
std::vector<Item*> m_items;
|
||||||
ActionType m_action {UndefAction};
|
|
||||||
|
Button* m_confirm {nullptr};
|
||||||
std::string m_ph_printer_name;
|
Button* m_cancel {nullptr};
|
||||||
std::string m_old_preset_name;
|
wxBoxSizer* m_presets_sizer {nullptr};
|
||||||
|
wxStaticText* m_label {nullptr};
|
||||||
public:
|
wxBoxSizer* m_radio_sizer {nullptr};
|
||||||
SavePresetDialog(wxWindow *parent, Preset::Type type, std::string suffix = "");
|
ActionType m_action {UndefAction};
|
||||||
SavePresetDialog(wxWindow* parent, std::vector<Preset::Type> types, std::string suffix = "");
|
int m_mode;
|
||||||
~SavePresetDialog();
|
|
||||||
|
std::string m_ph_printer_name;
|
||||||
void AddItem(Preset::Type type, const std::string& suffix);
|
std::string m_old_preset_name;
|
||||||
|
|
||||||
std::string get_name();
|
public:
|
||||||
std::string get_name(Preset::Type type);
|
SavePresetDialog(wxWindow* parent, Preset::Type type, int mode = 0, std::string suffix = "");
|
||||||
void input_name_from_other(std::string new_preset_name);
|
SavePresetDialog(wxWindow* parent, std::vector<Preset::Type> types, int mode = 0, std::string suffix = "");
|
||||||
void confirm_from_other();
|
~SavePresetDialog();
|
||||||
|
|
||||||
bool enable_ok_btn() const;
|
void AddItem(Preset::Type type, const std::string& suffix);
|
||||||
void add_info_for_edit_ph_printer(wxBoxSizer *sizer);
|
|
||||||
void update_info_for_edit_ph_printer(const std::string &preset_name);
|
std::string get_name();
|
||||||
void layout();
|
std::string get_name(Preset::Type type);
|
||||||
//BBS: add project embedded preset relate logic
|
void input_name_from_other(std::string new_preset_name);
|
||||||
bool get_save_to_project_selection(Preset::Type type);
|
void confirm_from_other();
|
||||||
|
|
||||||
protected:
|
bool enable_ok_btn() const;
|
||||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
void add_info_for_edit_ph_printer(wxBoxSizer *sizer);
|
||||||
void on_sys_color_changed() override {}
|
void update_info_for_edit_ph_printer(const std::string &preset_name);
|
||||||
|
void layout();
|
||||||
private:
|
//BBS: add project embedded preset relate logic
|
||||||
void build(std::vector<Preset::Type> types, std::string suffix = "");
|
bool get_save_to_project_selection(Preset::Type type);
|
||||||
void on_select_cancel(wxCommandEvent &event);
|
|
||||||
void update_physical_printers(const std::string &preset_name);
|
// Method to get the detach state
|
||||||
void accept(wxCommandEvent &event);
|
bool get_detach_value(Preset::Type type);
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace GUI
|
protected:
|
||||||
} // namespace Slic3r
|
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||||
|
void on_sys_color_changed() override {}
|
||||||
#endif
|
|
||||||
|
private:
|
||||||
|
void build(std::vector<Preset::Type> types, std::string suffix = "");
|
||||||
|
void on_select_cancel(wxCommandEvent &event);
|
||||||
|
void update_physical_printers(const std::string &preset_name);
|
||||||
|
void accept(wxCommandEvent &event);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace GUI
|
||||||
|
} // namespace Slic3r
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -5506,17 +5506,18 @@ void Tab::save_preset(std::string name /*= ""*/, bool detach, bool save_to_proje
|
|||||||
// focus currently.is there anything better than this ?
|
// focus currently.is there anything better than this ?
|
||||||
//! m_tabctrl->OnSetFocus();
|
//! m_tabctrl->OnSetFocus();
|
||||||
if (from_input) {
|
if (from_input) {
|
||||||
SavePresetDialog dlg(m_parent, m_type, detach ? _u8L("Detached") : "");
|
SavePresetDialog dlg(m_parent, m_type, m_mode, detach ? _u8L("Detached") : "");
|
||||||
dlg.Show(false);
|
dlg.Show(false);
|
||||||
dlg.input_name_from_other(input_name);
|
dlg.input_name_from_other(input_name);
|
||||||
wxCommandEvent evt(wxEVT_TEXT, GetId());
|
wxCommandEvent evt(wxEVT_TEXT, GetId());
|
||||||
dlg.GetEventHandler()->ProcessEvent(evt);
|
dlg.GetEventHandler()->ProcessEvent(evt);
|
||||||
dlg.confirm_from_other();
|
dlg.confirm_from_other();
|
||||||
name = input_name;
|
name = input_name;
|
||||||
|
detach = dlg.get_detach_value(m_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.empty()) {
|
if (name.empty()) {
|
||||||
SavePresetDialog dlg(m_parent, m_type, detach ? _u8L("Detached") : "");
|
SavePresetDialog dlg(m_parent, m_type, m_mode, detach ? _u8L("Detached") : "");
|
||||||
if (!m_just_edit) {
|
if (!m_just_edit) {
|
||||||
if (dlg.ShowModal() != wxID_OK)
|
if (dlg.ShowModal() != wxID_OK)
|
||||||
return;
|
return;
|
||||||
@@ -5524,6 +5525,7 @@ void Tab::save_preset(std::string name /*= ""*/, bool detach, bool save_to_proje
|
|||||||
name = dlg.get_name();
|
name = dlg.get_name();
|
||||||
//BBS: add project embedded preset relate logic
|
//BBS: add project embedded preset relate logic
|
||||||
save_to_project = dlg.get_save_to_project_selection(m_type);
|
save_to_project = dlg.get_save_to_project_selection(m_type);
|
||||||
|
detach = dlg.get_detach_value(m_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
//BBS record current preset name
|
//BBS record current preset name
|
||||||
|
|||||||
Reference in New Issue
Block a user