mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #2111 from chrox/fix_2110
fix #2110 by adding disable double tap option in screen options
This commit is contained in:
@@ -8,4 +8,4 @@ make all
|
||||
retry_cmd 2 make testfront
|
||||
set +o pipefail
|
||||
luajit $(which luacheck) --no-color -q frontend | tee ./luacheck.out
|
||||
test $(grep Total ./luacheck.out | awk '{print $2}') -le 53
|
||||
test $(grep Total ./luacheck.out | awk '{print $2}') -le 25
|
||||
|
||||
@@ -605,7 +605,7 @@ function ReaderPaging:genPageStatesFromTop(top_page_state, blank_area, offset)
|
||||
if self.current_page == self.number_of_pages then break end
|
||||
self:_gotoPage(current_page + 1, "scrolling")
|
||||
current_page = current_page + 1
|
||||
local state = self:getNextPageState(blank_area, Geom:new{})
|
||||
state = self:getNextPageState(blank_area, Geom:new{})
|
||||
table.insert(page_states, state)
|
||||
end
|
||||
end
|
||||
@@ -627,7 +627,7 @@ function ReaderPaging:genPageStatesFromBottom(bottom_page_state, blank_area, off
|
||||
if self.current_page == 1 then break end
|
||||
self:_gotoPage(current_page - 1, "scrolling")
|
||||
current_page = current_page - 1
|
||||
local state = self:getPrevPageState(blank_area, Geom:new{})
|
||||
state = self:getPrevPageState(blank_area, Geom:new{})
|
||||
table.insert(page_states, 1, state)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -27,9 +27,9 @@ function ReaderSearch:addToMainMenu(tab_item_table)
|
||||
end
|
||||
|
||||
function ReaderSearch:onShowSearchDialog(text)
|
||||
local do_search = function(search_func, text, param)
|
||||
local do_search = function(search_func, _text, param)
|
||||
return function()
|
||||
local res = search_func(self, text, param)
|
||||
local res = search_func(self, _text, param)
|
||||
if res then
|
||||
if self.ui.document.info.has_pages then
|
||||
self.ui.link:onGotoLink({page = res.page - 1})
|
||||
|
||||
@@ -452,7 +452,7 @@ function ReaderView:drawXPointerSavedHighlight(bb, x, y)
|
||||
end -- end for all saved highlight
|
||||
end
|
||||
|
||||
function ReaderView:drawHighlightRect(bb, x, y, rect, drawer)
|
||||
function ReaderView:drawHighlightRect(bb, _x, _y, rect, drawer)
|
||||
local x, y, w, h = rect.x, rect.y, rect.w, rect.h
|
||||
|
||||
if drawer == "underscore" then
|
||||
|
||||
@@ -284,6 +284,7 @@ function ReaderUI:init()
|
||||
view = self.view,
|
||||
ui = self
|
||||
})
|
||||
self.disable_double_tap = G_reader_settings:readSetting("disable_double_tap") ~= false
|
||||
end
|
||||
-- fulltext search
|
||||
self:registerModule("search", ReaderSearch:new{
|
||||
|
||||
@@ -322,12 +322,12 @@ function KoptInterface:renderOptimizedPage(doc, pageno, rect, zoom, rotation, re
|
||||
local cached = Cache:check(renderpg_hash, TileCacheItem)
|
||||
if not cached then
|
||||
local page_size = Document.getNativePageDimensions(doc, pageno)
|
||||
local bbox = {
|
||||
local full_page_bbox = {
|
||||
x0 = 0, y0 = 0,
|
||||
x1 = page_size.w,
|
||||
y1 = page_size.h,
|
||||
}
|
||||
local kc = self:createContext(doc, pageno, bbox)
|
||||
local kc = self:createContext(doc, pageno, full_page_bbox)
|
||||
local page = doc._document:openPage(pageno)
|
||||
kc:setZoom(zoom)
|
||||
page:getPagePix(kc)
|
||||
@@ -444,7 +444,7 @@ function KoptInterface:getReflowedTextBoxes(doc, pageno)
|
||||
local cached = Cache:check(hash)
|
||||
if not cached then
|
||||
local kctx_hash = "kctx|"..context_hash
|
||||
local cached = Cache:check(kctx_hash)
|
||||
cached = Cache:check(kctx_hash)
|
||||
if cached then
|
||||
local kc = self:waitForContext(cached.kctx)
|
||||
--kc:setDebug()
|
||||
@@ -468,7 +468,7 @@ function KoptInterface:getNativeTextBoxes(doc, pageno)
|
||||
local cached = Cache:check(hash)
|
||||
if not cached then
|
||||
local kctx_hash = "kctx|"..context_hash
|
||||
local cached = Cache:check(kctx_hash)
|
||||
cached = Cache:check(kctx_hash)
|
||||
if cached then
|
||||
local kc = self:waitForContext(cached.kctx)
|
||||
--kc:setDebug()
|
||||
@@ -493,7 +493,7 @@ function KoptInterface:getReflowedTextBoxesFromScratch(doc, pageno)
|
||||
local cached = Cache:check(hash)
|
||||
if not cached then
|
||||
local kctx_hash = "kctx|"..context_hash
|
||||
local cached = Cache:check(kctx_hash)
|
||||
cached = Cache:check(kctx_hash)
|
||||
if cached then
|
||||
local reflowed_kc = self:waitForContext(cached.kctx)
|
||||
local fullwidth, fullheight = reflowed_kc:getPageDim()
|
||||
@@ -541,19 +541,19 @@ end
|
||||
get page regions in native page via optical method,
|
||||
--]]
|
||||
function KoptInterface:getPageBlock(doc, pageno, x, y)
|
||||
local kctx = nil
|
||||
local kctx
|
||||
local bbox = doc:getPageBBox(pageno)
|
||||
local context_hash = self:getContextHash(doc, pageno, bbox)
|
||||
local hash = "pageblocks|"..context_hash
|
||||
local cached = Cache:check(hash)
|
||||
if not cached then
|
||||
local page_size = Document.getNativePageDimensions(doc, pageno)
|
||||
local bbox = {
|
||||
local full_page_bbox = {
|
||||
x0 = 0, y0 = 0,
|
||||
x1 = page_size.w,
|
||||
y1 = page_size.h,
|
||||
}
|
||||
local kc = self:createContext(doc, pageno, bbox)
|
||||
local kc = self:createContext(doc, pageno, full_page_bbox)
|
||||
local screen_size = Screen:getSize()
|
||||
-- leptonica needs a source image of at least 300dpi
|
||||
kc:setZoom(screen_size.w / page_size.w * 300 / self.screen_dpi)
|
||||
@@ -594,7 +594,7 @@ function KoptInterface:getReflewOCRWord(doc, pageno, rect)
|
||||
local cached = Cache:check(hash)
|
||||
if not cached then
|
||||
local kctx_hash = "kctx|"..context_hash
|
||||
local cached = Cache:check(kctx_hash)
|
||||
cached = Cache:check(kctx_hash)
|
||||
if cached then
|
||||
local kc = self:waitForContext(cached.kctx)
|
||||
local _, word = pcall(
|
||||
@@ -665,8 +665,8 @@ function KoptInterface:getClipPageContext(doc, pos0, pos1, pboxes, drawer)
|
||||
x = box.x, y = box.y,
|
||||
w = box.w, h = box.h,
|
||||
}
|
||||
for _, box in ipairs(pboxes) do
|
||||
rect = rect:combine(Geom:new(box))
|
||||
for _, _box in ipairs(pboxes) do
|
||||
rect = rect:combine(Geom:new(_box))
|
||||
end
|
||||
else
|
||||
local zoom = pos0.zoom or 1
|
||||
@@ -910,9 +910,9 @@ end
|
||||
get link from position in screen page
|
||||
]]--
|
||||
function KoptInterface:getLinkFromPosition(doc, pageno, pos)
|
||||
local function inside_box(pos, box)
|
||||
if pos then
|
||||
local x, y = pos.x, pos.y
|
||||
local function _inside_box(_pos, box)
|
||||
if _pos then
|
||||
local x, y = _pos.x, _pos.y
|
||||
if box.x <= x and box.y <= y
|
||||
and box.x + box.w >= x
|
||||
and box.y + box.h >= y then
|
||||
@@ -934,7 +934,7 @@ function KoptInterface:getLinkFromPosition(doc, pageno, pos)
|
||||
w = link.x1 - link.x0 + Screen:scaleBySize(10),
|
||||
h = link.y1 - link.y0 + Screen:scaleBySize(10)
|
||||
}
|
||||
if inside_box(pos, lbox) and link.page then
|
||||
if _inside_box(pos, lbox) and link.page then
|
||||
return link, lbox
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,14 +6,6 @@ local function enable_if_equals(configurable, option, value)
|
||||
return configurable[option] == value
|
||||
end
|
||||
|
||||
local function enable_if_greater_than(configurable, option, value)
|
||||
return configurable[option] > value
|
||||
end
|
||||
|
||||
local function enable_if_less_than(configurable, option, value)
|
||||
return configurable[option] < value
|
||||
end
|
||||
|
||||
local KoptOptions = {
|
||||
prefix = 'kopt',
|
||||
{
|
||||
|
||||
@@ -39,6 +39,7 @@ table.insert(common_settings, {
|
||||
sub_item_table = {
|
||||
require("ui/elements/screen_dpi_menu_table"),
|
||||
require("ui/elements/screen_eink_opt_menu_table"),
|
||||
require("ui/elements/screen_disable_double_tap_table"),
|
||||
require("ui/elements/refresh_menu_table"),
|
||||
},
|
||||
})
|
||||
|
||||
17
frontend/ui/elements/screen_disable_double_tap_table.lua
Normal file
17
frontend/ui/elements/screen_disable_double_tap_table.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local _ = require("gettext")
|
||||
|
||||
return {
|
||||
text = _("Disable double tap"),
|
||||
checked_func = function()
|
||||
return G_reader_settings:readSetting("disable_double_tap") ~= false
|
||||
end,
|
||||
callback = function()
|
||||
local disabled = G_reader_settings:readSetting("disable_double_tap") ~= false
|
||||
G_reader_settings:saveSetting("disable_double_tap", not disabled)
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("This will take effect on next restart."),
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -6,13 +6,13 @@ local function dpi() return G_reader_settings:readSetting("screen_dpi") end
|
||||
|
||||
local function custom() return G_reader_settings:readSetting("custom_screen_dpi") end
|
||||
|
||||
local function setDPI(dpi)
|
||||
local function setDPI(_dpi)
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local UIManager = require("ui/uimanager")
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("This will take effect on next restart."),
|
||||
})
|
||||
Screen:setDPI(dpi)
|
||||
Screen:setDPI(_dpi)
|
||||
end
|
||||
|
||||
|
||||
@@ -29,32 +29,32 @@ return {
|
||||
{
|
||||
text = _("Small"),
|
||||
checked_func = function()
|
||||
local dpi, custom = dpi(), custom()
|
||||
return dpi and dpi <= 140 and dpi ~= custom
|
||||
local _dpi, _custom = dpi(), custom()
|
||||
return _dpi and _dpi <= 140 and _dpi ~= _custom
|
||||
end,
|
||||
callback = function() setDPI(120) end
|
||||
},
|
||||
{
|
||||
text = _("Medium"),
|
||||
checked_func = function()
|
||||
local dpi, custom = dpi(), custom()
|
||||
return dpi and dpi > 140 and dpi <= 200 and dpi ~= custom
|
||||
local _dpi, _custom = dpi(), custom()
|
||||
return _dpi and _dpi > 140 and _dpi <= 200 and _dpi ~= _custom
|
||||
end,
|
||||
callback = function() setDPI(160) end
|
||||
},
|
||||
{
|
||||
text = _("Large"),
|
||||
checked_func = function()
|
||||
local dpi, custom = dpi(), custom()
|
||||
return dpi and dpi > 200 and dpi ~= custom
|
||||
local _dpi, _custom = dpi(), custom()
|
||||
return _dpi and _dpi > 200 and _dpi ~= _custom
|
||||
end,
|
||||
callback = function() setDPI(240) end
|
||||
},
|
||||
{
|
||||
text = _("Custom DPI") .. ": " .. (custom() or 160),
|
||||
checked_func = function()
|
||||
local dpi, custom = dpi(), custom()
|
||||
return custom and dpi == custom
|
||||
local _dpi, _custom = dpi(), custom()
|
||||
return _custom and _dpi == _custom
|
||||
end,
|
||||
callback = function() setDPI(custom() or 160) end,
|
||||
hold_input = {
|
||||
@@ -62,11 +62,11 @@ return {
|
||||
type = "number",
|
||||
hint = "(90 - 330)",
|
||||
callback = function(input)
|
||||
local dpi = tonumber(input)
|
||||
dpi = dpi < 90 and 90 or dpi
|
||||
dpi = dpi > 330 and 330 or dpi
|
||||
G_reader_settings:saveSetting("custom_screen_dpi", dpi)
|
||||
setDPI(dpi)
|
||||
local _dpi = tonumber(input)
|
||||
_dpi = _dpi < 90 and 90 or _dpi
|
||||
_dpi = _dpi > 330 and 330 or _dpi
|
||||
G_reader_settings:saveSetting("custom_screen_dpi", _dpi)
|
||||
setDPI(_dpi)
|
||||
end,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -168,7 +168,9 @@ function UIManager:show(widget, refreshtype, refreshregion, x, y)
|
||||
-- tell the widget that it is shown now
|
||||
widget:handleEvent(Event:new("Show"))
|
||||
-- check if this widget disables double tap gesture
|
||||
if widget.disable_double_tap then
|
||||
if widget.disable_double_tap == false then
|
||||
Input.disable_double_tap = false
|
||||
else
|
||||
Input.disable_double_tap = true
|
||||
end
|
||||
end
|
||||
@@ -184,6 +186,8 @@ function UIManager:close(widget, refreshtype, refreshregion)
|
||||
local dirty = false
|
||||
-- first send close event to widget
|
||||
widget:handleEvent(Event:new("CloseWidget"))
|
||||
-- make it enabled by default and check any widget that disable it
|
||||
Input.disable_double_tap = false
|
||||
-- then remove all reference to that widget on stack and update
|
||||
for i = #self._window_stack, 1, -1 do
|
||||
if self._window_stack[i].widget == widget then
|
||||
@@ -416,14 +420,14 @@ function UIManager:broadcastEvent(event)
|
||||
-- the widget's event handler might close widgets in which case
|
||||
-- a simple iterator like ipairs would skip over some entries
|
||||
local i = 1
|
||||
while (i <= #self._window_stack) do
|
||||
while i <= #self._window_stack do
|
||||
local prev_widget = self._window_stack[i].widget
|
||||
self._window_stack[i].widget:handleEvent(event)
|
||||
local top_widget = self._window_stack[i]
|
||||
if top_widget == nil then
|
||||
-- top widget closed itself
|
||||
break
|
||||
elseif (top_window.widget == prev_widget) then
|
||||
elseif top_widget.widget == prev_widget then
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user