mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 14:44:19 -06:00
Open menubar item by name with translations
This commit is contained in:
parent
2bb14849f4
commit
5f7a4982f6
4 changed files with 29 additions and 24 deletions
|
@ -1480,29 +1480,34 @@ void MainFrame::init_menubar_as_editor()
|
|||
if (plater()->printer_technology() == ptSLA)
|
||||
update_menubar();
|
||||
}
|
||||
/*
|
||||
void MainFrame::open_menubar_item(int menu_index, int item_index)
|
||||
|
||||
void MainFrame::open_menubar_item(const wxString& menu_name,const wxString& item_name)
|
||||
{
|
||||
if (m_menubar == nullptr)
|
||||
return;
|
||||
wxMenu* menu = m_menubar->GetMenu(menu_index);
|
||||
// Get menu object from menubar
|
||||
int menu_index = m_menubar->FindMenu(menu_name);
|
||||
wxMenu* menu = m_menubar->GetMenu(menu_index);
|
||||
if (menu == nullptr) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Mainframe open_menubar_item function couldn't find menu: " << menu_index;
|
||||
BOOST_LOG_TRIVIAL(error) << "Mainframe open_menubar_item function couldn't find menu: " << menu_name;
|
||||
return;
|
||||
}
|
||||
wxMenuItemList items = menu->GetMenuItems();
|
||||
if (items.size() <= item_index) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Mainframe open_menubar_item function couldn't find item: " << item_index;
|
||||
return;
|
||||
}
|
||||
wxMenuItem* item = items[item_index];
|
||||
if (item == nullptr) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Mainframe open_menubar_item function couldn't find item: " << item_index;
|
||||
// Get item id from menu
|
||||
int item_id = menu->FindItem(item_name);
|
||||
if (item_id == wxNOT_FOUND)
|
||||
{
|
||||
// try adding three dots char
|
||||
item_id = menu->FindItem(item_name + dots);
|
||||
}
|
||||
if (item_id == wxNOT_FOUND)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(error) << "Mainframe open_menubar_item function couldn't find item: " << item_name;
|
||||
return;
|
||||
}
|
||||
wxPostEvent((wxEvtHandler*)menu, wxCommandEvent(wxEVT_MENU, item->GetId()));
|
||||
// wxEVT_MENU will trigger item
|
||||
wxPostEvent((wxEvtHandler*)menu, wxCommandEvent(wxEVT_MENU, item_id));
|
||||
}
|
||||
*/
|
||||
|
||||
void MainFrame::init_menubar_as_gcodeviewer()
|
||||
{
|
||||
wxMenu* fileMenu = new wxMenu;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue