mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #430 from chrox/master
save page margins for credocument
This commit is contained in:
@@ -78,13 +78,14 @@ DKOPTREADER_CONFIG_DOC_DEFAULT_LANG_CODE = "eng" -- that have filenames start
|
||||
|
||||
-- crereader font sizes
|
||||
-- feel free to add more entries in this list
|
||||
DCREREADER_CONFIG_FONT_SIZES = {16, 20, 22, 24, 28, 32, 38, 44} -- range from 16 to 44
|
||||
DCREREADER_CONFIG_FONT_SIZES = {16, 20, 22, 24, 26, 28, 30, 34, 38, 44} -- option range from 16 to 44
|
||||
DCREREADER_CONFIG_DEFAULT_FONT_SIZE = 22 -- default font size
|
||||
|
||||
-- crereader margin sizes
|
||||
-- margin {left, top, right, bottom} in pixels
|
||||
DCREREADER_CONFIG_MARGIN_SIZES_SMALL = {5, 5, 5, 5}
|
||||
DCREREADER_CONFIG_MARGIN_SIZES_MEDIUM = {15, 10, 15, 10}
|
||||
DCREREADER_CONFIG_MARGIN_SIZES_LARGE = {25, 10, 25, 10}
|
||||
DCREREADER_CONFIG_MARGIN_SIZES_SMALL = {15, 5, 15, 5}
|
||||
DCREREADER_CONFIG_MARGIN_SIZES_MEDIUM = {22, 10, 22, 10}
|
||||
DCREREADER_CONFIG_MARGIN_SIZES_LARGE = {30, 10, 30, 10}
|
||||
|
||||
-- gesture detector defaults
|
||||
DGESDETECT_DISABLE_DOUBLE_TAP = true
|
||||
|
||||
@@ -174,6 +174,7 @@ function CreDocument:renderPage(pageno, rect, zoom, rotation)
|
||||
end
|
||||
|
||||
function CreDocument:gotoXPointer(xpointer)
|
||||
DEBUG("CreDocument: goto xpointer", xpointer)
|
||||
self._document:gotoXPointer(xpointer)
|
||||
end
|
||||
|
||||
@@ -198,10 +199,12 @@ function CreDocument:getCurrentPos()
|
||||
end
|
||||
|
||||
function Document:gotoPos(pos)
|
||||
DEBUG("CreDocument: goto position", pos)
|
||||
self._document:gotoPos(pos)
|
||||
end
|
||||
|
||||
function CreDocument:gotoPage(page)
|
||||
DEBUG("CreDocument: goto page", page)
|
||||
self._document:gotoPage(page)
|
||||
end
|
||||
|
||||
@@ -211,6 +214,7 @@ end
|
||||
|
||||
function CreDocument:setFontFace(new_font_face)
|
||||
if new_font_face then
|
||||
DEBUG("CreDocument: set font face", new_font_face)
|
||||
self._document:setFontFace(new_font_face)
|
||||
end
|
||||
end
|
||||
@@ -221,12 +225,14 @@ end
|
||||
|
||||
function CreDocument:setFontSize(new_font_size)
|
||||
if new_font_size then
|
||||
DEBUG("CreDocument: set font size", new_font_size)
|
||||
self._document:setFontSize(new_font_size)
|
||||
end
|
||||
end
|
||||
|
||||
function CreDocument:setViewMode(new_mode)
|
||||
if new_mode then
|
||||
DEBUG("CreDocument: set view mode", new_mode)
|
||||
if new_mode == "scroll" then
|
||||
self._document:setViewMode(self.SCROLL_VIEW_MODE)
|
||||
else
|
||||
@@ -237,47 +243,53 @@ end
|
||||
|
||||
function CreDocument:setHeaderFont(new_font)
|
||||
if new_font then
|
||||
DEBUG("CreDocument: set header font", new_font)
|
||||
self._document:setHeaderFont(new_font)
|
||||
end
|
||||
end
|
||||
|
||||
function CreDocument:zoomFont(delta)
|
||||
DEBUG("CreDocument: zoom font", delta)
|
||||
self._document:zoomFont(delta)
|
||||
end
|
||||
|
||||
function CreDocument:setInterlineSpacePercent(percent)
|
||||
DEBUG("CreDocument: set interline space", percent)
|
||||
self._document:setDefaultInterlineSpace(percent)
|
||||
end
|
||||
|
||||
function CreDocument:toggleFontBolder()
|
||||
DEBUG("CreDocument: toggle font bolder")
|
||||
self._document:toggleFontBolder()
|
||||
end
|
||||
|
||||
function CreDocument:setGammaIndex(index)
|
||||
DEBUG("CreDocument: set gamma index", index)
|
||||
cre.setGammaIndex(index)
|
||||
end
|
||||
|
||||
function CreDocument:setStyleSheet(new_css)
|
||||
DEBUG("CreDocument: set style sheet", new_css)
|
||||
self._document:setStyleSheet(new_css)
|
||||
end
|
||||
|
||||
function CreDocument:setEmbeddedStyleSheet(toggle)
|
||||
DEBUG("CreDocument: set embedded style sheet", toggle)
|
||||
self._document:setEmbeddedStyleSheet(toggle)
|
||||
end
|
||||
|
||||
function CreDocument:setPageMargins(left, top, right, bottom)
|
||||
DEBUG("CreDocument: set page margins", left, top, right, bottom)
|
||||
self._document:setPageMargins(left, top, right, bottom)
|
||||
self._document:setIntProperty("crengine.page.margin.left", left)
|
||||
self._document:setIntProperty("crengine.page.margin.top", top)
|
||||
self._document:setIntProperty("crengine.page.margin.right", right)
|
||||
self._document:setIntProperty("crengine.page.margin.bottom", bottom)
|
||||
end
|
||||
|
||||
function CreDocument:setFloatingPunctuation(enabled)
|
||||
DEBUG("CreDocument: set floating punctuation", enabled)
|
||||
self._document:setIntProperty("crengine.style.floating.punctuation.enabled", enabled)
|
||||
end
|
||||
|
||||
function CreDocument:setVisiblePageCount(new_count)
|
||||
DEBUG("CreDocument: set visible page count", new_count)
|
||||
self._document:setVisiblePageCount(new_count)
|
||||
end
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ local CreOptions = {
|
||||
spacing = 15,
|
||||
item_font_size = DCREREADER_CONFIG_FONT_SIZES,
|
||||
values = DCREREADER_CONFIG_FONT_SIZES,
|
||||
default_value = 22,
|
||||
default_value = DCREREADER_CONFIG_DEFAULT_FONT_SIZE,
|
||||
args = DCREREADER_CONFIG_FONT_SIZES,
|
||||
event = "SetFontSize",
|
||||
},
|
||||
|
||||
@@ -22,13 +22,12 @@ function ReaderCoptListener:onReadSettings(config)
|
||||
end
|
||||
|
||||
local copt_margins = config:readSetting("copt_page_margins")
|
||||
if copt_margins then
|
||||
table.insert(self.ui.postInitCallback, function()
|
||||
-- FIXME: SetPageMargins will mess up current reading position
|
||||
-- for now we simply disable this feature.
|
||||
--self.ui:handleEvent(Event:new("SetPageMargins", copt_margins))
|
||||
end)
|
||||
if copt_margins == nil then
|
||||
copt_margins = DCREREADER_CONFIG_MARGIN_SIZES_MEDIUM
|
||||
end
|
||||
table.insert(self.ui.postInitCallback, function()
|
||||
self.ui:handleEvent(Event:new("SetPageMargins", copt_margins))
|
||||
end)
|
||||
end
|
||||
|
||||
return ReaderCoptListener
|
||||
|
||||
@@ -79,7 +79,7 @@ function ReaderFont:onReadSettings(config)
|
||||
self.font_size = config:readSetting("font_size")
|
||||
if not self.font_size then
|
||||
--@TODO change this! 12.01 2013 (houqp)
|
||||
self.font_size = 29
|
||||
self.font_size = DCREREADER_CONFIG_DEFAULT_FONT_SIZE
|
||||
end
|
||||
self.ui.document:setFontSize(Screen:scaleByDPI(self.font_size))
|
||||
|
||||
|
||||
@@ -146,8 +146,9 @@ function ReaderUI:init()
|
||||
ui = self
|
||||
})
|
||||
end
|
||||
-- config panel controller
|
||||
-- configuable controller
|
||||
if self.document.info.configurable then
|
||||
-- config panel controller
|
||||
local config_dialog = ReaderConfig:new{
|
||||
configurable = self.document.configurable,
|
||||
options = self.document.options,
|
||||
@@ -156,6 +157,14 @@ function ReaderUI:init()
|
||||
ui = self
|
||||
}
|
||||
table.insert(self, config_dialog)
|
||||
-- cre option controller
|
||||
local coptlistener = ReaderCoptListener:new{
|
||||
dialog = self.dialog,
|
||||
view = self[1],
|
||||
ui = self,
|
||||
document = self.document,
|
||||
}
|
||||
table.insert(self, coptlistener)
|
||||
end
|
||||
-- for page specific controller
|
||||
if self.document.info.has_pages then
|
||||
@@ -205,20 +214,6 @@ function ReaderUI:init()
|
||||
table.insert(self.postInitCallback, function()
|
||||
self.document:loadDocument()
|
||||
end)
|
||||
-- rolling controller
|
||||
local roller = ReaderRolling:new{
|
||||
dialog = self.dialog,
|
||||
view = self[1],
|
||||
ui = self
|
||||
}
|
||||
table.insert(self, roller)
|
||||
-- font menu
|
||||
local font_menu = ReaderFont:new{
|
||||
dialog = self.dialog,
|
||||
view = self[1],
|
||||
ui = self
|
||||
}
|
||||
table.insert(self, font_menu)
|
||||
-- typeset controller
|
||||
local typeset = ReaderTypeset:new{
|
||||
dialog = self.dialog,
|
||||
@@ -226,13 +221,27 @@ function ReaderUI:init()
|
||||
ui = self
|
||||
}
|
||||
table.insert(self, typeset)
|
||||
|
||||
-- font menu
|
||||
local font_menu = ReaderFont:new{
|
||||
dialog = self.dialog,
|
||||
view = self[1],
|
||||
ui = self
|
||||
}
|
||||
table.insert(self, font_menu)
|
||||
table.insert(self, ReaderHyphenation:new{
|
||||
dialog = self.dialog,
|
||||
view = self[1],
|
||||
ui = self
|
||||
})
|
||||
-- rolling controller
|
||||
local roller = ReaderRolling:new{
|
||||
dialog = self.dialog,
|
||||
view = self[1],
|
||||
ui = self
|
||||
}
|
||||
table.insert(self, roller)
|
||||
end
|
||||
-- configuable controller
|
||||
if self.document.info.configurable then
|
||||
-- kopt option controller
|
||||
local koptlistener = ReaderKoptListener:new{
|
||||
@@ -242,14 +251,6 @@ function ReaderUI:init()
|
||||
document = self.document,
|
||||
}
|
||||
table.insert(self, koptlistener)
|
||||
-- cre option controller
|
||||
local coptlistener = ReaderCoptListener:new{
|
||||
dialog = self.dialog,
|
||||
view = self[1],
|
||||
ui = self,
|
||||
document = self.document,
|
||||
}
|
||||
table.insert(self, coptlistener)
|
||||
-- activity indicator
|
||||
local activity_listener = ReaderActivityIndicator:new{
|
||||
dialog = self.dialog,
|
||||
|
||||
Reference in New Issue
Block a user