[Hotkeys] add single-key shortcuts (#14867)
This commit is contained in:
1 parent
1ad6674eec
commit
1e0e859ba8
17 files changed
+111
-204
No files matched your search
@@ -366,11 +366,7 @@ function FileManager:registerKeyEvents()
|
||||
self.key_events.Home = { { "Home" } }
|
||||
-- Override the menu.lua way of handling the back key
|
||||
self.file_chooser.key_events.Back = { { Device.input.group.Back } }
|
||||
if Device:hasScreenKB() then
|
||||
self.key_events.ToggleWifi = { { "ScreenKB", "Home" } }
|
||||
elseif Device:hasKeyboard() then
|
||||
self.key_events.ToggleWifi = { { "Shift", "Home" } }
|
||||
end
|
||||
-- ToggleWifi = { { "Shift", "Home" } } handled by hotkeys
|
||||
if not Device:hasFewKeys() then
|
||||
-- Also remove the handler assigned to the "Back" key by menu.lua
|
||||
self.file_chooser.key_events.Close = nil
|
||||
|
||||
@@ -25,18 +25,18 @@ local FileSearcher = InputContainer:extend{
|
||||
}
|
||||
|
||||
function FileSearcher:init()
|
||||
self:registerKeyEvents()
|
||||
if not self.ui.document then
|
||||
self.ui.menu:registerToMainMenu(self)
|
||||
end
|
||||
end
|
||||
|
||||
function FileSearcher:registerKeyEvents()
|
||||
if Device:hasKeyboard() then
|
||||
self.key_events.ShowFileSearch = { { "Alt", "F" }, { "Ctrl", "F" } }
|
||||
self.key_events.ShowFileSearchBlank = { { "Alt", "Shift", "F" }, { "Ctrl", "Shift", "F" }, event = "ShowFileSearch", args = "" }
|
||||
end
|
||||
end
|
||||
-- function FileSearcher:registerKeyEvents()
|
||||
-- now handled by hotkeys.koplugin:
|
||||
-- onShowFileSearch = { { "Alt", "F" }, { "Ctrl", "F" } }
|
||||
-- if Device:hasKeyboard() then
|
||||
-- onShowFileSearchBlank = { { "Alt", "Shift", "F" }, { "Ctrl", "Shift", "F" } }
|
||||
-- end
|
||||
-- end
|
||||
|
||||
function FileSearcher:addToMainMenu(menu_items)
|
||||
menu_items.file_search = {
|
||||
|
||||
@@ -66,9 +66,7 @@ function FileManagerMenu:registerKeyEvents()
|
||||
if Device:hasFewKeys() then
|
||||
self.key_events.KeyPressShowMenu = { { { "Menu", "Right" } } }
|
||||
end
|
||||
if Device:hasScreenKB() then
|
||||
self.key_events.OpenLastDoc = { { "ScreenKB", "Back" } }
|
||||
end
|
||||
-- OpenLastDoc = { { "ScreenKB", "Back" } } handled by hotkeys
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -43,8 +43,6 @@ local ReaderBookmark = InputContainer:extend{
|
||||
}
|
||||
|
||||
function ReaderBookmark:init()
|
||||
self:registerKeyEvents()
|
||||
|
||||
if G_reader_settings:hasNot("bookmarks_items_per_page") then
|
||||
-- The Bookmarks items per page and items' font size can now be
|
||||
-- configured. Previously, the ones set for the file browser
|
||||
@@ -67,17 +65,11 @@ end
|
||||
|
||||
function ReaderBookmark:onGesture() end
|
||||
|
||||
function ReaderBookmark:registerKeyEvents()
|
||||
if Device:hasKeyboard() then
|
||||
self.key_events.ShowBookmark = { { "B" }, { "Shift", "Left" } }
|
||||
self.key_events.ToggleBookmark = { { "Shift", "Right" } }
|
||||
elseif Device:hasScreenKB() then
|
||||
self.key_events.ShowBookmark = { { "ScreenKB", "Left" } }
|
||||
self.key_events.ToggleBookmark = { { "ScreenKB", "Right" } }
|
||||
end
|
||||
end
|
||||
|
||||
ReaderBookmark.onPhysicalKeyboardConnected = ReaderBookmark.registerKeyEvents
|
||||
-- function ReaderBookmark:registerKeyEvents()
|
||||
-- Now handled by hotkeys.koplugin:
|
||||
-- onShowBookmark (B, Shift-Left)
|
||||
-- onToggleBookmark (Shift-Right)
|
||||
-- end
|
||||
|
||||
function ReaderBookmark:addToMainMenu(menu_items)
|
||||
menu_items.bookmarks = {
|
||||
|
||||
@@ -103,8 +103,6 @@ local function getDictionaryFixHtmlFunc(path)
|
||||
end
|
||||
|
||||
function ReaderDictionary:init()
|
||||
self:registerKeyEvents()
|
||||
|
||||
self.disable_lookup_history = G_reader_settings:isTrue("disable_lookup_history")
|
||||
self.dicts_order = G_reader_settings:readSetting("dicts_order", {})
|
||||
self.dicts_disabled = G_reader_settings:readSetting("dicts_disabled", {})
|
||||
@@ -179,11 +177,10 @@ function ReaderDictionary:init()
|
||||
}
|
||||
end
|
||||
|
||||
function ReaderDictionary:registerKeyEvents()
|
||||
if Device:hasKeyboard() then
|
||||
self.key_events.ShowDictionaryLookup = { { "Alt", "D" }, { "Ctrl", "D" } }
|
||||
end
|
||||
end
|
||||
-- function ReaderDictionary:registerKeyEvents()
|
||||
-- Now handled by hotkeys.koplugin:
|
||||
-- onShowDictionaryLookup = { { "Alt", "D" }, { "Ctrl", "D" } }
|
||||
-- end
|
||||
|
||||
function ReaderDictionary:sortAvailableIfos()
|
||||
table.sort(available_ifos, function(lifo, rifo)
|
||||
|
||||
@@ -5,7 +5,6 @@ local Event = require("ui/event")
|
||||
local Font = require("ui/font")
|
||||
local FontList = require("fontlist")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local Input = Device.input
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local MultiConfirmBox = require("ui/widget/multiconfirmbox")
|
||||
local Notification = require("ui/widget/notification")
|
||||
@@ -30,7 +29,6 @@ local ReaderFont = InputContainer:extend{
|
||||
local newly_added_fonts = nil -- not yet filled
|
||||
|
||||
function ReaderFont:init()
|
||||
self:registerKeyEvents()
|
||||
self.ui.menu:registerToMainMenu(self)
|
||||
-- NOP our own gesture handling
|
||||
self.ges_events = nil
|
||||
@@ -150,25 +148,11 @@ end
|
||||
|
||||
function ReaderFont:onGesture() end
|
||||
|
||||
function ReaderFont:registerKeyEvents()
|
||||
if Device:hasKeyboard() then
|
||||
if not (Device:hasScreenKB() or Device:hasSymKey()) then
|
||||
-- add shortcut for keyboard
|
||||
self.key_events.IncreaseSize = {
|
||||
{ "Shift", Input.group.PgFwd },
|
||||
event = "ChangeSize",
|
||||
args = 0.5
|
||||
}
|
||||
self.key_events.DecreaseSize = {
|
||||
{ "Shift", Input.group.PgBack },
|
||||
event = "ChangeSize",
|
||||
args = -0.5
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ReaderFont.onPhysicalKeyboardConnected = ReaderFont.registerKeyEvents
|
||||
-- function ReaderFont:registerKeyEvents()
|
||||
-- Now handled by hotkeys.koplugin:
|
||||
-- Technically speaking, there are no default key_event replacements
|
||||
-- for font size changes, but users can assign hotkeys to these actions.
|
||||
-- end
|
||||
|
||||
function ReaderFont:onSetDimensions(dimen)
|
||||
self.dimen = dimen
|
||||
|
||||
@@ -290,9 +290,7 @@ function ReaderHighlight:registerKeyEvents()
|
||||
self.key_events.QuickLeftHighlightIndicator = { { modifier, "Left" }, event = "MoveHighlightIndicator", args = {-1, 0, QUICK_INDICATOR_MOVE} }
|
||||
self.key_events.QuickRightHighlightIndicator = { { modifier, "Right" }, event = "MoveHighlightIndicator", args = {1, 0, QUICK_INDICATOR_MOVE} }
|
||||
self.key_events.HighlightModifierPress = { { modifier, "Press" } }
|
||||
if Device:hasKeyboard() then
|
||||
self.key_events.StartHighlightIndicator = { { "H" } }
|
||||
end
|
||||
-- onStartHighlightIndicator (H) is handled by hotkeys.koplugin
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -243,16 +243,7 @@ function ReaderLink:onGesture() end
|
||||
function ReaderLink:registerKeyEvents()
|
||||
if Device:hasScreenKB() or Device:hasSymKey() then
|
||||
self.key_events.GotoSelectedPageLink = { { "Press" }, event = "GotoSelectedPageLink" }
|
||||
if Device:hasKeyboard() then
|
||||
self.key_events.AddCurrentLocationToStackNonTouch = { { "Shift", "Press" } }
|
||||
self.key_events.SelectNextPageLink = { { "Shift", "LPgFwd" }, event = "SelectNextPageLink" }
|
||||
self.key_events.SelectPrevPageLink = { { "Shift", "LPgBack" }, event = "SelectPrevPageLink" }
|
||||
else
|
||||
self.key_events.AddCurrentLocationToStackNonTouch = { { "ScreenKB", "Press" } }
|
||||
self.key_events.SelectNextPageLink = { { "ScreenKB", "LPgFwd" }, event = "SelectNextPageLink" }
|
||||
self.key_events.SelectPrevPageLink = { { "ScreenKB", "LPgBack" }, event = "SelectPrevPageLink" }
|
||||
end
|
||||
elseif Device:hasKeys() then
|
||||
elseif Device:hasKeyboard() then
|
||||
self.key_events = {
|
||||
SelectNextPageLink = {
|
||||
{ "Tab" },
|
||||
|
||||
@@ -41,8 +41,6 @@ local ReaderSearch = InputContainer:extend{
|
||||
}
|
||||
|
||||
function ReaderSearch:init()
|
||||
self:registerKeyEvents()
|
||||
|
||||
-- number of words before and after the search string in All search results
|
||||
self.findall_nb_context_words = G_reader_settings:readSetting("fulltext_search_nb_context_words") or 5
|
||||
self.findall_results_per_page = G_reader_settings:readSetting("fulltext_search_results_per_page") or 10
|
||||
@@ -83,12 +81,12 @@ SRELL_ERROR_CODES[110] = _("No preceding expression in repetition.")
|
||||
SRELL_ERROR_CODES[111] = _("Expression too complex, some hits will not be shown.")
|
||||
SRELL_ERROR_CODES[666] = _("Expression may lead to an extremely long search time.")
|
||||
|
||||
function ReaderSearch:registerKeyEvents()
|
||||
if Device:hasKeyboard() then
|
||||
self.key_events.ShowFulltextSearchInputBlank = { { "Alt", "Shift", "S" }, { "Ctrl", "Shift", "S" }, event = "ShowFulltextSearchInput", args = "" }
|
||||
self.key_events.ShowFulltextSearchInputRecent = { { "Alt", "S" }, { "Ctrl", "S" }, event = "ShowFulltextSearchInput" }
|
||||
end
|
||||
end
|
||||
-- function ReaderSearch:registerKeyEvents()
|
||||
-- handled by hotkeys.koplugin:
|
||||
-- if Device:hasKeyboard() then
|
||||
-- onShowFulltextSearchInputBlank = { { "Alt", "Shift", "S" }, { "Ctrl", "Shift", "S" } }
|
||||
-- end
|
||||
-- end
|
||||
|
||||
function ReaderSearch:addToMainMenu(menu_items)
|
||||
menu_items.fulltext_search_settings = {
|
||||
|
||||
@@ -21,7 +21,6 @@ local _ = require("gettext")
|
||||
local ReaderThumbnail = InputContainer:extend{}
|
||||
|
||||
function ReaderThumbnail:init()
|
||||
self:registerKeyEvents()
|
||||
if not Device:isTouchDevice() and not Device:useDPadAsActionKeys() then
|
||||
-- The BookMap and PageBrowser widgets depend too much on gestures,
|
||||
-- making them work with not enough keys on Non-Touch would be hard and very limited, so
|
||||
@@ -64,15 +63,10 @@ function ReaderThumbnail:init()
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderThumbnail:registerKeyEvents()
|
||||
if Device:hasDPad() and Device:useDPadAsActionKeys() then
|
||||
if Device:hasKeyboard() then
|
||||
self.key_events.ShowBookMap = { { "Shift", "Down" } }
|
||||
else
|
||||
self.key_events.ShowBookMap = { { "ScreenKB", "Down" } }
|
||||
end
|
||||
end
|
||||
end
|
||||
-- function ReaderThumbnail:registerKeyEvents()
|
||||
-- Now handled by hotkeys.koplugin:
|
||||
-- onShowBookMap = { { "Shift", "Down" } }
|
||||
-- end
|
||||
|
||||
function ReaderThumbnail:addToMainMenu(menu_items)
|
||||
menu_items.book_map = {
|
||||
|
||||
@@ -36,8 +36,6 @@ local ReaderToc = InputContainer:extend{
|
||||
}
|
||||
|
||||
function ReaderToc:init()
|
||||
self:registerKeyEvents()
|
||||
|
||||
if G_reader_settings:hasNot("toc_items_per_page") then
|
||||
-- The TOC items per page and items' font size can now be
|
||||
-- configured. Previously, the ones set for the file browser
|
||||
@@ -61,13 +59,10 @@ end
|
||||
|
||||
function ReaderToc:onGesture() end
|
||||
|
||||
function ReaderToc:registerKeyEvents()
|
||||
if Device:hasScreenKB() then
|
||||
self.key_events.ShowToc = { { "ScreenKB", "Up" } }
|
||||
elseif Device:hasKeyboard() then
|
||||
self.key_events.ShowToc = { { "T" }, { "Shift", "Up" } }
|
||||
end
|
||||
end
|
||||
-- function ReaderToc:registerKeyEvents()
|
||||
-- Now handled by hotkeys.koplugin:
|
||||
-- onShowToc = { { "T" }, { "Shift", "Up" } }
|
||||
-- end
|
||||
|
||||
function ReaderToc:getTitle()
|
||||
local title = _("Table of contents")
|
||||
@@ -80,8 +75,6 @@ function ReaderToc:getTitle()
|
||||
return title
|
||||
end
|
||||
|
||||
ReaderToc.onPhysicalKeyboardConnected = ReaderToc.registerKeyEvents
|
||||
|
||||
function ReaderToc:onReadSettings(config)
|
||||
self.toc_ticks_ignored_levels = config:readSetting("toc_ticks_ignored_levels") or {}
|
||||
self.toc_chapter_navigation_bind_to_ticks = config:readSetting("toc_chapter_navigation_bind_to_ticks")
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
local ConfirmBox = require("ui/widget/confirmbox")
|
||||
local DataStorage = require("datastorage")
|
||||
local Device = require("device")
|
||||
local DictQuickLookup = require("ui/widget/dictquicklookup")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local InputDialog = require("ui/widget/inputdialog")
|
||||
@@ -29,7 +28,6 @@ local ReaderWikipedia = ReaderDictionary:extend{
|
||||
}
|
||||
|
||||
function ReaderWikipedia:init()
|
||||
self:registerKeyEvents()
|
||||
self.wiki_languages = {}
|
||||
-- Read this from G_reader_settings for when used in FileBrowser
|
||||
-- (:onReadSettings() may replace it from the one saved in doc_settings)
|
||||
@@ -40,14 +38,10 @@ function ReaderWikipedia:init()
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderWikipedia:registerKeyEvents()
|
||||
if Device:hasKeyboard() then
|
||||
self.key_events.ShowWikipediaLookup = { { "Alt", "W" }, { "Ctrl", "W" } }
|
||||
if Device.k3_alt_plus_key_kernel_translated then
|
||||
self.key_events.ShowWikipediaLookup = { { Device.k3_alt_plus_key_kernel_translated["W"] } }
|
||||
end
|
||||
end
|
||||
end
|
||||
-- function ReaderWikipedia:registerKeyEvents()
|
||||
-- Now handled by hotkeys.koplugin:
|
||||
-- onShowWikipediaLookup = { { "Alt", "W" }, { "Ctrl", "W" } }
|
||||
-- end
|
||||
|
||||
function ReaderWikipedia:lookupInput()
|
||||
self.input_dialog = InputDialog:new{
|
||||
|
||||
@@ -529,15 +529,6 @@ function ReaderUI:registerKeyEvents()
|
||||
if Device:hasDPad() and Device:useDPadAsActionKeys() then
|
||||
self.key_events.StartHighlightIndicator = { { { "Up", "Down" } } }
|
||||
end
|
||||
if Device:hasScreenKB() or Device:hasSymKey() then
|
||||
if Device:hasKeyboard() then
|
||||
self.key_events.ToggleWifi = { { "Shift", "Home" } }
|
||||
self.key_events.OpenLastDoc = { { "Shift", "Back" } }
|
||||
else -- Currently exclusively targets Kindle 4.
|
||||
self.key_events.ToggleWifi = { { "ScreenKB", "Home" } }
|
||||
self.key_events.OpenLastDoc = { { "ScreenKB", "Back" } }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -216,6 +216,7 @@ local settingsList = {
|
||||
toggle_handmade_toc = {category="none", event="ToggleHandmadeToc", title=_("Toggle custom TOC"), reader=true, condition=Device:isTouchDevice() or (Device:hasDPad() and Device:useDPadAsActionKeys())},
|
||||
toggle_handmade_flows = {category="none", event="ToggleHandmadeFlows", title=_("Toggle custom hidden flows"), reader=true, separator=true, condition=Device:isTouchDevice() or (Device:hasDPad() and Device:useDPadAsActionKeys())},
|
||||
----
|
||||
text_selection = {category="none", event="StartHighlightIndicator", title=_("Toggle text selection mode"), reader=true, condition=Device:hasKeyboard()},
|
||||
set_highlight_action = {category="string", event="SetHighlightAction", title=_("Set highlight action"), args_func=ReaderHighlight.getHighlightActions, reader=true},
|
||||
cycle_highlight_action = {category="none", event="CycleHighlightAction", title=_("Cycle highlight action"), reader=true},
|
||||
cycle_highlight_style = {category="none", event="CycleHighlightStyle", title=_("Cycle highlight style"), reader=true, separator=true},
|
||||
@@ -473,6 +474,7 @@ local dispatcher_menu_order = {
|
||||
"toggle_handmade_toc",
|
||||
"toggle_handmade_flows",
|
||||
----
|
||||
"text_selection",
|
||||
"set_highlight_action",
|
||||
"cycle_highlight_action",
|
||||
"cycle_highlight_style",
|
||||
|
||||
@@ -12,7 +12,7 @@ local util = require("util")
|
||||
local _ = require("gettext")
|
||||
|
||||
-- Date at which the last migration snippet was added
|
||||
local CURRENT_MIGRATION_DATE = 20260306
|
||||
local CURRENT_MIGRATION_DATE = 20260428
|
||||
|
||||
-- Retrieve the date of the previous migration, if any
|
||||
local last_migration_date = G_reader_settings:readSetting("last_migration_date", 0)
|
||||
@@ -956,5 +956,25 @@ if last_migration_date < 20260306 then
|
||||
end
|
||||
end
|
||||
|
||||
-- 20260428, Hotkeys plugin: add text_selection to hotkeys_reader defaults
|
||||
-- https://github.com/koreader/koreader/pull/14867
|
||||
if last_migration_date < 20260428 then
|
||||
logger.info("Performing one-time migration for 20260428")
|
||||
|
||||
local Device = require("device")
|
||||
if Device:hasKeyboard() then
|
||||
local hotkeys_path = ffiUtil.joinPath(DataStorage:getSettingsDir(), "hotkeys.lua")
|
||||
if lfs.attributes(hotkeys_path, "mode") == "file" then
|
||||
local hotkeys_settings = LuaSettings:open(hotkeys_path)
|
||||
if hotkeys_settings.data.hotkeys_reader then
|
||||
hotkeys_settings.data.hotkeys_reader.b = {bookmarks = true}
|
||||
hotkeys_settings.data.hotkeys_reader.h = {text_selection = true}
|
||||
hotkeys_settings.data.hotkeys_reader.t = {toc = true}
|
||||
hotkeys_settings:flush()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- We're done, store the current migration date
|
||||
G_reader_settings:saveSetting("last_migration_date", CURRENT_MIGRATION_DATE)
|
||||
@@ -63,6 +63,14 @@ return {
|
||||
alt_plus_x = nil,
|
||||
alt_plus_y = nil,
|
||||
alt_plus_z = nil,
|
||||
-- alphabet (no modifier)
|
||||
-- Note: these are all nil in FM mode since we already use them
|
||||
-- as shortcuts for opening documents.
|
||||
-- a = nil, b = nil, c = nil, d = nil, e = nil, f = nil,
|
||||
-- g = nil, h = nil, i = nil, j = nil, k = nil, l = nil,
|
||||
-- m = nil, n = nil, o = nil, p = nil, q = nil, r = nil,
|
||||
-- s = nil, t = nil, u = nil, v = nil, w = nil, x = nil,
|
||||
-- y = nil, z = nil,
|
||||
},
|
||||
hotkeys_reader = {
|
||||
modifier_plus_up = {toc = true,},
|
||||
@@ -119,5 +127,14 @@ return {
|
||||
alt_plus_x = nil,
|
||||
alt_plus_y = nil,
|
||||
alt_plus_z = nil,
|
||||
-- alphabet (no modifier)
|
||||
a = nil,
|
||||
b = Device:hasKeyboard() and {bookmarks = true,} or {},
|
||||
c = nil, d = nil, e = nil, f = nil, g = nil,
|
||||
h = Device:hasKeyboard() and {text_selection = true,} or {},
|
||||
i = nil, j = nil, k = nil, l = nil, m = nil, n = nil,
|
||||
o = nil, p = nil, q = nil, r = nil, s = nil,
|
||||
t = Device:hasKeyboard() and {toc = true,} or {},
|
||||
u = nil, v = nil, w = nil, x = nil, y = nil, z = nil,
|
||||
},
|
||||
}
|
||||
@@ -52,9 +52,14 @@ if Device:hasKeyboard() then
|
||||
for key, label in pairs(base_keys) do
|
||||
hotkeys_list_haskeyboard["alt_plus_" .. key] = _(modifier_two .. label)
|
||||
end
|
||||
-- Alt/Ctrl + alphabet keys
|
||||
|
||||
local type_to_search = LuaSettings:open(hotkeys_path).data["type_to_search"]
|
||||
-- Alt/Ctrl + alphabet keys and (no modifier) + alphabet keys
|
||||
for dummy, char in ipairs(Device.input.group.Alphabet) do
|
||||
hotkeys_list_haskeyboard["alt_plus_" .. char:lower()] = _(modifier_two .. char)
|
||||
if not type_to_search then
|
||||
hotkeys_list_haskeyboard[char:lower()] = char
|
||||
end
|
||||
end
|
||||
util.tableMerge(hotkeys_list, hotkeys_list_haskeyboard)
|
||||
end
|
||||
@@ -173,6 +178,12 @@ function HotKeys:registerKeyEvents()
|
||||
addKeyEvents(second_modifier, top_row_keys, "HotkeyAction", "alt_plus_")
|
||||
end
|
||||
addKeyEvents(second_modifier, remaining_keys, "HotkeyAction", "alt_plus_")
|
||||
|
||||
if not self.type_to_search then
|
||||
for _, key in ipairs(Device.input.group.Alphabet) do
|
||||
self.key_events[key] = { { key }, event = "HotkeyAction", args = key:lower() }
|
||||
end
|
||||
end
|
||||
end -- if hasKeyboard()
|
||||
|
||||
local key_event_count = util.tableSize(self.key_events)
|
||||
@@ -398,129 +409,60 @@ function HotKeys:addToMainMenu(menu_items)
|
||||
"alt_plus_s", "alt_plus_t", "alt_plus_u", "alt_plus_v", "alt_plus_w", "alt_plus_x", "alt_plus_y", "alt_plus_z",
|
||||
}),
|
||||
})
|
||||
if not self.type_to_search then
|
||||
table.insert(menu_items.hotkeys.sub_item_table, {
|
||||
text = _("Alphabet keys (single key)"),
|
||||
enabled_func = function()
|
||||
return self.hotkey_mode == "hotkeys_reader"
|
||||
end,
|
||||
sub_item_table = self:genSubItemTable({
|
||||
"a", "b", "c", "d", "e", "f", "g", "h", "i",
|
||||
"j", "k", "l", "m", "n", "o", "p", "q", "r",
|
||||
"s", "t", "u", "v", "w", "x", "y", "z",
|
||||
}),
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
Description:
|
||||
This function resets existing key_event tables in various modules to resolve conflicts and customize key event handling
|
||||
Details:
|
||||
- Resets and overrides key events for the following modules:
|
||||
- ReaderBookmark
|
||||
- ReaderConfig
|
||||
- ReaderLink
|
||||
- ReaderSearch; also adds a type to search feature.
|
||||
- ReaderToc
|
||||
- ReaderThumbnail
|
||||
- ReaderUI
|
||||
- ReaderDictionary
|
||||
- ReaderWikipedia
|
||||
- FileSearcher
|
||||
- FileManagerMenu (if in docless mode)
|
||||
- Logs debug messages indicating which key events have been overridden.
|
||||
]]
|
||||
function HotKeys:overrideConflictingKeyEvents()
|
||||
if not self.is_docless then
|
||||
self.ui.bookmark.key_events = {} -- reset it.
|
||||
logger.dbg("Hotkey ReaderBookmark:registerKeyEvents() overridden.")
|
||||
|
||||
if self.ui.font then -- readerfont is not available for pdf/djvu files.
|
||||
self.ui.font.key_events = {} -- reset it.
|
||||
logger.dbg("Hotkey ReaderFont:registerKeyEvents() overridden.")
|
||||
end
|
||||
|
||||
if Device:hasScreenKB() or Device:hasSymKey() then
|
||||
local readerconfig = self.ui.config
|
||||
readerconfig.key_events = {} -- reset it, then add our own
|
||||
if self.settings_data.data["press_key_does_hotkeys"] then
|
||||
local readerconfig = self.ui.config
|
||||
readerconfig.key_events = {} -- reset it, then add our own
|
||||
readerconfig.key_events.ShowConfigMenu = { { "AA" }, event = "ShowConfigMenu" }
|
||||
else
|
||||
readerconfig.key_events.ShowConfigMenu = { { { "Press", "AA" } }, event = "ShowConfigMenu" }
|
||||
logger.dbg("Hotkey ReaderConfig:registerKeyEvents() overridden. press_key_does_hotkeys = true")
|
||||
end
|
||||
logger.dbg("Hotkey ReaderConfig:registerKeyEvents() overridden.")
|
||||
end
|
||||
|
||||
local readerlink = self.ui.link
|
||||
readerlink.key_events = {} -- reset it.
|
||||
if Device:hasScreenKB() or Device:hasSymKey() then
|
||||
readerlink.key_events.GotoSelectedPageLink = { { "Press" }, event = "GotoSelectedPageLink" }
|
||||
elseif Device:hasKeyboard() then
|
||||
readerlink.key_events = {
|
||||
SelectNextPageLink = {
|
||||
{ "Tab" },
|
||||
event = "SelectNextPageLink",
|
||||
},
|
||||
SelectPrevPageLink = {
|
||||
{ "Shift", "Tab" },
|
||||
event = "SelectPrevPageLink",
|
||||
},
|
||||
GotoSelectedPageLink = {
|
||||
{ "Press" },
|
||||
event = "GotoSelectedPageLink",
|
||||
},
|
||||
}
|
||||
end
|
||||
logger.dbg("Hotkey ReaderLink:registerKeyEvents() overridden.")
|
||||
|
||||
if Device:hasKeyboard() then
|
||||
local readersearch = self.ui.search
|
||||
readersearch.key_events = {} -- reset it.
|
||||
readersearch.key_events.ShowFulltextSearchInputBlank = {
|
||||
{ "Alt", "Shift", "S" }, { "Ctrl", "Shift", "S" },
|
||||
event = "ShowFulltextSearchInput",
|
||||
args = ""
|
||||
}
|
||||
if self.type_to_search then
|
||||
self.ui.highlight.key_events.StartHighlightIndicator = nil -- remove 'H' shortcut used for highlight indicator
|
||||
readersearch.key_events.Alphabet = {
|
||||
{ Device.input.group.Alphabet }, { "Shift", Device.input.group.Alphabet },
|
||||
event = "ShowFulltextSearchInput",
|
||||
args = ""
|
||||
}
|
||||
end
|
||||
logger.dbg("Hotkey ReaderSearch:registerKeyEvents() overridden.")
|
||||
end
|
||||
|
||||
self.ui.toc.key_events = {} -- reset it.
|
||||
logger.dbg("Hotkey ReaderToc:registerKeyEvents() overridden.")
|
||||
|
||||
self.ui.thumbnail.key_events = {} -- reset it.
|
||||
logger.dbg("Hotkey ReaderThumbnail:registerKeyEvents() overridden.")
|
||||
|
||||
local readerui = self.ui
|
||||
readerui.key_events = {} -- reset it, then add our own
|
||||
readerui.key_events.Home = { { "Home" } }
|
||||
readerui.key_events.Back = { { Device.input.group.Back } }
|
||||
if Device:hasDPad() and Device:useDPadAsActionKeys() then
|
||||
readerui.key_events.KeyContentSelection = { { { "Up", "Down" } }, event = "StartHighlightIndicator" }
|
||||
elseif Device:hasKeyboard() then
|
||||
readerui.key_events.Reload = { { "F5" } }
|
||||
end
|
||||
logger.dbg("Hotkey ReaderUI:registerKeyEvents() overridden.")
|
||||
end
|
||||
|
||||
if Device:hasKeyboard() then
|
||||
self.ui.dictionary.key_events = {} -- reset it.
|
||||
logger.dbg("Hotkey ReaderDictionary:registerKeyEvents() overridden.")
|
||||
|
||||
self.ui.wikipedia.key_events = {} -- reset it.
|
||||
logger.dbg("Hotkey ReaderWikipedia:registerKeyEvents() overridden.")
|
||||
|
||||
local filesearcher = self.ui.filesearcher
|
||||
filesearcher.key_events = {} -- reset it.
|
||||
filesearcher.key_events.ShowFileSearchBlank = {
|
||||
{ "Alt", "Shift", "F" }, { "Ctrl", "Shift", "F" },
|
||||
event = "ShowFileSearch",
|
||||
args = ""
|
||||
}
|
||||
logger.dbg("Hotkey FileSearcher:registerKeyEvents() overridden.")
|
||||
end
|
||||
|
||||
if self.is_docless then
|
||||
local filemanagermenu = self.ui.menu
|
||||
filemanagermenu.key_events = {} -- reset it.
|
||||
filemanagermenu.key_events.KeyPressShowMenu = { { "Menu" } }
|
||||
logger.dbg("Hotkey FileManagerMenu:registerKeyEvents() overridden.")
|
||||
end
|
||||
end -- overrideConflictingKeyEvents()
|
||||
|
||||
|
||||
Reference in new issue
Block a user