diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index a81af52ff..3b8302216 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -1758,10 +1758,10 @@ bool MachineObject::is_studio_cmd(int sequence_id) return false; } -bool MachineObject::canEnableTimelapse() const +bool MachineObject::canEnableTimelapse(wxString &error_message) const { - if (!is_support_timelapse) - { + if (!is_support_timelapse) { + error_message = _L("Timelapse is not supported on this printer."); return false; } @@ -1770,7 +1770,19 @@ bool MachineObject::canEnableTimelapse() const return true; } - return sdcard_state == MachineObject::SdcardState::HAS_SDCARD_NORMAL; + if (sdcard_state != MachineObject::SdcardState::HAS_SDCARD_NORMAL) { + if (sdcard_state == MachineObject::SdcardState::NO_SDCARD) { + error_message = _L("Timelapse is not supported while the SD card does not exist."); + } else if (sdcard_state == MachineObject::SdcardState::HAS_SDCARD_ABNORMAL) { + error_message = _L("Timelapse is not supported while the SD card is unavailable."); + } else if (sdcard_state == MachineObject::SdcardState::HAS_SDCARD_READONLY) { + error_message = _L("Timelapse is not supported while the SD card is readonly."); + } + + return false; + } + + return true; } int MachineObject::command_select_extruder(int id) diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 809057f65..6684730a8 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -1150,7 +1150,7 @@ public: bool is_studio_cmd(int seq); /* quick check*/ - bool canEnableTimelapse() const; + bool canEnableTimelapse(wxString& error_message) const; /* command commands */ int command_get_version(bool with_retry = true); diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index f0f61c844..89e2325d3 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -1005,9 +1005,10 @@ void SelectMachineDialog::update_select_layout(MachineObject *obj) } /*STUDIO-9197*/ - if (obj && obj->canEnableTimelapse()) + wxString error_messgae; + if (obj && obj->canEnableTimelapse(error_messgae)) { - m_checkbox_list["timelapse"]->Enable(); + m_checkbox_list["timelapse"]->enable(true); if (config->get("print", "timelapse") == "1" && !has_timelapse_warning()) { m_checkbox_list["timelapse"]->setValue("on"); config->set_str("print", "timelapse", "1"); @@ -1018,10 +1019,11 @@ void SelectMachineDialog::update_select_layout(MachineObject *obj) } else { - m_checkbox_list["timelapse"]->Disable(); + m_checkbox_list["timelapse"]->enable(false); m_checkbox_list["timelapse"]->setValue("off"); config->set_str("print", "timelapse", "0"); } + m_checkbox_list["timelapse"]->update_tooltip(error_messgae); update_options_layout(); Layout(); @@ -4813,7 +4815,7 @@ std::string SelectMachineDialog::get_print_status_info(PrintDialogStatus status) m_printoption_title = new Label(this, title); m_printoption_title->SetFont(Label::Body_13); - m_printoption_title->SetBackgroundColour(0xF8F8F8); + //m_printoption_title->SetBackgroundColour(0xF8F8F8); m_printoption_title->SetToolTip(tips); m_printoption_item = new PrintOptionItem(this, m_ops, param); @@ -4876,6 +4878,11 @@ void PrintOption::update_options(std::vector ops, const wxString &tips) if (m_printoption_item->GetToolTipText() != tips) { m_printoption_item->SetToolTip(tips); } } +void PrintOption::update_tooltip(const wxString &tips) { + if (m_printoption_title->GetToolTipText() != tips) { m_printoption_title->SetToolTip(tips); } + if (m_printoption_item->GetToolTipText() != tips) { m_printoption_item->SetToolTip(tips); } +} + std::string PrintOption::getValue() { return m_printoption_item->getValue(); @@ -4946,6 +4953,8 @@ void PrintOptionItem::render(wxDC &dc) void PrintOptionItem::on_left_down(wxMouseEvent &evt) { + if (!m_enabled) { return;} + auto pos = ClientToScreen(evt.GetPosition()); auto rect = ClientToScreen(wxPoint(0, 0)); auto select_size = GetSize().x / m_ops.size(); @@ -4983,7 +4992,7 @@ void PrintOptionItem::doRender(wxDC &dc) auto size = GetSize(); dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); dc.SetBrush(GetBackgroundColour()); - dc.DrawRoundedRectangle(0, 0, size.x, size.y, 5); + dc.DrawRoundedRectangle(0, 0, size.x, size.y, FromDIP(5)); auto left = FromDIP(4); diff --git a/src/slic3r/GUI/SelectMachine.hpp b/src/slic3r/GUI/SelectMachine.hpp index 0079be5df..26e28f139 100644 --- a/src/slic3r/GUI/SelectMachine.hpp +++ b/src/slic3r/GUI/SelectMachine.hpp @@ -212,21 +212,25 @@ struct POItem class PrintOptionItem : public wxPanel { + ScalableBitmap m_selected_bk; + std::vector m_ops; + std::string selected_key; + std::string m_param; + + bool m_enabled = true; + public: PrintOptionItem(wxWindow *parent, std::vector ops, std::string param = ""); ~PrintOptionItem(){}; - void OnPaint(wxPaintEvent &event); - void render(wxDC &dc); - void on_left_down(wxMouseEvent &evt); - void doRender(wxDC &dc); - ScalableBitmap m_selected_bk; - std::vector m_ops; - std::string selected_key; - std::string m_param; +public: + bool Enable(bool enable) override { m_enabled = enable; return m_enabled;} - void setValue(std::string value); - void update_options(std::vector ops){ + void setValue(std::string value); + std::string getValue(); + + void msw_rescale() { m_selected_bk.msw_rescale(); Refresh();}; + void update_options(std::vector ops){ m_ops = ops; selected_key = ""; auto width = ops.size() * FromDIP(56) + FromDIP(8); @@ -235,31 +239,42 @@ public: SetMaxSize(wxSize(width, height)); Refresh(); }; - std::string getValue(); -public: - void msw_rescale() { m_selected_bk.msw_rescale(); Refresh(); }; +private: + void OnPaint(wxPaintEvent &event); + void render(wxDC &dc); + void on_left_down(wxMouseEvent &evt); + void doRender(wxDC &dc); }; class PrintOption : public wxPanel { +private: + std::string m_param; + std::vector m_ops; + Label *m_printoption_title{nullptr}; + PrintOptionItem *m_printoption_item{nullptr}; + public: PrintOption(wxWindow *parent, wxString title, wxString tips, std::vector ops, std::string param = ""); ~PrintOption(){}; + +public: + void enable(bool en) { m_printoption_item->Enable(en); } + + void setValue(std::string value); + std::string getValue(); + int getValueInt(); + + void update_options(std::vector ops, const wxString &tips); + void update_tooltip(const wxString &tips); + + void msw_rescale() { m_printoption_item->msw_rescale(); }; + +private: void OnPaint(wxPaintEvent &event); void render(wxDC &dc); void doRender(wxDC &dc); - void msw_rescale() { m_printoption_item->msw_rescale(); }; - void enable(bool en){m_printoption_item->Enable(en);}; - - std::string m_param; - std::vector m_ops; - Label* m_printoption_title{nullptr}; - PrintOptionItem* m_printoption_item{nullptr}; - void setValue(std::string value); - void update_options(std::vector ops, const wxString &tips); - std::string getValue(); - int getValueInt(); }; class ThumbnailPanel : public wxPanel