add last read page/percent setting support

This commit is contained in:
Qingping Hou
2012-06-27 01:00:21 +08:00
parent 59592e862e
commit 1c216b6458
2 changed files with 22 additions and 4 deletions

View File

@@ -31,10 +31,6 @@ function ReaderRolling:init()
self.old_doc_height = self.doc_height
end
function ReaderRolling:onPosUpdate(new_pos)
self.current_pos = new_pos
end
function ReaderRolling:gotoPos(new_pos)
if new_pos == self.current_pos then return end
if new_pos < 0 then new_pos = 0 end
@@ -46,6 +42,14 @@ function ReaderRolling:gotoPercent(new_percent)
self:gotoPos(new_percent * self.doc_height / 10000)
end
function ReaderRolling:onReadSettings(config)
self:gotoPercent(config:readSetting("last_percent") or 0)
end
function ReaderRolling:onPosUpdate(new_pos)
self.current_pos = new_pos
end
-- remember to signal this event the document has been zoomed,
-- font has been changed, or line height has been changed.
function ReaderRolling:onUpdatePos()
@@ -84,3 +88,8 @@ function ReaderRolling:onZoom()
--@TODO re-read doc_height info after font or lineheight changes 05.06 2012 (houqp)
self:onUpdatePos()
end
function ReaderRolling:onCloseDocument()
self.ui.doc_settings:saveSetting("last_percent",
10000 * self.current_pos / self.doc_height)
end