mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
MenuSearch: open upper menu when needed only (#11495)
This commit is contained in:
@@ -812,10 +812,11 @@ 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 for filemanager
|
||||
-- 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
|
||||
|
||||
if not Device:isTouchDevice() then
|
||||
-- add a shortcut on non touch-device
|
||||
-- because this menu is not accessible otherwise
|
||||
@@ -924,20 +925,14 @@ function FileManagerMenu:exitOrRestart(callback, force)
|
||||
end
|
||||
end
|
||||
|
||||
function FileManagerMenu:onShowMenu(tab_index)
|
||||
function FileManagerMenu:genMenu(tab_index)
|
||||
if self.tab_item_table == nil then
|
||||
self:setUpdateItemTable()
|
||||
end
|
||||
|
||||
if not tab_index then
|
||||
if tab_index == nil 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")
|
||||
@@ -945,7 +940,6 @@ function FileManagerMenu:onShowMenu(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")
|
||||
@@ -953,14 +947,23 @@ function FileManagerMenu:onShowMenu(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
|
||||
@@ -1022,8 +1025,8 @@ function FileManagerMenu:onSetDimensions(dimen)
|
||||
end
|
||||
|
||||
function FileManagerMenu:onMenuSearch()
|
||||
self:onShowMenu()
|
||||
self.menu_container[1]:onShowMenuSearch()
|
||||
local main_menu = self:genMenu()
|
||||
main_menu:onShowMenuSearch()
|
||||
end
|
||||
|
||||
function FileManagerMenu:registerToMainMenu(widget)
|
||||
|
||||
@@ -5,6 +5,7 @@ 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")
|
||||
@@ -295,16 +296,8 @@ 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
|
||||
|
||||
-- main menu tab
|
||||
self.menu_items.open_previous_document = {
|
||||
text_func = function()
|
||||
local previous_file = self:getPreviousFile()
|
||||
@@ -331,6 +324,14 @@ 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")
|
||||
|
||||
@@ -408,21 +409,14 @@ function ReaderMenu:exitOrRestart(callback, force)
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderMenu:onShowMenu(tab_index)
|
||||
function ReaderMenu:genMenu(tab_index)
|
||||
if self.tab_item_table == nil then
|
||||
self:setUpdateItemTable()
|
||||
end
|
||||
|
||||
if not tab_index then
|
||||
if tab_index == nil 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")
|
||||
@@ -430,26 +424,31 @@ function ReaderMenu:onShowMenu(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() - 100,
|
||||
show_parent = menu_container,
|
||||
width = Screen:getWidth() - (Size.margin.fullscreen_popout * 2),
|
||||
}
|
||||
end
|
||||
|
||||
main_menu.close_callback = function()
|
||||
self:onCloseReaderMenu()
|
||||
end
|
||||
return main_menu
|
||||
end
|
||||
|
||||
main_menu.touch_menu_callback = function ()
|
||||
self.ui:handleEvent(Event:new("CloseConfigMenu"))
|
||||
function ReaderMenu:onShowMenu(tab_index, main_menu)
|
||||
if main_menu == nil then
|
||||
main_menu = self:genMenu(tab_index)
|
||||
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
|
||||
@@ -552,8 +551,8 @@ function ReaderMenu:onSaveSettings()
|
||||
end
|
||||
|
||||
function ReaderMenu:onMenuSearch()
|
||||
self:onShowMenu()
|
||||
self.menu_container[1]:onShowMenuSearch()
|
||||
local main_menu = self:genMenu()
|
||||
main_menu:onShowMenuSearch()
|
||||
end
|
||||
|
||||
function ReaderMenu:registerToMainMenu(widget)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local BD = require("ui/bidi")
|
||||
local ConfirmBox = require("ui/widget/confirmbox")
|
||||
local Device = require("device")
|
||||
local Event = require("ui/event")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local Notification = require("ui/widget/notification")
|
||||
local UIManager = require("ui/uimanager")
|
||||
@@ -12,28 +13,19 @@ local T = require("ffi/util").template
|
||||
|
||||
local common_info = {}
|
||||
|
||||
if Device:hasOTAUpdates() then
|
||||
local OTAManager = require("ui/otamanager")
|
||||
common_info.ota_update = OTAManager:getOTAMenuTable()
|
||||
end
|
||||
common_info.version = {
|
||||
text = T(_("Version: %1"), Version:getShortVersion()),
|
||||
keep_menu_open = true,
|
||||
callback = function()
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = Version:getCurrentRevision(),
|
||||
})
|
||||
end
|
||||
}
|
||||
common_info.help = {
|
||||
text = _("Help"),
|
||||
}
|
||||
-- tools tab
|
||||
common_info.more_tools = {
|
||||
text = _("More tools"),
|
||||
}
|
||||
|
||||
common_info.device = {
|
||||
text = _("Device"),
|
||||
-- main tab
|
||||
if Device:hasOTAUpdates() then
|
||||
local OTAManager = require("ui/otamanager")
|
||||
common_info.ota_update = OTAManager:getOTAMenuTable()
|
||||
end
|
||||
|
||||
common_info.help = {
|
||||
text = _("Help"),
|
||||
}
|
||||
common_info.quickstart_guide = {
|
||||
text = _("Quickstart guide"),
|
||||
@@ -43,15 +35,12 @@ common_info.quickstart_guide = {
|
||||
ReaderUI:showReader(QuickStart:getQuickStart())
|
||||
end
|
||||
}
|
||||
common_info.about = {
|
||||
text = _("About"),
|
||||
keep_menu_open = true,
|
||||
common_info.search_menu = {
|
||||
text = _("Menu search"),
|
||||
callback = function()
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = T(_("KOReader %1\n\nA document viewer for E Ink devices.\n\nLicensed under Affero GPL v3. All dependencies are free software.\n\nhttp://koreader.rocks"), BD.ltr(Version:getCurrentRevision())),
|
||||
icon = "koreader",
|
||||
})
|
||||
end
|
||||
UIManager:sendEvent(Event:new("ShowMenuSearch"))
|
||||
end,
|
||||
keep_menu_open = true,
|
||||
}
|
||||
common_info.report_bug = {
|
||||
text_func = function()
|
||||
@@ -114,5 +103,24 @@ common_info.report_bug = {
|
||||
})
|
||||
end
|
||||
}
|
||||
common_info.version = {
|
||||
text = T(_("Version: %1"), Version:getShortVersion()),
|
||||
keep_menu_open = true,
|
||||
callback = function()
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = Version:getCurrentRevision(),
|
||||
})
|
||||
end
|
||||
}
|
||||
common_info.about = {
|
||||
text = _("About"),
|
||||
keep_menu_open = true,
|
||||
callback = function()
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = T(_("KOReader %1\n\nA document viewer for E Ink devices.\n\nLicensed under Affero GPL v3. All dependencies are free software.\n\nhttp://koreader.rocks"), BD.ltr(Version:getCurrentRevision())),
|
||||
icon = "koreader",
|
||||
})
|
||||
end
|
||||
}
|
||||
|
||||
return common_info
|
||||
|
||||
@@ -271,8 +271,9 @@ common_settings.screen_eink_opt = require("ui/elements/screen_eink_opt_menu_tabl
|
||||
common_settings.screen_notification = require("ui/elements/screen_notification_menu_table")
|
||||
|
||||
if Device:isTouchDevice() then
|
||||
common_settings.menu_activate = require("ui/elements/menu_activate")
|
||||
common_settings.screen_disable_double_tab = require("ui/elements/screen_disable_double_tap_table")
|
||||
common_settings.taps_and_gestures = {
|
||||
text = _("Taps and gestures"),
|
||||
}
|
||||
common_settings.ignore_hold_corners = {
|
||||
text = _("Ignore long-press on corners"),
|
||||
checked_func = function()
|
||||
@@ -282,6 +283,12 @@ if Device:isTouchDevice() then
|
||||
UIManager:broadcastEvent(Event:new("IgnoreHoldCorners"))
|
||||
end,
|
||||
}
|
||||
common_settings.screen_disable_double_tab = require("ui/elements/screen_disable_double_tap_table")
|
||||
common_settings.menu_activate = require("ui/elements/menu_activate")
|
||||
common_settings.keyboard_layout = {
|
||||
text = _("Keyboard"),
|
||||
sub_item_table = require("ui/elements/menu_keyboard_layout"),
|
||||
}
|
||||
end
|
||||
|
||||
-- NOTE: Allow disabling color if it's mistakenly enabled on a Grayscale screen (after a settings import?)
|
||||
@@ -368,16 +375,6 @@ Please don't change any settings unless you know what you're doing.]])
|
||||
end
|
||||
end
|
||||
|
||||
if Device:isTouchDevice() then
|
||||
common_settings.keyboard_layout = {
|
||||
text = _("Keyboard"),
|
||||
sub_item_table = require("ui/elements/menu_keyboard_layout"),
|
||||
}
|
||||
common_settings.taps_and_gestures = {
|
||||
text = _("Taps and gestures"),
|
||||
}
|
||||
end
|
||||
|
||||
common_settings.navigation = {
|
||||
text = _("Navigation"),
|
||||
}
|
||||
@@ -398,7 +395,6 @@ local function genGenericMenuEntry(title, setting, value, default, radiomark)
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
common_settings.back_to_exit = {
|
||||
text_func = function()
|
||||
local back_to_exit = G_reader_settings:readSetting("back_to_exit", "prompt") -- set "back_to_exit" to "prompt"
|
||||
@@ -715,17 +711,12 @@ common_settings.document_end_action = {
|
||||
|
||||
common_settings.language = Language:getLangMenuTable()
|
||||
|
||||
common_settings.font_ui_fallbacks = require("ui/elements/font_ui_fallbacks")
|
||||
|
||||
common_settings.screenshot = {
|
||||
text = _("Screenshot folder"),
|
||||
callback = function()
|
||||
local Screenshoter = require("ui/widget/screenshoter")
|
||||
Screenshoter:chooseFolder()
|
||||
end,
|
||||
keep_menu_open = true,
|
||||
common_settings.device = {
|
||||
text = _("Device"),
|
||||
}
|
||||
|
||||
common_settings.font_ui_fallbacks = require("ui/elements/font_ui_fallbacks")
|
||||
|
||||
common_settings.units = {
|
||||
text = _("Units"),
|
||||
sub_item_table = {
|
||||
@@ -743,10 +734,11 @@ common_settings.units = {
|
||||
},
|
||||
}
|
||||
|
||||
common_settings.search_menu = {
|
||||
text = _("Menu search"),
|
||||
common_settings.screenshot = {
|
||||
text = _("Screenshot folder"),
|
||||
callback = function()
|
||||
UIManager:sendEvent(Event:new("ShowMenuSearch"))
|
||||
local Screenshoter = require("ui/widget/screenshoter")
|
||||
Screenshoter:chooseFolder()
|
||||
end,
|
||||
keep_menu_open = true,
|
||||
}
|
||||
|
||||
@@ -1048,6 +1048,10 @@ 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