2019-09-06 15:01:37 +00:00
|
|
|
local Language = require("ui/language")
|
|
|
|
local VirtualKeyboard = require("ui/widget/virtualkeyboard")
|
|
|
|
local orderedPairs = require("ffi/util").orderedPairs
|
|
|
|
|
|
|
|
local sub_item_table = {}
|
|
|
|
|
|
|
|
for k, _ in orderedPairs(VirtualKeyboard.lang_to_keyboard_layout) do
|
|
|
|
table.insert(sub_item_table, {
|
2019-11-18 16:16:06 +00:00
|
|
|
text_func = function()
|
|
|
|
local text = Language:getLanguageName(k)
|
|
|
|
if VirtualKeyboard:getKeyboardLayout() == k then
|
|
|
|
text = text .. " ★"
|
|
|
|
end
|
|
|
|
return text
|
|
|
|
end,
|
2019-09-06 15:01:37 +00:00
|
|
|
checked_func = function()
|
2019-11-18 16:16:06 +00:00
|
|
|
local keyboard_layouts = G_reader_settings:readSetting("keyboard_layouts") or {}
|
|
|
|
return keyboard_layouts[k] == true
|
2019-09-06 15:01:37 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
2019-11-18 16:16:06 +00:00
|
|
|
local keyboard_layouts = G_reader_settings:readSetting("keyboard_layouts") or {}
|
|
|
|
keyboard_layouts[k] = not keyboard_layouts[k]
|
|
|
|
G_reader_settings:saveSetting("keyboard_layouts", keyboard_layouts)
|
|
|
|
end,
|
|
|
|
hold_callback = function(touchmenu_instance)
|
2019-09-06 15:01:37 +00:00
|
|
|
G_reader_settings:saveSetting("keyboard_layout", k)
|
2019-11-18 16:16:06 +00:00
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
2019-09-06 15:01:37 +00:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
return sub_item_table
|