FileManager: tell plugins to save settings on close (#5872)

So that Statistics settings modified while in FileManager
are saved.
Also allows resetting statistics when in FileManager
(where there is no current book id to exclude).
reviewable/pr5874/r1
poire-z 4 years ago committed by GitHub
parent 95d18fe8d9
commit c2a5d3f3f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -664,6 +664,7 @@ end
function FileManager:onClose()
logger.dbg("close filemanager")
self:handleEvent(Event:new("SaveSettings"))
G_reader_settings:flush()
UIManager:close(self)
if self.onExit then

@ -972,9 +972,11 @@ function ReaderDictionary:onReadSettings(config)
end
function ReaderDictionary:onSaveSettings()
logger.dbg("save default dictionary", self.default_dictionary)
self.ui.doc_settings:saveSetting("default_dictionary", self.default_dictionary)
self.ui.doc_settings:saveSetting("disable_fuzzy_search", self.disable_fuzzy_search)
if self.ui.doc_settings then
logger.dbg("save default dictionary", self.default_dictionary)
self.ui.doc_settings:saveSetting("default_dictionary", self.default_dictionary)
self.ui.doc_settings:saveSetting("disable_fuzzy_search", self.disable_fuzzy_search)
end
end
function ReaderDictionary:toggleFuzzyDefault()

@ -1808,6 +1808,9 @@ function ReaderStatistics:deleteBooksByTotalDuration(max_total_duration_mn)
max_total_duration_mn), max_total_duration_mn),
ok_text = _("Remove"),
ok_callback = function()
-- Allow following SQL statements to work even when doc less by
-- using -1 as the book id, as real book ids are positive.
local id_curr_book = self.id_curr_book or -1
local conn = SQ3.open(db_location)
local sql_stmt = [[
DELETE from page_stat
@ -1816,13 +1819,13 @@ function ReaderStatistics:deleteBooksByTotalDuration(max_total_duration_mn)
)
]]
local stmt = conn:prepare(sql_stmt)
stmt:reset():bind(self.id_curr_book, max_total_duration_sec):step()
stmt:reset():bind(id_curr_book, max_total_duration_sec):step()
sql_stmt = [[
DELETE from book
WHERE id != ? and (total_read_time is NULL or total_read_time < ?)
]]
stmt = conn:prepare(sql_stmt)
stmt:reset():bind(self.id_curr_book, max_total_duration_sec):step()
stmt:reset():bind(id_curr_book, max_total_duration_sec):step()
stmt:close()
-- Get nb of deleted books
sql_stmt = [[

Loading…
Cancel
Save