Remember last selected settings page in Printer Settings too, like in Print Settings and Filament Settings. #2568

This commit is contained in:
Alessandro Ranellucci 2015-01-25 11:43:34 +01:00
parent 0a1f5992ad
commit a10a554e2a

View File

@ -292,16 +292,24 @@ sub reload_config {
} }
sub update_tree { sub update_tree {
my $self = shift; my ($self) = @_;
my ($select) = @_;
$select //= 0; #/ # get label of the currently selected item
my $selected = $self->{treectrl}->GetItemText($self->{treectrl}->GetSelection);
my $rootItem = $self->{treectrl}->GetRootItem; my $rootItem = $self->{treectrl}->GetRootItem;
$self->{treectrl}->DeleteChildren($rootItem); $self->{treectrl}->DeleteChildren($rootItem);
my $have_selection = 0;
foreach my $page (@{$self->{pages}}) { foreach my $page (@{$self->{pages}}) {
my $itemId = $self->{treectrl}->AppendItem($rootItem, $page->{title}, $page->{iconID}); my $itemId = $self->{treectrl}->AppendItem($rootItem, $page->{title}, $page->{iconID});
$self->{treectrl}->SelectItem($itemId) if $self->{treectrl}->GetChildrenCount($rootItem) == $select + 1; if ($page->{title} eq $selected) {
$self->{treectrl}->SelectItem($itemId);
$have_selection = 1;
}
}
if (!$have_selection) {
$self->{treectrl}->SelectItem($self->{treectrl}->GetFirstChild($rootItem));
} }
} }
@ -1182,6 +1190,7 @@ sub _build_extruder_pages {
# remove extra pages # remove extra pages
if ($self->{extruders_count} <= $#{$self->{extruder_pages}}) { if ($self->{extruders_count} <= $#{$self->{extruder_pages}}) {
$_->Destroy for @{$self->{extruder_pages}}[$self->{extruders_count}..$#{$self->{extruder_pages}}];
splice @{$self->{extruder_pages}}, $self->{extruders_count}; splice @{$self->{extruder_pages}}, $self->{extruders_count};
} }
@ -1198,7 +1207,7 @@ sub _build_extruder_pages {
(grep $_->{title} !~ /^Extruder \d+/, @{$self->{pages}}), (grep $_->{title} !~ /^Extruder \d+/, @{$self->{pages}}),
@{$self->{extruder_pages}}[ 0 .. $self->{extruders_count}-1 ], @{$self->{extruder_pages}}[ 0 .. $self->{extruders_count}-1 ],
); );
$self->update_tree(0); $self->update_tree;
} }
sub _update { sub _update {