mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-21 21:58:03 -06:00
Moved the Bonjour discovery to Tab.pm,
when no Bonjour devices found, a simple message box is shown. Otherwise the Bonjour selection dialog with an empty list crashes on windows.
This commit is contained in:
parent
bb9c3dd9ce
commit
5573faec6b
2 changed files with 20 additions and 13 deletions
|
@ -9,14 +9,10 @@ use base 'Wx::Dialog';
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
my ($parent) = @_;
|
my ($parent, $devices) = @_;
|
||||||
my $self = $class->SUPER::new($parent, -1, "Device Browser", wxDefaultPosition, [350,700], wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
|
my $self = $class->SUPER::new($parent, -1, "Device Browser", wxDefaultPosition, [350,700], wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
|
||||||
|
|
||||||
# look for devices
|
$self->{devices} = $devices;
|
||||||
eval "use Net::Bonjour; 1";
|
|
||||||
my $res = Net::Bonjour->new('http');
|
|
||||||
$res->discover;
|
|
||||||
$self->{devices} = [ $res->entries ];
|
|
||||||
|
|
||||||
# label
|
# label
|
||||||
my $text = Wx::StaticText->new($self, -1, "Choose an OctoPrint device in your network:", wxDefaultPosition, wxDefaultSize);
|
my $text = Wx::StaticText->new($self, -1, "Choose an OctoPrint device in your network:", wxDefaultPosition, wxDefaultSize);
|
||||||
|
|
|
@ -1130,13 +1130,24 @@ sub build {
|
||||||
}
|
}
|
||||||
|
|
||||||
EVT_BUTTON($self, $btn, sub {
|
EVT_BUTTON($self, $btn, sub {
|
||||||
my $dlg = Slic3r::GUI::BonjourBrowser->new($self);
|
# look for devices
|
||||||
if ($dlg->ShowModal == wxID_OK) {
|
my $entries;
|
||||||
my $value = $dlg->GetValue . ":" . $dlg->GetPort;
|
{
|
||||||
$self->{config}->set('octoprint_host', $value);
|
my $res = Net::Bonjour->new('http');
|
||||||
$self->update_dirty;
|
$res->discover;
|
||||||
$self->_on_value_change('octoprint_host', $value);
|
$entries = [ $res->entries ];
|
||||||
$self->reload_config;
|
}
|
||||||
|
if (@{$entries}) {
|
||||||
|
my $dlg = Slic3r::GUI::BonjourBrowser->new($self, $entries);
|
||||||
|
if ($dlg->ShowModal == wxID_OK) {
|
||||||
|
my $value = $dlg->GetValue . ":" . $dlg->GetPort;
|
||||||
|
$self->{config}->set('octoprint_host', $value);
|
||||||
|
$self->update_dirty;
|
||||||
|
$self->_on_value_change('octoprint_host', $value);
|
||||||
|
$self->reload_config;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Wx::MessageDialog->new($self, 'No Bonjour device found', 'Device Browser', wxOK | wxICON_INFORMATION)->ShowModal;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue