Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autostart fix 2 #2331

Merged
merged 3 commits into from
Nov 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions firmware/application/ui_navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::codecvt_utf8_utf16<char16_t>, 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) {
Expand Down
Loading