Add buttons to collections

reviewable/pr10074/r12^2
Melik 1 year ago committed by Frans de Jonge
parent 57849b3f7c
commit a9313dda1a

@ -8,6 +8,7 @@ local ReadCollection = require("readcollection")
local UIManager = require("ui/uimanager")
local WidgetContainer = require("ui/widget/container/widgetcontainer")
local Screen = require("device").screen
local filemanagerutil = require("apps/filemanager/filemanagerutil")
local BaseUtil = require("ffi/util")
local util = require("util")
local _ = require("gettext")
@ -42,7 +43,38 @@ end
function FileManagerCollection:onMenuHold(item)
self.collfile_dialog = nil
local status = filemanagerutil.getStatus(item.file)
local buttons = {
{
{
text = _("Mark as reading"),
enabled = status ~= "reading",
callback = function()
filemanagerutil.setStatus(item.file, "reading")
self._manager:updateItemTable()
UIManager:close(self.collfile_dialog)
end,
},
{
text = _("Mark as read"),
enabled = status ~= "complete",
callback = function()
filemanagerutil.setStatus(item.file, "complete")
self._manager:updateItemTable()
UIManager:close(self.collfile_dialog)
end,
},
{
text = _("Put on hold"),
enabled = status ~= "abandoned",
callback = function()
filemanagerutil.setStatus(item.file, "abandoned")
self._manager:updateItemTable()
UIManager:close(self.collfile_dialog)
end,
},
},
{},
{
{
text = _("Sort"),

@ -625,6 +625,28 @@ function CoverMenu:onCollectionsMenuHold(item)
},
})
-- Fudge the setting resets (e.g. "Reset settings" button) to also trash the cover_info_cache
local orig_purgeSettings = filemanagerutil.purgeSettings
filemanagerutil.purgeSettings = function(f)
-- Wipe the cache
if self.cover_info_cache and self.cover_info_cache[f] then
self.cover_info_cache[f] = nil
end
-- And then purge the sidecar folder as expected
orig_purgeSettings(f)
end
-- Fudge status changes (e.g. "Mark as read" button) to also update the cover_info_cache
local orig_setStatus = filemanagerutil.setStatus
filemanagerutil.setStatus = function(f, status)
-- Update the cache
if self.cover_info_cache and self.cover_info_cache[f] then
self.cover_info_cache[f][3] = status
end
-- And then set the status on file as expected
orig_setStatus(f, status)
end
-- Create the new ButtonDialog, and let UIManager show it
local ButtonDialogTitle = require("ui/widget/buttondialogtitle")
self.collfile_dialog = ButtonDialogTitle:new{

Loading…
Cancel
Save