From 888802f618b3f083c176dd56c32cbcca23f4f03b Mon Sep 17 00:00:00 2001 From: yparitcher Date: Thu, 30 Sep 2021 22:30:18 -0400 Subject: [PATCH] kopt: allow pdf auto straighten --- frontend/document/koptinterface.lua | 6 +++--- frontend/ui/data/koptoptions.lua | 17 +++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/frontend/document/koptinterface.lua b/frontend/document/koptinterface.lua index c15ea7e4e..c3a3b64bd 100644 --- a/frontend/document/koptinterface.lua +++ b/frontend/document/koptinterface.lua @@ -334,7 +334,7 @@ end function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, gamma, render_mode, hinting) if doc.configurable.text_wrap == 1 then return self:renderReflowedPage(doc, pageno, rect, zoom, rotation, render_mode, hinting) - elseif doc.configurable.page_opt == 1 then + elseif doc.configurable.page_opt == 1 or doc.configurable.auto_straighten > 0 then return self:renderOptimizedPage(doc, pageno, rect, zoom, rotation, render_mode, hinting) else return Document.renderPage(doc, pageno, rect, zoom, rotation, gamma, render_mode, hinting) @@ -439,7 +439,7 @@ function KoptInterface:hintPage(doc, pageno, zoom, rotation, gamma, render_mode) if doc.configurable.text_wrap == 1 then self:hintReflowedPage(doc, pageno, zoom, rotation, gamma, render_mode, true) - elseif doc.configurable.page_opt == 1 then + elseif doc.configurable.page_opt == 1 or doc.configurable.auto_straighten > 0 then self:renderOptimizedPage(doc, pageno, nil, zoom, rotation, gamma, render_mode, true) else Document.hintPage(doc, pageno, zoom, rotation, gamma, render_mode) @@ -487,7 +487,7 @@ end function KoptInterface:drawPage(doc, target, x, y, rect, pageno, zoom, rotation, gamma, render_mode) if doc.configurable.text_wrap == 1 then self:drawContextPage(doc, target, x, y, rect, pageno, zoom, rotation, render_mode) - elseif doc.configurable.page_opt == 1 then + elseif doc.configurable.page_opt == 1 or doc.configurable.auto_straighten > 0 then self:drawContextPage(doc, target, x, y, rect, pageno, zoom, rotation, render_mode) else Document.drawPage(doc, target, x, y, rect, pageno, zoom, rotation, gamma, render_mode) diff --git a/frontend/ui/data/koptoptions.lua b/frontend/ui/data/koptoptions.lua index 1b351fef6..2bc95694b 100644 --- a/frontend/ui/data/koptoptions.lua +++ b/frontend/ui/data/koptoptions.lua @@ -123,7 +123,7 @@ In 'semi-auto' and 'manual' modes, you may need to define areas once on an odd p return optionsutil.enableIfEquals(configurable, "text_wrap", 0) end, buttonprogress = true, - fine_tune = true, + more_options = true, values = {0, 12, 24, 36, 48, 60, 72, 84}, default_pos = 4, default_value = 36, @@ -145,7 +145,7 @@ In 'semi-auto' and 'manual' modes, you may need to define areas once on an odd p return optionsutil.enableIfEquals(configurable, "text_wrap", 0) end, buttonprogress = true, - fine_tune = true, + more_options = true, values = {0, 12, 24, 36, 48, 60, 72, 84}, default_pos = 4, default_value = 36, @@ -569,14 +569,15 @@ This can also be used to remove some gray background or to convert a grayscale o { name = "auto_straighten", name_text = _("Auto Straighten"), - toggle = {_("0 deg"), _("5 deg"), _("10 deg")}, - values = {0, 5, 10}, + toggle = {_("0°"), _("5°"), _("10°"), _("15°"), _("25°")}, + values = {0, 5, 10, 15, 25}, + event = "DummyEvent", + args = {0, 5, 10, 15, 25}, + more_options = true, default_value = DKOPTREADER_CONFIG_AUTO_STRAIGHTEN, - show = false, -- does not work (and slows rendering) - enabled_func = function(configurable) - return optionsutil.enableIfEquals(configurable, "text_wrap", 1) - end, name_text_hold_callback = optionsutil.showValues, + help_text = _([[Attempt to automatically straighten tilted source pages. +Will rotate up to specified value.]]), }, { name = "detect_indent",