MenuSorter: split out menu order configuration

pull/2677/head
Frans de Jonge 7 years ago
parent 33c848f813
commit ddf590eb6d

@ -280,66 +280,7 @@ function FileManagerMenu:setUpdateItemTable()
end, end,
} }
local order = { local order = require("ui/elements/filemanager_menu_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 MenuSorter = require("frontend/ui/menusorter") local MenuSorter = require("frontend/ui/menusorter")
self.tab_item_table = MenuSorter:sort(self.menu_items, order, "filemanager") self.tab_item_table = MenuSorter:sort(self.menu_items, order, "filemanager")
@ -347,7 +288,7 @@ end
function FileManagerMenu:onShowMenu() function FileManagerMenu:onShowMenu()
local tab_index = G_reader_settings:readSetting("filemanagermenu_tab_index") or 1 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() self:setUpdateItemTable()
end end

@ -165,86 +165,14 @@ function ReaderMenu:setUpdateItemTable()
end, end,
} }
local order = { local order = require("frontend/ui/elements/reader_menu_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 MenuSorter = require("frontend/ui/menusorter") local MenuSorter = require("frontend/ui/menusorter")
self.tab_item_table = MenuSorter:sort(self.menu_items, order, "reader") self.tab_item_table = MenuSorter:sort(self.menu_items, order, "reader")
end end
function ReaderMenu:onShowReaderMenu() function ReaderMenu:onShowReaderMenu()
if #self.menu_items.setting == 0 then if self.tab_item_table == nil then
self:setUpdateItemTable() self:setUpdateItemTable()
end end

@ -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

@ -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) end)
it("should compress menus when items from order are missing", function() it("should compress menus when items from order are missing", function()
end)
it("should allow for attaching menu items multiple times", function()
end) end)
end) end)

Loading…
Cancel
Save