mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-12-31 11:50:33 -07:00
FIX:add darkmode of thermalprecondition
jira:[STUDIO-14662] Change-Id: I75998ff04e1073d07e23ff6970dce90627b7b860 (cherry picked from commit 93fc862f7e74c52d7a9cfb75d24ecf0685788341)
This commit is contained in:
parent
2e19dfea93
commit
bfd8a0cbd7
2 changed files with 44 additions and 42 deletions
|
|
@ -1,24 +1,27 @@
|
|||
#include "ThermalPreconditioningDialog.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "DeviceManager.hpp"
|
||||
#include "DeviceCore/DevManager.h"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
BEGIN_EVENT_TABLE(ThermalPreconditioningDialog, wxDialog)
|
||||
EVT_BUTTON(wxID_OK, ThermalPreconditioningDialog::on_ok_clicked)
|
||||
EVT_BUTTON(wxID_OK, ThermalPreconditioningDialog::on_ok_clicked)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
ThermalPreconditioningDialog::ThermalPreconditioningDialog(wxWindow* parent, std::string dev_id,const wxString& remaining_time)
|
||||
ThermalPreconditioningDialog::ThermalPreconditioningDialog(wxWindow *parent, std::string dev_id, const wxString &remaining_time)
|
||||
: wxDialog(parent, wxID_ANY, _L("Thermal Preconditioning for first layer optimization"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
, m_dev_id(dev_id)
|
||||
{
|
||||
wxBitmap bitmap = create_scaled_bitmap("thermal_preconditioning_title", this, 16);
|
||||
wxIcon icon;
|
||||
wxIcon icon;
|
||||
icon.CopyFromBitmap(bitmap);
|
||||
SetIcon(icon);
|
||||
// Apply dark-mode-friendly background for the dialog
|
||||
SetBackgroundColour(StateColor::darkModeColorFor(wxColour(255, 255, 255)));
|
||||
create_ui();
|
||||
m_refresh_timer = new wxTimer(this);
|
||||
this->Bind(wxEVT_TIMER, &ThermalPreconditioningDialog::on_timer, this);
|
||||
|
|
@ -33,46 +36,48 @@ ThermalPreconditioningDialog::ThermalPreconditioningDialog(wxWindow* parent, std
|
|||
|
||||
// Set dialog size and position
|
||||
SetSize(wxSize(FromDIP(400), FromDIP(200)));
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
CentreOnScreen();
|
||||
}
|
||||
|
||||
ThermalPreconditioningDialog::~ThermalPreconditioningDialog() {
|
||||
if (m_refresh_timer && m_refresh_timer->IsRunning())
|
||||
{
|
||||
ThermalPreconditioningDialog::~ThermalPreconditioningDialog()
|
||||
{
|
||||
if (m_refresh_timer && m_refresh_timer->IsRunning()) {
|
||||
m_refresh_timer->Stop();
|
||||
delete m_refresh_timer;
|
||||
m_refresh_timer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ThermalPreconditioningDialog::create_ui()
|
||||
{
|
||||
wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
// Remaining time label
|
||||
m_remaining_time_label = new wxStaticText(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
|
||||
wxFont time_font = m_remaining_time_label->GetFont();
|
||||
wxFont time_font = m_remaining_time_label->GetFont();
|
||||
time_font.SetPointSize(14);
|
||||
time_font.SetWeight(wxFONTWEIGHT_BOLD);
|
||||
m_remaining_time_label->SetFont(time_font);
|
||||
m_remaining_time_label->SetForegroundColour(wxColour(50, 58, 61));
|
||||
m_remaining_time_label->SetForegroundColour(StateColor::darkModeColorFor(wxColour(50, 58, 61)));
|
||||
|
||||
// Explanation text
|
||||
m_explanation_label = new wxStaticText(this, wxID_ANY,
|
||||
_L("The heated bed's thermal preconditioning helps optimize the first layer print quality. Printing will start once preconditioning is complete."),
|
||||
wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
|
||||
m_explanation_label =
|
||||
new wxStaticText(this, wxID_ANY,
|
||||
_L("The heated bed's thermal preconditioning helps optimize the first layer print quality. Printing will start once preconditioning is complete."),
|
||||
wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
|
||||
m_explanation_label->Wrap(FromDIP(350));
|
||||
m_explanation_label->SetForegroundColour(wxColour(50, 58, 61));
|
||||
m_explanation_label->SetForegroundColour(StateColor::darkModeColorFor(wxColour(50, 58, 61)));
|
||||
|
||||
m_ok_button = new wxButton(this, wxID_OK, _L("OK"));
|
||||
#ifdef __WXMAC__
|
||||
m_ok_button->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
|
||||
m_ok_button->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
|
||||
#else
|
||||
m_ok_button->SetBackgroundColour(wxColour("#B6F34F"));
|
||||
m_ok_button->SetForegroundColour(wxColour("#000000"));
|
||||
#endif
|
||||
m_ok_button->SetBackgroundColour(StateColor::darkModeColorFor(wxColour("#B6F34F")));
|
||||
m_ok_button->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#000000")));
|
||||
m_ok_button->SetMinSize(wxSize(FromDIP(80), FromDIP(32)));
|
||||
m_ok_button->SetMaxSize(wxSize(FromDIP(80), FromDIP(32)));
|
||||
#endif
|
||||
|
||||
// Layout
|
||||
main_sizer->Add(0, 0, 1, wxEXPAND);
|
||||
|
|
@ -84,27 +89,23 @@ void ThermalPreconditioningDialog::create_ui()
|
|||
SetSizer(main_sizer);
|
||||
}
|
||||
|
||||
void ThermalPreconditioningDialog::on_ok_clicked(wxCommandEvent& event)
|
||||
{
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
void ThermalPreconditioningDialog::on_ok_clicked(wxCommandEvent &event) { EndModal(wxID_OK); }
|
||||
|
||||
void ThermalPreconditioningDialog::update_thermal_remaining_time()
|
||||
{
|
||||
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) return;
|
||||
MachineObject * m_obj = dev->get_my_machine(m_dev_id);
|
||||
MachineObject *m_obj = dev->get_my_machine(m_dev_id);
|
||||
|
||||
int remaining_seconds = m_obj->get_stage_remaining_seconds();
|
||||
int remaining_seconds = m_obj->get_stage_remaining_seconds();
|
||||
wxString remaining_time;
|
||||
if (remaining_seconds >= 0) {
|
||||
int minutes = remaining_seconds/60;
|
||||
int seconds = remaining_seconds % 60;
|
||||
remaining_time = wxString::Format("Remaining time: %dmin%ds", minutes, seconds);
|
||||
int minutes = remaining_seconds / 60;
|
||||
int seconds = remaining_seconds % 60;
|
||||
remaining_time = wxString::Format(_L("Remaining time: %dmin%ds"), minutes, seconds);
|
||||
}
|
||||
|
||||
if (m_remaining_time_label)
|
||||
m_remaining_time_label->SetLabelText(remaining_time);
|
||||
if (m_remaining_time_label) m_remaining_time_label->SetLabelText(remaining_time);
|
||||
}
|
||||
|
||||
void ThermalPreconditioningDialog::on_timer(wxTimerEvent &event) {
|
||||
|
|
@ -112,11 +113,11 @@ void ThermalPreconditioningDialog::on_timer(wxTimerEvent &event) {
|
|||
if (!dev) return;
|
||||
MachineObject *m_obj = dev->get_my_machine(m_dev_id);
|
||||
|
||||
if (IsShown() && m_obj && m_obj->stage_curr == 58) {
|
||||
update_thermal_remaining_time();
|
||||
if (IsShown() && m_obj && m_obj->stage_curr == 58) {
|
||||
update_thermal_remaining_time();
|
||||
} else {
|
||||
m_refresh_timer->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
}} // namespace Slic3r
|
||||
|
|
@ -11,29 +11,30 @@
|
|||
namespace Slic3r {
|
||||
|
||||
class MachineObject;
|
||||
namespace GUI {
|
||||
|
||||
class ThermalPreconditioningDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
ThermalPreconditioningDialog(wxWindow *parent, std::string dev_id, const wxString &remaining_time);
|
||||
~ThermalPreconditioningDialog() ;
|
||||
|
||||
~ThermalPreconditioningDialog();
|
||||
|
||||
void update_thermal_remaining_time();
|
||||
|
||||
private:
|
||||
void create_ui();
|
||||
void on_ok_clicked(wxCommandEvent& event);
|
||||
void on_timer(wxTimerEvent &event);
|
||||
void on_ok_clicked(wxCommandEvent &event);
|
||||
void on_timer(wxTimerEvent &event);
|
||||
|
||||
std::string m_dev_id;
|
||||
wxTimer* m_refresh_timer;
|
||||
wxStaticText* m_remaining_time_label;
|
||||
wxStaticText* m_explanation_label;
|
||||
wxButton* m_ok_button;
|
||||
wxStaticBitmap* m_title_bitmap;
|
||||
std::string m_dev_id;
|
||||
wxTimer *m_refresh_timer;
|
||||
wxStaticText *m_remaining_time_label;
|
||||
wxStaticText *m_explanation_label;
|
||||
wxButton *m_ok_button;
|
||||
wxStaticBitmap *m_title_bitmap;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
Loading…
Add table
Add a link
Reference in a new issue