feat: system settings stored as applets in virtual folder

This commit is contained in:
2026-04-23 15:36:03 +02:00
parent 348ff6981b
commit d912a636e9
21 changed files with 747 additions and 359 deletions
+14 -33
View File
@@ -110,39 +110,20 @@ void desktop_scan_apps(DesktopState* ds) {
static const char* CATEGORY_NAMES[] = { "Applications", "Internet", "System", "Games" };
static constexpr int NUM_CATEGORIES = 4;
// Embedded app definitions: { display_name, app_id, category_index }
struct EmbeddedAppDef {
const char* name;
int app_id;
int category; // index into CATEGORY_NAMES
};
static const EmbeddedAppDef embedded_apps[] = {
{ "Files", 1, 0 },
};
static constexpr int NUM_EMBEDDED = sizeof(embedded_apps) / sizeof(embedded_apps[0]);
// Resolve embedded app_id to an icon pointer in DesktopState
static SvgIcon* icon_for_embedded(DesktopState* ds, int app_id) {
switch (app_id) {
case 1: return &ds->icon_filemanager;
default: return nullptr;
}
}
void desktop_build_menu(DesktopState* ds) {
menu_row_count = 0;
int builtin_count = 0;
const DesktopBuiltinEntry* builtins = desktop_builtin_registry(&builtin_count);
// Build each category
for (int cat = 0; cat < NUM_CATEGORIES; cat++) {
menu_add_category(CATEGORY_NAMES[cat]);
// Add embedded apps in this category
for (int e = 0; e < NUM_EMBEDDED; e++) {
if (embedded_apps[e].category == cat) {
menu_add_embedded(embedded_apps[e].name, embedded_apps[e].app_id,
icon_for_embedded(ds, embedded_apps[e].app_id));
// Add desktop builtins in this category
for (int b = 0; b < builtin_count; b++) {
if (builtins[b].launcher_category == cat) {
menu_add_embedded(builtins[b].label, builtins[b].id,
desktop_builtin_menu_icon(ds, builtins[b].id));
}
}
@@ -158,12 +139,12 @@ void desktop_build_menu(DesktopState* ds) {
// Divider + always-visible entries
menu_add_category(""); // divider (cat 4, always expanded)
menu_add_embedded("Settings", 11, &ds->icon_settings);
menu_add_embedded("Lock Screen", 17, &ds->icon_lock);
menu_add_embedded("Log Out", 16, &ds->icon_logout);
menu_add_embedded("Sleep", 18, &ds->icon_sleep);
menu_add_embedded("Reboot", 12, &ds->icon_reboot);
menu_add_embedded("Shutdown", 14, &ds->icon_shutdown);
for (int b = 0; b < builtin_count; b++) {
if (builtins[b].launcher_footer) {
menu_add_embedded(builtins[b].label, builtins[b].id,
desktop_builtin_menu_icon(ds, builtins[b].id));
}
}
}
// ============================================================================
@@ -211,7 +192,7 @@ void gui::desktop_init(DesktopState* ds) {
ds->icon_exec_lg = svg_load("0:/icons/utilities-terminal.svg", 48, 48, defColor);
// drive icons loaded lazily by file manager to reduce startup heap pressure
ds->icon_settings = svg_load("0:/icons/help-about.svg", 20, 20, defColor);
ds->icon_settings = svg_load("0:/icons/preferences-desktop-apps.svg", 20, 20, defColor);
ds->icon_reboot = svg_load("0:/icons/system-reboot.svg", 20, 20, defColor);
ds->icon_shutdown = svg_load("0:/icons/system-shutdown.svg", 20, 20, defColor);
ds->icon_sleep = svg_load("0:/icons/sleep.svg", 20, 20, defColor);