mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
"Page turns" menu development (#8022)
Make "Taps and gestures - Page turns" available only in reader. Move there other page turn related menu items from Navigation. Remove duplicated code. Added standard "star" for default RTL.
This commit is contained in:
@@ -180,6 +180,7 @@ function ReaderMenu:setUpdateItemTable()
|
||||
for id, common_setting in pairs(dofile("frontend/ui/elements/common_settings_menu_table.lua")) do
|
||||
self.menu_items[id] = common_setting
|
||||
end
|
||||
self.menu_items.page_turns = require("ui/elements/page_turns")
|
||||
-- insert DjVu render mode submenu just before the last entry (show advanced)
|
||||
-- this is a bit of a hack
|
||||
if self.ui.document.is_djvu then
|
||||
|
||||
@@ -4,7 +4,6 @@ local Event = require("ui/event")
|
||||
local Geom = require("ui/geometry")
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local Math = require("optmath")
|
||||
local MultiConfirmBox = require("ui/widget/multiconfirmbox")
|
||||
local Notification = require("ui/widget/notification")
|
||||
local ReaderZooming = require("apps/reader/modules/readerzooming")
|
||||
local TimeVal = require("ui/timeval")
|
||||
@@ -265,34 +264,6 @@ function ReaderPaging:addToMainMenu(menu_items)
|
||||
end,
|
||||
sub_item_table = page_overlap_menu,
|
||||
}
|
||||
menu_items.invert_page_turn_gestures = {
|
||||
text = _("Invert page turn taps and swipes"),
|
||||
checked_func = function() return self.inverse_reading_order end,
|
||||
callback = function()
|
||||
self.ui:handleEvent(Event:new("ToggleReadingOrder"))
|
||||
end,
|
||||
hold_callback = function(touchmenu_instance)
|
||||
local inverse_reading_order = G_reader_settings:isTrue("inverse_reading_order")
|
||||
UIManager:show(MultiConfirmBox:new{
|
||||
text = inverse_reading_order and _("The default (★) for newly opened books is right-to-left (RTL) page turning.\n\nWould you like to change it?")
|
||||
or _("The default (★) for newly opened books is left-to-right (LTR) page turning.\n\nWould you like to change it?"),
|
||||
choice1_text_func = function()
|
||||
return inverse_reading_order and _("LTR") or _("LTR (★)")
|
||||
end,
|
||||
choice1_callback = function()
|
||||
G_reader_settings:makeFalse("inverse_reading_order")
|
||||
if touchmenu_instance then touchmenu_instance:updateItems() end
|
||||
end,
|
||||
choice2_text_func = function()
|
||||
return inverse_reading_order and _("RTL (★)") or _("RTL")
|
||||
end,
|
||||
choice2_callback = function()
|
||||
G_reader_settings:makeTrue("inverse_reading_order")
|
||||
if touchmenu_instance then touchmenu_instance:updateItems() end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
function ReaderPaging:onColorRenderingUpdate()
|
||||
|
||||
@@ -4,7 +4,6 @@ local ConfirmBox = require("ui/widget/confirmbox")
|
||||
local Device = require("device")
|
||||
local Event = require("ui/event")
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local MultiConfirmBox = require("ui/widget/multiconfirmbox")
|
||||
local Notification = require("ui/widget/notification")
|
||||
local ProgressWidget = require("ui/widget/progresswidget")
|
||||
local ReaderPanning = require("apps/reader/modules/readerpanning")
|
||||
@@ -399,35 +398,6 @@ function ReaderRolling:getLastProgress()
|
||||
end
|
||||
|
||||
function ReaderRolling:addToMainMenu(menu_items)
|
||||
--- @fixme Repeated code with ReaderPaging read from left to right.
|
||||
menu_items.invert_page_turn_gestures = {
|
||||
text = _("Invert page turn taps and swipes"),
|
||||
checked_func = function() return self.inverse_reading_order end,
|
||||
callback = function()
|
||||
self.ui:handleEvent(Event:new("ToggleReadingOrder"))
|
||||
end,
|
||||
hold_callback = function(touchmenu_instance)
|
||||
local inverse_reading_order = G_reader_settings:isTrue("inverse_reading_order")
|
||||
UIManager:show(MultiConfirmBox:new{
|
||||
text = inverse_reading_order and _("The default (★) for newly opened books is right-to-left (RTL) page turning.\n\nWould you like to change it?")
|
||||
or _("The default (★) for newly opened books is left-to-right (LTR) page turning.\n\nWould you like to change it?"),
|
||||
choice1_text_func = function()
|
||||
return inverse_reading_order and _("LTR") or _("LTR (★)")
|
||||
end,
|
||||
choice1_callback = function()
|
||||
G_reader_settings:makeFalse("inverse_reading_order")
|
||||
if touchmenu_instance then touchmenu_instance:updateItems() end
|
||||
end,
|
||||
choice2_text_func = function()
|
||||
return inverse_reading_order and _("RTL (★)") or _("RTL")
|
||||
end,
|
||||
choice2_callback = function()
|
||||
G_reader_settings:makeTrue("inverse_reading_order")
|
||||
if touchmenu_instance then touchmenu_instance:updateItems() end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
--- @fixme repeated code with page overlap menu for readerpaging
|
||||
-- needs to keep only one copy of the logic as for the DRY principle.
|
||||
-- The difference between the two menus is only the enabled func.
|
||||
|
||||
@@ -236,7 +236,6 @@ common_settings.screen_dpi = require("ui/elements/screen_dpi_menu_table")
|
||||
common_settings.screen_eink_opt = require("ui/elements/screen_eink_opt_menu_table")
|
||||
common_settings.screen_notification = require("ui/elements/screen_notification_menu_table")
|
||||
common_settings.menu_activate = require("ui/elements/menu_activate")
|
||||
common_settings.page_turns = require("ui/elements/page_turns")
|
||||
common_settings.screen_disable_double_tab = require("ui/elements/screen_disable_double_tap_table")
|
||||
common_settings.ignore_hold_corners = {
|
||||
text = _("Ignore hold on corners"),
|
||||
@@ -460,18 +459,6 @@ common_settings.back_in_reader = {
|
||||
},
|
||||
},
|
||||
}
|
||||
if Device:hasKeys() then
|
||||
common_settings.invert_page_turn_buttons = {
|
||||
text = _("Invert page turn buttons"),
|
||||
checked_func = function()
|
||||
return G_reader_settings:isTrue("input_invert_page_turn_keys")
|
||||
end,
|
||||
callback = function()
|
||||
G_reader_settings:flipNilOrFalse("input_invert_page_turn_keys")
|
||||
Device:invertButtons()
|
||||
end,
|
||||
}
|
||||
end
|
||||
common_settings.opening_page_location_stack = {
|
||||
text = _("Add opening page to location history"),
|
||||
checked_func = function()
|
||||
|
||||
@@ -93,7 +93,6 @@ local order = {
|
||||
"gesture_intervals",
|
||||
"----------------------------",
|
||||
"menu_activate",
|
||||
"page_turns",
|
||||
"ignore_hold_corners",
|
||||
"screen_disable_double_tab",
|
||||
},
|
||||
|
||||
@@ -6,7 +6,7 @@ return {
|
||||
text = _("Activate menu"),
|
||||
sub_item_table = {
|
||||
{
|
||||
text = _("Tap"),
|
||||
text = _("With a tap"),
|
||||
checked_func = function()
|
||||
return G_reader_settings:readSetting("activate_menu") ~= "swipe"
|
||||
end,
|
||||
@@ -22,7 +22,7 @@ return {
|
||||
end,
|
||||
},
|
||||
{
|
||||
text = _("Swipe"),
|
||||
text = _("With a swipe"),
|
||||
checked_func = function()
|
||||
return G_reader_settings:readSetting("activate_menu") ~= "tap"
|
||||
end,
|
||||
|
||||
@@ -1,25 +1,85 @@
|
||||
local Device = require("device")
|
||||
local Event = require("ui/event")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local _ = require("gettext")
|
||||
|
||||
return {
|
||||
local PageTurns = {
|
||||
text = _("Page turns"),
|
||||
sub_item_table = {
|
||||
{
|
||||
text = _("Disable taps"),
|
||||
text = _("With taps"),
|
||||
checked_func = function()
|
||||
return G_reader_settings:isTrue("page_turns_disable_tap")
|
||||
return G_reader_settings:nilOrFalse("page_turns_disable_tap")
|
||||
end,
|
||||
callback = function()
|
||||
G_reader_settings:toggle("page_turns_disable_tap")
|
||||
end
|
||||
G_reader_settings:flipNilOrFalse("page_turns_disable_tap")
|
||||
end,
|
||||
},
|
||||
{
|
||||
text = _("Disable swipes"),
|
||||
text = _("With swipes"),
|
||||
checked_func = function()
|
||||
return G_reader_settings:isTrue("page_turns_disable_swipe")
|
||||
return G_reader_settings:nilOrFalse("page_turns_disable_swipe")
|
||||
end,
|
||||
callback = function()
|
||||
G_reader_settings:toggle("page_turns_disable_swipe")
|
||||
end
|
||||
G_reader_settings:flipNilOrFalse("page_turns_disable_swipe")
|
||||
end,
|
||||
separator = true,
|
||||
},
|
||||
{
|
||||
text_func = function()
|
||||
local text = _("Invert page turn taps and swipes")
|
||||
if G_reader_settings:isTrue("inverse_reading_order") then
|
||||
text = text .. " ★"
|
||||
end
|
||||
return text
|
||||
end,
|
||||
checked_func = function()
|
||||
local ui = require("apps/reader/readerui"):_getRunningInstance()
|
||||
if ui.document.info.has_pages then
|
||||
return ui.paging.inverse_reading_order
|
||||
else
|
||||
return ui.rolling.inverse_reading_order
|
||||
end
|
||||
end,
|
||||
callback = function()
|
||||
UIManager:broadcastEvent(Event:new("ToggleReadingOrder"))
|
||||
end,
|
||||
hold_callback = function(touchmenu_instance)
|
||||
local inverse_reading_order = G_reader_settings:isTrue("inverse_reading_order")
|
||||
local MultiConfirmBox = require("ui/widget/multiconfirmbox")
|
||||
UIManager:show(MultiConfirmBox:new{
|
||||
text = inverse_reading_order and _("The default (★) for newly opened books is right-to-left (RTL) page turning.\n\nWould you like to change it?")
|
||||
or _("The default (★) for newly opened books is left-to-right (LTR) page turning.\n\nWould you like to change it?"),
|
||||
choice1_text_func = function()
|
||||
return inverse_reading_order and _("LTR") or _("LTR (★)")
|
||||
end,
|
||||
choice1_callback = function()
|
||||
G_reader_settings:makeFalse("inverse_reading_order")
|
||||
if touchmenu_instance then touchmenu_instance:updateItems() end
|
||||
end,
|
||||
choice2_text_func = function()
|
||||
return inverse_reading_order and _("RTL (★)") or _("RTL")
|
||||
end,
|
||||
choice2_callback = function()
|
||||
G_reader_settings:makeTrue("inverse_reading_order")
|
||||
if touchmenu_instance then touchmenu_instance:updateItems() end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if Device:hasKeys() then
|
||||
table.insert(PageTurns.sub_item_table, {
|
||||
text = _("Invert page turn buttons"),
|
||||
checked_func = function()
|
||||
return G_reader_settings:isTrue("input_invert_page_turn_keys")
|
||||
end,
|
||||
callback = function()
|
||||
G_reader_settings:flipNilOrFalse("input_invert_page_turn_keys")
|
||||
Device:invertButtons()
|
||||
end,
|
||||
})
|
||||
end
|
||||
return PageTurns
|
||||
|
||||
Reference in New Issue
Block a user