|
|
|
@ -26,24 +26,11 @@ function ReaderTypeset:onReadSettings(config)
|
|
|
|
|
-- default to enable embedded css
|
|
|
|
|
self.embedded_css = config:readSetting("embedded_css") or true
|
|
|
|
|
self.ui.document:setEmbeddedStyleSheet(self.embedded_css and 1 or 0)
|
|
|
|
|
|
|
|
|
|
-- default to enable floating punctuation
|
|
|
|
|
self.floating_punctuation = config:readSetting("floating_punctuation") or 1
|
|
|
|
|
self.ui.document:setFloatingPunctuation(self.floating_punctuation)
|
|
|
|
|
self:_setPageMargins()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderTypeset:_setPageMargins()
|
|
|
|
|
local copt_margins = self.ui.document.configurable.page_margins or
|
|
|
|
|
self.ui.doc_settings:readSetting("copt_page_margins") or
|
|
|
|
|
DCREREADER_CONFIG_MARGIN_SIZES_MEDIUM
|
|
|
|
|
self.ui:handleEvent(Event:new("SetPageMargins", copt_margins))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderTypeset:onSaveSettings()
|
|
|
|
|
self.ui.doc_settings:saveSetting("css", self.css)
|
|
|
|
|
self.ui.doc_settings:saveSetting("embedded_css", self.embedded_css)
|
|
|
|
|
self.ui.doc_settings:saveSetting("floating_punctuation", self.floating_punctuation)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderTypeset:onToggleEmbeddedStyleSheet(toggle)
|
|
|
|
@ -114,31 +101,12 @@ function ReaderTypeset:toggleEmbeddedStyleSheet(toggle)
|
|
|
|
|
self.ui:handleEvent(Event:new("UpdatePos"))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderTypeset:toggleFloatingPunctuation()
|
|
|
|
|
self.floating_punctuation = self.floating_punctuation == 0 and 1 or 0
|
|
|
|
|
self.ui.document:setFloatingPunctuation(self.floating_punctuation)
|
|
|
|
|
--self.ui:handleEvent(Event:new("UpdatePos"))
|
|
|
|
|
-- workaround: set again things unset by crengine after changing floating punctuation
|
|
|
|
|
self.ui.document:setFontFace(self.ui.font.font_face)
|
|
|
|
|
self.ui.document:setInterlineSpacePercent(self.ui.font.line_space_percent)
|
|
|
|
|
cre.setHyphDictionary(self.ui.hyphenation.hyph_alg)
|
|
|
|
|
self:_setPageMargins()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderTypeset:addToMainMenu(tab_item_table)
|
|
|
|
|
-- insert table to main reader menu
|
|
|
|
|
table.insert(tab_item_table.typeset, {
|
|
|
|
|
text = self.css_menu_title,
|
|
|
|
|
sub_item_table = self:genStyleSheetMenu(),
|
|
|
|
|
})
|
|
|
|
|
table.insert(tab_item_table.typeset, {
|
|
|
|
|
text_func = function()
|
|
|
|
|
return self.floating_punctuation == 1 and
|
|
|
|
|
_("Turn off floating punctuation") or
|
|
|
|
|
_("Turn on floating punctuation")
|
|
|
|
|
end,
|
|
|
|
|
callback = function () self:toggleFloatingPunctuation() end,
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return ReaderTypeset
|
|
|
|
|