Display a warning when no USB/serial printers were configured

This commit is contained in:
Alessandro Ranellucci 2015-11-03 23:00:59 +01:00
parent e8ae2d6ec2
commit 8f7e820a01

View file

@ -14,8 +14,17 @@ sub new {
$self->SetScrollbars(0, 1, 0, 1); $self->SetScrollbars(0, 1, 0, 1);
$self->{sizer} = my $sizer = Wx::BoxSizer->new(wxVERTICAL); $self->{sizer} = my $sizer = Wx::BoxSizer->new(wxVERTICAL);
# warning to show when there are no printers configured
{ {
my $btn = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new("$Slic3r::var/add.png", wxBITMAP_TYPE_PNG), $self->{text_no_printers} = Wx::StaticText->new($self, -1,
"No printers were configured for USB/serial control.",
wxDefaultPosition, wxDefaultSize);
$self->{sizer}->Add($self->{text_no_printers}, 0, wxTOP | wxLEFT, 30);
}
# button for adding new printer panels
{
my $btn = $self->{btn_add} = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new("$Slic3r::var/add.png", wxBITMAP_TYPE_PNG),
wxDefaultPosition, wxDefaultSize, Wx::wxBORDER_NONE); wxDefaultPosition, wxDefaultSize, Wx::wxBORDER_NONE);
$btn->SetToolTipString("Add printer…") $btn->SetToolTipString("Add printer…")
if $btn->can('SetToolTipString'); if $btn->can('SetToolTipString');
@ -118,6 +127,12 @@ sub OnActivate {
} }
$self->add_printer($_, $presets{$_}) for sort keys %active; $self->add_printer($_, $presets{$_}) for sort keys %active;
# show/hide the warning about no printers
$self->{text_no_printers}->Show(!%presets);
# show/hide the Add button
$self->{btn_add}->Show(keys %presets != keys %active);
$self->Layout; $self->Layout;
# we need this in order to trigger the OnSize event of wxScrolledWindow which # we need this in order to trigger the OnSize event of wxScrolledWindow which