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:
59
src/activities/home/BookManageMenuActivity.h
Normal file
59
src/activities/home/BookManageMenuActivity.h
Normal 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();
|
||||
};
|
||||
Reference in New Issue
Block a user