2019-12-06 21:55:39 +00:00
|
|
|
local BD = require("ui/bidi")
|
2013-10-18 20:38:07 +00:00
|
|
|
local CenterContainer = require("ui/widget/container/centercontainer")
|
2018-07-07 11:03:33 +00:00
|
|
|
local ConfirmBox = require("ui/widget/confirmbox")
|
2014-10-30 18:42:18 +00:00
|
|
|
local Device = require("device")
|
2013-10-18 20:38:07 +00:00
|
|
|
local Event = require("ui/event")
|
2017-03-28 22:10:36 +00:00
|
|
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
|
|
|
local Screensaver = require("ui/screensaver")
|
|
|
|
local UIManager = require("ui/uimanager")
|
2017-04-21 09:19:14 +00:00
|
|
|
local logger = require("logger")
|
|
|
|
local dbg = require("dbg")
|
2018-07-07 11:03:33 +00:00
|
|
|
local util = require("util")
|
2017-04-21 09:19:14 +00:00
|
|
|
local Screen = Device.screen
|
2017-04-24 06:27:29 +00:00
|
|
|
local _ = require("gettext")
|
2018-07-07 11:03:33 +00:00
|
|
|
local T = require("ffi/util").template
|
2013-10-18 20:38:07 +00:00
|
|
|
|
|
|
|
local ReaderMenu = InputContainer:new{
|
2014-03-13 13:52:43 +00:00
|
|
|
tab_item_table = nil,
|
2017-02-28 21:46:32 +00:00
|
|
|
menu_items = {},
|
2014-03-13 13:52:43 +00:00
|
|
|
registered_widgets = {},
|
2012-12-15 01:20:12 +00:00
|
|
|
}
|
2012-11-11 07:24:11 +00:00
|
|
|
|
|
|
|
function ReaderMenu:init()
|
2017-03-03 06:41:10 +00:00
|
|
|
self.menu_items = {
|
|
|
|
["KOMenu:menu_buttons"] = {
|
|
|
|
-- top menu
|
|
|
|
},
|
|
|
|
-- items in top menu
|
|
|
|
navi = {
|
|
|
|
icon = "resources/icons/appbar.page.corner.bookmark.png",
|
|
|
|
},
|
|
|
|
typeset = {
|
|
|
|
icon = "resources/icons/appbar.page.text.png",
|
|
|
|
},
|
|
|
|
setting = {
|
|
|
|
icon = "resources/icons/appbar.settings.png",
|
|
|
|
},
|
|
|
|
tools = {
|
|
|
|
icon = "resources/icons/appbar.tools.png",
|
|
|
|
},
|
|
|
|
search = {
|
|
|
|
icon = "resources/icons/appbar.magnify.browse.png",
|
|
|
|
},
|
|
|
|
filemanager = {
|
|
|
|
icon = "resources/icons/appbar.cabinet.files.png",
|
|
|
|
remember = false,
|
|
|
|
callback = function()
|
|
|
|
self:onTapCloseMenu()
|
|
|
|
self.ui:onClose()
|
2017-06-17 03:44:29 +00:00
|
|
|
self.ui:showFileManager()
|
2017-03-03 06:41:10 +00:00
|
|
|
end,
|
|
|
|
},
|
|
|
|
main = {
|
|
|
|
icon = "resources/icons/menu-icon.png",
|
|
|
|
}
|
2017-02-28 21:46:32 +00:00
|
|
|
}
|
|
|
|
|
2014-03-13 13:52:43 +00:00
|
|
|
self.registered_widgets = {}
|
|
|
|
|
2014-06-10 07:57:10 +00:00
|
|
|
if Device:hasKeys() then
|
2016-12-27 07:06:47 +00:00
|
|
|
if Device:isTouchDevice() then
|
|
|
|
self.key_events.TapShowMenu = { { "Menu" }, doc = "show menu", }
|
2020-06-04 11:26:18 +00:00
|
|
|
if Device:hasFewKeys() then
|
|
|
|
self.key_events.TapShowMenu = { { { "Menu", "Right" } }, doc = "show menu", }
|
|
|
|
end
|
2016-12-27 07:06:47 +00:00
|
|
|
else
|
|
|
|
-- map menu key to only top menu because bottom menu is only
|
|
|
|
-- designed for touch devices
|
|
|
|
self.key_events.ShowReaderMenu = { { "Menu" }, doc = "show menu", }
|
2020-06-04 11:26:18 +00:00
|
|
|
if Device:hasFewKeys() then
|
|
|
|
self.key_events.ShowReaderMenu = { { { "Menu", "Right" } }, doc = "show menu", }
|
|
|
|
end
|
2016-12-27 07:06:47 +00:00
|
|
|
end
|
2014-03-13 13:52:43 +00:00
|
|
|
end
|
2017-08-08 16:20:46 +00:00
|
|
|
self.activation_menu = G_reader_settings:readSetting("activate_menu")
|
|
|
|
if self.activation_menu == nil then
|
|
|
|
self.activation_menu = "swipe_tap"
|
|
|
|
end
|
2012-11-11 07:24:11 +00:00
|
|
|
end
|
2012-06-10 18:14:29 +00:00
|
|
|
|
2019-02-22 15:29:19 +00:00
|
|
|
function ReaderMenu:getPreviousFile()
|
2020-05-06 19:11:34 +00:00
|
|
|
return require("readhistory"):getPreviousFile(self.ui.document.file)
|
2019-02-22 15:29:19 +00:00
|
|
|
end
|
|
|
|
|
2016-12-19 04:27:56 +00:00
|
|
|
function ReaderMenu:onReaderReady()
|
|
|
|
-- deligate gesture listener to readerui
|
|
|
|
self.ges_events = {}
|
|
|
|
self.onGesture = nil
|
|
|
|
if not Device:isTouchDevice() then return end
|
|
|
|
|
|
|
|
self.ui:registerTouchZones({
|
2017-06-01 16:32:06 +00:00
|
|
|
{
|
|
|
|
id = "readermenu_tap",
|
|
|
|
ges = "tap",
|
|
|
|
screen_zone = {
|
|
|
|
ratio_x = DTAP_ZONE_MENU.x, ratio_y = DTAP_ZONE_MENU.y,
|
|
|
|
ratio_w = DTAP_ZONE_MENU.w, ratio_h = DTAP_ZONE_MENU.h,
|
|
|
|
},
|
2019-03-30 20:05:44 +00:00
|
|
|
overrides = {
|
|
|
|
"tap_forward",
|
|
|
|
"tap_backward",
|
|
|
|
},
|
2017-06-01 16:32:06 +00:00
|
|
|
handler = function(ges) return self:onTapShowMenu(ges) end,
|
|
|
|
},
|
2016-12-19 04:27:56 +00:00
|
|
|
{
|
2017-04-15 12:45:56 +00:00
|
|
|
id = "readermenu_swipe",
|
|
|
|
ges = "swipe",
|
2016-12-19 04:27:56 +00:00
|
|
|
screen_zone = {
|
|
|
|
ratio_x = DTAP_ZONE_MENU.x, ratio_y = DTAP_ZONE_MENU.y,
|
|
|
|
ratio_w = DTAP_ZONE_MENU.w, ratio_h = DTAP_ZONE_MENU.h,
|
|
|
|
},
|
2019-03-30 20:05:44 +00:00
|
|
|
overrides = {
|
|
|
|
"rolling_swipe",
|
|
|
|
"paging_swipe",
|
|
|
|
},
|
2017-04-15 12:45:56 +00:00
|
|
|
handler = function(ges) return self:onSwipeShowMenu(ges) end,
|
2014-03-13 13:52:43 +00:00
|
|
|
},
|
2017-04-24 06:33:12 +00:00
|
|
|
{
|
|
|
|
id = "readermenu_pan",
|
|
|
|
ges = "pan",
|
|
|
|
screen_zone = {
|
|
|
|
ratio_x = DTAP_ZONE_MENU.x, ratio_y = DTAP_ZONE_MENU.y,
|
|
|
|
ratio_w = DTAP_ZONE_MENU.w, ratio_h = DTAP_ZONE_MENU.h,
|
|
|
|
},
|
2019-03-30 20:05:44 +00:00
|
|
|
overrides = {
|
|
|
|
"rolling_pan",
|
|
|
|
"paging_pan",
|
|
|
|
},
|
2017-04-24 06:33:12 +00:00
|
|
|
handler = function(ges) return self:onSwipeShowMenu(ges) end,
|
|
|
|
},
|
2016-12-19 04:27:56 +00:00
|
|
|
})
|
2013-02-02 06:36:29 +00:00
|
|
|
end
|
|
|
|
|
2012-12-15 01:20:12 +00:00
|
|
|
function ReaderMenu:setUpdateItemTable()
|
2014-03-13 13:52:43 +00:00
|
|
|
for _, widget in pairs(self.registered_widgets) do
|
2017-04-21 09:19:14 +00:00
|
|
|
local ok, err = pcall(widget.addToMainMenu, widget, self.menu_items)
|
|
|
|
if not ok then
|
|
|
|
logger.err("failed to register widget", widget.name, err)
|
|
|
|
end
|
2014-03-13 13:52:43 +00:00
|
|
|
end
|
|
|
|
|
2014-11-21 14:41:14 +00:00
|
|
|
-- settings tab
|
|
|
|
-- insert common settings
|
2019-03-02 20:45:12 +00:00
|
|
|
for id, common_setting in pairs(dofile("frontend/ui/elements/common_settings_menu_table.lua")) do
|
2017-02-28 21:46:32 +00:00
|
|
|
self.menu_items[id] = common_setting
|
2014-11-21 14:41:14 +00:00
|
|
|
end
|
|
|
|
-- insert DjVu render mode submenu just before the last entry (show advanced)
|
|
|
|
-- this is a bit of a hack
|
2014-10-15 12:31:24 +00:00
|
|
|
if self.ui.document.is_djvu then
|
2017-03-03 06:41:10 +00:00
|
|
|
self.menu_items.djvu_render_mode = self.view:getRenderModeMenuTable()
|
2014-10-15 12:31:24 +00:00
|
|
|
end
|
2014-07-27 13:41:38 +00:00
|
|
|
|
2017-11-10 10:31:00 +00:00
|
|
|
if Device:supportsScreensaver() then
|
2017-12-17 17:27:24 +00:00
|
|
|
local ss_book_settings = {
|
2018-01-21 18:44:12 +00:00
|
|
|
text = _("Exclude this book's cover from screensaver"),
|
2017-12-17 17:27:24 +00:00
|
|
|
enabled_func = function()
|
|
|
|
return not (self.ui == nil or self.ui.document == nil)
|
|
|
|
and G_reader_settings:readSetting('screensaver_type') == "cover"
|
|
|
|
end,
|
2018-01-21 18:44:12 +00:00
|
|
|
checked_func = function()
|
|
|
|
return self.ui and self.ui.doc_settings and self.ui.doc_settings:readSetting("exclude_screensaver") == true
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
if Screensaver:excluded() then
|
|
|
|
self.ui.doc_settings:saveSetting("exclude_screensaver", false)
|
|
|
|
else
|
|
|
|
self.ui.doc_settings:saveSetting("exclude_screensaver", true)
|
|
|
|
end
|
|
|
|
self.ui:saveSettings()
|
2019-10-17 13:03:40 +00:00
|
|
|
end,
|
|
|
|
added_by_readermenu_flag = true,
|
2017-02-28 21:46:32 +00:00
|
|
|
}
|
2019-10-17 13:03:40 +00:00
|
|
|
local screensaver_sub_item_table = require("ui/elements/screensaver_menu")
|
|
|
|
-- Before inserting this new item, remove any previously added one
|
|
|
|
for i = #screensaver_sub_item_table, 1, -1 do
|
|
|
|
if screensaver_sub_item_table[i].added_by_readermenu_flag then
|
|
|
|
table.remove(screensaver_sub_item_table, i)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
table.insert(screensaver_sub_item_table, ss_book_settings)
|
2017-12-17 17:27:24 +00:00
|
|
|
self.menu_items.screensaver = {
|
|
|
|
text = _("Screensaver"),
|
2019-10-17 13:03:40 +00:00
|
|
|
sub_item_table = screensaver_sub_item_table,
|
2017-12-17 17:27:24 +00:00
|
|
|
}
|
2014-09-17 10:25:13 +00:00
|
|
|
end
|
2018-08-17 18:54:11 +00:00
|
|
|
|
|
|
|
local PluginLoader = require("pluginloader")
|
|
|
|
self.menu_items.plugin_management = {
|
|
|
|
text = _("Plugin management"),
|
|
|
|
sub_item_table = PluginLoader:genPluginManagerSubItem()
|
|
|
|
}
|
2017-02-25 10:58:39 +00:00
|
|
|
-- main menu tab
|
|
|
|
-- insert common info
|
2019-03-02 20:45:12 +00:00
|
|
|
for id, common_setting in pairs(dofile("frontend/ui/elements/common_info_menu_table.lua")) do
|
2017-02-28 21:46:32 +00:00
|
|
|
self.menu_items[id] = common_setting
|
2017-02-25 10:58:39 +00:00
|
|
|
end
|
|
|
|
|
2017-09-03 13:40:50 +00:00
|
|
|
self.menu_items.exit_menu = {
|
|
|
|
text = _("Exit"),
|
|
|
|
hold_callback = function()
|
|
|
|
self:exitOrRestart()
|
|
|
|
end,
|
|
|
|
}
|
2017-03-03 06:41:10 +00:00
|
|
|
self.menu_items.exit = {
|
2017-02-25 10:58:39 +00:00
|
|
|
text = _("Exit"),
|
|
|
|
callback = function()
|
2017-05-16 09:11:11 +00:00
|
|
|
self:exitOrRestart()
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
self.menu_items.restart_koreader = {
|
|
|
|
text = _("Restart KOReader"),
|
|
|
|
callback = function()
|
|
|
|
self:exitOrRestart(function() UIManager:restartKOReader() end)
|
2017-02-25 10:58:39 +00:00
|
|
|
end,
|
2017-02-28 21:46:32 +00:00
|
|
|
}
|
2019-08-15 12:49:15 +00:00
|
|
|
if not Device:canRestart() then
|
2019-01-21 21:44:13 +00:00
|
|
|
self.menu_items.exit_menu = self.menu_items.exit
|
|
|
|
self.menu_items.exit = nil
|
|
|
|
self.menu_items.restart_koreader = nil
|
|
|
|
end
|
2017-02-25 10:58:39 +00:00
|
|
|
|
2018-07-07 11:03:33 +00:00
|
|
|
self.menu_items.open_previous_document = {
|
|
|
|
text_func = function()
|
2019-02-22 15:29:19 +00:00
|
|
|
local previous_file = self:getPreviousFile()
|
2018-07-07 11:03:33 +00:00
|
|
|
if not G_reader_settings:isTrue("open_last_menu_show_filename") or not previous_file then
|
|
|
|
return _("Open previous document")
|
|
|
|
end
|
2018-11-28 20:14:07 +00:00
|
|
|
local path, file_name = util.splitFilePathName(previous_file) -- luacheck: no unused
|
2020-01-04 00:18:51 +00:00
|
|
|
return T(_("Previous: %1"), BD.filename(file_name))
|
2018-07-07 11:03:33 +00:00
|
|
|
end,
|
|
|
|
enabled_func = function()
|
2019-02-22 15:29:19 +00:00
|
|
|
return self:getPreviousFile() ~= nil
|
2018-07-07 11:03:33 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
2019-02-22 15:29:19 +00:00
|
|
|
self.ui:switchDocument(self:getPreviousFile())
|
2018-07-07 11:03:33 +00:00
|
|
|
end,
|
|
|
|
hold_callback = function()
|
2019-02-22 15:29:19 +00:00
|
|
|
local previous_file = self:getPreviousFile()
|
2018-07-07 11:03:33 +00:00
|
|
|
UIManager:show(ConfirmBox:new{
|
2020-01-04 00:18:51 +00:00
|
|
|
text = T(_("Would you like to open the previous document: %1?"), BD.filepath(previous_file)),
|
2018-07-07 11:03:33 +00:00
|
|
|
ok_text = _("OK"),
|
|
|
|
ok_callback = function()
|
|
|
|
self.ui:switchDocument(previous_file)
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2017-04-14 18:12:21 +00:00
|
|
|
local order = require("ui/elements/reader_menu_order")
|
2017-02-28 21:46:32 +00:00
|
|
|
|
2017-04-14 18:12:21 +00:00
|
|
|
local MenuSorter = require("ui/menusorter")
|
2017-03-24 20:15:35 +00:00
|
|
|
self.tab_item_table = MenuSorter:mergeAndSort("reader", self.menu_items, order)
|
2012-12-15 01:20:12 +00:00
|
|
|
end
|
2017-04-21 09:19:14 +00:00
|
|
|
dbg:guard(ReaderMenu, 'setUpdateItemTable',
|
|
|
|
function(self)
|
|
|
|
local mock_menu_items = {}
|
|
|
|
for _, widget in pairs(self.registered_widgets) do
|
|
|
|
-- make sure addToMainMenu works in debug mode
|
|
|
|
widget:addToMainMenu(mock_menu_items)
|
|
|
|
end
|
|
|
|
end)
|
2012-12-15 01:20:12 +00:00
|
|
|
|
2017-05-16 09:11:11 +00:00
|
|
|
function ReaderMenu:exitOrRestart(callback)
|
2017-09-11 19:37:00 +00:00
|
|
|
if self.menu_container then self:onTapCloseMenu() end
|
2017-05-16 09:11:11 +00:00
|
|
|
UIManager:nextTick(function()
|
|
|
|
self.ui:onClose()
|
|
|
|
if callback ~= nil then
|
2017-09-11 19:37:00 +00:00
|
|
|
-- show an empty widget so that the callback always happens
|
|
|
|
local Widget = require("ui/widget/widget")
|
|
|
|
local widget = Widget:new{
|
|
|
|
width = Screen:getWidth(),
|
|
|
|
height = Screen:getHeight(),
|
|
|
|
}
|
|
|
|
UIManager:show(widget)
|
|
|
|
local waiting = function(waiting)
|
|
|
|
-- if we don't do this you can get a situation where either the
|
|
|
|
-- program won't exit due to remaining widgets until they're
|
|
|
|
-- dismissed or if the callback forces all widgets to close,
|
|
|
|
-- that the save document ConfirmBox is also closed
|
|
|
|
if self.ui and self.ui.document and self.ui.document:isEdited() then
|
|
|
|
logger.dbg("waiting for save settings")
|
|
|
|
UIManager:scheduleIn(1, function() waiting(waiting) end)
|
|
|
|
else
|
|
|
|
callback()
|
|
|
|
UIManager:close(widget)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
UIManager:scheduleIn(1, function() waiting(waiting) end)
|
2017-05-16 09:11:11 +00:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
local FileManager = require("apps/filemanager/filemanager")
|
|
|
|
if FileManager.instance then
|
|
|
|
FileManager.instance:onClose()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-01-13 22:11:09 +00:00
|
|
|
function ReaderMenu:onShowReaderMenu(tab_index)
|
2017-03-05 11:46:27 +00:00
|
|
|
if self.tab_item_table == nil then
|
2014-03-13 13:52:43 +00:00
|
|
|
self:setUpdateItemTable()
|
|
|
|
end
|
|
|
|
|
2018-01-13 22:11:09 +00:00
|
|
|
if not tab_index then
|
|
|
|
tab_index = self.last_tab_index
|
|
|
|
end
|
|
|
|
|
2014-03-13 13:52:43 +00:00
|
|
|
local menu_container = CenterContainer:new{
|
|
|
|
ignore = "height",
|
|
|
|
dimen = Screen:getSize(),
|
|
|
|
}
|
|
|
|
|
2015-04-27 00:49:27 +00:00
|
|
|
local main_menu
|
2018-03-14 21:16:38 +00:00
|
|
|
if Device:isTouchDevice() or Device:hasDPad() then
|
2014-10-25 08:02:42 +00:00
|
|
|
local TouchMenu = require("ui/widget/touchmenu")
|
2014-03-13 13:52:43 +00:00
|
|
|
main_menu = TouchMenu:new{
|
|
|
|
width = Screen:getWidth(),
|
2018-01-13 22:11:09 +00:00
|
|
|
last_index = tab_index,
|
2017-02-28 21:46:32 +00:00
|
|
|
tab_item_table = self.tab_item_table,
|
2014-03-13 13:52:43 +00:00
|
|
|
show_parent = menu_container,
|
|
|
|
}
|
|
|
|
else
|
2014-10-25 08:02:42 +00:00
|
|
|
local Menu = require("ui/widget/menu")
|
2014-03-13 13:52:43 +00:00
|
|
|
main_menu = Menu:new{
|
|
|
|
title = _("Document menu"),
|
2014-10-25 08:02:42 +00:00
|
|
|
item_table = Menu.itemTableFromTouchMenu(self.tab_item_table),
|
2014-03-13 13:52:43 +00:00
|
|
|
width = Screen:getWidth() - 100,
|
2014-10-25 08:02:42 +00:00
|
|
|
show_parent = menu_container,
|
2014-03-13 13:52:43 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
main_menu.close_callback = function ()
|
2014-11-05 04:15:07 +00:00
|
|
|
self.ui:handleEvent(Event:new("CloseReaderMenu"))
|
|
|
|
end
|
|
|
|
|
|
|
|
main_menu.touch_menu_callback = function ()
|
|
|
|
self.ui:handleEvent(Event:new("CloseConfigMenu"))
|
2014-03-13 13:52:43 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
menu_container[1] = main_menu
|
|
|
|
-- maintain a reference to menu_container
|
|
|
|
self.menu_container = menu_container
|
|
|
|
UIManager:show(menu_container)
|
|
|
|
return true
|
2012-06-10 18:14:29 +00:00
|
|
|
end
|
2012-11-11 07:24:11 +00:00
|
|
|
|
2014-09-05 13:02:13 +00:00
|
|
|
function ReaderMenu:onCloseReaderMenu()
|
2018-05-20 23:19:36 +00:00
|
|
|
if self.menu_container then
|
|
|
|
self.last_tab_index = self.menu_container[1].last_index
|
|
|
|
self:onSaveSettings()
|
|
|
|
UIManager:close(self.menu_container)
|
|
|
|
end
|
2014-09-05 13:02:13 +00:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2018-01-21 18:44:12 +00:00
|
|
|
function ReaderMenu:onCloseDocument()
|
|
|
|
if Device:supportsScreensaver() then
|
2019-10-07 15:46:09 +00:00
|
|
|
-- Remove the item we added (which cleans up references to document
|
2018-01-21 18:44:12 +00:00
|
|
|
-- and doc_settings embedded in functions)
|
|
|
|
local screensaver_sub_item_table = require("ui/elements/screensaver_menu")
|
2019-10-17 13:03:40 +00:00
|
|
|
for i = #screensaver_sub_item_table, 1, -1 do
|
|
|
|
if screensaver_sub_item_table[i].added_by_readermenu_flag then
|
|
|
|
table.remove(screensaver_sub_item_table, i)
|
|
|
|
end
|
|
|
|
end
|
2018-01-21 18:44:12 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-01-13 22:11:09 +00:00
|
|
|
function ReaderMenu:_getTabIndexFromLocation(ges)
|
|
|
|
if self.tab_item_table == nil then
|
|
|
|
self:setUpdateItemTable()
|
|
|
|
end
|
2018-03-14 21:16:38 +00:00
|
|
|
if not ges then
|
|
|
|
return self.last_tab_index
|
2018-01-13 22:11:09 +00:00
|
|
|
-- if the start position is far right
|
2018-03-14 21:16:38 +00:00
|
|
|
elseif ges.pos.x > 2 * Screen:getWidth() / 3 then
|
2019-12-06 21:55:39 +00:00
|
|
|
return BD.mirroredUILayout() and 1 or #self.tab_item_table
|
2018-01-13 22:11:09 +00:00
|
|
|
-- if the start position is far left
|
|
|
|
elseif ges.pos.x < Screen:getWidth() / 3 then
|
2019-12-06 21:55:39 +00:00
|
|
|
return BD.mirroredUILayout() and #self.tab_item_table or 1
|
2018-01-13 22:11:09 +00:00
|
|
|
-- if center return the last index
|
|
|
|
else
|
|
|
|
return self.last_tab_index
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-04-15 12:45:56 +00:00
|
|
|
function ReaderMenu:onSwipeShowMenu(ges)
|
2017-08-08 16:20:46 +00:00
|
|
|
if self.activation_menu ~= "tap" and ges.direction == "south" then
|
2017-10-08 10:27:53 +00:00
|
|
|
if G_reader_settings:nilOrTrue("show_bottom_menu") then
|
|
|
|
self.ui:handleEvent(Event:new("ShowConfigMenu"))
|
|
|
|
end
|
2018-01-13 22:11:09 +00:00
|
|
|
self.ui:handleEvent(Event:new("ShowReaderMenu", self:_getTabIndexFromLocation(ges)))
|
2017-04-15 12:45:56 +00:00
|
|
|
return true
|
|
|
|
end
|
2012-11-11 07:24:11 +00:00
|
|
|
end
|
|
|
|
|
2018-01-13 22:11:09 +00:00
|
|
|
function ReaderMenu:onTapShowMenu(ges)
|
2017-08-08 16:20:46 +00:00
|
|
|
if self.activation_menu ~= "swipe" then
|
2017-10-08 10:27:53 +00:00
|
|
|
if G_reader_settings:nilOrTrue("show_bottom_menu") then
|
|
|
|
self.ui:handleEvent(Event:new("ShowConfigMenu"))
|
|
|
|
end
|
2018-01-13 22:11:09 +00:00
|
|
|
self.ui:handleEvent(Event:new("ShowReaderMenu", self:_getTabIndexFromLocation(ges)))
|
2017-08-08 16:20:46 +00:00
|
|
|
return true
|
|
|
|
end
|
2017-06-01 16:32:06 +00:00
|
|
|
end
|
|
|
|
|
2014-10-10 10:14:16 +00:00
|
|
|
function ReaderMenu:onTapCloseMenu()
|
|
|
|
self.ui:handleEvent(Event:new("CloseReaderMenu"))
|
|
|
|
self.ui:handleEvent(Event:new("CloseConfigMenu"))
|
|
|
|
end
|
|
|
|
|
2014-11-11 02:06:17 +00:00
|
|
|
function ReaderMenu:onReadSettings(config)
|
2014-12-01 07:32:12 +00:00
|
|
|
self.last_tab_index = config:readSetting("readermenu_tab_index") or 1
|
2014-11-11 02:06:17 +00:00
|
|
|
end
|
|
|
|
|
2013-12-27 15:18:16 +00:00
|
|
|
function ReaderMenu:onSaveSettings()
|
2014-12-03 16:14:30 +00:00
|
|
|
self.ui.doc_settings:saveSetting("readermenu_tab_index", self.last_tab_index)
|
2012-12-15 01:20:12 +00:00
|
|
|
end
|
|
|
|
|
2012-12-15 01:30:48 +00:00
|
|
|
function ReaderMenu:registerToMainMenu(widget)
|
2014-03-13 13:52:43 +00:00
|
|
|
table.insert(self.registered_widgets, widget)
|
2012-12-08 17:25:32 +00:00
|
|
|
end
|
|
|
|
|
2013-10-18 20:38:07 +00:00
|
|
|
return ReaderMenu
|