-
-
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
Tapplus shortcut #3773
Tapplus shortcut #3773
Conversation
Pssht ;-) koreader/frontend/device/sdl/device.lua Lines 20 to 22 in c40e2bc
|
end, | ||
} | ||
else | ||
self.menu_items.plus_menu = {} |
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.
Does the top menu not accept it if you just leave it out?
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 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.
Apparently I didn't consider the scenario that a top-level menu item might not be there. :-)
It should suffice to put a simple if menu_table["KOMenu:menu_buttons"][i].sub_item_table
(or something like that)
koreader/frontend/ui/menusorter.lua
Lines 134 to 136 in 24c0132
for i,top_menu in ipairs(menu_table["KOMenu:menu_buttons"]) do | |
menu_table["KOMenu:menu_buttons"][i] = menu_table["KOMenu:menu_buttons"][i].sub_item_table | |
end |
And of course a unit test, but I'll worry about that — unless you want to. ;-)
Would you mind checking if you can quickly fix the problem as suggested so that we can remove this else branch?
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.
Ok, I'm hitting a bit of a road block on this one. I really can't figure out how it all works.
If I add a simple check like you suggested, it works but the next menu are empty.
I'm trying to dig into the code but I'm progressing very slowly. Maybe we can close this one and I will keep working on it on another PR ?
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.
Codecov Report
@@ Coverage Diff @@
## master #3773 +/- ##
==========================================
- Coverage 52.07% 52.04% -0.03%
==========================================
Files 207 207
Lines 27879 27910 +31
==========================================
+ Hits 14517 14525 +8
- Misses 13362 13385 +23
Continue to review full report at Codecov.
|
@@ -93,7 +94,7 @@ function CoverMenu:updateItems(select_number) | |||
-- reset focus manager accordingly | |||
self.selected = { x = 1, y = select_number } | |||
-- set focus to requested menu item | |||
self.item_group[select_number]:onFocus() | |||
self:getFocusItem():handleEvent(Event:new("Focus")) |
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.
@poire-z Oh sorry, ignore #3745 (comment) It's fixed here already.
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.
oh, good :)
Ok, I'm not touching menusorter ever again :-) Not quite as simple as #3773 (comment) suggested. |
@onde2rock I don't think there's a need for an extra loop. -- cleanup, top-level items shouldn't have sub_item_table
-- they should, however have one going in
local menu_buttons_offset = 0
for i,top_menu in ipairs(menu_table["KOMenu:menu_buttons"]) do
if menu_table["KOMenu:menu_buttons"][i].sub_item_table then
menu_table["KOMenu:menu_buttons"][i-menu_buttons_offset] = menu_table["KOMenu:menu_buttons"][i].sub_item_table
else
menu_table["KOMenu:menu_buttons"][i] = nil
menu_buttons_offset = menu_buttons_offset + 1
end
end |
Yes that's better. The returned table stay dirty this way, but the touchmenu still work. An example with a lot of top-level that sould be removed :
|
Ok, unless further comment, I consider this PR done. |
Alright, thanks! Someone will need to extend the unit tests for MenuSorter. |
There is a side effect with this: #3792 does not work when tapping on the right. koreader/frontend/ui/widget/touchmenu.lua Lines 336 to 341 in 38a0519
I take that as an advice, and let the menusorter guru have a look at it :) |
Aside from the issue in question, if index is a high value wouldn't you expect it to be index = #self.icon_widgets? |
Indeed, I'll change that in a coming PR. |
Hum that really look like the issue I described earlier : #3773 (comment). Without adding a loop, there is no way to get a clean layout variable. |
An other minor thing: it outputs in touch devices' crash.log: |
If I remember right, this is "normal", I probably shoud do something about it. |
I can't reproduce this issue on SDL, tapping right in the filemanager on a non-key device correctly open the last menu. Oh but I remember a bug I saw once while developing, if you migrate to the new version and your last position is the 4th tab, it try to directly open that tab, which now is tab_plus, and crash. A crash log would be nice. |
Oh, yes, the tap on the top right was workaround'ed yesterday by https://github.com/koreader/koreader/pull/3836/files#diff-200e39a7a76e64783d1d2c16a6d7c01e (if we get a higher index, use the latest one instead of 1). But the following still remains (although it has now no visible side effect - dunno if it can still be considered a bug - or if it's ok for menusorter to put stuff in invisible slots):
About:
Yes, it's probably normal, it should just not output it as WARN on a regular (non debug) device. |
It is a bug, just a very minor one. I'd have blocked the plus menu PR otherwise. It negatively affects the clarity of analyzing MenuSorter.
But it should. It's only logger.dbg that's debugging info. It's a warning because it's the menu saying something's messed up as opposed to showing the resulting output of the sorting or something like that. |
Add an element in the filemanager touchmenu to open the tapPlus menu on non touch device only.