mirror of
https://github.com/koreader/koreader
synced 2024-10-31 21:20:20 +00:00
Alt-R to switch between STANDARD and KOPTReader
Currently it closes the file and drops you back to the filemanager, so you have to re-open it manually.
This commit is contained in:
parent
1be32e99a9
commit
e97770d8ae
@ -1,7 +1,6 @@
|
||||
-- List of acceptable extensions
|
||||
|
||||
ext = {
|
||||
koptRead = ";djvu;pdf;",
|
||||
djvuRead = ";djvu;",
|
||||
pdfRead = ";pdf;xps;cbz;",
|
||||
creRead = ";epub;txt;rtf;htm;html;mobi;prc;azw;fb2;chm;pdb;doc;tcr;zip;",
|
||||
@ -10,17 +9,22 @@ ext = {
|
||||
}
|
||||
|
||||
|
||||
function ext:getReader(ftype)
|
||||
function ext:getReader(ftype, oldreader)
|
||||
local s = ";"
|
||||
if ftype == "" then
|
||||
return nil
|
||||
-- for testing use koptreader for djvu/pdf files by default
|
||||
elseif string.find(self.koptRead,s..ftype..s) then
|
||||
return KOPTReader
|
||||
elseif string.find(self.pdfRead,s..ftype..s) then
|
||||
return PDFReader
|
||||
if oldreader and oldreader.use_koptreader == true then
|
||||
return KOPTReader
|
||||
else
|
||||
return PDFReader
|
||||
end
|
||||
elseif string.find(self.djvuRead,s..ftype..s) then
|
||||
return DJVUReader
|
||||
if oldreader and oldreader.use_koptreader then
|
||||
return KOPTReader
|
||||
else
|
||||
return DJVUReader
|
||||
end
|
||||
elseif string.find(self.picRead,s..ftype..s) then
|
||||
return PICViewer
|
||||
elseif FileChooser.filemanager_expert_mode > FileChooser.BEGINNERS_MODE
|
||||
|
@ -46,6 +46,9 @@ function openFile(filename)
|
||||
if reader then
|
||||
InfoMessage:inform("Opening document... ", nil, 0, MSG_AUX)
|
||||
reader:preLoadSettings(filename)
|
||||
-- re-establish the reader due to use_koptreader setting
|
||||
reader = ext:getReader(file_type, reader)
|
||||
reader:preLoadSettings(filename)
|
||||
local ok, err = reader:open(filename)
|
||||
if ok then
|
||||
reader:loadSettings(filename)
|
||||
|
@ -68,6 +68,7 @@ UniReader = {
|
||||
show_overlap = 0,
|
||||
show_overlap_enable,
|
||||
show_links_enable,
|
||||
use_koptreader,
|
||||
|
||||
-- the document:
|
||||
doc = nil,
|
||||
@ -949,6 +950,12 @@ end
|
||||
function UniReader:preLoadSettings(filename)
|
||||
self.settings = DocSettings:open(filename)
|
||||
self.cache_document_size = self.settings:readSetting("cache_document_size") or self.cache_document_size
|
||||
|
||||
local tmp = self.settings:readSetting("use_koptreader")
|
||||
if tmp ~= nil then
|
||||
self.use_koptreader = tmp
|
||||
print("set use_koptreader=", self.use_koptreader)
|
||||
end
|
||||
end
|
||||
|
||||
-- all defaults which can be overriden by reader objects
|
||||
@ -956,6 +963,7 @@ end
|
||||
function UniReader:setDefaults()
|
||||
self.show_overlap_enable = true
|
||||
self.show_links_enable = true
|
||||
self.use_koptreader = false
|
||||
end
|
||||
|
||||
-- This is a low-level method that can be shared with all readers.
|
||||
@ -2621,6 +2629,21 @@ function UniReader:addAllCommands()
|
||||
self:redrawCurrentPage()
|
||||
end)
|
||||
|
||||
self.commands:add(KEY_R, MOD_ALT, "R",
|
||||
"toggle between standard and koptreader",
|
||||
function(unireader)
|
||||
unireader.use_koptreader = not unireader.use_koptreader
|
||||
if unireader.use_koptreader then
|
||||
InfoMessage:inform("Switching to KOPTReader", 1000, 1, MSG_AUX)
|
||||
else
|
||||
InfoMessage:inform("Switching to STANDARD Reader", 1000, 1, MSG_AUX)
|
||||
end
|
||||
self.settings:saveSetting("use_koptreader", unireader.use_koptreader)
|
||||
self.doc:close()
|
||||
self.doc = nil
|
||||
return "break"
|
||||
end)
|
||||
|
||||
self.commands:add(KEY_R, MOD_SHIFT, "R",
|
||||
"set full screen refresh count",
|
||||
function(unireader)
|
||||
|
Loading…
Reference in New Issue
Block a user