diff --git a/frontend/settings.lua b/frontend/settings.lua index 757b14b3a..638484488 100644 --- a/frontend/settings.lua +++ b/frontend/settings.lua @@ -1,8 +1,36 @@ DocSettings = {} +function DocSettings:getHistoryPath(fullpath) + local i = #fullpath - 1 + -- search for last slash + while i > 0 do + if fullpath:sub(i,i) == "/" then + break + end + i = i - 1 + end + -- construct path to configuration file in history dir + local filename = fullpath:sub(i+1, -1) + local basename = fullpath:sub(1, i) + return "./history/["..basename:gsub("/","#").."] "..filename..".lua" +end + function DocSettings:open(docfile) - local new = { file = docfile..".kpdfview.lua", data = {} } - local ok, stored = pcall(dofile,new.file) + local conf_path = nil + if docfile == ".reader" then + -- we handle reader setting as special case + conf_path = "settings.reader.lua" + else + conf_path = self:getHistoryPath(docfile) + end + -- construct settings obj + local new = { file = conf_path, data = {} } + local ok, stored = pcall(dofile, new.file) + if not ok then + -- try legacy conf path, for backward compatibility. this also + -- takes care of reader legacy setting + ok, stored = pcall(dofile, docfile..".kpdfview.lua") + end if ok then new.data = stored end diff --git a/frontend/ui/filechooser.lua b/frontend/ui/filechooser.lua index dbfbf044f..8be30e3cb 100644 --- a/frontend/ui/filechooser.lua +++ b/frontend/ui/filechooser.lua @@ -3,7 +3,7 @@ require "ui/menu" FileChooser = Menu:new{ height = Screen:getHeight(), width = Screen:getWidth(), - path = ".", + path = lfs.currentdir(), parent = nil, show_hidden = false, filter = function(filename) return true end,