Open menubar item by name with translations
This commit is contained in:
parent
2bb14849f4
commit
5f7a4982f6
@ -40,8 +40,8 @@
|
|||||||
# hypertext_type = gallery
|
# hypertext_type = gallery
|
||||||
#
|
#
|
||||||
#Open top menubar item
|
#Open top menubar item
|
||||||
#hypertext_menubar_menu_id = 4 (0 - 5, index of menu from left: File = 0, Edit = 1...)
|
#hypertext_menubar_menu_name = (Name in english visible as menu name: File, )
|
||||||
#hypertext_menubar_item_id = 1 (index of item, starting at 0, Including separators! In Window: 0 = Plater Tab, 1 = SEPARATOR, 2 = Print Setting Tab...)
|
#hypertext_menubar_item_name = (Name of item in english, if there are three dots at the end of name, put name without three dots)
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Each notification can have disabled and enabled modes and techs - divided by ; and space
|
# Each notification can have disabled and enabled modes and techs - divided by ; and space
|
||||||
@ -196,9 +196,9 @@ disabled_tags = SLA
|
|||||||
[hint:Configuration snapshots]
|
[hint:Configuration snapshots]
|
||||||
text = Configuration snapshots\nDid you know that roll back to a complete backup of all system and user profiles? You can view and move back and forth between snapshots using the Configuration - Configuration snapshots menu.
|
text = Configuration snapshots\nDid you know that roll back to a complete backup of all system and user profiles? You can view and move back and forth between snapshots using the Configuration - Configuration snapshots menu.
|
||||||
documentation_link = https://help.prusa3d.com/en/article/configuration-snapshots_1776
|
documentation_link = https://help.prusa3d.com/en/article/configuration-snapshots_1776
|
||||||
#hypertext_type = menubar
|
hypertext_type = menubar
|
||||||
#hypertext_menubar_menu_id = 4
|
hypertext_menubar_menu_name = Configuration
|
||||||
#hypertext_menubar_item_id = 1
|
hypertext_menubar_item_name = Configuration Snapshots
|
||||||
|
|
||||||
[hint:Minimum wall thickness]
|
[hint:Minimum wall thickness]
|
||||||
text = Minimum wall thickness\nDid you know that instead of the number of top and bottom layers, you can define the<a>Minimum shell thickness</a>in millimeters? This feature is especially useful when using the variable layer height function.
|
text = Minimum wall thickness\nDid you know that instead of the number of top and bottom layers, you can define the<a>Minimum shell thickness</a>in millimeters? This feature is especially useful when using the variable layer height function.
|
||||||
|
@ -379,9 +379,9 @@ void HintDatabase::load_hints_from_file(const boost::filesystem::path& path)
|
|||||||
wxGetApp().obj_list()->load_shape_object_from_gallery(); }
|
wxGetApp().obj_list()->load_shape_object_from_gallery(); }
|
||||||
};
|
};
|
||||||
m_loaded_hints.emplace_back(hint_data);
|
m_loaded_hints.emplace_back(hint_data);
|
||||||
} /*else if (dict["hypertext_type"] == "menubar") {
|
} else if (dict["hypertext_type"] == "menubar") {
|
||||||
int menu = std::atoi(dict["hypertext_menubar_menu_id"].c_str());
|
wxString menu(_L("&" + dict["hypertext_menubar_menu_name"]));
|
||||||
int item = std::atoi(dict["hypertext_menubar_item_id"].c_str());
|
wxString item(_L(dict["hypertext_menubar_item_name"]));
|
||||||
HintData hint_data{ id_string, text1, weight, was_displayed, hypertext_text, follow_text, disabled_tags, enabled_tags, true, documentation_link, [menu, item]() { wxGetApp().mainframe->open_menubar_item(menu, item); } };
|
HintData hint_data{ id_string, text1, weight, was_displayed, hypertext_text, follow_text, disabled_tags, enabled_tags, true, documentation_link, [menu, item]() { wxGetApp().mainframe->open_menubar_item(menu, item); } };
|
||||||
m_loaded_hints.emplace_back(hint_data);
|
m_loaded_hints.emplace_back(hint_data);
|
||||||
}*/
|
}*/
|
||||||
|
@ -1480,29 +1480,34 @@ void MainFrame::init_menubar_as_editor()
|
|||||||
if (plater()->printer_technology() == ptSLA)
|
if (plater()->printer_technology() == ptSLA)
|
||||||
update_menubar();
|
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)
|
if (m_menubar == nullptr)
|
||||||
return;
|
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) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
wxMenuItemList items = menu->GetMenuItems();
|
// Get item id from menu
|
||||||
if (items.size() <= item_index) {
|
int item_id = menu->FindItem(item_name);
|
||||||
BOOST_LOG_TRIVIAL(error) << "Mainframe open_menubar_item function couldn't find item: " << item_index;
|
if (item_id == wxNOT_FOUND)
|
||||||
return;
|
{
|
||||||
}
|
// try adding three dots char
|
||||||
wxMenuItem* item = items[item_index];
|
item_id = menu->FindItem(item_name + dots);
|
||||||
if (item == nullptr) {
|
}
|
||||||
BOOST_LOG_TRIVIAL(error) << "Mainframe open_menubar_item function couldn't find item: " << item_index;
|
if (item_id == wxNOT_FOUND)
|
||||||
|
{
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "Mainframe open_menubar_item function couldn't find item: " << item_name;
|
||||||
return;
|
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()
|
void MainFrame::init_menubar_as_gcodeviewer()
|
||||||
{
|
{
|
||||||
wxMenu* fileMenu = new wxMenu;
|
wxMenu* fileMenu = new wxMenu;
|
||||||
|
@ -158,8 +158,8 @@ public:
|
|||||||
void init_menubar_as_editor();
|
void init_menubar_as_editor();
|
||||||
void init_menubar_as_gcodeviewer();
|
void init_menubar_as_gcodeviewer();
|
||||||
void update_menubar();
|
void update_menubar();
|
||||||
// Open item in menu by menu and item index (visible order of items including separators)
|
// Open item in menu by menu and item name (in actual language)
|
||||||
//void open_menubar_item(int menu_index, int item_index);
|
void open_menubar_item(const wxString& menu_name,const wxString& item_name);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
void show_tabs_menu(bool show);
|
void show_tabs_menu(bool show);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user