FIX: [STUDIO-2448] switch machine in camera popup

Change-Id: I40531dde899beb11efea985348de8b77354e6724
This commit is contained in:
chunmao.guo 2023-05-18 13:49:33 +08:00 committed by Lane.Wei
parent c770926142
commit 164251531e
3 changed files with 10 additions and 12 deletions

View file

@ -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();

View file

@ -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

View file

@ -3366,7 +3366,8 @@ void StatusPanel::on_camera_enter(wxMouseEvent& event)
{
if (obj) {
if (m_camera_popup == nullptr)
m_camera_popup = std::make_shared<CameraPopup>(this, obj);
m_camera_popup = std::make_shared<CameraPopup>(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) {