Skip to content

Commit 9b4dcc8

Browse files
Fix compare dialog stuck behind modal batch management
Create a standalone DiffPresetDialog constructor that takes any wxWindow* as parent. The batch management dialog now creates a local modal DiffPresetDialog parented to itself, so it appears on top correctly. Pre-selects the first two checked presets in the left/right dropdowns.
1 parent 6f19fba commit 9b4dcc8

3 files changed

Lines changed: 73 additions & 1 deletion

File tree

src/slic3r/GUI/UnsavedChangesDialog.cpp

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,6 +2052,75 @@ DiffPresetDialog::DiffPresetDialog(MainFrame* mainframe)
20522052
wxGetApp().UpdateDlgDarkUI(this);
20532053
}
20542054

2055+
DiffPresetDialog::DiffPresetDialog(wxWindow* parent, Preset::Type type, const std::string &left, const std::string &right)
2056+
: DPIDialog(parent, wxID_ANY, _L("Compare presets"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
2057+
m_pr_technology(wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology())
2058+
{
2059+
m_preset_bundle_left = std::make_unique<PresetBundle>(*wxGetApp().preset_bundle);
2060+
m_preset_bundle_right = std::make_unique<PresetBundle>(*wxGetApp().preset_bundle);
2061+
2062+
int border = 10;
2063+
int em = em_unit();
2064+
2065+
m_top_info_line = new wxStaticText(this, wxID_ANY, "");
2066+
m_bottom_info_line = new wxStaticText(this, wxID_ANY, "");
2067+
2068+
m_tree = new DiffViewCtrl(this, wxSize(em * 65, em * 40));
2069+
m_tree->AppendBmpTextColumn("", DiffModel::colIconText, 35);
2070+
m_tree->AppendBmpTextColumn("Left Preset Value", DiffModel::colOldValue, 15);
2071+
m_tree->AppendBmpTextColumn("Right Preset Value",DiffModel::colNewValue, 15);
2072+
2073+
// Create combo boxes for the target type only
2074+
wxFlexGridSizer *presets_sizer = new wxFlexGridSizer(3, 2, border, border);
2075+
presets_sizer->AddGrowableCol(0, 1);
2076+
presets_sizer->AddGrowableCol(2, 1);
2077+
2078+
auto add_preset_combobox = [this, presets_sizer, type](PresetComboBox** cb, PresetBundle* bundle) {
2079+
*cb = new PresetComboBox(this, type);
2080+
(*cb)->set_selection_changed_function([this](int) { update_tree(); });
2081+
(*cb)->SetFont(Label::Body_13);
2082+
presets_sizer->Add(*cb, 1, wxEXPAND);
2083+
};
2084+
2085+
PresetComboBox *presets_left, *presets_right;
2086+
add_preset_combobox(&presets_left, m_preset_bundle_left.get());
2087+
auto equal_bmp = new ScalableButton(this, wxID_ANY, "equal");
2088+
presets_sizer->Add(equal_bmp, 0, wxALIGN_CENTER);
2089+
add_preset_combobox(&presets_right, m_preset_bundle_right.get());
2090+
m_preset_combos.push_back({presets_left, equal_bmp, presets_right});
2091+
2092+
m_show_all_presets = new wxCheckBox(this, wxID_ANY, _L("Show all presets (including incompatible)"));
2093+
m_show_all_presets->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent&) {
2094+
bool show_all = m_show_all_presets->GetValue();
2095+
for (auto &pc : m_preset_combos) {
2096+
pc.presets_left->show_all(show_all);
2097+
pc.presets_right->show_all(show_all);
2098+
}
2099+
update_tree();
2100+
});
2101+
2102+
wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
2103+
topSizer->Add(m_top_info_line, 0, wxEXPAND | wxLEFT | wxTOP | wxRIGHT, 2 * border);
2104+
topSizer->Add(presets_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxRIGHT, border);
2105+
topSizer->Add(m_show_all_presets, 0, wxEXPAND | wxALL, border);
2106+
topSizer->Add(m_bottom_info_line, 0, wxEXPAND | wxALL, 2 * border);
2107+
topSizer->Add(m_tree, 1, wxEXPAND | wxALL, border);
2108+
2109+
this->SetMinSize(wxSize(80 * em, 30 * em));
2110+
this->SetSizer(topSizer);
2111+
topSizer->SetSizeHints(this);
2112+
2113+
m_view_type = type;
2114+
update_controls_visibility(type);
2115+
2116+
if (!left.empty()) presets_left->update(left);
2117+
if (!right.empty()) presets_right->update(right);
2118+
update_tree();
2119+
2120+
wxGetApp().UpdateDlgDarkUI(this);
2121+
CenterOnParent();
2122+
}
2123+
20552124
void DiffPresetDialog::update_controls_visibility(Preset::Type type /* = Preset::TYPE_INVALID*/)
20562125
{
20572126
for (auto preset_combos : m_preset_combos) {

src/slic3r/GUI/UnsavedChangesDialog.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ class DiffPresetDialog : public DPIDialog
446446

447447
public:
448448
DiffPresetDialog(MainFrame* mainframe);
449+
DiffPresetDialog(wxWindow* parent, Preset::Type type, const std::string &left, const std::string &right);
449450
~DiffPresetDialog(){};
450451

451452
void show(Preset::Type type = Preset::TYPE_INVALID);

src/slic3r/GUI/UserPresetsDialog.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "I18N.hpp"
44
#include "GUI_App.hpp"
55
#include "MainFrame.hpp"
6+
#include "UnsavedChangesDialog.hpp"
67
#include "libslic3r/Preset.hpp"
78

89
#include <slic3r/GUI/Widgets/CheckBox.hpp>
@@ -100,7 +101,8 @@ UserPresetsDialog::UserPresetsDialog(wxWindow *parent)
100101
std::string left, right;
101102
if (m_checked_presets.size() >= 1) left = m_checked_presets[0];
102103
if (m_checked_presets.size() >= 2) right = m_checked_presets[1];
103-
wxGetApp().mainframe->diff_dialog.show(types[m_collection], left, right);
104+
DiffPresetDialog dlg(this, types[m_collection], left, right);
105+
dlg.ShowModal();
104106
});
105107

106108
wxSizer *sizer_bottom = new wxBoxSizer(wxHORIZONTAL);

0 commit comments

Comments
 (0)