feat(automation): implement WxUiBackend::open_files via Plater::load_files

This commit is contained in:
SoftFever
2026-06-03 20:14:29 +08:00
parent b87dd23c74
commit 3f1a2a71bd
2 changed files with 23 additions and 0 deletions

View File

@@ -303,4 +303,26 @@ PngImage WxUiBackend::screenshot_window(const UiNode* target) {
});
}
int WxUiBackend::open_files(const std::vector<std::string>& paths) {
return run_on_gui(m_gui_timeout_ms, [&]() -> int {
Plater* plater = wxGetApp().plater();
if (plater == nullptr)
throw AutomationError(kErrLoadFailed, "no plater to load into");
// Default strategy matches drag-drop / Plater::load_files's own default: it
// routes .3mf as a project and meshes as models based on file content, so no
// as_project flag is needed in v1. ask_multi=false: never prompt.
const LoadStrategy strategy = LoadStrategy::LoadModel | LoadStrategy::LoadConfig;
std::vector<size_t> loaded;
try {
loaded = plater->load_files(paths, strategy, /*ask_multi=*/false);
} catch (const std::exception& e) {
throw AutomationError(kErrLoadFailed,
std::string("load_files failed: ") + e.what());
}
if (loaded.empty())
throw AutomationError(kErrLoadFailed, "load_files loaded nothing");
return static_cast<int>(loaded.size());
});
}
}}} // namespace Slic3r::GUI::Automation

View File

@@ -19,6 +19,7 @@ public:
bool type_text(const std::string& text) override;
bool send_keys(const std::vector<KeyChord>& chords) override;
PngImage screenshot_window(const UiNode* target) override;
int open_files(const std::vector<std::string>& paths) override;
private:
int m_gui_timeout_ms;