feat: add BookManageMenuActivity popup sub-activity

Contextual popup menu for book management with Archive/Unarchive,
Delete, Delete Cache Only, and Reindex options. Supports long-press
on Reindex to trigger full reindex including cover/thumbnail regen.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cottongin
2026-02-21 02:54:14 -05:00
parent 29954a3683
commit c44ac0272a
2 changed files with 174 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
#pragma once
#include <I18n.h>
#include <functional>
#include <string>
#include <vector>
#include "../Activity.h"
#include "util/ButtonNavigator.h"
class BookManageMenuActivity final : public Activity {
public:
enum class Action {
ARCHIVE,
UNARCHIVE,
DELETE,
DELETE_CACHE,
REINDEX,
REINDEX_FULL,
};
explicit BookManageMenuActivity(GfxRenderer& renderer, MappedInputManager& mappedInput,
const std::string& bookPath, bool isArchived,
const std::function<void(Action)>& onAction,
const std::function<void()>& onCancel)
: Activity("BookManageMenu", renderer, mappedInput),
bookPath(bookPath),
archived(isArchived),
onAction(onAction),
onCancel(onCancel) {
buildMenuItems();
}
void onEnter() override;
void onExit() override;
void loop() override;
void render(Activity::RenderLock&&) override;
private:
struct MenuItem {
Action action;
StrId labelId;
};
std::string bookPath;
bool archived;
std::vector<MenuItem> menuItems;
int selectedIndex = 0;
ButtonNavigator buttonNavigator;
bool ignoreNextConfirmRelease = false;
static constexpr unsigned long LONG_PRESS_MS = 700;
const std::function<void(Action)> onAction;
const std::function<void()> onCancel;
void buildMenuItems();
};