Reduce debug logging
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <Utf8.h>
|
||||
#include <Xtc.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
@@ -211,15 +212,27 @@ void HomeActivity::onEnter() {
|
||||
recentsLoaded = true;
|
||||
}
|
||||
|
||||
// Apply focus: book path takes priority, else combined selector index (covers
|
||||
// "return to the menu entry I was on").
|
||||
bool focused = false;
|
||||
if (!focusBookPath.empty()) {
|
||||
for (size_t i = 0; i < recentBooks.size(); ++i) {
|
||||
if (recentBooks[i].path == focusBookPath) {
|
||||
selectorIndex = static_cast<int>(i);
|
||||
focused = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
focusBookPath.clear();
|
||||
}
|
||||
if (!focused && focusSelectorIndex >= 0) {
|
||||
rebuildMenuEntries(); // need menu count to clamp; rebuild is idempotent
|
||||
const int combinedSize = static_cast<int>(recentBooks.size() + menuEntries.size());
|
||||
if (combinedSize > 0) {
|
||||
selectorIndex = std::min(focusSelectorIndex, combinedSize - 1);
|
||||
}
|
||||
}
|
||||
focusSelectorIndex = -1;
|
||||
|
||||
// Trigger first update
|
||||
menuEntriesDirty = true;
|
||||
@@ -366,6 +379,13 @@ void HomeActivity::onSelectBook(const std::string& path) {
|
||||
}
|
||||
|
||||
void HomeActivity::dispatchMenuAction(MenuAction action) {
|
||||
// Record where the menu entry was focused so that when the launched activity exits
|
||||
// (via returnFromChild() or an empty-stack finish()), we come back to the same row.
|
||||
ReturnHint hint;
|
||||
hint.target = ReturnTo::Home;
|
||||
hint.selectIndex = selectorIndex;
|
||||
activityManager.setReturnHint(std::move(hint));
|
||||
|
||||
switch (action) {
|
||||
case MenuAction::FileBrowser:
|
||||
activityManager.goToFileBrowser();
|
||||
|
||||
@@ -44,7 +44,8 @@ class HomeActivity final : public Activity {
|
||||
std::vector<MenuEntry> menuEntries;
|
||||
bool menuEntriesDirty = true;
|
||||
|
||||
std::string focusBookPath; // book path to re-select on first render, if present in recents
|
||||
std::string focusBookPath; // book path to re-select on first render, if present in recents
|
||||
int focusSelectorIndex = -1; // fallback combined-selector index when focusBookPath doesn't match
|
||||
|
||||
void onSelectBook(const std::string& path);
|
||||
void dispatchMenuAction(MenuAction action);
|
||||
@@ -57,8 +58,11 @@ class HomeActivity final : public Activity {
|
||||
void loadRecentCovers(int coverHeight);
|
||||
|
||||
public:
|
||||
explicit HomeActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, std::string focusBookPath = {})
|
||||
: Activity("Home", renderer, mappedInput), focusBookPath(std::move(focusBookPath)) {}
|
||||
explicit HomeActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, std::string focusBookPath = {},
|
||||
int focusSelectorIndex = -1)
|
||||
: Activity("Home", renderer, mappedInput),
|
||||
focusBookPath(std::move(focusBookPath)),
|
||||
focusSelectorIndex(focusSelectorIndex) {}
|
||||
void onEnter() override;
|
||||
void onExit() override;
|
||||
void loop() override;
|
||||
|
||||
Reference in New Issue
Block a user