Show help info of setting up connection

This commit is contained in:
SoftFever 2023-04-03 20:02:55 +08:00
parent 7816c93741
commit 1a281e99a6
4 changed files with 66 additions and 22 deletions

View file

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Printer Connection Required</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #272727;
}
.container {
text-align: center;
background-color: #272727;
padding: 30px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(39, 39, 39, 0.1);
}
</style>
</head>
<body>
<div class="container">
<h1>Printer Connection</h1>
<p>Please set up your printer connection to view the device.</p>
<img src="setup_connection.gif" alt="Printer connection setup demonstration" style="max-width: 100%; height: auto; display: block;"/>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 738 KiB

View file

@ -864,13 +864,13 @@ void MainFrame::show_option(bool show)
} }
} }
void MainFrame::init_tabpanel() void MainFrame::init_tabpanel() {
{ // wxNB_NOPAGETHEME: Disable Windows Vista theme for the Notebook background. The theme performance is terrible on
// wxNB_NOPAGETHEME: Disable Windows Vista theme for the Notebook background. The theme performance is terrible on Windows 10 // Windows 10 with multiple high resolution displays connected.
// with multiple high resolution displays connected. // BBS
// BBS wxBoxSizer *side_tools = create_side_tools();
wxBoxSizer* side_tools = create_side_tools(); m_tabpanel = new Notebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, side_tools,
m_tabpanel = new Notebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, side_tools, wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME); wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME);
m_tabpanel->SetBackgroundColour(*wxWHITE); m_tabpanel->SetBackgroundColour(*wxWHITE);
#ifndef __WXOSX__ // Don't call SetFont under OSX to avoid name cutting in ObjectList #ifndef __WXOSX__ // Don't call SetFont under OSX to avoid name cutting in ObjectList
@ -879,21 +879,32 @@ void MainFrame::init_tabpanel()
m_tabpanel->Hide(); m_tabpanel->Hide();
m_settings_dialog.set_tabpanel(m_tabpanel); m_settings_dialog.set_tabpanel(m_tabpanel);
m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGING, [this](wxBookCtrlEvent& e) { m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGING, [this](wxBookCtrlEvent &e) {
int old_sel = e.GetOldSelection(); int old_sel = e.GetOldSelection();
int new_sel = e.GetSelection(); int new_sel = e.GetSelection();
if (wxGetApp().preset_bundle && if (wxGetApp().preset_bundle &&
wxGetApp().preset_bundle->printers.get_edited_preset().is_bbl_vendor_preset(wxGetApp().preset_bundle) && wxGetApp().preset_bundle->printers.get_edited_preset().is_bbl_vendor_preset(wxGetApp().preset_bundle) &&
new_sel == tpMonitor) { new_sel == tpMonitor) {
if (!wxGetApp().getAgent()) { if (!wxGetApp().getAgent()) {
e.Veto(); e.Veto();
BOOST_LOG_TRIVIAL(info) << boost::format("skipped tab switch from %1% to %2%, lack of network plugins")%old_sel %new_sel; BOOST_LOG_TRIVIAL(info) << boost::format("skipped tab switch from %1% to %2%, lack of network plugins") %
if (m_plater) { old_sel % new_sel;
wxCommandEvent *evt = new wxCommandEvent(EVT_INSTALL_PLUGIN_HINT); if (m_plater) {
wxQueueEvent(m_plater, evt); wxCommandEvent *evt = new wxCommandEvent(EVT_INSTALL_PLUGIN_HINT);
} wxQueueEvent(m_plater, evt);
} }
} }
} else {
if (new_sel == tpMonitor && wxGetApp().preset_bundle != nullptr) {
auto cfg = wxGetApp().preset_bundle->printers.get_edited_preset().config;
wxString url = cfg.opt_string("print_host_webui").empty() ? cfg.opt_string("print_host")
: cfg.opt_string("print_host_webui");
if (url.empty()) {
wxString url = wxString::Format("file://%s/web/orca/missing_connection.html", from_u8(resources_dir()));
m_printer_view->load_url(url);
}
}
}
}); });
#ifdef __WXMSW__ #ifdef __WXMSW__

View file

@ -161,7 +161,7 @@ bool OctoPrint::test(wxString &msg) const
wxString OctoPrint::get_test_ok_msg () const wxString OctoPrint::get_test_ok_msg () const
{ {
return _(L("Connection to OctoPrint works correctly.")); return _(L("Connection to OctoPrint/Klipper works correctly."));
} }
wxString OctoPrint::get_test_failed_msg (wxString &msg) const wxString OctoPrint::get_test_failed_msg (wxString &msg) const