mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-01 02:22:03 +08:00
Query OctoPrint and prompt user if a file with same name exists. #2666
This commit is contained in:
parent
6f6ddf5086
commit
1ae8d13ffd
@ -240,6 +240,23 @@ sub new {
|
|||||||
$filename = Wx::GetTextFromUser("Save to printer with the following name:",
|
$filename = Wx::GetTextFromUser("Save to printer with the following name:",
|
||||||
"OctoPrint", $filename, $self);
|
"OctoPrint", $filename, $self);
|
||||||
|
|
||||||
|
my $process_dialog = Wx::ProgressDialog->new('Querying OctoPrint…', "Checking whether file already exists…", 100, $self, 0);
|
||||||
|
$process_dialog->Pulse;
|
||||||
|
|
||||||
|
my $ua = LWP::UserAgent->new;
|
||||||
|
$ua->timeout(5);
|
||||||
|
my $res = $ua->get("http://" . $self->{config}->octoprint_host . "/api/files/local");
|
||||||
|
$process_dialog->Destroy;
|
||||||
|
if ($res->is_success) {
|
||||||
|
if ($res->decoded_content =~ /"name":\s*"\Q$filename\E"/) {
|
||||||
|
my $dialog = Wx::MessageDialog->new($self,
|
||||||
|
"It looks like a file with the same name already exists in the server. "
|
||||||
|
. "Shall I overwrite it?",
|
||||||
|
'OctoPrint', wxICON_WARNING | wxYES | wxNO);
|
||||||
|
return if $dialog->ShowModal() == wxID_NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my $dialog = Wx::MessageDialog->new($self,
|
my $dialog = Wx::MessageDialog->new($self,
|
||||||
"Shall I start the print after uploading the file?",
|
"Shall I start the print after uploading the file?",
|
||||||
'OctoPrint', wxICON_QUESTION | wxYES | wxNO);
|
'OctoPrint', wxICON_QUESTION | wxYES | wxNO);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user