mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
Upper menu: fix generating the menu (#11513)
revert all changes to the upper menu made in #11495
This commit is contained in:
@@ -812,11 +812,10 @@ Tap a book in the search results to open it.]]),
|
||||
for id, common_setting in pairs(dofile("frontend/ui/elements/common_info_menu_table.lua")) do
|
||||
self.menu_items[id] = common_setting
|
||||
end
|
||||
-- insert common exit
|
||||
-- insert common exit for filemanager
|
||||
for id, common_setting in pairs(dofile("frontend/ui/elements/common_exit_menu_table.lua")) do
|
||||
self.menu_items[id] = common_setting
|
||||
end
|
||||
|
||||
if not Device:isTouchDevice() then
|
||||
-- add a shortcut on non touch-device
|
||||
-- because this menu is not accessible otherwise
|
||||
@@ -925,14 +924,20 @@ function FileManagerMenu:exitOrRestart(callback, force)
|
||||
end
|
||||
end
|
||||
|
||||
function FileManagerMenu:genMenu(tab_index)
|
||||
function FileManagerMenu:onShowMenu(tab_index)
|
||||
if self.tab_item_table == nil then
|
||||
self:setUpdateItemTable()
|
||||
end
|
||||
if tab_index == nil then
|
||||
|
||||
if not tab_index then
|
||||
tab_index = G_reader_settings:readSetting("filemanagermenu_tab_index") or 1
|
||||
end
|
||||
|
||||
local menu_container = CenterContainer:new{
|
||||
ignore = "height",
|
||||
dimen = Screen:getSize(),
|
||||
}
|
||||
|
||||
local main_menu
|
||||
if Device:isTouchDevice() or Device:hasDPad() then
|
||||
local TouchMenu = require("ui/widget/touchmenu")
|
||||
@@ -940,6 +945,7 @@ function FileManagerMenu:genMenu(tab_index)
|
||||
width = Screen:getWidth(),
|
||||
last_index = tab_index,
|
||||
tab_item_table = self.tab_item_table,
|
||||
show_parent = menu_container,
|
||||
}
|
||||
else
|
||||
local Menu = require("ui/widget/menu")
|
||||
@@ -947,23 +953,14 @@ function FileManagerMenu:genMenu(tab_index)
|
||||
title = _("File manager menu"),
|
||||
item_table = Menu.itemTableFromTouchMenu(self.tab_item_table),
|
||||
width = Screen:getWidth() - (Size.margin.fullscreen_popout * 2),
|
||||
show_parent = menu_container,
|
||||
}
|
||||
end
|
||||
|
||||
main_menu.close_callback = function()
|
||||
self:onCloseFileManagerMenu()
|
||||
end
|
||||
return main_menu
|
||||
end
|
||||
|
||||
function FileManagerMenu:onShowMenu(tab_index, main_menu)
|
||||
if main_menu == nil then
|
||||
main_menu = self:genMenu(tab_index)
|
||||
end
|
||||
local menu_container = CenterContainer:new{
|
||||
ignore = "height",
|
||||
dimen = Screen:getSize(),
|
||||
}
|
||||
main_menu.show_parent = menu_container
|
||||
menu_container[1] = main_menu
|
||||
-- maintain a reference to menu_container
|
||||
self.menu_container = menu_container
|
||||
@@ -1025,8 +1022,8 @@ function FileManagerMenu:onSetDimensions(dimen)
|
||||
end
|
||||
|
||||
function FileManagerMenu:onMenuSearch()
|
||||
local main_menu = self:genMenu()
|
||||
main_menu:onShowMenuSearch()
|
||||
self:onShowMenu()
|
||||
self.menu_container[1]:onShowMenuSearch()
|
||||
end
|
||||
|
||||
function FileManagerMenu:registerToMainMenu(widget)
|
||||
|
||||
@@ -5,7 +5,6 @@ local Device = require("device")
|
||||
local Event = require("ui/event")
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local Screensaver = require("ui/screensaver")
|
||||
local Size = require("ui/size")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local logger = require("logger")
|
||||
local dbg = require("dbg")
|
||||
@@ -296,8 +295,16 @@ function ReaderMenu:setUpdateItemTable()
|
||||
text = _("Plugin management"),
|
||||
sub_item_table = PluginLoader:genPluginManagerSubItem()
|
||||
}
|
||||
|
||||
-- main menu tab
|
||||
-- insert common info
|
||||
for id, common_setting in pairs(dofile("frontend/ui/elements/common_info_menu_table.lua")) do
|
||||
self.menu_items[id] = common_setting
|
||||
end
|
||||
-- insert common exit for reader
|
||||
for id, common_setting in pairs(dofile("frontend/ui/elements/common_exit_menu_table.lua")) do
|
||||
self.menu_items[id] = common_setting
|
||||
end
|
||||
|
||||
self.menu_items.open_previous_document = {
|
||||
text_func = function()
|
||||
local previous_file = self:getPreviousFile()
|
||||
@@ -324,14 +331,6 @@ function ReaderMenu:setUpdateItemTable()
|
||||
})
|
||||
end
|
||||
}
|
||||
-- insert common info
|
||||
for id, common_setting in pairs(dofile("frontend/ui/elements/common_info_menu_table.lua")) do
|
||||
self.menu_items[id] = common_setting
|
||||
end
|
||||
-- insert common exit
|
||||
for id, common_setting in pairs(dofile("frontend/ui/elements/common_exit_menu_table.lua")) do
|
||||
self.menu_items[id] = common_setting
|
||||
end
|
||||
|
||||
local order = require("ui/elements/reader_menu_order")
|
||||
|
||||
@@ -409,14 +408,21 @@ function ReaderMenu:exitOrRestart(callback, force)
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderMenu:genMenu(tab_index)
|
||||
function ReaderMenu:onShowMenu(tab_index)
|
||||
if self.tab_item_table == nil then
|
||||
self:setUpdateItemTable()
|
||||
end
|
||||
if tab_index == nil then
|
||||
|
||||
if not tab_index then
|
||||
tab_index = self.last_tab_index
|
||||
end
|
||||
|
||||
local menu_container = CenterContainer:new{
|
||||
covers_header = true,
|
||||
ignore = "height",
|
||||
dimen = Screen:getSize(),
|
||||
}
|
||||
|
||||
local main_menu
|
||||
if Device:isTouchDevice() or Device:hasDPad() then
|
||||
local TouchMenu = require("ui/widget/touchmenu")
|
||||
@@ -424,31 +430,26 @@ function ReaderMenu:genMenu(tab_index)
|
||||
width = Screen:getWidth(),
|
||||
last_index = tab_index,
|
||||
tab_item_table = self.tab_item_table,
|
||||
show_parent = menu_container,
|
||||
}
|
||||
else
|
||||
local Menu = require("ui/widget/menu")
|
||||
main_menu = Menu:new{
|
||||
title = _("Document menu"),
|
||||
item_table = Menu.itemTableFromTouchMenu(self.tab_item_table),
|
||||
width = Screen:getWidth() - (Size.margin.fullscreen_popout * 2),
|
||||
width = Screen:getWidth() - 100,
|
||||
show_parent = menu_container,
|
||||
}
|
||||
end
|
||||
|
||||
main_menu.close_callback = function()
|
||||
self:onCloseReaderMenu()
|
||||
end
|
||||
return main_menu
|
||||
end
|
||||
|
||||
function ReaderMenu:onShowMenu(tab_index, main_menu)
|
||||
if main_menu == nil then
|
||||
main_menu = self:genMenu(tab_index)
|
||||
main_menu.touch_menu_callback = function ()
|
||||
self.ui:handleEvent(Event:new("CloseConfigMenu"))
|
||||
end
|
||||
local menu_container = CenterContainer:new{
|
||||
covers_header = true,
|
||||
ignore = "height",
|
||||
dimen = Screen:getSize(),
|
||||
}
|
||||
main_menu.show_parent = menu_container
|
||||
|
||||
menu_container[1] = main_menu
|
||||
-- maintain a reference to menu_container
|
||||
self.menu_container = menu_container
|
||||
@@ -551,8 +552,8 @@ function ReaderMenu:onSaveSettings()
|
||||
end
|
||||
|
||||
function ReaderMenu:onMenuSearch()
|
||||
local main_menu = self:genMenu()
|
||||
main_menu:onShowMenuSearch()
|
||||
self:onShowMenu()
|
||||
self.menu_container[1]:onShowMenuSearch()
|
||||
end
|
||||
|
||||
function ReaderMenu:registerToMainMenu(widget)
|
||||
|
||||
@@ -1048,10 +1048,6 @@ function TouchMenu:search(search_for)
|
||||
end
|
||||
|
||||
function TouchMenu:openMenu(path, with_animation)
|
||||
if self.show_parent == self then -- MenuSearch called from dispatcher, menu generated but not opened yet
|
||||
UIManager:sendEvent(Event:new("ShowMenu", nil, self))
|
||||
end
|
||||
|
||||
local parts = {}
|
||||
for part in util.gsplit(path, "%.", false) do -- path is ie. "2.3.3.1"
|
||||
table.insert(parts, tonumber(part))
|
||||
|
||||
Reference in New Issue
Block a user