CrealityPrint: add calibration checkbox to send dialog

Add enableSelfTest checkbox to CrealityPrintHostSendDialog that
persists across sessions via AppConfig. The checkbox state is
passed to the upload via extendedInfo().

Signed-off-by: Igor Mammedov <niallain@gmail.com>
This commit is contained in:
Igor Mammedov
2026-04-23 00:49:21 +02:00
parent 02c71fa6c0
commit 35117ceedf
2 changed files with 33 additions and 1 deletions

View File

@@ -961,6 +961,7 @@ CrealityPrintHostSendDialog::CrealityPrintHostSendDialog(const fs::path&
bool switch_to_device_tab,
PrintHost* printhost)
: PrintHostSendDialog(path, post_actions, groups, storage_paths, storage_names, switch_to_device_tab)
, m_enableSelfTest(false)
, m_printhost(printhost)
{}
@@ -985,13 +986,41 @@ void CrealityPrintHostSendDialog::init()
auto* group_sizer = new wxStaticBoxSizer(group_box, wxVERTICAL);
content_sizer->Add(group_sizer, 0, wxEXPAND);
const AppConfig* app_config = wxGetApp().app_config;
std::string saved = app_config->get("recent", CONFIG_KEY_ENABLESELFTEST);
if (!saved.empty()) {
try { m_enableSelfTest = std::stoi(saved) != 0; } catch (...) {}
}
// Calibration checkbox
{
auto checkbox_sizer = new wxBoxSizer(wxHORIZONTAL);
auto checkbox = new ::CheckBox(this);
checkbox->SetValue(m_enableSelfTest);
checkbox->Bind(wxEVT_TOGGLEBUTTON, [this](wxCommandEvent& e) {
m_enableSelfTest = e.IsChecked();
AppConfig* ac = wxGetApp().app_config;
ac->set("recent", CONFIG_KEY_ENABLESELFTEST, m_enableSelfTest ? "1" : "0");
e.Skip();
});
checkbox_sizer->Add(checkbox, 0, wxALL | wxALIGN_CENTER, FromDIP(2));
auto checkbox_text = new wxStaticText(this, wxID_ANY, _L("Calibrate before printing"), wxDefaultPosition, wxDefaultSize, 0);
checkbox_sizer->Add(checkbox_text, 0, wxALL | wxALIGN_CENTER, FromDIP(2));
checkbox_text->SetFont(::Label::Body_13);
checkbox_text->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#323A3D")));
group_sizer->Add(checkbox_sizer);
group_sizer->AddSpacer(VERT_SPACING);
}
this->Layout();
this->Fit();
}
std::map<std::string, std::string> CrealityPrintHostSendDialog::extendedInfo() const
{
return {};
std::map<std::string, std::string> info;
info["enableSelfTest"] = m_enableSelfTest ? "1" : "0";
return info;
}
}}

View File

@@ -195,6 +195,9 @@ public:
virtual std::map<std::string, std::string> extendedInfo() const;
private:
static constexpr const char* CONFIG_KEY_ENABLESELFTEST = "crealityprint_enable_self_test";
bool m_enableSelfTest;
PrintHost* m_printhost;
};