mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-12-06 03:38:01 -05:00
fix: revert native device tab flag (#17162)
(cherry picked from commit fcab66ca9e)
This commit is contained in:
1 parent
44f792dbc3
commit
dacdb5a72d
8 files changed
+20
-78
No files matched your search
@@ -100,14 +100,8 @@ the active printer agent because a normal LAN agent represents one physical prin
|
||||
## Agent registration and selection
|
||||
|
||||
`NetworkAgentFactory` maintains the printer-agent registry. Each registry entry contains an agent ID,
|
||||
a display name, a factory function, and whether the native Device and Calibration tabs apply to the
|
||||
agent's printers. Built-in agents register during application initialization. Python printer-agent
|
||||
capabilities register dynamically and contribute an agent ID and factory entry.
|
||||
|
||||
The tab flag is read from the registry rather than the live agent because the main window lays out its
|
||||
tabs before the newly selected preset's agent is installed. It defaults to true. An agent that clears
|
||||
it is one whose printers have their own web interface and nothing the Bambu-shaped Device and
|
||||
Calibration tabs can show; for those printers the web Device page takes the Device tab's place.
|
||||
a display name, and a factory function. Built-in agents register during application initialization.
|
||||
Python printer-agent capabilities register dynamically and contribute an agent ID and factory entry.
|
||||
|
||||
The selected printer preset contains the printer-agent choice. If no explicit choice is stored, the
|
||||
application preserves the existing default behavior: Bambu presets select the Bambu agent and other
|
||||
|
||||
@@ -1660,14 +1660,6 @@ void MainFrame::show_device(bool should_use_native) {
|
||||
// get it — otherwise a Bambu user sees two Device tabs, one of them permanently empty.
|
||||
const bool want_web_device_tab = use_printer_agents && wxGetApp().preset_bundle != nullptr &&
|
||||
!wxGetApp().preset_bundle->use_bbl_device_tab();
|
||||
// An agent whose printers have nothing for the native Device and Calibration tabs leaves the web page as the only Device tab
|
||||
bool want_native_device_tabs = true;
|
||||
if (want_web_device_tab) {
|
||||
const std::string agent_id = wxGetApp().resolve_printer_agent_id(
|
||||
wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_string("printer_agent"));
|
||||
const PrinterAgentInfo* agent_info = NetworkAgentFactory::get_printer_agent_info(agent_id);
|
||||
want_native_device_tabs = agent_info == nullptr || agent_info->native_device_tab;
|
||||
}
|
||||
|
||||
// Remove the extra page before switching to any layout that shouldn't have it.
|
||||
if (!want_web_device_tab) {
|
||||
@@ -1678,16 +1670,7 @@ void MainFrame::show_device(bool should_use_native) {
|
||||
}
|
||||
|
||||
if (use_printer_agents) {
|
||||
if (!want_native_device_tabs) {
|
||||
if ((idx = m_tabpanel->FindPage(m_monitor_page)) != wxNOT_FOUND) {
|
||||
m_monitor_page->Show(false);
|
||||
m_tabpanel->RemovePage(idx);
|
||||
}
|
||||
if ((idx = m_tabpanel->FindPage(m_calibration_page)) != wxNOT_FOUND) {
|
||||
m_calibration_page->Show(false);
|
||||
m_tabpanel->RemovePage(idx);
|
||||
}
|
||||
} else if (!m_monitor_page->in_book()) {
|
||||
if (!m_monitor_page->in_book()) {
|
||||
if ((idx = m_tabpanel->FindPage(m_printer_view_page)) != wxNOT_FOUND) {
|
||||
m_printer_view_page->Show(false);
|
||||
m_tabpanel->RemovePage(idx);
|
||||
@@ -1707,29 +1690,20 @@ void MainFrame::show_device(bool should_use_native) {
|
||||
TAB_ID_MULTI_DEVICE, m_multi_machine_page, _L("Multi-device"), "tab_multi_active");
|
||||
}
|
||||
}
|
||||
if (want_native_device_tabs && !m_calibration_page->in_book()) {
|
||||
if (!m_calibration_page->in_book()) {
|
||||
m_calibration_page->Show(false);
|
||||
m_tabpanel->InsertPage(m_tabpanel->PositionAfter({TAB_ID_PROJECT}), TAB_ID_CALIBRATION, m_calibration_page,
|
||||
_L("Calibration"), "tab_calibration_active");
|
||||
}
|
||||
|
||||
if (want_web_device_tab) {
|
||||
// Without the native Device tab the web page takes its id, so every way to the Device tab leads here
|
||||
const char* id = want_native_device_tabs ? TAB_ID_MONITOR_WEB : TAB_ID_MONITOR;
|
||||
const wxString label = want_native_device_tabs ? _L("Device (Web)") : _L("Device");
|
||||
idx = m_tabpanel->FindPage(m_printer_view_page);
|
||||
if (idx != wxNOT_FOUND && m_tabpanel->FindPageByName(id) != idx) {
|
||||
if ((idx = m_tabpanel->FindPage(m_printer_view_page)) == wxNOT_FOUND) {
|
||||
m_printer_view_page->Show(false);
|
||||
m_tabpanel->RemovePage(idx);
|
||||
idx = wxNOT_FOUND;
|
||||
}
|
||||
if (idx == wxNOT_FOUND) {
|
||||
m_printer_view_page->Show(false);
|
||||
// Immediately right of the native Device tab, or of Preview without it, not at the end of the tab bar.
|
||||
m_tabpanel->InsertPage(m_tabpanel->PositionAfter({TAB_ID_MONITOR, TAB_ID_PREVIEW}), id, m_printer_view_page, label,
|
||||
"tab_monitor_active");
|
||||
// Immediately right of the native Device tab, not at the end of the tab bar.
|
||||
m_tabpanel->InsertPage(m_tabpanel->PositionAfter({TAB_ID_MONITOR}), TAB_ID_MONITOR_WEB,
|
||||
m_printer_view_page, _L("Device (Web)"), "tab_monitor_active");
|
||||
} else {
|
||||
m_tabpanel->SetPageText(idx, label);
|
||||
m_tabpanel->SetPageText(idx, _L("Device (Web)"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13901,12 +13901,7 @@ void Plater::priv::on_tab_selection_changing(wxBookCtrlEvent& e)
|
||||
const bool use_printer_agents = wxGetApp().app_config->get_bool("use_printer_agents");
|
||||
const bool use_native_device_tab = wxGetApp().preset_bundle &&
|
||||
(wxGetApp().preset_bundle->use_bbl_device_tab() || use_printer_agents);
|
||||
// Pointer test, not a name lookup: in printer-agents mode this page is TAB_ID_MONITOR_WEB
|
||||
// while the native Device tab holds TAB_ID_MONITOR, and in legacy-web mode, or for an agent
|
||||
// without the native tab, it holds TAB_ID_MONITOR itself.
|
||||
const bool selecting_web_device_tab = main_frame->m_printer_view_page &&
|
||||
main_frame->m_tabpanel->GetPage(new_sel) == main_frame->m_printer_view_page;
|
||||
if (use_native_device_tab && new_name == TAB_ID_MONITOR && !selecting_web_device_tab) {
|
||||
if (use_native_device_tab && new_name == TAB_ID_MONITOR) {
|
||||
// BBL network module is only required for BBL-vendor printers.
|
||||
// Non-BBL Python plugins (e.g. moonraker) drive the Device tab without it.
|
||||
if (!use_printer_agents && wxGetApp().preset_bundle->is_bbl_vendor() && !Slic3r::NetworkAgent::is_network_module_loaded()) {
|
||||
@@ -13918,6 +13913,11 @@ void Plater::priv::on_tab_selection_changing(wxBookCtrlEvent& e)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Pointer test, not a name lookup: in printer-agents mode this page is TAB_ID_MONITOR_WEB
|
||||
// while the native Device tab holds TAB_ID_MONITOR, and in legacy-web mode it holds
|
||||
// TAB_ID_MONITOR itself.
|
||||
const bool selecting_web_device_tab = main_frame->m_printer_view_page &&
|
||||
main_frame->m_tabpanel->GetPage(new_sel) == main_frame->m_printer_view_page;
|
||||
if (selecting_web_device_tab) {
|
||||
// Use the selected discovered machine when the preset has no host.
|
||||
main_frame->load_printer_url();
|
||||
|
||||
@@ -32,7 +32,6 @@ struct AgentInfo {
|
||||
std::string name; ///< Human-readable agent name, e.g. "Orca", "Bambu Lab"
|
||||
std::string version; ///< Agent version string, e.g. "1.0.0"
|
||||
std::string description; ///< Brief description of the agent's capabilities, e.g. "Orca printer agent"
|
||||
bool native_device_tab = true; ///< False when the native Device and Calibration tabs don't apply to the agent's printers
|
||||
};
|
||||
|
||||
struct PrinterConnectionParams
|
||||
|
||||
@@ -76,20 +76,16 @@ template<typename T> void register_agent()
|
||||
if (cloud_agent)
|
||||
agent->set_cloud_agent(cloud_agent);
|
||||
return agent;
|
||||
},
|
||||
info.native_device_tab);
|
||||
});
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
bool NetworkAgentFactory::register_printer_agent(const std::string& id, const std::string& display_name, PrinterAgentFactory factory,
|
||||
bool native_device_tab)
|
||||
bool NetworkAgentFactory::register_printer_agent(const std::string& id, const std::string& display_name, PrinterAgentFactory factory)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(s_registry_mutex);
|
||||
auto& agents = get_printer_agents();
|
||||
PrinterAgentInfo info(id, display_name, std::move(factory));
|
||||
info.native_device_tab = native_device_tab;
|
||||
return agents.emplace(id, std::move(info)).second;
|
||||
return agents.emplace(id, PrinterAgentInfo(id, display_name, std::move(factory))).second;
|
||||
}
|
||||
|
||||
bool NetworkAgentFactory::is_printer_agent_registered(const std::string& id)
|
||||
|
||||
@@ -31,7 +31,6 @@ struct PrinterAgentInfo
|
||||
std::string display_name; // e.g., "Orca Native", "Bambu Lab"
|
||||
std::string plugin_identifier; // Empty for built-ins, otherwise <plugin_key>;<uuid>;<capability_name>
|
||||
PrinterAgentFactory factory; // Function to create the agent
|
||||
bool native_device_tab = true; // See AgentInfo::native_device_tab
|
||||
|
||||
bool is_plugin() const { return !plugin_identifier.empty(); }
|
||||
PrinterAgentInfo(const std::string& id_, const std::string& display_name_, PrinterAgentFactory factory_)
|
||||
@@ -85,11 +84,9 @@ public:
|
||||
* @param id Unique identifier for the agent (e.g., "orca", "bbl")
|
||||
* @param display_name Human-readable name for UI
|
||||
* @param factory Factory function to create the agent
|
||||
* @param native_device_tab Whether the native Device and Calibration tabs apply to the agent's printers
|
||||
* @return true if registration succeeded, false if already registered
|
||||
*/
|
||||
static bool register_printer_agent(const std::string& id, const std::string& display_name, PrinterAgentFactory factory,
|
||||
bool native_device_tab = true);
|
||||
static bool register_printer_agent(const std::string& id, const std::string& display_name, PrinterAgentFactory factory);
|
||||
|
||||
/**
|
||||
* Check if an agent registry/config key is registered
|
||||
|
||||
@@ -46,8 +46,7 @@ QidiPrinterAgent::QidiPrinterAgent(std::string log_dir) : MoonrakerPrinterAgent(
|
||||
|
||||
AgentInfo QidiPrinterAgent::get_agent_info_static()
|
||||
{
|
||||
// The native Device and Calibration tabs have nothing to show for Qidi printers yet, so Fluidd's web Device tab is the only one
|
||||
return AgentInfo{"qidi", "Qidi", QidiPrinterAgent_VERSION, "Qidi printer agent", false};
|
||||
return AgentInfo{"qidi", "Qidi", QidiPrinterAgent_VERSION, "Qidi printer agent"};
|
||||
}
|
||||
|
||||
bool QidiPrinterAgent::fetch_filament_info(std::string dev_id, FilamentSyncMode /*sync_mode*/)
|
||||
|
||||
@@ -57,23 +57,6 @@ TEST_CASE("unit: printer-agent registry register / lookup / duplicate-reject", "
|
||||
CHECK(count == 1);
|
||||
}
|
||||
|
||||
TEST_CASE("The registry records whether the native Device tab applies to an agent", "[registry][unit]")
|
||||
{
|
||||
// why: ids unique to this case, as the registry is process-global
|
||||
auto stub_factory = [](std::shared_ptr<ICloudServiceAgent>, const std::string&)
|
||||
-> std::shared_ptr<IPrinterAgent> { return nullptr; };
|
||||
|
||||
REQUIRE(NetworkAgentFactory::register_printer_agent("orca-test::native-tab-default-2c91", "Default", stub_factory));
|
||||
REQUIRE(NetworkAgentFactory::register_printer_agent("orca-test::native-tab-off-2c91", "Web only", stub_factory, false));
|
||||
|
||||
const PrinterAgentInfo* with_tab = NetworkAgentFactory::get_printer_agent_info("orca-test::native-tab-default-2c91");
|
||||
const PrinterAgentInfo* web_only = NetworkAgentFactory::get_printer_agent_info("orca-test::native-tab-off-2c91");
|
||||
REQUIRE(with_tab != nullptr);
|
||||
REQUIRE(web_only != nullptr);
|
||||
CHECK(with_tab->native_device_tab);
|
||||
CHECK_FALSE(web_only->native_device_tab);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// INTEGRATION - the orca.printer_agent Python binding surface.
|
||||
// Boots the embedded interpreter and asserts the C++ to Python contract that
|
||||
|
||||
Reference in new issue
Block a user