Review comments
This commit is contained in:
@@ -323,5 +323,5 @@ void FileBrowserActivity::render(RenderLock&&) {
|
||||
size_t FileBrowserActivity::findEntry(const std::string& name) const {
|
||||
for (size_t i = 0; i < files.size(); i++)
|
||||
if (files[i] == name) return i;
|
||||
return 0;
|
||||
return files.size();
|
||||
}
|
||||
@@ -27,6 +27,26 @@ void GlobalBookmarksActivity::onEnter() {
|
||||
const int first = firstSelectableIndex();
|
||||
selectorIndex = first >= 0 ? first : 0;
|
||||
|
||||
if (restoreHint.target == ReturnTo::GlobalBookmarks) {
|
||||
const auto& entries = GLOBAL_BOOKMARKS.getEntries();
|
||||
if (!restoreHint.selectionContext.empty() && restoreHint.selectBookmarkIndex >= 0) {
|
||||
for (size_t i = 0; i < rows.size(); ++i) {
|
||||
const auto& row = rows[i];
|
||||
if (row.isSeparator) continue;
|
||||
if (row.bookmarkIndex == static_cast<size_t>(restoreHint.selectBookmarkIndex) &&
|
||||
row.bookIndex < entries.size() && entries[row.bookIndex].sourcePath == restoreHint.selectionContext) {
|
||||
selectorIndex = static_cast<int>(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (selectorIndex < 0 || selectorIndex >= static_cast<int>(rows.size()) || isSeparatorRow(selectorIndex)) {
|
||||
const int fallback = firstSelectableIndex();
|
||||
selectorIndex = fallback >= 0 ? fallback : 0;
|
||||
}
|
||||
restoreHint = {};
|
||||
}
|
||||
|
||||
const auto total = static_cast<int>(rows.size());
|
||||
buttonNavigator.setSelectablePredicate([this](int index) { return !isSeparatorRow(index); }, total);
|
||||
|
||||
@@ -126,8 +146,9 @@ void GlobalBookmarksActivity::openSelected() {
|
||||
|
||||
LOG_DBG("GBA", "Jumping to bookmark in %s at %u/%u", entry.sourcePath.c_str(), bm.spineIndex, bm.pageNumber);
|
||||
ReturnHint hint;
|
||||
hint.target = ReturnTo::Home;
|
||||
hint.selectName = entry.sourcePath;
|
||||
hint.target = ReturnTo::GlobalBookmarks;
|
||||
hint.selectionContext = entry.sourcePath;
|
||||
hint.selectBookmarkIndex = static_cast<int>(row.bookmarkIndex);
|
||||
activityManager.replaceWithReader(entry.sourcePath, std::move(hint));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ struct Rect;
|
||||
// header separator or a bookmark entry belonging to the preceding header.
|
||||
class GlobalBookmarksActivity final : public Activity {
|
||||
public:
|
||||
explicit GlobalBookmarksActivity(GfxRenderer& renderer, MappedInputManager& mappedInput)
|
||||
: Activity("GlobalBookmarks", renderer, mappedInput) {}
|
||||
explicit GlobalBookmarksActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, ReturnHint restoreHint = {})
|
||||
: Activity("GlobalBookmarks", renderer, mappedInput), restoreHint(std::move(restoreHint)) {}
|
||||
|
||||
void onEnter() override;
|
||||
void onExit() override;
|
||||
@@ -38,6 +38,7 @@ class GlobalBookmarksActivity final : public Activity {
|
||||
ButtonNavigator buttonNavigator;
|
||||
std::vector<Row> rows;
|
||||
int selectorIndex = 0;
|
||||
ReturnHint restoreHint;
|
||||
|
||||
void rebuildRows();
|
||||
std::string getRowTitle(int index) const;
|
||||
|
||||
Reference in New Issue
Block a user