|
|
|
@ -108,9 +108,14 @@ function filemanagerutil.getStatus(file)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Set a document status ("reading", "complete", or "abandoned")
|
|
|
|
|
function filemanagerutil.setStatus(file, status)
|
|
|
|
|
function filemanagerutil.setStatus(doc_settings_or_file, status)
|
|
|
|
|
-- In case the book doesn't have a sidecar file, this'll create it
|
|
|
|
|
local doc_settings = DocSettings:open(file)
|
|
|
|
|
local doc_settings
|
|
|
|
|
if type(doc_settings_or_file) == "table" then
|
|
|
|
|
doc_settings = doc_settings_or_file
|
|
|
|
|
else
|
|
|
|
|
doc_settings = DocSettings:open(doc_settings_or_file)
|
|
|
|
|
end
|
|
|
|
|
local summary = doc_settings:readSetting("summary", {})
|
|
|
|
|
summary.status = status
|
|
|
|
|
summary.modified = os.date("%Y-%m-%d", os.time())
|
|
|
|
@ -131,9 +136,9 @@ end
|
|
|
|
|
-- Generate all book status file dialog buttons in a row
|
|
|
|
|
function filemanagerutil.genStatusButtonsRow(doc_settings_or_file, caller_callback)
|
|
|
|
|
local file, summary, status
|
|
|
|
|
if type(doc_settings_or_file) == "table" then -- currently opened file
|
|
|
|
|
if type(doc_settings_or_file) == "table" then
|
|
|
|
|
file = doc_settings_or_file:readSetting("doc_path")
|
|
|
|
|
summary = doc_settings_or_file:readSetting("summary")
|
|
|
|
|
summary = doc_settings_or_file:readSetting("summary", {})
|
|
|
|
|
status = summary.status
|
|
|
|
|
else
|
|
|
|
|
file = doc_settings_or_file
|
|
|
|
@ -146,7 +151,7 @@ function filemanagerutil.genStatusButtonsRow(doc_settings_or_file, caller_callba
|
|
|
|
|
enabled = status ~= to_status,
|
|
|
|
|
callback = function()
|
|
|
|
|
summary.status = to_status
|
|
|
|
|
filemanagerutil.setStatus(file, to_status)
|
|
|
|
|
filemanagerutil.setStatus(doc_settings_or_file, to_status)
|
|
|
|
|
UIManager:broadcastEvent(Event:new("DocSettingsItemsChanged", file, { summary = summary })) -- for CoverBrowser
|
|
|
|
|
caller_callback()
|
|
|
|
|
end,
|
|
|
|
@ -160,9 +165,16 @@ function filemanagerutil.genStatusButtonsRow(doc_settings_or_file, caller_callba
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Generate "Reset" file dialog button
|
|
|
|
|
function filemanagerutil.genResetSettingsButton(file, caller_callback, button_disabled)
|
|
|
|
|
file = ffiutil.realpath(file) or file
|
|
|
|
|
local has_sidecar_file = DocSettings:hasSidecarFile(file)
|
|
|
|
|
function filemanagerutil.genResetSettingsButton(doc_settings_or_file, caller_callback, button_disabled)
|
|
|
|
|
local doc_settings, file, has_sidecar_file
|
|
|
|
|
if type(doc_settings_or_file) == "table" then
|
|
|
|
|
doc_settings = doc_settings_or_file
|
|
|
|
|
file = doc_settings_or_file:readSetting("doc_path")
|
|
|
|
|
has_sidecar_file = true
|
|
|
|
|
else
|
|
|
|
|
file = ffiutil.realpath(doc_settings_or_file) or doc_settings_or_file
|
|
|
|
|
has_sidecar_file = DocSettings:hasSidecarFile(file)
|
|
|
|
|
end
|
|
|
|
|
local custom_cover_file = DocSettings:findCustomCoverFile(file)
|
|
|
|
|
local has_custom_cover_file = custom_cover_file and true or false
|
|
|
|
|
local custom_metadata_file = DocSettings:findCustomMetadataFile(file)
|
|
|
|
@ -185,7 +197,7 @@ function filemanagerutil.genResetSettingsButton(file, caller_callback, button_di
|
|
|
|
|
custom_cover_file = check_button_cover.checked and custom_cover_file,
|
|
|
|
|
custom_metadata_file = check_button_metadata.checked and custom_metadata_file,
|
|
|
|
|
}
|
|
|
|
|
DocSettings:open(file):purge(nil, data_to_purge)
|
|
|
|
|
(doc_settings or DocSettings:open(file)):purge(nil, data_to_purge)
|
|
|
|
|
if data_to_purge.custom_cover_file or data_to_purge.custom_metadata_file then
|
|
|
|
|
UIManager:broadcastEvent(Event:new("InvalidateMetadataCache", file))
|
|
|
|
|
end
|
|
|
|
@ -260,23 +272,23 @@ function filemanagerutil.genShowFolderButton(file, caller_callback, button_disab
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function filemanagerutil.genBookInformationButton(file, bookinfo, caller_callback, button_disabled)
|
|
|
|
|
function filemanagerutil.genBookInformationButton(file, book_props, caller_callback, button_disabled)
|
|
|
|
|
return {
|
|
|
|
|
text = _("Book information"),
|
|
|
|
|
enabled = not button_disabled,
|
|
|
|
|
callback = function()
|
|
|
|
|
caller_callback()
|
|
|
|
|
local FileManagerBookInfo = require("apps/filemanager/filemanagerbookinfo")
|
|
|
|
|
FileManagerBookInfo:show(file, bookinfo and FileManagerBookInfo.extendProps(bookinfo))
|
|
|
|
|
FileManagerBookInfo:show(file, book_props and FileManagerBookInfo.extendProps(book_props))
|
|
|
|
|
end,
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function filemanagerutil.genBookCoverButton(file, bookinfo, caller_callback, button_disabled)
|
|
|
|
|
local has_cover = bookinfo and bookinfo.has_cover
|
|
|
|
|
function filemanagerutil.genBookCoverButton(file, book_props, caller_callback, button_disabled)
|
|
|
|
|
local has_cover = book_props and book_props.has_cover
|
|
|
|
|
return {
|
|
|
|
|
text = _("Book cover"),
|
|
|
|
|
enabled = (not button_disabled and (not bookinfo or has_cover)) and true or false,
|
|
|
|
|
enabled = (not button_disabled and (not book_props or has_cover)) and true or false,
|
|
|
|
|
callback = function()
|
|
|
|
|
caller_callback()
|
|
|
|
|
local FileManagerBookInfo = require("apps/filemanager/filemanagerbookinfo")
|
|
|
|
@ -285,12 +297,12 @@ function filemanagerutil.genBookCoverButton(file, bookinfo, caller_callback, but
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function filemanagerutil.genBookDescriptionButton(file, bookinfo, caller_callback, button_disabled)
|
|
|
|
|
local description = bookinfo and bookinfo.description
|
|
|
|
|
function filemanagerutil.genBookDescriptionButton(file, book_props, caller_callback, button_disabled)
|
|
|
|
|
local description = book_props and book_props.description
|
|
|
|
|
return {
|
|
|
|
|
text = _("Book description"),
|
|
|
|
|
-- enabled for deleted books if description is kept in CoverBrowser bookinfo cache
|
|
|
|
|
enabled = (not (button_disabled or bookinfo) or description) and true or false,
|
|
|
|
|
enabled = (not (button_disabled or book_props) or description) and true or false,
|
|
|
|
|
callback = function()
|
|
|
|
|
caller_callback()
|
|
|
|
|
local FileManagerBookInfo = require("apps/filemanager/filemanagerbookinfo")
|
|
|
|
|