mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-10-04 17:06:37 +08:00
add new hash to save dialog ref and also a function to show the dialog
This commit is contained in:
parent
2ef957dab6
commit
4f5b935ecf
@ -91,6 +91,9 @@ sub new {
|
|||||||
# Stack of redo operations.
|
# Stack of redo operations.
|
||||||
$self->{redo_stack} = [];
|
$self->{redo_stack} = [];
|
||||||
|
|
||||||
|
# Preset dialogs
|
||||||
|
$self->{'preset_dialogs'} = {};
|
||||||
|
|
||||||
$self->{print}->set_status_cb(sub {
|
$self->{print}->set_status_cb(sub {
|
||||||
my ($percent, $message) = @_;
|
my ($percent, $message) = @_;
|
||||||
|
|
||||||
@ -877,6 +880,23 @@ sub selected_presets {
|
|||||||
return $group ? @{$presets{$group}} : %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 {
|
sub show_preset_editor {
|
||||||
my ($self, $group, $i, $panel) = @_;
|
my ($self, $group, $i, $panel) = @_;
|
||||||
|
|
||||||
@ -884,7 +904,6 @@ sub show_preset_editor {
|
|||||||
my @presets = $self->selected_presets($group);
|
my @presets = $self->selected_presets($group);
|
||||||
|
|
||||||
my $preset_editor;
|
my $preset_editor;
|
||||||
my $dlg;
|
|
||||||
my $mainframe = $self->GetFrame;
|
my $mainframe = $self->GetFrame;
|
||||||
my $tabpanel = $mainframe->{tabpanel};
|
my $tabpanel = $mainframe->{tabpanel};
|
||||||
if (exists $mainframe->{preset_editor_tabs}{$group}) {
|
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);
|
$mainframe->{preset_editor_tabs}{$group} = $preset_editor = $class->new($tabpanel);
|
||||||
$tabpanel->AddPage($preset_editor, ucfirst($group) . " Settings");
|
$tabpanel->AddPage($preset_editor, ucfirst($group) . " Settings");
|
||||||
} else {
|
} else {
|
||||||
my $class = "Slic3r::GUI::PresetEditorDialog::" . ucfirst($group);
|
$preset_editor = $self->show_unique_preset_dialog($group);
|
||||||
$dlg = $class->new($self);
|
|
||||||
$preset_editor = $dlg->preset_editor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$preset_editor->select_preset_by_name($presets[$i // 0]->name);
|
$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_select_preset($cb);
|
||||||
$preset_editor->on_save_preset($cb);
|
$preset_editor->on_save_preset($cb);
|
||||||
|
|
||||||
if ($dlg) {
|
|
||||||
$dlg->Show;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user