-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pages remaining option to status bar #7047
Conversation
time = 2, | ||
pages_left = 3, | ||
battery = 4, | ||
percentage = 5, | ||
book_time_to_read = 6, | ||
chapter_time_to_read = 7, | ||
frontlight = 8, | ||
mem_usage = 9, | ||
wifi_status = 10, | ||
book_title = 11, | ||
book_chapter = 12, | ||
bookmark_count = 13, | ||
page_remaining = 2, | ||
time = 3, | ||
pages_left = 4, | ||
battery = 5, | ||
percentage = 6, | ||
book_time_to_read = 7, | ||
chapter_time_to_read = 8, | ||
frontlight = 9, | ||
mem_usage = 10, | ||
wifi_status = 11, | ||
book_title = 12, | ||
book_chapter = 13, | ||
bookmark_count = 14, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will changing the mode values have an effect on existing users?
Does it make sense to add page_remaining
at the end as number 14?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly don't know - I thought they were like const values and changing them would just work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be sure of that :)
I think the items we added the most recently were added last.
But looking at the code, it feels it would be fine with stuff added at any place in the list (it's possible we made it better because it was a mess previously and these kind of stuff were risky :)
Please just test that it's fine with a user previous custom ordering. (Can't test myself atm.)
There's also another ordered list as a comment at top of ReaderFooter:applyFooterMode(mode). Dunno if it should be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much!
I have tried turning on/off all the status bar options and moving them about and haven't seen any issues. Is that sufficient, or should I try something else?
The comment you mentioned reads
-- three modes switcher for reader footer
-- 0 for footer off
-- 1 for footer page info
-- 2 for footer time info
-- 3 for footer next_chapter info
-- 4 for battery status
-- 5 for progress percentage
-- 6 for from statistics book time to read
-- 7 for from statistics chapter time to read
-- 8 for front light level
-- 9 for memory usage
-- 10 for Wi-Fi status
-- 11 for book title
-- 12 for current chapter
-- 13 for bookmark count
and the "local mode" reads
off = 0,
page_progress = 1,
page_remaining = 2,
time = 3,
pages_left = 4,
battery = 5,
percentage = 6,
book_time_to_read = 7,
chapter_time_to_read = 8,
frontlight = 9,
mem_usage = 10,
wifi_status = 11,
book_title = 12,
book_chapter = 13,
bookmark_count = 14,
Should they line up? I'm not sure how to handle the "footer page info" and "footer time info" entries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment you mentioned reads
-- three modes switcher for reader footer
-- 0 for footer off
-- 1 for footer page info
Yep, and I don't even understand what this comment is trying to say :) It has been completed over the years with the added items - so, I guess they should line up for consistency.
But I'd also be happy if you just deleted the whole comment - so there's no second set to keep updated for nothing.
should I try something else?
I just checked:
- no ordering done before applying this PR - then PR applied - all ok.
- previous user ordering done before applying this PR - then PR applied - ordering kept, the new item is put at the end of the user order
So, I guess it's ok.
Is it the same symbol as for Pages left in chapter? |
It's the -331 / 373 (there are 331 pages left in the book). The minus sign is meant to show that it's pages remaining. |
Oh, I see, thanks. |
Thanks. I'd appreciate any thoughts on making it clearer. I thought it would be something to put up instead of "Current page" since having both up seems redundant. |
A trivial implementation of adding pages remaining to the status bar
Sync up with master
I hope you don't mind a git question. When I look at the repository I forked to create this PR: https://github.com/JasonInOttawa/koreader I see that it is 14 commits behind master. The branch created for this PR is add-pages-remaining. How should I rebase (?) to get my repository synced up with master? I did try
The result of git push is "Everything up-to-date" But I still see the commits-behind message. |
Your upstream points to here, e.g.?
What I'd do though: git checkout add-pages-remaining
# possibly git checkout -b copy-to-mess-up
# rebase commits in branch on top of whatever I'm pulling
git pull -r upstream master |
Thanks very much. I pretty sure I'm missing something quite basic :) This is what I see. I seem to be in sync with master, but my repository is still out of date.
|
It's not though? You have to look at that branch, not your master branch. ;-) https://github.com/JasonInOttawa/koreader/tree/add-pages-remaining |
Thank you! In future, I should check https://github.com/JasonInOttawa/koreader/tree/add-pages-remaining to see whether I'm behind in commits, and if so do this for a fresh build. (Right now I'm getting the "Current branch add-pages-remaining is up to date" because my add-pages-remaining branch is in fact up to date.)
|
Wild guess, because I seem to recall you're on macOS: the stock |
I tend to do it the other way around, e.g., in my topic branch (which is already tied to a remote branch, because I have a
(Or not interactive if it's a trivial rebase). [1]
|
Thanks very much for your help with git. I do have a Macbook (for work) and Linux running on an old Elitebook G1 (for messing around with). I'm mostly playing with git on Linux during the holidays. |
Please just remove your 2nd commit - your first commit is enough, no rebase/sync needed (readerfooter has not been updated by anybody since you started working on it). |
@@ -352,6 +378,7 @@ function ReaderFooter:init() | |||
bookmark_count = true, | |||
time = true, | |||
page_progress = true, | |||
page_remaining = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We most probably want page_remaining = false
- as having both page_progress and page_remaining enabled by default will confused people when they set "all at once".
(Also, it's the counterpart of page_progress
so it's fine it's named page_remaining
- but I would spell it more naturally as pages_remaining
- plural. Dunno which is best.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A quick Google shows many ways to delete a commit - could you kindly suggest the "best" method to use here?
I named it page_remaining
to match page_progress
- should I change one or both of them?
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you can't change page_progress
as it's already used and saved in current users' settings.
I let @Frenzie tell us that page_remaining
is just fine :)
could you kindly suggest the "best" method to use here?
Assuming you still have only these 2 commits:
git checkout add-pages-remaining
git reset --hard HEAD~1 # this resets 1 commit back, so removing your 2nd commit
git status # check all looks fine
git log # check all looks fine
git push -f origin add-pages-remaining
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I named it page_remaining to match page_progress - should I change one or both of them?
@poire-z's point is that you say "page progress" and "pages remaining" (or "remaining pages") in natural language. ;-) I'd also prefer that s.
Much more important for variable naming though, is that we already have a pages_left
which sounds completely synonymous. We should pick either left or remaining and add _chapter
or _in_chapter
to the one, _book
or _in_book
to the other, or both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should pick either left or remaining and add
But that's a bit tough for this PR, and a possible need for migration of previous settings names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but I was also talking about the menu text.
Also I think that implies that in principle the new setting should be called pages_left_book
unless there's a sufficiently strong reason not to.
This reverts commit 66b9c4e.
Change page_remaining to pages_left_book Set default page_remaining to false Remove out-of-date comment in ReaderFooter:applyFooterMode(mode)
@@ -792,7 +792,7 @@ function ReaderFooter:textOptionTitles(option) | |||
reclaim_height = _("Reclaim bar height from bottom margin"), | |||
bookmark_count = T(_("Bookmark count (%1)"), symbol_prefix[symbol].bookmark_count), | |||
page_progress = T(_("Current page (%1)"), "/"), | |||
page_remaining = T(_("Pages remaining (%1)"), "-"), | |||
pages_left_book = T(_("Pages remaining (%1)"), "-"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be Pages left in book
then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no maybe. The distinction between pages left and pages remaining cannot be chapter vs book. ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or rather, there's no distinction at all. Those are synonyms.
pages_left_book = function(footer) | ||
if footer.pageno then | ||
if footer.ui.pagemap and footer.ui.pagemap:wantsPageLabels() then | ||
-- (Page labels might not be numbers) | ||
return ("%s / %s"):format(footer.ui.pagemap:getCurrentPageLabel(true), | ||
footer.ui.pagemap:getLastPageLabel(true)) | ||
end | ||
if footer.ui.document:hasHiddenFlows() then | ||
-- i.e., if we are hiding non-linear fragments and there's anything to hide, | ||
local flow = footer.ui.document:getPageFlow(footer.pageno) | ||
local page = footer.ui.document:getPageNumberInFlow(footer.pageno) | ||
local pages = footer.ui.document:getTotalPagesInFlow(flow) | ||
if flow == 0 then | ||
return ("%d // %d"):format(page, pages) | ||
else | ||
return ("[%d / %d]%d"):format(page, pages, flow) | ||
end | ||
else | ||
local remaining = footer.pages - footer.pageno | ||
return ("-%d / %d"):format(remaining, footer.pages) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a quick copy and paste, where you just updated with -%d
the most used branch. But the others (pagemap, hiddent flow, footer.position) might need to be updated too for this option to be consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, yes. I can try revising the other branches but I don't know how to test them :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, for footer.position, not sure when/if it is used, but it should logically be:
return ("%d / %d"):format(footer.doc_height - footer.position, footer.doc_height)
For pagemap, well, these are strings, so you can't do any arithmetic with them. I guess you can let them as-is then.
For hidden flows, you need an EPUB with non-linear stuff. Dunno where to find one. But it should be similar to what you did:
local page = footer.ui.document:getPageNumberInFlow(footer.pageno)
local pages = footer.ui.document:getTotalPagesInFlow(flow)
+ local remaining = pages - page
+ -- and use it in the return -%d
Change menu text to "Pages left in book" Add proper handling of other situations in pages_left_book function
Tested with pagemap & non-linear flows: looks good to me. |
Great stuff. Did you test it by copying the changed readerfooter.lua file into an existing installation? |
I usually just do (when testing on the emulator, but also if I need to test it on my Kobo):
and when done testing (on the emulator):
|
That's quite cool, thank you |
A trivial implementation of adding pages remaining to the status bar, for those times when you want to know how many pages remain and aren't up to doing the subtraction.
This is added to the Status bar settings:
This is how things look in the status bar
This change is