From 5bb23b636e3abf47d784ba8e9662db809dee7b44 Mon Sep 17 00:00:00 2001 From: sommermorgentraum <24917424+zxkmm@users.noreply.github.com> Date: Sat, 2 Nov 2024 17:43:42 +0800 Subject: [PATCH] autostart fix 2 (#2331) --- firmware/application/ui_navigation.cpp | 33 +++++++++++++++++--------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index c98a0f2f..42e4ffaf 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -725,20 +725,31 @@ void NavigationView::handle_autostart() { {{"autostart_app"sv, &autostart_app}}}; if (!autostart_app.empty()) { bool app_started = false; - - // try innerapp + // inner app if (StartAppByName(autostart_app.c_str())) { app_started = true; - } else { - // try outside app - auto external_items = ExternalItemsMenuLoader::load_external_items(app_location_t::HOME, *this); - for (const auto& item : external_items) { - if (item.text == autostart_app) { - item.on_select(); - app_started = true; - break; - } + return; + } + + // lambda + auto execute_app = [=](const std::string& extension) { // TODO: capture ref aka [&] would also lagging th GUI, no idea why + std::string appwithpath = "/" + apps_dir.string() + "/" + autostart_app + extension; + std::wstring_convert, char16_t> conv; + std::filesystem::path pth = conv.from_bytes(appwithpath.c_str()); + if (ui::ExternalItemsMenuLoader::run_external_app(*this, pth)) { + return true; } + return false; + }; + + // outside app + if (!app_started) { + app_started = execute_app(".ppma"); + } + + // standalone app + if (!app_started) { + app_started = execute_app(".ppmp"); } if (!app_started) {