mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
History: fix book info buttons disable (#10244)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
local BD = require("ui/bidi")
|
||||
local ButtonDialogTitle = require("ui/widget/buttondialogtitle")
|
||||
local ConfirmBox = require("ui/widget/confirmbox")
|
||||
local FileManagerBookInfo = require("apps/filemanager/filemanagerbookinfo")
|
||||
local Menu = require("ui/widget/menu")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
@@ -78,6 +77,10 @@ function FileManagerHistory:onSetDimensions(dimen)
|
||||
self.dimen = dimen
|
||||
end
|
||||
|
||||
function FileManagerHistory:onMenuChoice(item)
|
||||
require("apps/reader/readerui"):showReader(item.file)
|
||||
end
|
||||
|
||||
function FileManagerHistory:onMenuHold(item)
|
||||
self.histfile_dialog = nil
|
||||
local function status_button_callback()
|
||||
@@ -122,33 +125,11 @@ function FileManagerHistory:onMenuHold(item)
|
||||
FileManager:showDeleteFileDialog(item.file, post_delete_callback)
|
||||
end,
|
||||
},
|
||||
{
|
||||
text = _("Book information"),
|
||||
id = "book_information", -- used by covermenu
|
||||
enabled = not item.dim,
|
||||
callback = function()
|
||||
UIManager:close(self.histfile_dialog)
|
||||
FileManagerBookInfo:show(item.file)
|
||||
end,
|
||||
},
|
||||
filemanagerutil.genBookInformationButton(item.file, self.histfile_dialog, item.dim),
|
||||
})
|
||||
table.insert(buttons, {
|
||||
{
|
||||
text = _("Book cover"),
|
||||
id = "book_cover", -- used by covermenu
|
||||
callback = function()
|
||||
UIManager:close(self.histfile_dialog)
|
||||
FileManagerBookInfo:onShowBookCover(item.file)
|
||||
end,
|
||||
},
|
||||
{
|
||||
text = _("Book description"),
|
||||
id = "book_description", -- used by covermenu
|
||||
callback = function()
|
||||
UIManager:close(self.histfile_dialog)
|
||||
FileManagerBookInfo:onShowBookDescription(nil, item.file)
|
||||
end,
|
||||
},
|
||||
filemanagerutil.genBookCoverButton(item.file, self.histfile_dialog, item.dim),
|
||||
filemanagerutil.genBookDescriptionButton(item.file, self.histfile_dialog, item.dim),
|
||||
})
|
||||
|
||||
self.histfile_dialog = ButtonDialogTitle:new{
|
||||
@@ -180,13 +161,12 @@ end
|
||||
function FileManagerHistory:onShowHist()
|
||||
self.hist_menu = Menu:new{
|
||||
ui = self.ui,
|
||||
width = Screen:getWidth(),
|
||||
height = Screen:getHeight(),
|
||||
covers_fullscreen = true, -- hint for UIManager:_repaint()
|
||||
is_borderless = true,
|
||||
is_popout = false,
|
||||
title_bar_left_icon = "appbar.menu",
|
||||
onLeftButtonTap = function() self:showHistDialog() end,
|
||||
onMenuChoice = self.onMenuChoice,
|
||||
onMenuHold = self.onMenuHold,
|
||||
onSetRotationMode = self.MenuSetRotationModeHandler,
|
||||
_manager = self,
|
||||
|
||||
@@ -140,6 +140,42 @@ function filemanagerutil.genResetSettingsButton(file, caller_callback, button_di
|
||||
}
|
||||
end
|
||||
|
||||
function filemanagerutil.genBookInformationButton(file, dialog, button_disabled)
|
||||
return {
|
||||
text = _("Book information"),
|
||||
id = "book_information", -- used by covermenu
|
||||
enabled = not button_disabled,
|
||||
callback = function()
|
||||
UIManager:close(dialog)
|
||||
require("apps/filemanager/filemanagerbookinfo"):show(file)
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
function filemanagerutil.genBookDescriptionButton(file, dialog, button_disabled)
|
||||
return {
|
||||
text = _("Book description"),
|
||||
id = "book_description", -- used by covermenu
|
||||
enabled = not button_disabled,
|
||||
callback = function()
|
||||
UIManager:close(dialog)
|
||||
require("apps/filemanager/filemanagerbookinfo"):onShowBookDescription(nil, file)
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
function filemanagerutil.genBookCoverButton(file, dialog, button_disabled)
|
||||
return {
|
||||
text = _("Book cover"),
|
||||
id = "book_cover", -- used by covermenu
|
||||
enabled = not button_disabled,
|
||||
callback = function()
|
||||
UIManager:close(dialog)
|
||||
require("apps/filemanager/filemanagerbookinfo"):onShowBookCover(file)
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
-- Generate "Execute script" file dialog button
|
||||
function filemanagerutil.genExecuteScriptButton(file, caller_callback)
|
||||
return {
|
||||
|
||||
@@ -16,24 +16,16 @@ local ReadHistory = {
|
||||
last_read_time = 0,
|
||||
}
|
||||
|
||||
local function selectCallback(path)
|
||||
local ReaderUI = require("apps/reader/readerui")
|
||||
ReaderUI:showReader(path)
|
||||
end
|
||||
|
||||
local function buildEntry(input_time, input_file)
|
||||
local file_path = realpath(input_file) or input_file -- keep orig file path of deleted files
|
||||
local is_file_deleted = lfs.attributes(file_path, "mode") ~= "file"
|
||||
local file_exists = lfs.attributes(file_path, "mode") == "file"
|
||||
return {
|
||||
time = input_time,
|
||||
file = file_path,
|
||||
text = input_file:gsub(".*/", ""),
|
||||
dim = is_file_deleted,
|
||||
dim = not file_exists,
|
||||
mandatory = datetime.secondsToDateTime(input_time),
|
||||
select_enabled = not is_file_deleted,
|
||||
callback = function()
|
||||
selectCallback(input_file)
|
||||
end,
|
||||
select_enabled = file_exists,
|
||||
}
|
||||
end
|
||||
|
||||
@@ -196,9 +188,6 @@ function ReadHistory:updateItemByPath(old_path, new_path)
|
||||
if index then
|
||||
self.hist[index].file = new_path
|
||||
self.hist[index].text = new_path:gsub(".*/", "")
|
||||
self.hist[index].callback = function()
|
||||
selectCallback(new_path)
|
||||
end
|
||||
self:_flush()
|
||||
self:reload(true)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user