diff --git a/src/slic3r/GUI/CameraPopup.cpp b/src/slic3r/GUI/CameraPopup.cpp index fbf0450a9..77e051094 100644 --- a/src/slic3r/GUI/CameraPopup.cpp +++ b/src/slic3r/GUI/CameraPopup.cpp @@ -28,9 +28,8 @@ wxDEFINE_EVENT(EVT_SDCARD_ABSENT_HINT, wxCommandEvent); const wxColour TEXT_COL = wxColour(43, 52, 54); -CameraPopup::CameraPopup(wxWindow *parent, MachineObject* obj) - : PopupWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS), - m_obj(obj) +CameraPopup::CameraPopup(wxWindow *parent) + : PopupWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS) { #ifdef __WINDOWS__ SetDoubleBuffered(true); @@ -52,8 +51,6 @@ CameraPopup::CameraPopup(wxWindow *parent, MachineObject* obj) m_text_recording->SetFont(Label::Head_14); m_text_recording->SetForegroundColour(TEXT_COL); m_switch_recording = new SwitchButton(m_panel); - if (obj) - m_switch_recording->SetValue(obj->camera_recording_when_printing); //vcamera m_text_vcamera = new wxStaticText(m_panel, wxID_ANY, _L("Go Live")); @@ -80,8 +77,6 @@ CameraPopup::CameraPopup(wxWindow *parent, MachineObject* obj) top_sizer->Add(m_resolution_options[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, FromDIP(5)); top_sizer->Add(0, 0, wxALL, 0); } - if (obj) - sync_resolution_setting(obj->camera_resolution); main_sizer->Add(top_sizer, 0, wxALL, FromDIP(10)); @@ -127,7 +122,6 @@ CameraPopup::CameraPopup(wxWindow *parent, MachineObject* obj) m_interval_timer = new wxTimer(); m_interval_timer->SetOwner(this); - check_func_supported(); wxGetApp().UpdateDarkUIWin(this); } @@ -260,8 +254,11 @@ void CameraPopup::sync_vcamera_state(bool show_vcamera) rescale(); } -void CameraPopup::check_func_supported() +void CameraPopup::check_func_supported(MachineObject *obj2) { + m_obj = obj2; + if (m_obj == nullptr) + return; // function supported if (m_obj->is_function_supported(PrinterFunction::FUNC_RECORDING) && m_obj->has_ipcam) { m_text_recording->Show(); diff --git a/src/slic3r/GUI/CameraPopup.hpp b/src/slic3r/GUI/CameraPopup.hpp index bab08850c..a9b53a621 100644 --- a/src/slic3r/GUI/CameraPopup.hpp +++ b/src/slic3r/GUI/CameraPopup.hpp @@ -24,7 +24,7 @@ wxDECLARE_EVENT(EVT_SDCARD_ABSENT_HINT, wxCommandEvent); class CameraPopup : public PopupWindow { public: - CameraPopup(wxWindow *parent, MachineObject* obj = nullptr); + CameraPopup(wxWindow *parent); virtual ~CameraPopup() {} // PopupWindow virtual methods are all overridden to log them @@ -34,7 +34,7 @@ public: virtual bool Show(bool show = true) wxOVERRIDE; void sync_vcamera_state(bool show_vcamera); - void check_func_supported(); + void check_func_supported(MachineObject* obj); void update(bool vcamera_streaming); enum CameraResolution diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index f39f02147..d35899345 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -3366,7 +3366,8 @@ void StatusPanel::on_camera_enter(wxMouseEvent& event) { if (obj) { if (m_camera_popup == nullptr) - m_camera_popup = std::make_shared(this, obj); + m_camera_popup = std::make_shared(this); + m_camera_popup->check_func_supported(obj); m_camera_popup->sync_vcamera_state(show_vcamera); m_camera_popup->Bind(EVT_VCAMERA_SWITCH, &StatusPanel::on_switch_vcamera, this); m_camera_popup->Bind(EVT_SDCARD_ABSENT_HINT, [this](wxCommandEvent &e) {