Refactor spaghetti code

This commit is contained in:
jpirnay
2026-04-17 15:39:02 +02:00
parent 3b8b389408
commit 2b17872c16
2 changed files with 85 additions and 97 deletions
+24 -9
View File
@@ -5,12 +5,31 @@
#include "../Activity.h"
#include "./FileBrowserActivity.h"
#include "components/UITheme.h"
#include "util/ButtonNavigator.h"
struct RecentBook;
struct Rect;
class HomeActivity final : public Activity {
public:
enum class MenuAction {
FileBrowser,
Recents,
GlobalBookmarks,
OpdsBrowser,
FileTransfer,
Weather,
Settings,
};
private:
struct MenuEntry {
MenuAction action;
StrId label;
UIIcon icon;
};
ButtonNavigator buttonNavigator;
int selectorIndex = 0;
bool recentsLoading = false;
@@ -22,16 +41,12 @@ class HomeActivity final : public Activity {
size_t nextRecentCoverIndex = 0;
uint8_t* coverBuffer = nullptr; // HomeActivity's own buffer for cover image
std::vector<RecentBook> recentBooks;
void onSelectBook(const std::string& path);
void onFileBrowserOpen();
void onRecentsOpen();
void onGlobalBookmarksOpen();
void onSettingsOpen();
void onFileTransferOpen();
void onOpdsBrowserOpen();
void onWeatherOpen();
std::vector<MenuEntry> menuEntries;
int getMenuItemCount() const;
void onSelectBook(const std::string& path);
void dispatchMenuAction(MenuAction action);
void rebuildMenuEntries();
bool storeCoverBuffer(); // Store frame buffer for cover image
bool restoreCoverBuffer(); // Restore frame buffer from stored cover
void freeCoverBuffer(); // Free the stored cover buffer