mirror of
https://github.com/koreader/koreader.git
synced 2025-12-18 12:02:09 +01:00
defaults(refactor): remove global hack in filemanagersetdefaults
also added screensaver folder setting dialog for kobo
This commit is contained in:
@@ -157,7 +157,6 @@ function FileManager:init()
|
|||||||
callback = function()
|
callback = function()
|
||||||
renameFile(file)
|
renameFile(file)
|
||||||
self:refreshPath()
|
self:refreshPath()
|
||||||
fileManager.rename_dialog:onClose()
|
|
||||||
UIManager:close(fileManager.rename_dialog)
|
UIManager:close(fileManager.rename_dialog)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
@@ -165,13 +164,10 @@ function FileManager:init()
|
|||||||
text = _("Cancel"),
|
text = _("Cancel"),
|
||||||
enabled = true,
|
enabled = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
fileManager.rename_dialog:onClose()
|
|
||||||
UIManager:close(fileManager.rename_dialog)
|
UIManager:close(fileManager.rename_dialog)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
width = Screen:getWidth() * 0.8,
|
|
||||||
height = Screen:getHeight() * 0.2,
|
|
||||||
}
|
}
|
||||||
fileManager.rename_dialog:onShowKeyboard()
|
fileManager.rename_dialog:onShowKeyboard()
|
||||||
UIManager:show(fileManager.rename_dialog)
|
UIManager:show(fileManager.rename_dialog)
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ end
|
|||||||
|
|
||||||
function FileSearcher:close()
|
function FileSearcher:close()
|
||||||
if self.search_value then
|
if self.search_value then
|
||||||
self.search_dialog:onClose()
|
|
||||||
UIManager:close(self.search_dialog)
|
UIManager:close(self.search_dialog)
|
||||||
if string.len(self.search_value) > 0 then
|
if string.len(self.search_value) > 0 then
|
||||||
self:readDir() -- TODO this probably doesn't need to be repeated once it's been done
|
self:readDir() -- TODO this probably doesn't need to be repeated once it's been done
|
||||||
@@ -131,8 +130,6 @@ function FileSearcher:showSearch()
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
width = Screen:getWidth() * 0.8,
|
|
||||||
height = Screen:getHeight() * 0.2,
|
|
||||||
}
|
}
|
||||||
self.search_dialog:onShowKeyboard()
|
self.search_dialog:onShowKeyboard()
|
||||||
UIManager:show(self.search_dialog)
|
UIManager:show(self.search_dialog)
|
||||||
|
|||||||
@@ -2,10 +2,11 @@ local CenterContainer = require("ui/widget/container/centercontainer")
|
|||||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||||
local ConfirmBox = require("ui/widget/confirmbox")
|
local ConfirmBox = require("ui/widget/confirmbox")
|
||||||
local UIManager = require("ui/uimanager")
|
local UIManager = require("ui/uimanager")
|
||||||
local Device = require("device")
|
|
||||||
local GestureRange = require("ui/gesturerange")
|
local GestureRange = require("ui/gesturerange")
|
||||||
|
local InputDialog = require("ui/widget/inputdialog")
|
||||||
local Geom = require("ui/geometry")
|
local Geom = require("ui/geometry")
|
||||||
local Screen = require("device").screen
|
local Device = require("device")
|
||||||
|
local Screen = Device.screen
|
||||||
local DEBUG = require("dbg")
|
local DEBUG = require("dbg")
|
||||||
local _ = require("gettext")
|
local _ = require("gettext")
|
||||||
local FileSearcher = require("apps/filemanager/filemanagerfilesearcher")
|
local FileSearcher = require("apps/filemanager/filemanagerfilesearcher")
|
||||||
@@ -14,7 +15,7 @@ local SetDefaults = require("apps/filemanager/filemanagersetdefaults")
|
|||||||
|
|
||||||
local FileManagerMenu = InputContainer:extend{
|
local FileManagerMenu = InputContainer:extend{
|
||||||
tab_item_table = nil,
|
tab_item_table = nil,
|
||||||
registered_widgets = {},
|
registered_widgets = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
function FileManagerMenu:init()
|
function FileManagerMenu:init()
|
||||||
@@ -93,8 +94,12 @@ function FileManagerMenu:setUpdateItemTable()
|
|||||||
})
|
})
|
||||||
table.insert(self.tab_item_table.setting, {
|
table.insert(self.tab_item_table.setting, {
|
||||||
text = _("Start with last opened file"),
|
text = _("Start with last opened file"),
|
||||||
checked_func = function() return G_reader_settings:readSetting("open_last") end,
|
checked_func = function() return
|
||||||
enabled_func = function() return G_reader_settings:readSetting("lastfile") ~= nil end,
|
G_reader_settings:readSetting("open_last")
|
||||||
|
end,
|
||||||
|
enabled_func = function() return
|
||||||
|
G_reader_settings:readSetting("lastfile") ~= nil
|
||||||
|
end,
|
||||||
callback = function()
|
callback = function()
|
||||||
local open_last = G_reader_settings:readSetting("open_last") or false
|
local open_last = G_reader_settings:readSetting("open_last") or false
|
||||||
G_reader_settings:saveSetting("open_last", not open_last)
|
G_reader_settings:saveSetting("open_last", not open_last)
|
||||||
@@ -112,6 +117,43 @@ function FileManagerMenu:setUpdateItemTable()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- tools tab
|
-- tools tab
|
||||||
|
if Device.isKobo() then
|
||||||
|
table.insert(self.tab_item_table.tools, {
|
||||||
|
text = _("Screen server folder"),
|
||||||
|
callback = function()
|
||||||
|
local ss_folder_path_input
|
||||||
|
local function save_folder_path()
|
||||||
|
G_reader_settings:saveSetting(
|
||||||
|
"screensaver_folder", ss_folder_path_input:getInputText())
|
||||||
|
UIManager:close(ss_folder_path_input)
|
||||||
|
end
|
||||||
|
local curr_path = G_reader_settings:readSetting("screensaver_folder")
|
||||||
|
ss_folder_path_input = InputDialog:new{
|
||||||
|
title = _("Screen saver folder"),
|
||||||
|
input = curr_path,
|
||||||
|
input_hint = "/mnt/onboard/screensaver",
|
||||||
|
input_type = "text",
|
||||||
|
buttons = {
|
||||||
|
{
|
||||||
|
{
|
||||||
|
text = _("Cancel"),
|
||||||
|
callback = function()
|
||||||
|
UIManager:close(ss_folder_path_input)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text = _("Save"),
|
||||||
|
callback = save_folder_path,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
enter_callback = save_folder_path,
|
||||||
|
}
|
||||||
|
ss_folder_path_input:onShowKeyboard()
|
||||||
|
UIManager:show(ss_folder_path_input)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
table.insert(self.tab_item_table.tools, {
|
table.insert(self.tab_item_table.tools, {
|
||||||
text = _("Advanced settings"),
|
text = _("Advanced settings"),
|
||||||
callback = function()
|
callback = function()
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ function Search:getCalibre()
|
|||||||
self.use_own_metadata_file = false
|
self.use_own_metadata_file = false
|
||||||
if self.metafile_1 then
|
if self.metafile_1 then
|
||||||
pcall(lfs.mkdir("temp"))
|
pcall(lfs.mkdir("temp"))
|
||||||
if io.open(koreaderfile,"r") then
|
if io.open(koreaderfile, "r") then
|
||||||
if lfs.attributes(koreaderfile).modification > lfs.attributes(self.metafile_1).modification then
|
if lfs.attributes(koreaderfile).modification > lfs.attributes(self.metafile_1).modification then
|
||||||
if self.metafile_2 then
|
if self.metafile_2 then
|
||||||
if lfs.attributes(koreaderfile).modification > lfs.attributes(self.metafile_2).modification then
|
if lfs.attributes(koreaderfile).modification > lfs.attributes(self.metafile_2).modification then
|
||||||
@@ -443,7 +443,9 @@ function Search:find(option)
|
|||||||
end
|
end
|
||||||
g.close()
|
g.close()
|
||||||
if lfs.attributes(koreaderfile).modification < lfs.attributes(self.metafile_1).modification then
|
if lfs.attributes(koreaderfile).modification < lfs.attributes(self.metafile_1).modification then
|
||||||
lfs.touch(koreaderfile, lfs.attributes(self.metafile_1).modification + 1, lfs.attributes(self.metafile_1).modification + 1)
|
lfs.touch(koreaderfile,
|
||||||
|
lfs.attributes(self.metafile_1).modification + 1,
|
||||||
|
lfs.attributes(self.metafile_1).modification + 1)
|
||||||
end
|
end
|
||||||
if self.metafile_2 then
|
if self.metafile_2 then
|
||||||
if lfs.attributes(koreaderfile).modification < lfs.attributes(self.metafile_2).modification then
|
if lfs.attributes(koreaderfile).modification < lfs.attributes(self.metafile_2).modification then
|
||||||
|
|||||||
@@ -10,41 +10,23 @@ local Screen = require("device").screen
|
|||||||
local Menu = require("ui/widget/menu")
|
local Menu = require("ui/widget/menu")
|
||||||
local Font = require("ui/font")
|
local Font = require("ui/font")
|
||||||
local util = require("ffi/util")
|
local util = require("ffi/util")
|
||||||
local DEBUG = require("dbg")
|
|
||||||
local _ = require("gettext")
|
local _ = require("gettext")
|
||||||
|
local dump = require("dump")
|
||||||
|
|
||||||
|
|
||||||
|
local defaults_path = DataStorage:getDataDir() .. "/defaults.lua"
|
||||||
|
local persistent_filename = DataStorage:getDataDir() .. "/defaults.persistent.lua"
|
||||||
|
|
||||||
|
|
||||||
local SetDefaults = InputContainer:new{
|
local SetDefaults = InputContainer:new{
|
||||||
defaults_name = {},
|
defaults_name = {},
|
||||||
defaults_value = {},
|
defaults_value = {},
|
||||||
results = {},
|
results = {},
|
||||||
defaults_menu = {},
|
defaults_menu = {},
|
||||||
already_read = false,
|
initialized = false,
|
||||||
changed = {}
|
changed = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
local function settype(b,t)
|
|
||||||
if t == "boolean" then
|
|
||||||
if b == "false" then return false else return true end
|
|
||||||
else
|
|
||||||
return b
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function getTableValues(t,dtap)
|
|
||||||
local dummy = "{"
|
|
||||||
for n,v in pairs(t) do
|
|
||||||
if dtap:sub(1,4) == "DTAP" or dtap:sub(1,11) == "DDOUBLE_TAP" then
|
|
||||||
dummy = dummy .. tostring(n) .. " = " .. tostring(v) .. ", "
|
|
||||||
elseif tonumber(v) then
|
|
||||||
dummy = dummy .. tostring(v) .. ", "
|
|
||||||
else
|
|
||||||
dummy = dummy .. "\"" .. tostring(v) .. "\", "
|
|
||||||
end
|
|
||||||
end
|
|
||||||
dummy = dummy:sub(1,string.len(dummy) - 2) .. "}"
|
|
||||||
return dummy
|
|
||||||
end
|
|
||||||
|
|
||||||
function SetDefaults:ConfirmEdit()
|
function SetDefaults:ConfirmEdit()
|
||||||
if not SetDefaults.EditConfirmed then
|
if not SetDefaults.EditConfirmed then
|
||||||
UIManager:show(ConfirmBox:new{
|
UIManager:show(ConfirmBox:new{
|
||||||
@@ -62,21 +44,20 @@ end
|
|||||||
function SetDefaults:init()
|
function SetDefaults:init()
|
||||||
self.results = {}
|
self.results = {}
|
||||||
|
|
||||||
if not self.already_read then
|
if not self.initialized then
|
||||||
local i = 0
|
local defaults = {}
|
||||||
for n,v in util.orderedPairs(_G) do
|
local load_defaults = loadfile(defaults_path)
|
||||||
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
|
setfenv(load_defaults, defaults)
|
||||||
i = i + 1
|
load_defaults()
|
||||||
self.defaults_name[i] = n
|
|
||||||
self.defaults_value[i] = v
|
local i = 1
|
||||||
end
|
for n, v in util.orderedPairs(defaults) do
|
||||||
if string.find(tostring(v), "table: ") and string.upper(n) == n and n ~= "ARGV" and n ~= "_G" then
|
self.defaults_name[i] = n
|
||||||
i = i + 1
|
self.defaults_value[i] = v
|
||||||
self.defaults_name[i] = n
|
i = i + 1
|
||||||
self.defaults_value[i] = getTableValues(v,n)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
self.already_read = true
|
|
||||||
|
self.initialized = true
|
||||||
end
|
end
|
||||||
|
|
||||||
local menu_container = CenterContainer:new{
|
local menu_container = CenterContainer:new{
|
||||||
@@ -102,176 +83,163 @@ function SetDefaults:init()
|
|||||||
UIManager:close(menu_container)
|
UIManager:close(menu_container)
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1,#self.defaults_name do
|
local cancel_button = {
|
||||||
|
text = _("Cancel"),
|
||||||
|
enabled = true,
|
||||||
|
callback = function()
|
||||||
|
self:close()
|
||||||
|
UIManager:show(menu_container)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
for i=1, #self.defaults_name do
|
||||||
self.changed[i] = false
|
self.changed[i] = false
|
||||||
local settings_type = type(_G[self.defaults_name[i]])
|
local setting_name = self.defaults_name[i]
|
||||||
if settings_type == "boolean" then
|
local setting_type = type(_G[setting_name])
|
||||||
table.insert(self.results, {
|
if setting_type == "boolean" then
|
||||||
text = self:build_setting(i),
|
local editBoolean = function()
|
||||||
callback = function()
|
self.set_dialog = InputDialog:new{
|
||||||
self.set_dialog = InputDialog:new{
|
title = setting_name,
|
||||||
title = self.defaults_name[i] .. ":",
|
input = tostring(self.defaults_value[i]),
|
||||||
input = tostring(self.defaults_value[i]),
|
buttons = {
|
||||||
buttons = {
|
{
|
||||||
|
cancel_button,
|
||||||
{
|
{
|
||||||
{
|
text = "true",
|
||||||
text = _("Cancel"),
|
enabled = true,
|
||||||
enabled = true,
|
callback = function()
|
||||||
callback = function()
|
self.defaults_value[i] = true
|
||||||
self:close()
|
_G[setting_name] = true
|
||||||
UIManager:show(menu_container)
|
settings_changed = true
|
||||||
end
|
self.changed[i] = true
|
||||||
},
|
self.results[i].text = self:build_setting(i)
|
||||||
{
|
self:close()
|
||||||
text = "true",
|
self.defaults_menu:swithItemTable("Defaults", self.results, i)
|
||||||
enabled = true,
|
UIManager:show(menu_container)
|
||||||
callback = function()
|
end
|
||||||
self.defaults_value[i] = true
|
},
|
||||||
_G[self.defaults_name[i]] = true
|
{
|
||||||
settings_changed = true
|
text = "false",
|
||||||
self.changed[i] = true
|
enabled = true,
|
||||||
self.results[i].text = self:build_setting(i)
|
callback = function()
|
||||||
self:close()
|
self.defaults_value[i] = false
|
||||||
self.defaults_menu:swithItemTable("Defaults", self.results, i)
|
_G[setting_name] = false
|
||||||
UIManager:show(menu_container)
|
settings_changed = true
|
||||||
end
|
self.changed[i] = true
|
||||||
},
|
self.results[i].text = self:build_setting(i)
|
||||||
{
|
self.defaults_menu:swithItemTable("Defaults", self.results, i)
|
||||||
text = "false",
|
self:close()
|
||||||
enabled = true,
|
UIManager:show(menu_container)
|
||||||
callback = function()
|
end
|
||||||
self.defaults_value[i] = false
|
|
||||||
_G[self.defaults_name[i]] = false
|
|
||||||
settings_changed = true
|
|
||||||
self.changed[i] = true
|
|
||||||
self.results[i].text = self:build_setting(i)
|
|
||||||
self.defaults_menu:swithItemTable("Defaults", self.results, i)
|
|
||||||
self:close()
|
|
||||||
UIManager:show(menu_container)
|
|
||||||
end
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
input_type = settings_type,
|
},
|
||||||
width = Screen:getWidth() * 0.95,
|
input_type = setting_type,
|
||||||
height = Screen:getHeight() * 0.2,
|
width = Screen:getWidth() * 0.95,
|
||||||
}
|
}
|
||||||
self.set_dialog:onShowKeyboard()
|
self.set_dialog:onShowKeyboard()
|
||||||
UIManager:show(self.set_dialog)
|
UIManager:show(self.set_dialog)
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(self.results, {
|
||||||
|
text = self:build_setting(i),
|
||||||
|
callback = editBoolean
|
||||||
|
})
|
||||||
|
elseif setting_type == "table" then
|
||||||
|
local editTable = function()
|
||||||
|
local fields = {}
|
||||||
|
for k, v in util.orderedPairs(_G[setting_name]) do
|
||||||
|
table.insert(fields, {
|
||||||
|
text = tostring(k) .. " = " .. tostring(v),
|
||||||
|
hint = "",
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
self.set_dialog = MultiInputDialog:new{
|
||||||
|
title = setting_name,
|
||||||
|
fields = fields,
|
||||||
|
buttons = {
|
||||||
|
{
|
||||||
|
cancel_button,
|
||||||
|
{
|
||||||
|
text = _("OK"),
|
||||||
|
enabled = true,
|
||||||
|
callback = function()
|
||||||
|
local new_table = {}
|
||||||
|
for _, field in ipairs(MultiInputDialog:getFields()) do
|
||||||
|
new_table[field:match("^[^= ]+")] = field:match("[^= ]+$")
|
||||||
|
end
|
||||||
|
_G[setting_name] = new_table
|
||||||
|
|
||||||
|
self.defaults_value[i] = _G[setting_name]
|
||||||
|
settings_changed = true
|
||||||
|
self.changed[i] = true
|
||||||
|
|
||||||
|
self.results[i].text = self:build_setting(i)
|
||||||
|
|
||||||
|
self:close()
|
||||||
|
self.defaults_menu:swithItemTable("Defaults", self.results, i)
|
||||||
|
UIManager:show(menu_container)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
input_type = "number",
|
||||||
|
width = Screen:getWidth() * 0.95,
|
||||||
|
height = Screen:getHeight() * 0.2,
|
||||||
|
}
|
||||||
|
self.set_dialog:onShowKeyboard()
|
||||||
|
UIManager:show(self.set_dialog)
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(self.results, {
|
||||||
|
text = self:build_setting(i),
|
||||||
|
callback = editTable
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
if type(_G[self.defaults_name[i]]) == "table" then
|
local editNumStr = function()
|
||||||
table.insert(self.results, {
|
self.set_dialog = InputDialog:new{
|
||||||
text = self:build_setting(i),
|
title = setting_name,
|
||||||
callback = function()
|
input = tostring(self.defaults_value[i]),
|
||||||
local fields = {}
|
buttons = {
|
||||||
for m, n in util.orderedPairs(_G[self.defaults_name[i]]) do
|
{
|
||||||
table.insert(fields, {
|
cancel_button,
|
||||||
text = tostring(m) .. " = " .. tostring(n),
|
{
|
||||||
hint = "",
|
text = _("OK"),
|
||||||
})
|
enabled = true,
|
||||||
end
|
callback = function()
|
||||||
self.set_dialog = MultiInputDialog:new{
|
local new_value = self.set_dialog:getInputText()
|
||||||
title = self.defaults_name[i] .. ":",
|
if setting_type == "boolean" then
|
||||||
fields = fields,
|
if new_value == "true" then
|
||||||
buttons = {
|
new_value = true
|
||||||
{
|
else
|
||||||
{
|
new_value = false
|
||||||
text = _("Cancel"),
|
end
|
||||||
enabled = true,
|
end
|
||||||
callback = function()
|
if _G[setting_name] ~= new_value then
|
||||||
self:close()
|
_G[setting_name] = new_value
|
||||||
UIManager:show(menu_container)
|
self.defaults_value[i] = new_value
|
||||||
end,
|
settings_changed = true
|
||||||
},
|
self.changed[i] = true
|
||||||
{
|
self.results[i].text = self:build_setting(i)
|
||||||
text = _("OK"),
|
end
|
||||||
enabled = true,
|
self:close()
|
||||||
callback = function()
|
self.defaults_menu:swithItemTable("Defaults", self.results, i)
|
||||||
local fields = {}
|
UIManager:show(menu_container)
|
||||||
for _, field in ipairs(MultiInputDialog:getFields()) do
|
end,
|
||||||
fields[field:match("^[^= ]+")] = field:match("[^= ]+$")
|
|
||||||
end
|
|
||||||
_G[self.defaults_name[i]] = fields
|
|
||||||
self.defaults_value[i] = "{"
|
|
||||||
DEBUG(_G[self.defaults_name[i]])
|
|
||||||
for k,v in util.orderedPairs(_G[self.defaults_name[i]]) do
|
|
||||||
if tonumber(k) then
|
|
||||||
self.defaults_value[i] = self.defaults_value[i] .. v .. ", "
|
|
||||||
else
|
|
||||||
self.defaults_value[i] = self.defaults_value[i] .. k .. " = " .. v .. ", "
|
|
||||||
end
|
|
||||||
end
|
|
||||||
self.defaults_value[i] = self.defaults_value[i]:sub(1,self.defaults_value[i]:len()-2) .. "}"
|
|
||||||
|
|
||||||
settings_changed = true
|
|
||||||
self.changed[i] = true
|
|
||||||
|
|
||||||
self.results[i].text = self:build_setting(i)
|
|
||||||
|
|
||||||
self:close()
|
|
||||||
self.defaults_menu:swithItemTable("Defaults", self.results, i)
|
|
||||||
UIManager:show(menu_container)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
input_type = "number",
|
},
|
||||||
width = Screen:getWidth() * 0.95,
|
},
|
||||||
height = Screen:getHeight() * 0.2,
|
input_type = setting_type,
|
||||||
}
|
width = Screen:getWidth() * 0.95,
|
||||||
self.set_dialog:onShowKeyboard()
|
}
|
||||||
UIManager:show(self.set_dialog)
|
self.set_dialog:onShowKeyboard()
|
||||||
end
|
UIManager:show(self.set_dialog)
|
||||||
})
|
|
||||||
|
|
||||||
else
|
|
||||||
table.insert(self.results, {
|
|
||||||
text = self:build_setting(i),
|
|
||||||
callback = function()
|
|
||||||
self.set_dialog = InputDialog:new{
|
|
||||||
title = self.defaults_name[i] .. ":",
|
|
||||||
input = tostring(self.defaults_value[i]),
|
|
||||||
buttons = {
|
|
||||||
{
|
|
||||||
{
|
|
||||||
text = _("Cancel"),
|
|
||||||
enabled = true,
|
|
||||||
callback = function()
|
|
||||||
self:close()
|
|
||||||
UIManager:show(menu_container)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text = _("OK"),
|
|
||||||
enabled = true,
|
|
||||||
callback = function()
|
|
||||||
if type(_G[self.defaults_name[i]]) == "table" then
|
|
||||||
self.defaults_value[i] = self.set_dialog:getInputText()
|
|
||||||
elseif _G[self.defaults_name[i]] ~= settype(self.set_dialog:getInputText(),settings_type) then
|
|
||||||
_G[self.defaults_name[i]] = settype(self.set_dialog:getInputText(),settings_type)
|
|
||||||
self.defaults_value[i] = _G[self.defaults_name[i]]
|
|
||||||
end
|
|
||||||
settings_changed = true
|
|
||||||
self.changed[i] = true
|
|
||||||
self.results[i].text = self:build_setting(i)
|
|
||||||
self:close()
|
|
||||||
self.defaults_menu:swithItemTable("Defaults", self.results, i)
|
|
||||||
UIManager:show(menu_container)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
input_type = settings_type,
|
|
||||||
width = Screen:getWidth() * 0.95,
|
|
||||||
height = Screen:getHeight() * 0.2,
|
|
||||||
}
|
|
||||||
self.set_dialog:onShowKeyboard()
|
|
||||||
UIManager:show(self.set_dialog)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
table.insert(self.results, {
|
||||||
|
text = self:build_setting(i),
|
||||||
|
callback = editNumStr
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.defaults_menu:swithItemTable("Defaults", self.results)
|
self.defaults_menu:swithItemTable("Defaults", self.results)
|
||||||
@@ -279,13 +247,12 @@ function SetDefaults:init()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function SetDefaults:close()
|
function SetDefaults:close()
|
||||||
self.set_dialog:onClose()
|
|
||||||
UIManager:close(self.set_dialog)
|
UIManager:close(self.set_dialog)
|
||||||
end
|
end
|
||||||
|
|
||||||
function SetDefaults:ConfirmSave()
|
function SetDefaults:ConfirmSave()
|
||||||
UIManager:show(ConfirmBox:new{
|
UIManager:show(ConfirmBox:new{
|
||||||
text = _("Are you sure you want to save the settings to \"defaults.persistent.lua\"?"),
|
text = _('Are you sure you want to save the settings to "defaults.persistent.lua"?'),
|
||||||
ok_callback = function()
|
ok_callback = function()
|
||||||
self:SaveSettings()
|
self:SaveSettings()
|
||||||
end,
|
end,
|
||||||
@@ -293,73 +260,64 @@ function SetDefaults:ConfirmSave()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function SetDefaults:build_setting(j)
|
function SetDefaults:build_setting(j)
|
||||||
local ret = self.defaults_name[j] .. " = "
|
local setting_name = self.defaults_name[j]
|
||||||
if type(_G[self.defaults_name[j]]) == "boolean" or type(_G[self.defaults_name[j]]) == "table" then
|
local ret = setting_name .. " = "
|
||||||
ret = ret .. tostring(self.defaults_value[j])
|
if type(_G[setting_name]) == "boolean" then
|
||||||
|
return ret .. tostring(self.defaults_value[j])
|
||||||
|
elseif type(_G[setting_name]) == "table" then
|
||||||
|
return ret .. "{...}"
|
||||||
elseif tonumber(self.defaults_value[j]) then
|
elseif tonumber(self.defaults_value[j]) then
|
||||||
ret = ret .. tostring(tonumber(self.defaults_value[j]))
|
return ret .. tostring(tonumber(self.defaults_value[j]))
|
||||||
else
|
else
|
||||||
ret = ret .. "\"" .. tostring(self.defaults_value[j]) .. "\""
|
return ret .. "\"" .. tostring(self.defaults_value[j]) .. "\""
|
||||||
end
|
end
|
||||||
return ret
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function SetDefaults:SaveSettings()
|
function SetDefaults:SaveSettings()
|
||||||
|
|
||||||
local function fileread(filename,array)
|
|
||||||
local file = io.open(filename)
|
|
||||||
local line = file:read()
|
|
||||||
local counter = 0
|
|
||||||
while line do
|
|
||||||
counter = counter + 1
|
|
||||||
local i = string.find(line,"[-][-]") -- remove comments from file
|
|
||||||
if (i or 0)>1 then line = string.sub(line,1,i-1) end
|
|
||||||
array[counter] = line:gsub("^%s*(.-)%s*$", "%1") -- trim
|
|
||||||
line = file:read()
|
|
||||||
end
|
|
||||||
file:close()
|
|
||||||
end
|
|
||||||
|
|
||||||
local persistent_filename = DataStorage:getDataDir() .. "/defaults.persistent.lua"
|
|
||||||
local file
|
|
||||||
if io.open(persistent_filename,"r") == nil then
|
|
||||||
file = io.open(persistent_filename, "w")
|
|
||||||
file:write("-- For configuration changes that persists between (nightly) releases\n")
|
|
||||||
file:close()
|
|
||||||
end
|
|
||||||
|
|
||||||
local dpl = {}
|
|
||||||
fileread(persistent_filename, dpl)
|
|
||||||
local dl = {}
|
|
||||||
fileread("defaults.lua",dl)
|
|
||||||
self.results = {}
|
self.results = {}
|
||||||
local done = {}
|
local persisted_defaults = {}
|
||||||
|
local file = io.open(persistent_filename, "r")
|
||||||
for j=1,#SetDefaults.defaults_name do
|
if file ~= nil then
|
||||||
if not self.changed[j] then done[j] = true end
|
file:close()
|
||||||
|
local load_defaults = loadfile(persistent_filename)
|
||||||
|
setfenv(load_defaults, persisted_defaults)
|
||||||
|
load_defaults()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- handle case "found in persistent", replace it
|
local checked = {}
|
||||||
for i = 1,#dpl do
|
for j=1, #self.defaults_name do
|
||||||
for j=1,#SetDefaults.defaults_name do
|
if not self.changed[j] then checked[j] = true end
|
||||||
if not done[j] and string.find(dpl[i],SetDefaults.defaults_name[j] .. " ") == 1 then
|
end
|
||||||
dpl[i] = self:build_setting(j)
|
|
||||||
done[j] = true
|
-- handle case "found in persistent" and changed, replace it
|
||||||
|
for k, v in pairs(persisted_defaults) do
|
||||||
|
for j=1, #self.defaults_name do
|
||||||
|
if not checked[j]
|
||||||
|
and k == self.defaults_name[j] then
|
||||||
|
persisted_defaults[k] = self.defaults_value[j]
|
||||||
|
checked[j] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- handle case "not in persistent and different in non-persistent", add to persistent
|
-- handle case "not in persistent and different in non-persistent", add to
|
||||||
for j=1,#SetDefaults.defaults_name do
|
-- persistent
|
||||||
if not done[j] then
|
for j=1, #self.defaults_name do
|
||||||
dpl[#dpl+1] = self:build_setting(j)
|
if not checked[j] then
|
||||||
|
persisted_defaults[self.defaults_name[j]] = self.defaults_value[j]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
file = io.open(persistent_filename, "w")
|
file = io.open(persistent_filename, "w")
|
||||||
if file then
|
if file then
|
||||||
for i = 1,#dpl do
|
file:write("-- For configuration changes that persists between updates\n")
|
||||||
file:write(dpl[i] .. "\n")
|
for k, v in pairs(persisted_defaults) do
|
||||||
|
local line = {}
|
||||||
|
table.insert(line, k)
|
||||||
|
table.insert(line, " = ")
|
||||||
|
table.insert(line, dump(v))
|
||||||
|
table.insert(line, "\n")
|
||||||
|
file:write(table.concat(line))
|
||||||
end
|
end
|
||||||
file:close()
|
file:close()
|
||||||
UIManager:show(InfoMessage:new{
|
UIManager:show(InfoMessage:new{
|
||||||
@@ -368,4 +326,5 @@ function SetDefaults:SaveSettings()
|
|||||||
end
|
end
|
||||||
settings_changed = false
|
settings_changed = false
|
||||||
end
|
end
|
||||||
|
|
||||||
return SetDefaults
|
return SetDefaults
|
||||||
|
|||||||
@@ -116,8 +116,6 @@ function ReaderFrontLight:onShowFlDialog()
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
input_type = "number",
|
input_type = "number",
|
||||||
width = Screen:getWidth() * 0.8,
|
|
||||||
height = Screen:getHeight() * 0.2,
|
|
||||||
}
|
}
|
||||||
self.fl_dialog:onShowKeyboard()
|
self.fl_dialog:onShowKeyboard()
|
||||||
UIManager:show(self.fl_dialog)
|
UIManager:show(self.fl_dialog)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||||
local InputDialog = require("ui/widget/inputdialog")
|
local InputDialog = require("ui/widget/inputdialog")
|
||||||
local UIManager = require("ui/uimanager")
|
local UIManager = require("ui/uimanager")
|
||||||
local Screen = require("device").screen
|
|
||||||
local Event = require("ui/event")
|
local Event = require("ui/event")
|
||||||
local _ = require("gettext")
|
local _ = require("gettext")
|
||||||
|
|
||||||
@@ -58,15 +57,12 @@ function ReaderGoto:onShowGotoDialog()
|
|||||||
},
|
},
|
||||||
input_type = "number",
|
input_type = "number",
|
||||||
enter_callback = function() self:gotoPage() end,
|
enter_callback = function() self:gotoPage() end,
|
||||||
width = Screen:getWidth() * 0.8,
|
|
||||||
height = Screen:getHeight() * 0.2,
|
|
||||||
}
|
}
|
||||||
self.goto_dialog:onShowKeyboard()
|
self.goto_dialog:onShowKeyboard()
|
||||||
UIManager:show(self.goto_dialog)
|
UIManager:show(self.goto_dialog)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ReaderGoto:close()
|
function ReaderGoto:close()
|
||||||
self.goto_dialog:onClose()
|
|
||||||
UIManager:close(self.goto_dialog)
|
UIManager:close(self.goto_dialog)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -426,8 +426,6 @@ function ReaderUI:unlockDocumentWithPassword(document, try_again)
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
text_type = "password",
|
text_type = "password",
|
||||||
width = Screen:getWidth() * 0.8,
|
|
||||||
height = Screen:getHeight() * 0.2,
|
|
||||||
}
|
}
|
||||||
self.password_dialog:onShowKeyboard()
|
self.password_dialog:onShowKeyboard()
|
||||||
UIManager:show(self.password_dialog)
|
UIManager:show(self.password_dialog)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ simple serialization function, won't do uservalues, functions, loops
|
|||||||
|
|
||||||
local isUbuntuTouch = os.getenv("UBUNTU_APPLICATION_ISOLATION") ~= nil
|
local isUbuntuTouch = os.getenv("UBUNTU_APPLICATION_ISOLATION") ~= nil
|
||||||
local insert = table.insert
|
local insert = table.insert
|
||||||
|
local indent_prefix = " "
|
||||||
|
|
||||||
local function _serialize(what, outt, indent, max_lv, history)
|
local function _serialize(what, outt, indent, max_lv, history)
|
||||||
if not max_lv then
|
if not max_lv then
|
||||||
@@ -19,7 +20,7 @@ local function _serialize(what, outt, indent, max_lv, history)
|
|||||||
for up, item in ipairs(history) do
|
for up, item in ipairs(history) do
|
||||||
if item == what then
|
if item == what then
|
||||||
insert(outt, "nil --[[ LOOP:\n")
|
insert(outt, "nil --[[ LOOP:\n")
|
||||||
insert(outt, string.rep("\t", indent - up))
|
insert(outt, string.rep(indent_prefix, indent - up))
|
||||||
insert(outt, "^------- ]]")
|
insert(outt, "^------- ]]")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -32,7 +33,7 @@ local function _serialize(what, outt, indent, max_lv, history)
|
|||||||
insert(outt, ",")
|
insert(outt, ",")
|
||||||
end
|
end
|
||||||
insert(outt, "\n")
|
insert(outt, "\n")
|
||||||
insert(outt, string.rep("\t", indent+1))
|
insert(outt, string.rep(indent_prefix, indent+1))
|
||||||
insert(outt, "[")
|
insert(outt, "[")
|
||||||
_serialize(k, outt, indent+1, max_lv, new_history)
|
_serialize(k, outt, indent+1, max_lv, new_history)
|
||||||
insert(outt, "] = ")
|
insert(outt, "] = ")
|
||||||
@@ -41,7 +42,7 @@ local function _serialize(what, outt, indent, max_lv, history)
|
|||||||
end
|
end
|
||||||
if didrun then
|
if didrun then
|
||||||
insert(outt, "\n")
|
insert(outt, "\n")
|
||||||
insert(outt, string.rep("\t", indent))
|
insert(outt, string.rep(indent_prefix, indent))
|
||||||
end
|
end
|
||||||
insert(outt, "}")
|
insert(outt, "}")
|
||||||
elseif type(what) == "string" then
|
elseif type(what) == "string" then
|
||||||
|
|||||||
@@ -545,15 +545,12 @@ function BookStatusWidget:onSwitchFocus(inputbox)
|
|||||||
enter_callback = function()
|
enter_callback = function()
|
||||||
self:closeInputDialog()
|
self:closeInputDialog()
|
||||||
end,
|
end,
|
||||||
width = Screen:getWidth() * 0.8,
|
|
||||||
height = Screen:getHeight() * 0.2,
|
|
||||||
}
|
}
|
||||||
self.note_dialog:onShowKeyboard()
|
self.note_dialog:onShowKeyboard()
|
||||||
UIManager:show(self.note_dialog)
|
UIManager:show(self.note_dialog)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BookStatusWidget:closeInputDialog()
|
function BookStatusWidget:closeInputDialog()
|
||||||
self.note_dialog:onClose()
|
|
||||||
UIManager:close(self.note_dialog)
|
UIManager:close(self.note_dialog)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||||
local UIManager = require("ui/uimanager")
|
local UIManager = require("ui/uimanager")
|
||||||
local Screen = require("device").screen
|
|
||||||
local Geom = require("ui/geometry")
|
local Geom = require("ui/geometry")
|
||||||
local Event = require("ui/event")
|
local Event = require("ui/event")
|
||||||
local _ = require("gettext")
|
local _ = require("gettext")
|
||||||
@@ -128,15 +127,12 @@ function InputContainer:onInput(input)
|
|||||||
input.callback(self.input_dialog:getInputText())
|
input.callback(self.input_dialog:getInputText())
|
||||||
self:closeInputDialog()
|
self:closeInputDialog()
|
||||||
end,
|
end,
|
||||||
width = Screen:getWidth() * 0.8,
|
|
||||||
height = Screen:getHeight() * 0.2,
|
|
||||||
}
|
}
|
||||||
self.input_dialog:onShowKeyboard()
|
self.input_dialog:onShowKeyboard()
|
||||||
UIManager:show(self.input_dialog)
|
UIManager:show(self.input_dialog)
|
||||||
end
|
end
|
||||||
|
|
||||||
function InputContainer:closeInputDialog()
|
function InputContainer:closeInputDialog()
|
||||||
self.input_dialog:onClose()
|
|
||||||
UIManager:close(self.input_dialog)
|
UIManager:close(self.input_dialog)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -424,8 +424,6 @@ function DictQuickLookup:lookupInputWord(hint)
|
|||||||
self:closeInputDialog()
|
self:closeInputDialog()
|
||||||
self:inputLookup()
|
self:inputLookup()
|
||||||
end,
|
end,
|
||||||
width = Screen:getWidth() * 0.8,
|
|
||||||
height = Screen:getHeight() * 0.2,
|
|
||||||
}
|
}
|
||||||
self.input_dialog:onShowKeyboard()
|
self.input_dialog:onShowKeyboard()
|
||||||
UIManager:show(self.input_dialog)
|
UIManager:show(self.input_dialog)
|
||||||
@@ -440,7 +438,6 @@ function DictQuickLookup:inputLookup()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function DictQuickLookup:closeInputDialog()
|
function DictQuickLookup:closeInputDialog()
|
||||||
self.input_dialog:onClose()
|
|
||||||
UIManager:close(self.input_dialog)
|
UIManager:close(self.input_dialog)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,40 @@
|
|||||||
|
--[[--
|
||||||
|
Widget for taking user input.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
local _ = require("gettext")
|
||||||
|
local UIManager = require("ui/uimanager")
|
||||||
|
local sample_input
|
||||||
|
local saveHandler = function()
|
||||||
|
print('Got user input:', sample_input:getInputText())
|
||||||
|
end
|
||||||
|
sample_input = InputDialog:new{
|
||||||
|
title = _("Dialog title"),
|
||||||
|
input = "default value",
|
||||||
|
input_hint = "hint text",
|
||||||
|
input_type = "text",
|
||||||
|
buttons = {
|
||||||
|
{
|
||||||
|
{
|
||||||
|
text = _("Cancel"),
|
||||||
|
callback = function()
|
||||||
|
UIManager:close(sample_input)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text = _("Save"),
|
||||||
|
callback = saveHandler,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
enter_callback = saveHandler,
|
||||||
|
}
|
||||||
|
sample_input:onShowKeyboard()
|
||||||
|
UIManager:show(sample_input)
|
||||||
|
|
||||||
|
]]
|
||||||
|
|
||||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||||
local FrameContainer = require("ui/widget/container/framecontainer")
|
local FrameContainer = require("ui/widget/container/framecontainer")
|
||||||
local CenterContainer = require("ui/widget/container/centercontainer")
|
local CenterContainer = require("ui/widget/container/centercontainer")
|
||||||
@@ -38,6 +75,7 @@ local InputDialog = InputContainer:new{
|
|||||||
}
|
}
|
||||||
|
|
||||||
function InputDialog:init()
|
function InputDialog:init()
|
||||||
|
self.width = self.width or Screen:getWidth() * 0.8
|
||||||
local title_width = RenderText:sizeUtf8Text(0, self.width,
|
local title_width = RenderText:sizeUtf8Text(0, self.width,
|
||||||
self.title_face, self.title, true).x
|
self.title_face, self.title, true).x
|
||||||
if title_width > self.width then
|
if title_width > self.width then
|
||||||
@@ -78,7 +116,6 @@ function InputDialog:init()
|
|||||||
show_parent = self,
|
show_parent = self,
|
||||||
}
|
}
|
||||||
self.title_bar = LineWidget:new{
|
self.title_bar = LineWidget:new{
|
||||||
--background = Blitbuffer.gray(0.5),
|
|
||||||
dimen = Geom:new{
|
dimen = Geom:new{
|
||||||
w = self.button_table:getSize().w + self.button_padding,
|
w = self.button_table:getSize().w + self.button_padding,
|
||||||
h = Screen:scaleBySize(2),
|
h = Screen:scaleBySize(2),
|
||||||
@@ -138,6 +175,7 @@ function InputDialog:onShow()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function InputDialog:onCloseWidget()
|
function InputDialog:onCloseWidget()
|
||||||
|
self:onClose()
|
||||||
UIManager:setDirty(nil, function()
|
UIManager:setDirty(nil, function()
|
||||||
return "partial", self.dialog_frame.dimen
|
return "partial", self.dialog_frame.dimen
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ function MultiInputDialog:init()
|
|||||||
scroll = false,
|
scroll = false,
|
||||||
parent = self,
|
parent = self,
|
||||||
}
|
}
|
||||||
table.insert(VerticalGroupData,CenterContainer:new{
|
table.insert(VerticalGroupData, CenterContainer:new{
|
||||||
dimen = Geom:new{
|
dimen = Geom:new{
|
||||||
w = self.title_bar:getSize().w,
|
w = self.title_bar:getSize().w,
|
||||||
h = input_field[k]:getSize().h,
|
h = input_field[k]:getSize().h,
|
||||||
|
|||||||
90
spec/unit/defaults_spec.lua
Normal file
90
spec/unit/defaults_spec.lua
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
describe("defaults module", function()
|
||||||
|
local Defaults, DataStorage
|
||||||
|
setup(function()
|
||||||
|
require("commonrequire")
|
||||||
|
Defaults = require("apps/filemanager/filemanagersetdefaults")
|
||||||
|
DataStorage = require("datastorage")
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("should load all defaults from defaults.lua", function()
|
||||||
|
Defaults:init()
|
||||||
|
assert.is_same(#Defaults.defaults_name, 78)
|
||||||
|
assert.is_same(Defaults.defaults_name[29], 'DHINTCOUNT')
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("should save changes to defaults.persistent.lua", function()
|
||||||
|
local persistent_filename = DataStorage:getDataDir() .. "/defaults.persistent.lua"
|
||||||
|
os.remove(persistent_filename)
|
||||||
|
|
||||||
|
-- not in persistent but checked in defaults
|
||||||
|
Defaults.changed[14] = true
|
||||||
|
Defaults.changed[19] = true
|
||||||
|
Defaults.changed[29] = true
|
||||||
|
Defaults.changed[64] = true
|
||||||
|
Defaults.changed[78] = true
|
||||||
|
Defaults:SaveSettings()
|
||||||
|
assert.is_same(#Defaults.defaults_name, 78)
|
||||||
|
assert.is_same(Defaults.defaults_name[29], 'DHINTCOUNT')
|
||||||
|
assert.is_same(Defaults.defaults_name[78], 'SEARCH_TITLE')
|
||||||
|
assert.is_same(Defaults.defaults_name[64], 'DTAP_ZONE_MENU')
|
||||||
|
assert.is_same(Defaults.defaults_name[19], 'DCREREADER_VIEW_MODE')
|
||||||
|
assert.is_same(Defaults.defaults_name[14],
|
||||||
|
'DCREREADER_CONFIG_MARGIN_SIZES_LARGE')
|
||||||
|
local fd = io.open(persistent_filename, "r")
|
||||||
|
assert.Equals(
|
||||||
|
[[-- For configuration changes that persists between updates
|
||||||
|
SEARCH_TITLE = true
|
||||||
|
DCREREADER_CONFIG_MARGIN_SIZES_LARGE = {
|
||||||
|
[1] = 20,
|
||||||
|
[2] = 20,
|
||||||
|
[3] = 20,
|
||||||
|
[4] = 20
|
||||||
|
}
|
||||||
|
DCREREADER_VIEW_MODE = "page"
|
||||||
|
DHINTCOUNT = 1
|
||||||
|
DTAP_ZONE_MENU = {
|
||||||
|
["y"] = 0,
|
||||||
|
["x"] = 0.125,
|
||||||
|
["h"] = 0.25,
|
||||||
|
["w"] = 0.75
|
||||||
|
}
|
||||||
|
]],
|
||||||
|
fd:read("*a"))
|
||||||
|
fd:close()
|
||||||
|
|
||||||
|
-- in persistent
|
||||||
|
Defaults:init()
|
||||||
|
Defaults.changed[29] = true
|
||||||
|
Defaults.defaults_value[29] = 2
|
||||||
|
Defaults.changed[64] = true
|
||||||
|
Defaults.defaults_value[64] = {
|
||||||
|
y = 10,
|
||||||
|
x = 10.125,
|
||||||
|
h = 20.25,
|
||||||
|
w = 20.75
|
||||||
|
}
|
||||||
|
Defaults:SaveSettings()
|
||||||
|
fd = io.open(persistent_filename)
|
||||||
|
assert.Equals(
|
||||||
|
[[-- For configuration changes that persists between updates
|
||||||
|
SEARCH_TITLE = true
|
||||||
|
DHINTCOUNT = 2
|
||||||
|
DTAP_ZONE_MENU = {
|
||||||
|
["y"] = 10,
|
||||||
|
["x"] = 10.125,
|
||||||
|
["h"] = 20.25,
|
||||||
|
["w"] = 20.75
|
||||||
|
}
|
||||||
|
DCREREADER_CONFIG_MARGIN_SIZES_LARGE = {
|
||||||
|
[1] = 20,
|
||||||
|
[2] = 20,
|
||||||
|
[3] = 20,
|
||||||
|
[4] = 20
|
||||||
|
}
|
||||||
|
DCREREADER_VIEW_MODE = "page"
|
||||||
|
]],
|
||||||
|
fd:read("*a"))
|
||||||
|
fd:close()
|
||||||
|
os.remove(persistent_filename)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
Reference in New Issue
Block a user