add new hash to save dialog ref and also a function to show the dialog

This commit is contained in:
Kaustubh Tripathi 2019-10-13 16:38:35 +05:30 committed by Joseph Lenox
parent 2ef957dab6
commit 4f5b935ecf

View File

@ -91,6 +91,9 @@ sub new {
# Stack of redo operations.
$self->{redo_stack} = [];
# Preset dialogs
$self->{'preset_dialogs'} = {};
$self->{print}->set_status_cb(sub {
my ($percent, $message) = @_;
@ -877,6 +880,23 @@ sub selected_presets {
return $group ? @{$presets{$group}} : %presets;
}
sub show_unique_preset_dialog {
my($self, $group) = @_;
my $dlg;
my $preset_editor;
if( $self->{'preset_dialogs'}->{$group} ) {
$dlg = $self->{'preset_dialogs'}->{$group};
}
else {
my $class = "Slic3r::GUI::PresetEditorDialog::" . ucfirst($group);
$dlg = $class->new($self);
$self->{'preset_dialogs'}->{$group} = $dlg;
}
$dlg->Show;
$preset_editor = $dlg->preset_editor;
return $preset_editor;
}
sub show_preset_editor {
my ($self, $group, $i, $panel) = @_;
@ -884,7 +904,6 @@ sub show_preset_editor {
my @presets = $self->selected_presets($group);
my $preset_editor;
my $dlg;
my $mainframe = $self->GetFrame;
my $tabpanel = $mainframe->{tabpanel};
if (exists $mainframe->{preset_editor_tabs}{$group}) {
@ -901,9 +920,7 @@ sub show_preset_editor {
$mainframe->{preset_editor_tabs}{$group} = $preset_editor = $class->new($tabpanel);
$tabpanel->AddPage($preset_editor, ucfirst($group) . " Settings");
} else {
my $class = "Slic3r::GUI::PresetEditorDialog::" . ucfirst($group);
$dlg = $class->new($self);
$preset_editor = $dlg->preset_editor;
$preset_editor = $self->show_unique_preset_dialog($group);
}
$preset_editor->select_preset_by_name($presets[$i // 0]->name);
@ -928,10 +945,6 @@ sub show_preset_editor {
};
$preset_editor->on_select_preset($cb);
$preset_editor->on_save_preset($cb);
if ($dlg) {
$dlg->Show;
}
});
}