mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-16 03:07:55 -06:00
QoL: Port profile value transfer on profile diff dialog from PrusaSlicer (#3737)
* DiffDialog: Implemented a transfer of options from one preset to another Related to [Feature Request] #5384 - Copy values in Profile comparaison dialog Cherry-picked from prusa3d/PrusaSlicer@0b8d7380ff Co-authored-by: YuSanka <yusanka@gmail.com> * Remove save button * Sync with latest PS * Use Orca button style * Show tips about trasnfer disabled --------- Co-authored-by: YuSanka <yusanka@gmail.com>
This commit is contained in:
parent
48541be681
commit
55b6f2a588
13 changed files with 422 additions and 108 deletions
|
@ -1,3 +1,7 @@
|
|||
///|/ Copyright (c) Prusa Research 2020 - 2023 Oleksandra Iushchenko @YuSanka, Lukáš Hejl @hejllukas, Vojtěch Bubník @bubnikv, David Kocík @kocikdav
|
||||
///|/
|
||||
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
|
||||
///|/
|
||||
#ifndef slic3r_UnsavedChangesDialog_hpp_
|
||||
#define slic3r_UnsavedChangesDialog_hpp_
|
||||
|
||||
|
@ -17,6 +21,8 @@ class wxStaticText;
|
|||
namespace Slic3r {
|
||||
namespace GUI{
|
||||
|
||||
wxDECLARE_EVENT(EVT_DIFF_DIALOG_TRANSFER, SimpleEvent);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ModelNode: a node inside DiffModel
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -101,7 +107,7 @@ public:
|
|||
ModelNode* GetParent() { return m_parent; }
|
||||
ModelNodePtrArray& GetChildren() { return m_children; }
|
||||
ModelNode* GetNthChild(unsigned int n) { return m_children[n].get(); }
|
||||
unsigned int GetChildCount() const { return m_children.size(); }
|
||||
unsigned int GetChildCount() const { return (unsigned int)(m_children.size()); }
|
||||
|
||||
void Append(std::unique_ptr<ModelNode> child) { m_children.emplace_back(std::move(child)); }
|
||||
|
||||
|
@ -148,7 +154,7 @@ public:
|
|||
};
|
||||
|
||||
DiffModel(wxWindow* parent);
|
||||
~DiffModel(){};
|
||||
~DiffModel() override = default;
|
||||
|
||||
void SetAssociatedControl(wxDataViewCtrl* ctrl) { m_ctrl = ctrl; }
|
||||
|
||||
|
@ -228,6 +234,21 @@ public:
|
|||
std::vector<std::string> selected_options();
|
||||
};
|
||||
|
||||
// Discard and Cancel buttons are always but next buttons are optional
|
||||
enum ActionButtons {
|
||||
TRANSFER = 1,
|
||||
KEEP = 2,
|
||||
SAVE = 4,
|
||||
DONT_SAVE = 8,
|
||||
REMEMBER_CHOISE = 0x10000
|
||||
};
|
||||
|
||||
enum class Action {
|
||||
Undef,
|
||||
Transfer,
|
||||
Discard,
|
||||
Save
|
||||
};
|
||||
|
||||
//------------------------------------------
|
||||
// UnsavedChangesDialog
|
||||
|
@ -275,13 +296,6 @@ protected:
|
|||
|
||||
std::string m_app_config_key;
|
||||
|
||||
enum class Action {
|
||||
Undef,
|
||||
Transfer, // Or KEEP
|
||||
Save,
|
||||
Discard,
|
||||
};
|
||||
|
||||
static constexpr char ActTransfer[] = "transfer";
|
||||
static constexpr char ActDiscard[] = "discard";
|
||||
static constexpr char ActSave[] = "save";
|
||||
|
@ -314,20 +328,12 @@ private:
|
|||
std::string m_new_selected_preset_name;
|
||||
|
||||
public:
|
||||
// Discard and Cancel buttons are always but next buttons are optional
|
||||
enum ActionButtons {
|
||||
TRANSFER = 1,
|
||||
KEEP = 2,
|
||||
SAVE = 4,
|
||||
DONT_SAVE = 8,
|
||||
REMEMBER_CHOISE = 0x10000
|
||||
};
|
||||
|
||||
// show unsaved changes when preset is switching
|
||||
UnsavedChangesDialog(Preset::Type type, PresetCollection* dependent_presets, const std::string& new_selected_preset, bool no_transfer = false);
|
||||
// show unsaved changes for all another cases
|
||||
UnsavedChangesDialog(const wxString& caption, const wxString& header, const std::string& app_config_key, int act_buttons);
|
||||
~UnsavedChangesDialog(){};
|
||||
~UnsavedChangesDialog() override = default;
|
||||
|
||||
int ShowModal();
|
||||
|
||||
|
@ -394,7 +400,7 @@ class FullCompareDialog : public wxDialog
|
|||
public:
|
||||
FullCompareDialog(const wxString& option_name, const wxString& old_value, const wxString& new_value,
|
||||
const wxString& old_value_header, const wxString& new_value_header);
|
||||
~FullCompareDialog(){};
|
||||
~FullCompareDialog() override = default;
|
||||
};
|
||||
|
||||
|
||||
|
@ -404,19 +410,36 @@ public:
|
|||
class DiffPresetDialog : public DPIDialog
|
||||
{
|
||||
DiffViewCtrl* m_tree { nullptr };
|
||||
wxBoxSizer* m_presets_sizer { nullptr };
|
||||
wxStaticText* m_top_info_line { nullptr };
|
||||
wxStaticText* m_bottom_info_line { nullptr };
|
||||
wxCheckBox* m_show_all_presets { nullptr };
|
||||
wxCheckBox* m_use_for_transfer { nullptr };
|
||||
Button* m_transfer_btn { nullptr };
|
||||
Button* m_cancel_btn { nullptr };
|
||||
wxBoxSizer* m_buttons { nullptr };
|
||||
wxBoxSizer* m_edit_sizer { nullptr };
|
||||
|
||||
Preset::Type m_view_type { Preset::TYPE_INVALID };
|
||||
PrinterTechnology m_pr_technology;
|
||||
std::unique_ptr<PresetBundle> m_preset_bundle_left;
|
||||
std::unique_ptr<PresetBundle> m_preset_bundle_right;
|
||||
|
||||
void update_tree();
|
||||
void update_bundles_from_app();
|
||||
void update_controls_visibility(Preset::Type type = Preset::TYPE_INVALID);
|
||||
void update_compatibility(const std::string& preset_name, Preset::Type type, PresetBundle* preset_bundle);
|
||||
void create_buttons();
|
||||
void create_edit_sizer();
|
||||
void complete_dialog_creation();
|
||||
void create_presets_sizer();
|
||||
void create_info_lines();
|
||||
void create_tree();
|
||||
void create_show_all_presets_chb();
|
||||
|
||||
void update_bottom_info(wxString bottom_info = "");
|
||||
void update_tree();
|
||||
void update_bundles_from_app();
|
||||
void update_controls_visibility(Preset::Type type = Preset::TYPE_INVALID);
|
||||
void update_compatibility(const std::string& preset_name, Preset::Type type, PresetBundle* preset_bundle);
|
||||
|
||||
void button_event(Action act);
|
||||
|
||||
struct DiffPresets
|
||||
{
|
||||
|
@ -428,11 +451,21 @@ class DiffPresetDialog : public DPIDialog
|
|||
std::vector<DiffPresets> m_preset_combos;
|
||||
|
||||
public:
|
||||
DiffPresetDialog(MainFrame* mainframe);
|
||||
~DiffPresetDialog(){};
|
||||
DiffPresetDialog(MainFrame*mainframe);
|
||||
~DiffPresetDialog() override = default;
|
||||
|
||||
void show(Preset::Type type = Preset::TYPE_INVALID);
|
||||
void update_presets(Preset::Type type = Preset::TYPE_INVALID);
|
||||
void show(Preset::Type type = Preset::TYPE_INVALID);
|
||||
void update_presets(Preset::Type type = Preset::TYPE_INVALID);
|
||||
|
||||
Preset::Type view_type() const { return m_view_type; }
|
||||
PrinterTechnology printer_technology() const { return m_pr_technology; }
|
||||
|
||||
std::string get_left_preset_name(Preset::Type type);
|
||||
std::string get_right_preset_name(Preset::Type type);
|
||||
|
||||
std::vector<std::string> get_selected_options(Preset::Type type) const { return std::move(m_tree->options(type, true)); }
|
||||
|
||||
std::array<Preset::Type, 3> types_list() const;
|
||||
|
||||
protected:
|
||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue