mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
MenuSorter: split out menu order configuration
This commit is contained in:
@@ -280,66 +280,7 @@ function FileManagerMenu:setUpdateItemTable()
|
||||
end,
|
||||
}
|
||||
|
||||
local order = {
|
||||
["KOMenu:menu_buttons"] = {
|
||||
"setting",
|
||||
"tools",
|
||||
"search",
|
||||
"main",
|
||||
},
|
||||
["setting"] = {
|
||||
"show_hidden_files",
|
||||
"----------------------------",
|
||||
"sort_by",
|
||||
"reverse_sorting",
|
||||
"----------------------------",
|
||||
"start_with_last_opened_file",
|
||||
"screensaver",
|
||||
"----------------------------",
|
||||
-- common settings
|
||||
-- those that don't exist will simply be skipped during menu gen
|
||||
"frontlight", -- if Device:hasFrontlight()
|
||||
"night_mode",
|
||||
"----------------------------",
|
||||
"network",
|
||||
"screen",
|
||||
"save_document",
|
||||
"----------------------------",
|
||||
"language",
|
||||
"----------------------------",
|
||||
"show_advanced_options",
|
||||
-- end common settings
|
||||
},
|
||||
["tools"] = {
|
||||
"calibre_wireless_connection",
|
||||
"evernote",
|
||||
"goodreads",
|
||||
"keep_alive",
|
||||
"statistics",
|
||||
"storage_stat",
|
||||
"cloud_storage",
|
||||
"----------------------------",
|
||||
"advanced_settings",
|
||||
"developer_options",
|
||||
},
|
||||
["search"] = {
|
||||
"dictionary_lookup",
|
||||
"find_book_in_calibre_catalog",
|
||||
"find_file",
|
||||
"----------------------------",
|
||||
"opds_catalog",
|
||||
},
|
||||
["main"] = {
|
||||
"history",
|
||||
"open_last_document",
|
||||
"----------------------------",
|
||||
"ota_update", -- if Device:isKindle() or Device:isKobo() or Device:isPocketBook() or Device:isAndroid()
|
||||
"version",
|
||||
"help",
|
||||
"----------------------------",
|
||||
"exit",
|
||||
},
|
||||
}
|
||||
local order = require("ui/elements/filemanager_menu_order")
|
||||
|
||||
local MenuSorter = require("frontend/ui/menusorter")
|
||||
self.tab_item_table = MenuSorter:sort(self.menu_items, order, "filemanager")
|
||||
@@ -347,7 +288,7 @@ end
|
||||
|
||||
function FileManagerMenu:onShowMenu()
|
||||
local tab_index = G_reader_settings:readSetting("filemanagermenu_tab_index") or 1
|
||||
if #self.menu_items.setting == 0 then
|
||||
if self.tab_item_table == nil then
|
||||
self:setUpdateItemTable()
|
||||
end
|
||||
|
||||
|
||||
@@ -165,86 +165,14 @@ function ReaderMenu:setUpdateItemTable()
|
||||
end,
|
||||
}
|
||||
|
||||
local order = {
|
||||
["KOMenu:menu_buttons"] = {
|
||||
"navi",
|
||||
"typeset",
|
||||
"setting",
|
||||
"tools",
|
||||
"search",
|
||||
"filemanager",
|
||||
"main",
|
||||
},
|
||||
["navi"] = {
|
||||
"table_of_contents",
|
||||
"bookmarks",
|
||||
"go_to",
|
||||
"skim_to",
|
||||
"follow_links",
|
||||
},
|
||||
["typeset"] = {
|
||||
"page_overlap",
|
||||
"switch_zoom_mode",
|
||||
"set_render_style",
|
||||
"floating_punctuation",
|
||||
"highlight_options",
|
||||
"change_font",
|
||||
"hyphenation",
|
||||
},
|
||||
["setting"] = {
|
||||
"read_from_right_to_left",
|
||||
-- common settings
|
||||
-- those that don't exist will simply be skipped during menu gen
|
||||
"frontlight", -- if Device:hasFrontlight()
|
||||
"night_mode",
|
||||
"----------------------------",
|
||||
"network",
|
||||
"screen",
|
||||
"screensaver",
|
||||
"save_document",
|
||||
"----------------------------",
|
||||
"language",
|
||||
"----------------------------",
|
||||
"djvu_render_mode",
|
||||
"status_bar",
|
||||
"show_advanced_options",
|
||||
},
|
||||
["tools"] = {
|
||||
"calibre_wireless_connection",
|
||||
"evernote",
|
||||
"goodreads",
|
||||
"keep_alive",
|
||||
"statistics",
|
||||
"storage_stat",
|
||||
"speed_reading_module_perception_expander",
|
||||
"synchronize_time",
|
||||
"progress_sync",
|
||||
"zsync",
|
||||
},
|
||||
["search"] = {
|
||||
"dictionary_lookup",
|
||||
"wikipedia_lookup",
|
||||
"fulltext_search",
|
||||
},
|
||||
["filemanager"] = {},
|
||||
["main"] = {
|
||||
"history",
|
||||
"book_status",
|
||||
"----------------------------",
|
||||
"ota_update", -- if Device:isKindle() or Device:isKobo() or Device:isPocketBook() or Device:isAndroid()
|
||||
"version",
|
||||
"help",
|
||||
"----------------------------",
|
||||
"exit",
|
||||
},
|
||||
}
|
||||
local order = require("frontend/ui/elements/reader_menu_order")
|
||||
|
||||
local MenuSorter = require("frontend/ui/menusorter")
|
||||
self.tab_item_table = MenuSorter:sort(self.menu_items, order, "reader")
|
||||
end
|
||||
|
||||
function ReaderMenu:onShowReaderMenu()
|
||||
if #self.menu_items.setting == 0 then
|
||||
if self.tab_item_table == nil then
|
||||
self:setUpdateItemTable()
|
||||
end
|
||||
|
||||
|
||||
62
frontend/ui/elements/filemanager_menu_order.lua
Normal file
62
frontend/ui/elements/filemanager_menu_order.lua
Normal file
@@ -0,0 +1,62 @@
|
||||
local order = {
|
||||
["KOMenu:menu_buttons"] = {
|
||||
"setting",
|
||||
"tools",
|
||||
"search",
|
||||
"main",
|
||||
},
|
||||
setting = {
|
||||
"show_hidden_files",
|
||||
"----------------------------",
|
||||
"sort_by",
|
||||
"reverse_sorting",
|
||||
"----------------------------",
|
||||
"start_with_last_opened_file",
|
||||
"screensaver",
|
||||
"----------------------------",
|
||||
-- common settings
|
||||
-- those that don't exist will simply be skipped during menu gen
|
||||
"frontlight", -- if Device:hasFrontlight()
|
||||
"night_mode",
|
||||
"----------------------------",
|
||||
"network",
|
||||
"screen",
|
||||
"save_document",
|
||||
"----------------------------",
|
||||
"language",
|
||||
"----------------------------",
|
||||
"show_advanced_options",
|
||||
-- end common settings
|
||||
},
|
||||
tools = {
|
||||
"calibre_wireless_connection",
|
||||
"evernote",
|
||||
"goodreads",
|
||||
"keep_alive",
|
||||
"statistics",
|
||||
"storage_stat",
|
||||
"cloud_storage",
|
||||
"----------------------------",
|
||||
"advanced_settings",
|
||||
"developer_options",
|
||||
},
|
||||
search = {
|
||||
"dictionary_lookup",
|
||||
"find_book_in_calibre_catalog",
|
||||
"find_file",
|
||||
"----------------------------",
|
||||
"opds_catalog",
|
||||
},
|
||||
main = {
|
||||
"history",
|
||||
"open_last_document",
|
||||
"----------------------------",
|
||||
"ota_update", -- if Device:isKindle() or Device:isKobo() or Device:isPocketBook() or Device:isAndroid()
|
||||
"version",
|
||||
"help",
|
||||
"----------------------------",
|
||||
"exit",
|
||||
},
|
||||
}
|
||||
|
||||
return order
|
||||
75
frontend/ui/elements/reader_menu_order.lua
Normal file
75
frontend/ui/elements/reader_menu_order.lua
Normal file
@@ -0,0 +1,75 @@
|
||||
local order = {
|
||||
["KOMenu:menu_buttons"] = {
|
||||
"navi",
|
||||
"typeset",
|
||||
"setting",
|
||||
"tools",
|
||||
"search",
|
||||
"filemanager",
|
||||
"main",
|
||||
},
|
||||
navi = {
|
||||
"table_of_contents",
|
||||
"bookmarks",
|
||||
"go_to",
|
||||
"skim_to",
|
||||
"follow_links",
|
||||
},
|
||||
typeset = {
|
||||
"page_overlap",
|
||||
"switch_zoom_mode",
|
||||
"set_render_style",
|
||||
"floating_punctuation",
|
||||
"highlight_options",
|
||||
"change_font",
|
||||
"hyphenation",
|
||||
},
|
||||
setting = {
|
||||
"read_from_right_to_left",
|
||||
-- common settings
|
||||
-- those that don't exist will simply be skipped during menu gen
|
||||
"frontlight", -- if Device:hasFrontlight()
|
||||
"night_mode",
|
||||
"----------------------------",
|
||||
"network",
|
||||
"screen",
|
||||
"screensaver",
|
||||
"save_document",
|
||||
"----------------------------",
|
||||
"language",
|
||||
"----------------------------",
|
||||
"djvu_render_mode",
|
||||
"status_bar",
|
||||
"show_advanced_options",
|
||||
},
|
||||
tools = {
|
||||
"calibre_wireless_connection",
|
||||
"evernote",
|
||||
"goodreads",
|
||||
"keep_alive",
|
||||
"statistics",
|
||||
"storage_stat",
|
||||
"speed_reading_module_perception_expander",
|
||||
"synchronize_time",
|
||||
"progress_sync",
|
||||
"zsync",
|
||||
},
|
||||
search = {
|
||||
"dictionary_lookup",
|
||||
"wikipedia_lookup",
|
||||
"fulltext_search",
|
||||
},
|
||||
filemanager = {},
|
||||
main = {
|
||||
"history",
|
||||
"book_status",
|
||||
"----------------------------",
|
||||
"ota_update", -- if Device:isKindle() or Device:isKobo() or Device:isPocketBook() or Device:isAndroid()
|
||||
"version",
|
||||
"help",
|
||||
"----------------------------",
|
||||
"exit",
|
||||
},
|
||||
}
|
||||
|
||||
return order
|
||||
@@ -85,5 +85,8 @@ describe("MenuSorter module", function()
|
||||
end)
|
||||
it("should compress menus when items from order are missing", function()
|
||||
|
||||
end)
|
||||
it("should allow for attaching menu items multiple times", function()
|
||||
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user