mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
Customizable association of .3mf, .stl and .gcode files on Windows
This commit is contained in:
parent
7da1622e76
commit
e2b4de455b
7 changed files with 292 additions and 111 deletions
|
@ -804,7 +804,14 @@ bool GUI_App::on_init_inner()
|
|||
|
||||
if (is_editor()) {
|
||||
#ifdef __WXMSW__
|
||||
associate_3mf_files();
|
||||
#if ENABLE_CUSTOMIZABLE_FILES_ASSOCIATION_ON_WIN
|
||||
if (app_config->get("associate_3mf") == "1")
|
||||
#endif // ENABLE_CUSTOMIZABLE_FILES_ASSOCIATION_ON_WIN
|
||||
associate_3mf_files();
|
||||
#if ENABLE_CUSTOMIZABLE_FILES_ASSOCIATION_ON_WIN
|
||||
if (app_config->get("associate_stl") == "1")
|
||||
associate_stl_files();
|
||||
#endif // ENABLE_CUSTOMIZABLE_FILES_ASSOCIATION_ON_WIN
|
||||
#endif // __WXMSW__
|
||||
|
||||
preset_updater = new PresetUpdater();
|
||||
|
@ -820,7 +827,10 @@ bool GUI_App::on_init_inner()
|
|||
}
|
||||
else {
|
||||
#ifdef __WXMSW__
|
||||
associate_gcode_files();
|
||||
#if ENABLE_CUSTOMIZABLE_FILES_ASSOCIATION_ON_WIN
|
||||
if (app_config->get("associate_gcode") == "1")
|
||||
#endif // ENABLE_CUSTOMIZABLE_FILES_ASSOCIATION_ON_WIN
|
||||
associate_gcode_files();
|
||||
#endif // __WXMSW__
|
||||
}
|
||||
|
||||
|
@ -1577,6 +1587,20 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
|
|||
app_layout_changed = dlg.settings_layout_changed();
|
||||
if (dlg.seq_top_layer_only_changed())
|
||||
this->plater_->refresh_print();
|
||||
#if ENABLE_CUSTOMIZABLE_FILES_ASSOCIATION_ON_WIN
|
||||
#ifdef _WIN32
|
||||
if (is_editor()) {
|
||||
if (app_config->get("associate_3mf") == "1")
|
||||
associate_3mf_files();
|
||||
if (app_config->get("associate_stl") == "1")
|
||||
associate_stl_files();
|
||||
}
|
||||
else {
|
||||
if (app_config->get("associate_gcode") == "1")
|
||||
associate_gcode_files();
|
||||
}
|
||||
#endif // _WIN32
|
||||
#endif // ENABLE_CUSTOMIZABLE_FILES_ASSOCIATION_ON_WIN
|
||||
}
|
||||
if (app_layout_changed) {
|
||||
// hide full main_sizer for mainFrame
|
||||
|
@ -2112,6 +2136,32 @@ void GUI_App::associate_3mf_files()
|
|||
::SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nullptr, nullptr);
|
||||
}
|
||||
|
||||
#if ENABLE_CUSTOMIZABLE_FILES_ASSOCIATION_ON_WIN
|
||||
void GUI_App::associate_stl_files()
|
||||
{
|
||||
wchar_t app_path[MAX_PATH];
|
||||
::GetModuleFileNameW(nullptr, app_path, sizeof(app_path));
|
||||
|
||||
std::wstring prog_path = L"\"" + std::wstring(app_path) + L"\"";
|
||||
std::wstring prog_id = L"Prusa.Slicer.1";
|
||||
std::wstring prog_desc = L"PrusaSlicer";
|
||||
std::wstring prog_command = prog_path + L" \"%1\"";
|
||||
std::wstring reg_base = L"Software\\Classes";
|
||||
std::wstring reg_extension = reg_base + L"\\.stl";
|
||||
std::wstring reg_prog_id = reg_base + L"\\" + prog_id;
|
||||
std::wstring reg_prog_id_command = reg_prog_id + L"\\Shell\\Open\\Command";
|
||||
|
||||
bool is_new = false;
|
||||
is_new |= set_into_win_registry(HKEY_CURRENT_USER, reg_extension.c_str(), prog_id.c_str());
|
||||
is_new |= set_into_win_registry(HKEY_CURRENT_USER, reg_prog_id.c_str(), prog_desc.c_str());
|
||||
is_new |= set_into_win_registry(HKEY_CURRENT_USER, reg_prog_id_command.c_str(), prog_command.c_str());
|
||||
|
||||
if (is_new)
|
||||
// notify Windows only when any of the values gets changed
|
||||
::SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nullptr, nullptr);
|
||||
}
|
||||
#endif // ENABLE_CUSTOMIZABLE_FILES_ASSOCIATION_ON_WIN
|
||||
|
||||
void GUI_App::associate_gcode_files()
|
||||
{
|
||||
wchar_t app_path[MAX_PATH];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue