|
|
|
@ -19,7 +19,7 @@ function ReaderTypeset:init()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderTypeset:onReadSettings(config)
|
|
|
|
|
self.css = config:readSetting("css")
|
|
|
|
|
self.css = config:readSetting("css") or G_reader_settings:readSetting("copt_css")
|
|
|
|
|
if self.css then
|
|
|
|
|
self.ui.document:setStyleSheet(self.css)
|
|
|
|
|
else
|
|
|
|
@ -65,31 +65,37 @@ function ReaderTypeset:onToggleEmbeddedStyleSheet(toggle)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderTypeset:genStyleSheetMenu()
|
|
|
|
|
local style_table = {}
|
|
|
|
|
local file_list = {
|
|
|
|
|
{
|
|
|
|
|
text = _("clear all external styles"),
|
|
|
|
|
callback = function()
|
|
|
|
|
self:setStyleSheet("")
|
|
|
|
|
end
|
|
|
|
|
css = ""
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text = _("Auto"),
|
|
|
|
|
callback = function()
|
|
|
|
|
self:setStyleSheet(self.ui.document.default_css)
|
|
|
|
|
end
|
|
|
|
|
css = self.ui.document.default_css
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
for f in lfs.dir("./data") do
|
|
|
|
|
if lfs.attributes("./data/"..f, "mode") == "file" and string.match(f, "%.css$") then
|
|
|
|
|
table.insert(file_list, {
|
|
|
|
|
text = f,
|
|
|
|
|
callback = function()
|
|
|
|
|
self:setStyleSheet("./data/"..f)
|
|
|
|
|
end
|
|
|
|
|
css = "./data/"..f
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return file_list
|
|
|
|
|
for i,file in ipairs(file_list) do
|
|
|
|
|
table.insert(style_table, {
|
|
|
|
|
text = file["text"],
|
|
|
|
|
callback = function()
|
|
|
|
|
self:setStyleSheet(file["css"])
|
|
|
|
|
end,
|
|
|
|
|
hold_callback = function()
|
|
|
|
|
self:makeDefaultStyleSheet(file["css"], file["text"])
|
|
|
|
|
end
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
return style_table
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderTypeset:setStyleSheet(new_css)
|
|
|
|
@ -166,6 +172,18 @@ function ReaderTypeset:makeDefaultFloatingPunctuation()
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderTypeset:makeDefaultStyleSheet(css, text)
|
|
|
|
|
text = text or css
|
|
|
|
|
if css then
|
|
|
|
|
UIManager:show(ConfirmBox:new{
|
|
|
|
|
text = T( _("Set default style to %1?"), text),
|
|
|
|
|
ok_callback = function()
|
|
|
|
|
G_reader_settings:saveSetting("copt_css", css)
|
|
|
|
|
end,
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderTypeset:onSetPageMargins(margins)
|
|
|
|
|
local left = Screen:scaleBySize(margins[1])
|
|
|
|
|
local top = Screen:scaleBySize(margins[2])
|
|
|
|
|