fix devtools on release builds

This commit is contained in:
Josh Junon 2024-04-16 16:43:22 +02:00
parent ed7fd43874
commit fa06586cdf
No known key found for this signature in database
2 changed files with 24 additions and 16 deletions

View File

@ -115,6 +115,7 @@ jobs:
- check-tests
features:
- ''
- [devtools]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/check-crate

View File

@ -31,11 +31,14 @@ pub async fn menu_item_set_enabled(
}
pub fn build(package_info: &PackageInfo) -> Menu {
#[allow(unused_mut)]
let mut menu = Menu::os_default(&package_info.name).add_submenu(Submenu::new(
"Project",
Menu::with_items([disabled_menu_item("project/settings", "Project Settings")]),
));
#[cfg(any(debug_assertions, feature = "devtools"))]
{
// Try to find the View menu and attach the dev tools item
let view_menu = menu.items.iter_mut().find(|item| match item {
MenuEntry::CustomItem(_) => false,
@ -52,6 +55,7 @@ pub fn build(package_info: &PackageInfo) -> Menu {
Menu::with_items([devtools.into()]),
));
}
}
menu
}
@ -63,9 +67,12 @@ fn disabled_menu_item(id: &str, title: &str) -> MenuEntry {
}
pub fn handle_event<R: Runtime>(event: &WindowMenuEvent<R>) {
#[cfg(any(debug_assertions, feature = "devtools"))]
{
if event.menu_item_id() == "view/devtools" {
event.window().open_devtools();
}
}
emit(
event.window(),
format!("menu://{}/clicked", event.menu_item_id()).as_str(),