SPE-2564: Use only 1 menu item to reload from disk (on plater) or reload webview

Two items on mac.
This commit is contained in:
David Kocik 2024-12-03 09:32:04 +01:00 committed by Lukas Matena
parent 882e291daa
commit cfcb284520
2 changed files with 43 additions and 8 deletions

View File

@ -691,6 +691,10 @@ void MainFrame::init_tabpanel()
old_tab->validate_custom_gcodes(); old_tab->validate_custom_gcodes();
} }
#ifndef __APPLE__
on_tab_change_rename_reload_item(e.GetSelection());
#endif // !__APPLE__
wxWindow* panel = m_tabpanel->GetCurrentPage(); wxWindow* panel = m_tabpanel->GetCurrentPage();
Tab* tab = dynamic_cast<Tab*>(panel); Tab* tab = dynamic_cast<Tab*>(panel);
@ -995,6 +999,35 @@ void MainFrame::reload_selected_webview()
m_printer_webview->do_reload(); m_printer_webview->do_reload();
} }
void MainFrame::on_tab_change_rename_reload_item(int new_tab)
{
if (!m_tabpanel) {
return;
}
if ( new_tab == m_tabpanel->FindPage(m_printables_webview)
|| (m_connect_webview_added && new_tab == m_tabpanel->FindPage(m_connect_webview))
|| (m_printer_webview_added && new_tab == m_tabpanel->FindPage(m_printer_webview)))
{
m_menu_item_reload->SetItemLabel(_L("Re&load Web Content") + "\t\xA0" + "F5");
m_menu_item_reload->SetHelp(_L("Reload Web Content"));
} else {
m_menu_item_reload->SetItemLabel(_L("Re&load from Disk") + "\t\xA0" + "F5");
m_menu_item_reload->SetHelp(_L("Reload the plater from disk"));
}
}
bool MainFrame::reload_item_condition_cb()
{
return is_any_webview_selected() ? true :
!m_plater->model().objects.empty();
}
void MainFrame::reload_item_function_cb()
{
is_any_webview_selected()
? reload_selected_webview()
: m_plater->reload_all_from_disk();
}
void Slic3r::GUI::MainFrame::refresh_account_menu(bool avatar/* = false */) void Slic3r::GUI::MainFrame::refresh_account_menu(bool avatar/* = false */)
{ {
// Update User name in TopBar // Update User name in TopBar
@ -1605,10 +1638,13 @@ void MainFrame::init_menubar_as_editor()
append_menu_item(editMenu, wxID_ANY, _L("Re&load from Disk") + dots + "\tCtrl+Shift+R", append_menu_item(editMenu, wxID_ANY, _L("Re&load from Disk") + dots + "\tCtrl+Shift+R",
_L("Reload the plater from disk"), [this](wxCommandEvent&) { m_plater->reload_all_from_disk(); }, _L("Reload the plater from disk"), [this](wxCommandEvent&) { m_plater->reload_all_from_disk(); },
"", nullptr, [this]() {return !m_plater->model().objects.empty(); }, this); "", nullptr, [this]() {return !m_plater->model().objects.empty(); }, this);
m_menu_item_reload = append_menu_item(editMenu, wxID_ANY, _L("Re&load Web Content") + "\tF5",
_L("Reload Web Content"), [this](wxCommandEvent&) { reload_selected_webview(); },
"", nullptr, [this]() {return is_any_webview_selected(); }, this);
#else #else
append_menu_item(editMenu, wxID_ANY, _L("Re&load from Disk") + sep + "F5", m_menu_item_reload = append_menu_item(editMenu, wxID_ANY, _L("Re&load from Disk") + sep + "F5",
_L("Reload the plater from disk"), [this](wxCommandEvent&) { m_plater->reload_all_from_disk(); }, _L("Reload the plater from disk"), [this](wxCommandEvent&) { reload_item_function_cb(); },
"", nullptr, [this]() {return !m_plater->model().objects.empty(); }, this); "", nullptr, [this]() {return reload_item_condition_cb(); }, this);
#endif // __APPLE__ #endif // __APPLE__
editMenu->AppendSeparator(); editMenu->AppendSeparator();
@ -1697,10 +1733,6 @@ void MainFrame::init_menubar_as_editor()
wxFULLSCREEN_NOSTATUSBAR | wxFULLSCREEN_NOBORDER | wxFULLSCREEN_NOCAPTION); }, wxFULLSCREEN_NOSTATUSBAR | wxFULLSCREEN_NOBORDER | wxFULLSCREEN_NOCAPTION); },
this, []() { return true; }, [this]() { return this->IsFullScreen(); }, this); this, []() { return true; }, [this]() { return this->IsFullScreen(); }, this);
#endif // __APPLE__ #endif // __APPLE__
viewMenu->AppendSeparator();
append_menu_item(viewMenu, wxID_ANY, _L("&Reload Web Content") + "\tF5", _L("Reload WebView"),
[this](wxCommandEvent&) { reload_selected_webview(); }, "", nullptr, [this]() {return is_any_webview_selected(); }, this);
} }
// Help menu // Help menu

View File

@ -94,6 +94,7 @@ class MainFrame : public DPIFrame
TopBarMenus m_bar_menus; TopBarMenus m_bar_menus;
wxMenuItem* m_menu_item_reslice_now { nullptr }; wxMenuItem* m_menu_item_reslice_now { nullptr };
wxMenuItem* m_menu_item_reload { nullptr };
wxSizer* m_main_sizer{ nullptr }; wxSizer* m_main_sizer{ nullptr };
size_t m_last_selected_tab; size_t m_last_selected_tab;
@ -129,7 +130,9 @@ class MainFrame : public DPIFrame
void add_connect_webview_tab(); void add_connect_webview_tab();
void remove_connect_webview_tab(); void remove_connect_webview_tab();
void on_tab_change_rename_reload_item(int new_tab);
bool reload_item_condition_cb();
void reload_item_function_cb();
// MenuBar items changeable in respect to printer technology // MenuBar items changeable in respect to printer technology
enum MenuItems enum MenuItems
{ // FFF SLA { // FFF SLA