mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-13 22:17:46 +00:00
setting&autostart&widgets (OptionField and Waveform) imp (#2286)
* test * test * format * format * tune order
This commit is contained in:

committed by
GitHub

parent
536d25db64
commit
d4edb5f5f9
@@ -5,6 +5,7 @@
|
||||
* Copyright (C) 2023 Kyle Reed
|
||||
* Copyright (C) 2024 Mark Thompson
|
||||
* Copyright (C) 2024 u-foka
|
||||
* Copyright (C) 2024 HTotoo
|
||||
* Copyleft (ɔ) 2024 zxkmm under GPL license
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
@@ -876,6 +877,7 @@ SetAutostartView::SetAutostartView(NavigationView& nav) {
|
||||
add_children({&labels,
|
||||
&button_save,
|
||||
&button_cancel,
|
||||
&button_reset,
|
||||
&options});
|
||||
|
||||
button_save.on_select = [&nav, this](Button&) {
|
||||
@@ -892,6 +894,12 @@ SetAutostartView::SetAutostartView(NavigationView& nav) {
|
||||
nav.pop();
|
||||
};
|
||||
|
||||
button_reset.on_select = [this](Button&) {
|
||||
selected = 0;
|
||||
options.set_selected_index(0);
|
||||
autostart_app = "";
|
||||
};
|
||||
|
||||
// options
|
||||
i = 0;
|
||||
OptionsField::option_t o{"-none-", i};
|
||||
|
@@ -843,14 +843,19 @@ class SetAutostartView : public View {
|
||||
"Save"};
|
||||
|
||||
OptionsField options{
|
||||
{8 * 8, 4 * 16},
|
||||
30,
|
||||
{}};
|
||||
{0 * 8, 4 * 16},
|
||||
screen_width / 8,
|
||||
{},
|
||||
true};
|
||||
|
||||
Button button_cancel{
|
||||
{16 * 8, 16 * 16, 12 * 8, 32},
|
||||
"Cancel",
|
||||
};
|
||||
|
||||
Button button_reset{
|
||||
{2 * 8, 6 * 16, screen_width - 4 * 8, 32},
|
||||
"Reset"};
|
||||
};
|
||||
|
||||
class SetThemeView : public View {
|
||||
@@ -872,15 +877,16 @@ class SetThemeView : public View {
|
||||
"Save"};
|
||||
|
||||
OptionsField options{
|
||||
{8 * 8, 4 * 16},
|
||||
30,
|
||||
{0 * 8, 4 * 16},
|
||||
screen_width / 8,
|
||||
{
|
||||
{"Default - Grey", 0},
|
||||
{"Yellow", 1},
|
||||
{"Aqua", 2},
|
||||
{"Green", 3},
|
||||
{"Red", 4},
|
||||
}};
|
||||
},
|
||||
true};
|
||||
|
||||
Checkbox checkbox_menuset{
|
||||
{2 * 8, 6 * 16},
|
||||
|
@@ -758,14 +758,30 @@ void NavigationView::handle_autostart() {
|
||||
"nav"sv,
|
||||
{{"autostart_app"sv, &autostart_app}}};
|
||||
if (!autostart_app.empty()) {
|
||||
if (StartAppByName(autostart_app.c_str())) return;
|
||||
// if returned false, check for external apps by that name, and try to start it
|
||||
std::string appwithpath = "/" + apps_dir.string() + "/";
|
||||
appwithpath += autostart_app;
|
||||
appwithpath += ".ppma";
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> conv;
|
||||
std::filesystem::path pth = conv.from_bytes(appwithpath.c_str());
|
||||
ui::ExternalItemsMenuLoader::run_external_app(*this, pth);
|
||||
bool app_started = false;
|
||||
|
||||
// try innerapp
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!app_started) {
|
||||
display_modal(
|
||||
"Notice", "Autostart failed:\n" +
|
||||
autostart_app +
|
||||
"\nupdate sdcard content\n" +
|
||||
"and check if .ppma exists");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user