[ReaderFooter] add status bar presets - #13689
Conversation
|
Woah, that's cool! Here is an idea: how about cycling through presets when you tap on status bar? Say, I have two presets: all book related (pages, titles, reading speed, etc), all system related (memory, battery, etc). So I can cycle through preset 1, tap - preset 2, another tap - status off. |
|
Depending on how radical the different presets are, a simple switch can trigger a re-render. Now i know you personally would keep that in mind and only apply “item” changes (which wouldn’t be problematic) but you are not most people… I also think there is a possibility of adding this to profiles/gestures/hotkeys but baby steps first. edit:
thanks! |
…ating it to avoid unexpected merges
| end, | ||
| callback = function() | ||
| self.settings.progress_style_thin = nil | ||
| self.settings.progress_style_thin = false |
There was a problem hiding this comment.
this little change here is giving me a bit of a headache. It needs to be false so that there is an actual entry into self.setting (nil removes it altogether) which in turn makes switching between modes (thick and thin) not possible. The problem resides in that anyone whose value at time of update is nil would have issues should they create a preset with our first making it false, so, should I make a migration from nil to false? or is there perhaps another approach that could be taken here?
| end | ||
| -- Create a copy of current settings, excluding presets themselves. | ||
| local current_settings = {} | ||
| for k, v in pairs(self.settings) do |
There was a problem hiding this comment.
There are some clone table util functions too fwiw.
|
We have standard UX/architecture approach for such things. Menu "Presets" with submenu items: "New with current settings" and the saved presets. Presets are not stored in the memory, they are not a part of Preset are saved to settings.reader.lua as a separate entry |
do we have any other examples of this besides the profile plugin? I actually find, for this particular case at least, the system of one sub_menu to save and another to load a bit easier to grasp, the slots came from reminiscing about the good old PS1 Memory Card days, and also the fact that it requires a lot less intrusion into reader footer. I wonder if @Frenzie or @poire-z have anything to say... others as well of course. We don't discriminate around here, we only gang up on hardback readers ;) |
Text efitor, Book shortcuts, Patch management. |
Few things are worse than being limited to a handful of save slots. ;-) I doubt it matters in this context but it does seem like an unnecessary restriction and deviation from the norm. |
Fine, have it your way. But you are all wrong ;) there’s nothing more delightful than a good old memory slot. |
|
You missed I think that after a preset has been loaded, any changes to the footer configuration will not be saved, because of the broken |
I'm not sure I understand what your concern is, could you clarify it a bit? |
|
footer.settings are linked to G_reader_settings: breaks the link and the settings are not saved anymore. |
…d NOT track current status bar settings
function ReaderFooter:loadFromNamedPreset(preset_name)
local preset = G_reader_settings:readSetting("footer_presets")[preset_name]
G_reader_settings:saveSetting("footer", util.tableDeepCopy(preset.footer))
G_reader_settings:saveSetting("reader_footer_mode", preset.reader_footer_mode)
G_reader_settings:saveSetting("reader_footer_custom_text", preset.reader_footer_custom_text)
G_reader_settings:saveSetting("reader_footer_custom_text_repetitions", preset.reader_footer_custom_text_repetitions)
self.settings = G_reader_settings:readSetting("footer")
self.mode = preset.reader_footer_mode
self.custom_text = preset.reader_footer_custom_text
self.custom_text_repetitions = tonumber(preset.reader_footer_custom_text_repetitions)
self:updateFooterTextGenerator()
self:refreshFooter(true, true)
end |
|
I think the checkboxes are not useful. |
| local footer_presets = G_reader_settings:readSetting("footer_presets", {}) | ||
| local items = { | ||
| { | ||
| text = _("Create new preset from current settings"), |
There was a problem hiding this comment.
Just to double check, is this congruent with similar usage elsewhere? There's new profile from current document settings or some such for example.
There was a problem hiding this comment.
koreader/plugins/profiles.koplugin/main.lua
Lines 108 to 122 in 8b1605b
|
what's up with that circleCI failure? |
|
It means it's trying to fetch a commit that doesn't exist. Maybe a GH issue? (I.e., it's presumably distributed around the world, and maybe the node CircleCI tried to pull from didn't have it yet.) |
we tend to disagree sometimes... as people start using it, I have no doubt some will add different options and will want to know what is actually active without having to "remember" anything. Furthermore, that is just a nice visual hint that perhaps you should "update" your preset. |
| function ReaderFooter:loadFromNamedPreset(preset_name) | ||
| local footer_presets = G_reader_settings:readSetting("footer_presets") | ||
| local preset = footer_presets[preset_name] | ||
| if preset and next(preset) then -- only load if preset exists and is not empty |
There was a problem hiding this comment.
No need to check, the menu is built of the existing presets.
There was a problem hiding this comment.
are you saying that you are doing the gestures bit? can I get a straight answer please
There was a problem hiding this comment.
Yes, I'll merge this PR after you remove checkboxes, then will add Dispatcher actions in a separate PR.
There was a problem hiding this comment.
Yes
thank you.
will add Dispatcher actions in a separate PR
I wasn't expecting it to be otherwise.
|
The checked_func here is not cheap and gives doubtful benefits for its cost. |
is not really problematic for a few ones. I imagine it would be if you had hundreds of them. I suppose is up to @Frenzie to break to tie then, to |
|
What do you mean "for a few ones"? 55 entries. |
|
few presets, we are also leaving as soon as there is a discrepancy so not really comparing all of them [entries] for every preset. |
I mean, without if it's not really necessary of course. ;-) |
what's new
This PR seeks to enhance the status bar admin, recently I found myself in a situation where my usual status bar was simply inadequate for the content and was therefore forced to make some adjustments, but hey, I now need to remember what settings I had before and.. I ain't got time for that. So PRESETS yay!
Users will be able to save multiple presets and switch to them simply by selecting them, that's it.
This allows for things like: having a status bar specifically for PDFs and another for ePUB, or another for when on Landscape mode, etc.
changes
getNamedPresetMenuItemsto dynamically generate menu items for creating, loading, updating, and deleting named presets.createPresetFromCurrentSettings: Allows users to save the current settings as a new preset.saveToNamedPreset: Saves a preset with a specific name.loadFromNamedPreset: Loads and applies a named preset.progress_style_thinsetting to default tofalseinstead ofnilwhen toggled, ensuring its entry is maintained inself.settingsInfoMessage,InputDialog,MultiConfirmBox,ffiUtil, andutil.screenshots
related issues
This change is