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>
60 lines
1.4 KiB
C++
60 lines
1.4 KiB
C++
#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();
|
|
};
|