mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-22 04:28:05 +08:00
Ask for confirmation before stopping prints
This commit is contained in:
parent
13b7316807
commit
e58c32bee8
@ -3,7 +3,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use utf8;
|
use utf8;
|
||||||
|
|
||||||
use Wx qw(wxTheApp :frame :id :misc :sizer :bitmap :button);
|
use Wx qw(wxTheApp :frame :id :misc :sizer :bitmap :button :icon :dialog);
|
||||||
use Wx::Event qw(EVT_CLOSE EVT_LEFT_DOWN EVT_MENU);
|
use Wx::Event qw(EVT_CLOSE EVT_LEFT_DOWN EVT_MENU);
|
||||||
use base 'Wx::ScrolledWindow';
|
use base 'Wx::ScrolledWindow';
|
||||||
|
|
||||||
@ -46,6 +46,20 @@ sub new {
|
|||||||
EVT_CLOSE($self, sub {
|
EVT_CLOSE($self, sub {
|
||||||
my (undef, $event) = @_;
|
my (undef, $event) = @_;
|
||||||
|
|
||||||
|
if ($event->CanVeto) {
|
||||||
|
foreach my $panel ($self->print_panels) {
|
||||||
|
if ($panel->printing) {
|
||||||
|
my $confirm = Wx::MessageDialog->new(
|
||||||
|
$self, "Printer '" . $panel->printer_name . "' is printing.\n\nDo you want to stop printing?",
|
||||||
|
'Unfinished Print', wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION,
|
||||||
|
);
|
||||||
|
if ($confirm->ShowModal == wxID_NO) {
|
||||||
|
$event->Veto;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
foreach my $panel ($self->print_panels) {
|
foreach my $panel ($self->print_panels) {
|
||||||
$panel->disconnect;
|
$panel->disconnect;
|
||||||
}
|
}
|
||||||
@ -54,12 +68,13 @@ sub new {
|
|||||||
$event->Skip;
|
$event->Skip;
|
||||||
});
|
});
|
||||||
|
|
||||||
# if only one preset exists, load it
|
|
||||||
{
|
{
|
||||||
my %presets = wxTheApp->presets('printer');
|
my %presets = wxTheApp->presets('printer');
|
||||||
my %configs = map { my $name = $_; $name => Slic3r::Config->load($presets{$name}) } keys %presets;
|
my %configs = map { my $name = $_; $name => Slic3r::Config->load($presets{$name}) } keys %presets;
|
||||||
my @presets_with_printer = grep $configs{$_}->serial_port, keys %presets;
|
my @presets_with_printer = grep $configs{$_}->serial_port, keys %presets;
|
||||||
|
|
||||||
if (@presets_with_printer == 1) {
|
if (@presets_with_printer == 1) {
|
||||||
|
# if only one preset exists, load it
|
||||||
my $name = $presets_with_printer[0];
|
my $name = $presets_with_printer[0];
|
||||||
$self->add_printer($name, $configs{$name});
|
$self->add_printer($name, $configs{$name});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user