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
Reset document font and page settings #8412
Conversation
|
@@ -253,6 +253,18 @@ function FileManager:setupLayout() | |||
text = _("Reset settings"), | |||
enabled = is_file and DocSettings:hasSidecarFile(BaseUtil.realpath(file)), | |||
callback = function() | |||
local other_buttons | |||
if DocumentRegistry:getProvider(file).provider == "crengine" 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.
Why limit this to crengine documents ? Some cre docs may be opened with MuPDF, and vice-versa.
-- Purge reflowable doc font and page settings | ||
function filemanagerutil.purgeViewSettings(file) | ||
local view_settings = { | ||
"font_face", |
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.
Again, why only reflowable docs ?
-- crop tab | ||
"copt_h_page_margins", | ||
"copt_t_page_margin", | ||
"copt_b_page_margin", | ||
-- pageview tab | ||
"copt_line_spacing", | ||
"line_space_percent", | ||
-- textsize tab |
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.
What is kept then ?
And why not remove visible_pages, page_overlap_style, toc_ticks_ignored_levels, book style tweak ?
I'm not saying these should be deleted, it just feels a bit arbitrary to remove your choice of settings, or mine - and being not really sure of what got reset.
Before looking at your code, from the screenshots and in spite of the wording, I thought this option would remove everything except bookmarks/highlights (ie. a safer Reset settings :)
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.
Have you read the Issue related?
It's a real use case I understand well.
Only settings from the bottom menu are reset (plus the font face).
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've just read it, and I understand it.
But this use case is just a use case of changing fonts and wanting to reset some font related settings so the new defaults associated to your new preferred default fonts are used instead.
But Word spacing and page margins are not related to changing fonts - so you might do a bit more than some use case would wish.
Or a bit less than some other use case would wish (ie. I messed with style tweaks, Toc ticks, page overlap).
But may be your choice of settings is the most consistent and the one most wished for, so why not. But it's a bit low at the area of use cases it can solve, as it's limited to a single set of settings.
And it still feels a bit convoluted to have to close the book, open another book, go to History, long-press on that book to Reset page and font settings
, and re-open it.
Ideally, you would have another menu invoked on the current opened book. a set of "sets" of settings as radio buttons, that you would check for what you want remove: it would close the book, clean up settings, and re-open the book.
Not really convinced this is best. Yes, |
Can we have Reset at left or at right side, but the same in both popup menus? |
I guess I'd prefer this - if you manage to re-order the other ones in a consistent way. |
I'm so sad with disabled CircleCI tests for my commits. |
@@ -38,12 +38,13 @@ local order = { | |||
"bookmarks_settings", | |||
}, | |||
typeset = { | |||
"reset_view_settings", |
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.
Can be renamed reset_document_settings
as it is no longer just "view" settings.
function filemanagerutil.purgeSettings(file) | ||
local file_abs_path = util.realpath(file) | ||
if file_abs_path then | ||
DocSettings:open(file_abs_path):purge() | ||
end | ||
end | ||
|
||
-- Purge doc settings except kept | ||
function filemanagerutil.purgeViewSettings(file) |
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.
Not sure it is now appropriate to have this defined in filenamanagerutil - as we don't invoke it at all from FileManager - and it is quite not different than the above function.
But I can't think of an obvious better place for this (docsettings.lua is a generic and currently doesn't know about any real setting).
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 this function name can now be filemanagerutil.resetDocumentSettings(file)
if file_abs_path then | ||
local doc_settings = DocSettings:open(file_abs_path) | ||
for k in pairs(doc_settings.data) do | ||
if not require("util").arrayContains(settings_kept, k) 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.
This is a bit ugly/expensive (doesn't matter much in this context, so, just ugly :)
I would build a hash table from the array, and just use the hash table:
local settings_to_keep = {}
for _, k in ipairs(settings_kept ) do settings_to_keep[k] = true end
and here just:
if not settings_to_keep[k] then
or just define this little bit uglier:
local settings_kept = {
"bookmarks" = true
"bookmarks_sorted" = true
"bookmarks_version" = 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.
Thanks
function filemanagerutil.purgeSettings(file) | ||
local file_abs_path = util.realpath(file) | ||
if file_abs_path then | ||
DocSettings:open(file_abs_path):purge() | ||
end | ||
end | ||
|
||
-- Purge doc settings except kept | ||
function filemanagerutil.purgeViewSettings(file) |
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 this function name can now be filemanagerutil.resetDocumentSettings(file)
bookmarks = true, | ||
bookmarks_sorted = true, | ||
bookmarks_version = true, | ||
cre_dom_version = true, | ||
highlight = true, | ||
highlights_imported = true, | ||
last_page = true, | ||
last_xpointer = 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.
Have you had another look at some of your setting files ? Or did you just trust my quick look ? :)
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's my list.
function filemanagerutil.purgeSettings(file) | ||
local file_abs_path = util.realpath(file) | ||
if file_abs_path then | ||
DocSettings:open(file_abs_path):purge() | ||
end | ||
end | ||
|
||
-- Purge doc settings except kept | ||
function filemanagerutil.purgeViewSettings(file) | ||
local settings_kept = { |
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.
(settings_to_keep
sounds better)
keep_menu_open = true, | ||
callback = function() | ||
UIManager:show(ConfirmBox:new{ | ||
text = _("Reset current document settings to default values?\n\nReading position, highlights and bookmarks will be kept.\nThe document will be reopened."), |
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.
to their default values
? to defaults
? to your default values
@Frenzie ?
We have (The book will be reloaded.)
in readertoc.lua - sounds a bit better than reopened
to my french ears.
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.
to their default values
sounds good to me.
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 book will be reloaded.
That was initially, but after this ConfirmBox we immediately have an infomessage "Opening file...", so I've changed to "reopened".
Ready |
Minor issue noticed at #8770 - not sure we really need to find a solution. Because of this bit of logic (depending on last_xpointer, which is preserved by "Reset doc settings"): koreader/frontend/apps/reader/modules/readertypeset.lua Lines 63 to 79 in cb7e670
|
What's going on with saved highlights when changing rendering mode? |
Some old hell... detailed in #3940 and buggins/coolreader#125 (comment). For old read books with highlights not opened since 2018, if the user is to re-open them now, we need to render them at least one last time with some old code (cre_dom_version and block_rendering_mode = legacy) to be able to get xpointers the same as before 2018. Only that way we are able to migrate xpointers and allow using new dom_version and changing block rendering. |
I think this must be fixed. |
That's a bit radical and not user friendly :) We may be can do better if, on reset settings, you add (I don't like the word "reset" which is identical whether it's something done or something to do... if I saw "reseted", I would understand it is something done, but that's not correct English :) |
Allows to reset document view (font and page) settings to default.
Available for reflowable documents via the
Reset settings
button.Closes #7708.
Additionally: swaps two buttons in the History popup menu for consistency with the file browser popup menu.
This change is