Merge remote-tracking branch 'upstream/master'

pull/846/head
Michael Hall 10 years ago
commit d49153059d

@ -200,10 +200,10 @@ end
function Search:ShowSearch()
if self.metafile_1 ~= nil then
GLOBAL_INPUT_VALUE = self.search_value
local dummy = GLOBAL_INPUT_VALUE
local dummy = self.search_value
self.search_dialog = InputDialog:new{
title = _("Search Books"),
input = self.search_value,
buttons = {
{
{
@ -263,8 +263,6 @@ function Search:ShowSearch()
width = Screen:getWidth() * 0.8,
height = Screen:getHeight() * 0.2,
}
GLOBAL_INPUT_VALUE = nil
self.search_dialog:onShowKeyboard()
UIManager:show(self.search_dialog)
else
@ -543,8 +541,7 @@ function Search:onMenuHold(item)
item.notchecked = false
end
local thumbwidth = math.min(240, Screen:getWidth()/3)
local thumbheight = thumbwidth/2*3
UIManager:show(InfoMessage:new{text = item.info,image = UIToolbox:getPicture(item.path), image_width = thumbwidth,image_height = thumbheight})
UIManager:show(InfoMessage:new{text = item.info,image = UIToolbox:getPicture(item.path), image_width = thumbwidth,image_height = thumbwidth/2*3})
end
end

@ -109,7 +109,7 @@ function SetDefaults:init()
if not self.already_read then
local i = 0
for n,v in orderedPairs(_G) do
if (not string.find(tostring(v), "<")) and (not string.find(tostring(v), ": ")) and string.sub(n,1,1) ~= "_" and string.upper(n) == n and n ~= "GLOBAL_INPUT_VALUE" and n ~= "LIBRARY_PATH" then
if (not string.find(tostring(v), "<")) and (not string.find(tostring(v), ": ")) and string.sub(n,1,1) ~= "_" and string.upper(n) == n and n ~= "LIBRARY_PATH" then
i = i + 1
self.defaults_name[i] = n
self.defaults_value[i] = v
@ -146,9 +146,9 @@ function SetDefaults:init()
table.insert(self.results, {
text = self:build_setting(i),
callback = function()
GLOBAL_INPUT_VALUE = tostring(self.defaults_value[i])
self.set_dialog = InputDialog:new{
title = self.defaults_name[i] .. ":",
input = tostring(self.defaults_value[i]),
buttons = {
{
{
@ -193,7 +193,6 @@ function SetDefaults:init()
width = Screen:getWidth() * 0.95,
height = Screen:getHeight() * 0.2,
}
GLOBAL_INPUT_VALUE = nil
self.set_dialog:onShowKeyboard()
UIManager:show(self.set_dialog)
end
@ -202,9 +201,9 @@ function SetDefaults:init()
table.insert(self.results, {
text = self:build_setting(i),
callback = function()
GLOBAL_INPUT_VALUE = tostring(self.defaults_value[i])
self.set_dialog = InputDialog:new{
title = self.defaults_name[i] .. ":",
input = tostring(self.defaults_value[i]),
buttons = {
{
{
@ -239,7 +238,6 @@ function SetDefaults:init()
width = Screen:getWidth() * 0.95,
height = Screen:getHeight() * 0.2,
}
GLOBAL_INPUT_VALUE = nil
self.set_dialog:onShowKeyboard()
UIManager:show(self.set_dialog)
end

@ -59,9 +59,9 @@ end
function ReaderKoptListener:onDocLangUpdate(lang)
if lang == "chi_sim" or lang == "chi_tra" or
lang == "jpn" or lang == "kor" then
self.document.configurable.word_spacing = DKOPTREADER_CONFIG_WORD_SAPCINGS[1]
self.document.configurable.word_spacing = DKOPTREADER_CONFIG_WORD_SPACINGS[1]
else
self.document.configurable.word_spacing = DKOPTREADER_CONFIG_WORD_SAPCINGS[3]
self.document.configurable.word_spacing = DKOPTREADER_CONFIG_WORD_SPACINGS[3]
end
end

@ -1,10 +1,11 @@
local InputContainer = require("ui/widget/container/inputcontainer")
local Cache = require("cache")
local ConfirmBox = require("ui/widget/confirmbox")
local DocSettings = require("docsettings")
local UIManager = require("ui/uimanager")
local Geom = require("ui/geometry")
local Device = require("ui/device")
local DocSettings = require("docsettings")
local Event = require("ui/event")
local UIManager = require("ui/uimanager")
local Cache = require("cache")
local DEBUG = require("dbg")
local _ = require("gettext")
@ -56,8 +57,6 @@ local ReaderUI = InputContainer:new{
-- the document interface
document = nil,
-- initial page or percent inside document on opening
start_pos = nil,
-- password for document unlock
password = nil,
@ -307,14 +306,36 @@ function ReaderUI:onFlushSettings()
return true
end
function ReaderUI:closeDocument()
self.document:close()
self.document = nil
end
function ReaderUI:onCloseDocument()
if self.document:isEdited() then
UIManager:show(ConfirmBox:new{
text = _("Do you want to save this document?"),
ok_text = _("Yes"),
cancel_text = _("No"),
ok_callback = function()
self:closeDocument()
end,
cancel_callback = function()
self.document:discardChange()
self:closeDocument()
end,
})
else
self:closeDocument()
end
end
function ReaderUI:onClose()
DEBUG("closing reader")
self:saveSettings()
self:handleEvent(Event:new("CloseReader"))
if self.document ~= nil then
self.document:close()
self.document = nil
self.start_pos = nil
DEBUG("closing document")
self:onCloseDocument()
end
UIManager:close(self.dialog)
-- serialize last used items for later launch

@ -22,7 +22,7 @@ local CreDocument = Document:new{
line_space_percent = 100,
default_font = G_reader_settings:readSetting("cre_font") or "Noto Serif",
header_font = G_reader_settings:readSetting("header_font") or "Noto Sans",
fallback_font = G_reader_settings:readSetting("fallback_font") or "Droid Sans Fallback",
fallback_font = G_reader_settings:readSetting("fallback_font") or "Droid Sans Fallback H",
default_css = "./data/cr3.css",
options = CreOptions,
}

@ -51,6 +51,9 @@ local Document = {
-- flag to show that the document needs to be unlocked by a password
is_locked = false,
-- flag to show that the document is edited and needs to write back to disk
is_edited = false,
}
function Document:new(o)
@ -85,6 +88,17 @@ function Document:close()
end
end
-- check if document is edited and needs to write to disk
function Document:isEdited()
return self.is_edited
end
-- discard change will set is_edited flag to false and implematation of Document
-- should check the is_edited flag before writing document
function Document:discardChange()
self.is_edited = false
end
-- this might be overridden by a document implementation
function Document:getNativePageDimensions(pageno)
local hash = "pgdim|"..self.file.."|"..pageno

@ -4,6 +4,7 @@ local KoptOptions = require("ui/data/koptoptions")
local Document = require("document/document")
local Configurable = require("configurable")
local DrawContext = require("ffi/drawcontext")
local DEBUG = require("dbg")
local ffi = require("ffi")
ffi.cdef[[
typedef struct fz_point_s fz_point;
@ -46,7 +47,6 @@ local PdfDocument = Document:new{
dc_null = DrawContext.new(),
options = KoptOptions,
koptinterface = nil,
annot_revision = 0,
}
function PdfDocument:init()
@ -152,7 +152,7 @@ function PdfDocument:getPageLinks(pageno)
end
function PdfDocument:saveHighlight(pageno, item)
self.annot_revision = self.annot_revision + 1
self.is_edited = true
local n = #item.pboxes
local quadpoints = ffi.new("fz_point[?]", 4*n)
for i=1, n do
@ -179,11 +179,12 @@ function PdfDocument:saveHighlight(pageno, item)
end
function PdfDocument:writeDocument()
DEBUG("writing document to", self.file)
self._document:writeDocument(self.file)
end
function PdfDocument:close()
if self.annot_revision ~= 0 then
if self.is_edited then
self:writeDocument()
end
Document.close(self)

@ -83,7 +83,8 @@ function Font:_readList(target, dir, effective_dir)
self:_readList(target, dir.."/"..f, effective_dir..f.."/")
else
local file_type = string.lower(string.match(f, ".+%.([^.]+)") or "")
if file_type == "ttf" or file_type == "cff" or file_type == "otf" then
if file_type == "ttf" or file_type == "ttc"
or file_type == "cff" or file_type == "otf" then
table.insert(target, effective_dir..f)
end
end

@ -39,8 +39,9 @@ function FileChooser:genItemTableFromPath(path)
local files = {}
-- lfs.dir directory without permission will give error
if pcall(lfs.dir, self.path) then
for f in lfs.dir(self.path) do
local ok, iter, dir_obj = pcall(lfs.dir, self.path)
if ok then
for f in iter, dir_obj do
if self.show_hidden or not string.match(f, "^%.[^.]") then
local filename = self.path.."/"..f
local filemode = lfs.attributes(filename, "mode")

@ -203,11 +203,6 @@ function VirtualKeyboard:init()
}
}
self:initLayout(self.layout)
if GLOBAL_INPUT_VALUE then
for i = 1, string.len(GLOBAL_INPUT_VALUE) do
self:addChar(string.sub(GLOBAL_INPUT_VALUE,i,i))
end
end
end
function VirtualKeyboard:initLayout(layout)

Loading…
Cancel
Save