mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-09-24 08:23:16 +08:00
Move the overridable settings list in the preset editor without opening one more dialog
This commit is contained in:
parent
4ca5f9ee16
commit
0b180c6273
@ -338,7 +338,7 @@ sub _compatible_printers_widget {
|
|||||||
|
|
||||||
EVT_BUTTON($self, $btn, sub {
|
EVT_BUTTON($self, $btn, sub {
|
||||||
my @presets = map $_->name, grep !$_->default && !$_->external,
|
my @presets = map $_->name, grep !$_->default && !$_->external,
|
||||||
wxTheApp->presets('printer');
|
@{wxTheApp->presets->{printer}};
|
||||||
|
|
||||||
my $dlg = Wx::MultiChoiceDialog->new($self,
|
my $dlg = Wx::MultiChoiceDialog->new($self,
|
||||||
"Select the printers this profile is compatible with.\nIf none are selected, it will be considered compatible with all of them.",
|
"Select the printers this profile is compatible with.\nIf none are selected, it will be considered compatible with all of them.",
|
||||||
@ -370,7 +370,7 @@ use base 'Slic3r::GUI::PresetEditor';
|
|||||||
|
|
||||||
use List::Util qw(first any);
|
use List::Util qw(first any);
|
||||||
use Wx qw(:icon :dialog :id :misc :button :sizer);
|
use Wx qw(:icon :dialog :id :misc :button :sizer);
|
||||||
use Wx::Event qw(EVT_BUTTON);
|
use Wx::Event qw(EVT_BUTTON EVT_CHECKLISTBOX);
|
||||||
|
|
||||||
sub name { 'print' }
|
sub name { 'print' }
|
||||||
sub title { 'Print Settings' }
|
sub title { 'Print Settings' }
|
||||||
@ -424,40 +424,25 @@ sub build {
|
|||||||
my $overridable_widget = sub {
|
my $overridable_widget = sub {
|
||||||
my ($parent) = @_;
|
my ($parent) = @_;
|
||||||
|
|
||||||
my $btn = Wx::Button->new($parent, -1, "Set…", wxDefaultPosition, wxDefaultSize,
|
my %options = (
|
||||||
wxBU_LEFT | wxBU_EXACTFIT);
|
map { $_ => sprintf('%s > %s', $Slic3r::Config::Options->{$_}{category}, $Slic3r::Config::Options->{$_}{full_label} // $Slic3r::Config::Options->{$_}{label}) }
|
||||||
$btn->SetFont($Slic3r::GUI::small_font);
|
map @{$_->get_keys}, Slic3r::Config::PrintObject->new, Slic3r::Config::PrintRegion->new
|
||||||
if ($Slic3r::GUI::have_button_icons) {
|
);
|
||||||
$btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("cog.png"), wxBITMAP_TYPE_PNG));
|
my @opt_keys = sort { $options{$a} cmp $options{$b} } keys %options;
|
||||||
}
|
$self->{overridable_opt_keys} = [ @opt_keys ];
|
||||||
|
|
||||||
my $sizer = Wx::BoxSizer->new(wxHORIZONTAL);
|
my $listbox = $self->{overridable_list} = Wx::CheckListBox->new($parent, -1,
|
||||||
$sizer->Add($btn);
|
wxDefaultPosition, [-1, 320], [ map $options{$_}, @opt_keys ]);
|
||||||
|
|
||||||
EVT_BUTTON($self, $btn, sub {
|
EVT_CHECKLISTBOX($self, $listbox, sub {
|
||||||
my %options = (
|
my $value = [ map $opt_keys[$_], grep $listbox->IsChecked($_), 0..$#opt_keys ];
|
||||||
map { $_ => sprintf('%s > %s', $Slic3r::Config::Options->{$_}{category}, $Slic3r::Config::Options->{$_}{full_label} // $Slic3r::Config::Options->{$_}{label}) }
|
$self->config->set('overridable', $value);
|
||||||
map @{$_->get_keys}, Slic3r::Config::PrintObject->new, Slic3r::Config::PrintRegion->new
|
$self->_on_value_change('overridable');
|
||||||
);
|
|
||||||
my @opt_keys = sort { $options{$a} cmp $options{$b} } keys %options;
|
|
||||||
|
|
||||||
my $dlg = Wx::MultiChoiceDialog->new($self, "Selected options will be displayed in the plater screen for quick changes.",
|
|
||||||
"Overridable options",
|
|
||||||
[ map $options{$_}, @opt_keys ]);
|
|
||||||
|
|
||||||
my @selections = ();
|
|
||||||
foreach my $opt_key (@{ $self->config->get('overridable') }) {
|
|
||||||
push @selections, first { $opt_keys[$_] eq $opt_key } 0..$#opt_keys;
|
|
||||||
}
|
|
||||||
$dlg->SetSelections(@selections);
|
|
||||||
|
|
||||||
if ($dlg->ShowModal == wxID_OK) {
|
|
||||||
my $value = [ @opt_keys[$dlg->GetSelections] ];
|
|
||||||
$self->config->set('overridable', $value);
|
|
||||||
$self->_on_value_change('overridable');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
my $sizer = Wx::BoxSizer->new(wxVERTICAL);
|
||||||
|
$sizer->Add($listbox, 0, wxEXPAND);
|
||||||
|
|
||||||
return $sizer;
|
return $sizer;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -703,13 +688,6 @@ sub build {
|
|||||||
my $page = $self->add_options_page('Overrides', 'wrench.png');
|
my $page = $self->add_options_page('Overrides', 'wrench.png');
|
||||||
{
|
{
|
||||||
my $optgroup = $page->new_optgroup('Profile preferences');
|
my $optgroup = $page->new_optgroup('Profile preferences');
|
||||||
{
|
|
||||||
my $line = Slic3r::GUI::OptionsGroup::Line->new(
|
|
||||||
label => 'Overridable settings',
|
|
||||||
widget => $overridable_widget,
|
|
||||||
);
|
|
||||||
$optgroup->append_line($line);
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
my $line = Slic3r::GUI::OptionsGroup::Line->new(
|
my $line = Slic3r::GUI::OptionsGroup::Line->new(
|
||||||
label => 'Compatible printers',
|
label => 'Compatible printers',
|
||||||
@ -718,9 +696,32 @@ sub build {
|
|||||||
$optgroup->append_line($line);
|
$optgroup->append_line($line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
my $optgroup = $page->new_optgroup('Overridable settings (they will be displayed in the plater for quick changes)');
|
||||||
|
{
|
||||||
|
my $line = Slic3r::GUI::OptionsGroup::Line->new(
|
||||||
|
widget => $overridable_widget,
|
||||||
|
full_width => 1,
|
||||||
|
);
|
||||||
|
$optgroup->append_line($line);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub reload_config {
|
||||||
|
my ($self) = @_;
|
||||||
|
|
||||||
|
{
|
||||||
|
my %overridable = map { $_ => 1 } @{ $self->config->get('overridable') };
|
||||||
|
for my $i (0..$#{$self->{overridable_opt_keys}}) {
|
||||||
|
$self->{overridable_list}->Check($i, $overridable{ $self->{overridable_opt_keys}[$i] });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->SUPER::reload_config;
|
||||||
|
}
|
||||||
|
|
||||||
sub _update {
|
sub _update {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user