feat: system settings stored as applets in virtual folder
This commit is contained in:
@@ -12,13 +12,43 @@ namespace filemanager {
|
||||
|
||||
inline constexpr int FM_MAX_DRIVES = 16;
|
||||
|
||||
enum FileManagerEntryType : int {
|
||||
FM_ENTRY_FILE = 0,
|
||||
FM_ENTRY_DIR = 1,
|
||||
FM_ENTRY_EXEC = 2,
|
||||
FM_ENTRY_DRIVE = 3,
|
||||
FM_ENTRY_HOME = 4,
|
||||
FM_ENTRY_APPS_ROOT = 5,
|
||||
FM_ENTRY_VIRTUAL_APP = 6,
|
||||
FM_ENTRY_SPECIAL_DIR = 7,
|
||||
FM_ENTRY_SYSTEM_TOOLS_ROOT = 8,
|
||||
};
|
||||
|
||||
enum FileManagerVirtualViewKind : uint8_t {
|
||||
FM_VIRTUAL_VIEW_NONE = 0,
|
||||
FM_VIRTUAL_VIEW_APPS,
|
||||
FM_VIRTUAL_VIEW_SYSTEM_TOOLS,
|
||||
};
|
||||
|
||||
struct FileManagerLocation {
|
||||
char path[256];
|
||||
FileManagerVirtualViewKind virtual_view;
|
||||
};
|
||||
|
||||
struct FileManagerVirtualEntry {
|
||||
int external_app_index;
|
||||
DesktopBuiltinId builtin_id;
|
||||
SvgIcon icon_lg;
|
||||
SvgIcon icon_sm;
|
||||
};
|
||||
|
||||
struct FileManagerState {
|
||||
char current_path[256];
|
||||
char history[16][256];
|
||||
FileManagerLocation history[16];
|
||||
int history_pos;
|
||||
int history_count;
|
||||
char entry_names[64][128];
|
||||
int entry_types[64]; // 0=file, 1=dir, 2=exec, 3=drive, 4=home, 5=apps, 6=app, 7=special_dir
|
||||
int entry_types[64];
|
||||
int entry_sizes[64];
|
||||
int entry_count;
|
||||
int selected;
|
||||
@@ -29,8 +59,7 @@ struct FileManagerState {
|
||||
Scrollbar scrollbar;
|
||||
DesktopState* desktop;
|
||||
bool grid_view;
|
||||
bool at_drives_root;
|
||||
int drive_indices[FM_MAX_DRIVES]; // which drive number each entry maps to
|
||||
int drive_indices[64]; // drive number or special-folder index for Computer view entries
|
||||
|
||||
// Clipboard
|
||||
char clipboard_path[256];
|
||||
@@ -58,12 +87,10 @@ struct FileManagerState {
|
||||
int pathbar_cursor;
|
||||
int pathbar_len;
|
||||
|
||||
// Apps view
|
||||
bool at_apps_view;
|
||||
int app_map[64]; // entry index -> external_apps[] index
|
||||
SvgIcon app_icons_lg[64]; // 48x48 icons for grid view
|
||||
SvgIcon app_icons_sm[64]; // 16x16 icons for list view
|
||||
int app_icon_count;
|
||||
// Virtual views
|
||||
FileManagerVirtualViewKind virtual_view;
|
||||
FileManagerVirtualEntry virtual_entries[64];
|
||||
int virtual_entry_count;
|
||||
};
|
||||
|
||||
inline constexpr int FM_TOOLBAR_H = 32;
|
||||
@@ -100,6 +127,22 @@ inline constexpr int CTX_NEW_FOLDER = 6;
|
||||
inline constexpr int CTX_MENU_W = 140;
|
||||
inline constexpr int CTX_ITEM_H = 24;
|
||||
|
||||
inline bool filemanager_is_virtual_view(const FileManagerState* fm) {
|
||||
return fm && fm->virtual_view != FM_VIRTUAL_VIEW_NONE;
|
||||
}
|
||||
|
||||
inline bool filemanager_is_computer_view(const FileManagerState* fm) {
|
||||
return fm && !filemanager_is_virtual_view(fm) && fm->current_path[0] == '\0';
|
||||
}
|
||||
|
||||
inline const char* filemanager_virtual_view_label(FileManagerVirtualViewKind view) {
|
||||
switch (view) {
|
||||
case FM_VIRTUAL_VIEW_APPS: return "Apps";
|
||||
case FM_VIRTUAL_VIEW_SYSTEM_TOOLS: return "System Configuration";
|
||||
default: return "Computer";
|
||||
}
|
||||
}
|
||||
|
||||
int special_folder_index(const char* name);
|
||||
const char* ctx_label(int action);
|
||||
|
||||
@@ -119,7 +162,9 @@ const char* path_basename(const char* path);
|
||||
void filemanager_read_drives(FileManagerState* fm);
|
||||
void filemanager_read_dir(FileManagerState* fm);
|
||||
void filemanager_free_app_icons(FileManagerState* fm);
|
||||
void filemanager_read_virtual_view(FileManagerState* fm, FileManagerVirtualViewKind view);
|
||||
void filemanager_read_apps(FileManagerState* fm);
|
||||
void filemanager_read_system_tools(FileManagerState* fm);
|
||||
|
||||
bool filemanager_delete_recursive(const char* path);
|
||||
bool filemanager_copy_file(const char* src, const char* dst);
|
||||
|
||||
Reference in New Issue
Block a user