mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
Collections: add collection mark to books (#11868)
This commit is contained in:
@@ -293,7 +293,7 @@ function FileManager:setupLayout()
|
|||||||
table.insert(buttons, {}) -- separator
|
table.insert(buttons, {}) -- separator
|
||||||
table.insert(buttons, {
|
table.insert(buttons, {
|
||||||
filemanagerutil.genResetSettingsButton(doc_settings_or_file, close_dialog_refresh_callback),
|
filemanagerutil.genResetSettingsButton(doc_settings_or_file, close_dialog_refresh_callback),
|
||||||
file_manager.collections:genAddToCollectionButton(file, close_dialog_callback),
|
file_manager.collections:genAddToCollectionButton(file, close_dialog_callback, refresh_callback),
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
table.insert(buttons, {
|
table.insert(buttons, {
|
||||||
|
|||||||
@@ -70,8 +70,14 @@ function FileManagerHistory:updateItemTable()
|
|||||||
local item_table = {}
|
local item_table = {}
|
||||||
for _, v in ipairs(require("readhistory").hist) do
|
for _, v in ipairs(require("readhistory").hist) do
|
||||||
if self:isItemMatch(v) then
|
if self:isItemMatch(v) then
|
||||||
v.mandatory_dim = (self.is_frozen and v.status == "complete") and true or nil
|
local item = util.tableDeepCopy(v)
|
||||||
table.insert(item_table, v)
|
if item.select_enabled and ReadCollection:isFileInCollections(item.file) then
|
||||||
|
item.mandatory = "☆ " .. item.mandatory
|
||||||
|
end
|
||||||
|
if self.is_frozen and item.status == "complete" then
|
||||||
|
item.mandatory_dim = true
|
||||||
|
end
|
||||||
|
table.insert(item_table, item)
|
||||||
end
|
end
|
||||||
if self.statuses_fetched then
|
if self.statuses_fetched then
|
||||||
self.count[v.status] = self.count[v.status] + 1
|
self.count[v.status] = self.count[v.status] + 1
|
||||||
@@ -150,6 +156,9 @@ function FileManagerHistory:onMenuHold(item)
|
|||||||
self._manager:updateItemTable()
|
self._manager:updateItemTable()
|
||||||
self._manager.files_updated = true -- sidecar folder may be created/deleted
|
self._manager.files_updated = true -- sidecar folder may be created/deleted
|
||||||
end
|
end
|
||||||
|
local function update_callback()
|
||||||
|
self._manager:updateItemTable()
|
||||||
|
end
|
||||||
local is_currently_opened = file == (self.ui.document and self.ui.document.file)
|
local is_currently_opened = file == (self.ui.document and self.ui.document.file)
|
||||||
|
|
||||||
local buttons = {}
|
local buttons = {}
|
||||||
@@ -178,7 +187,7 @@ function FileManagerHistory:onMenuHold(item)
|
|||||||
end
|
end
|
||||||
table.insert(buttons, {
|
table.insert(buttons, {
|
||||||
filemanagerutil.genResetSettingsButton(doc_settings_or_file, close_dialog_update_callback, is_currently_opened),
|
filemanagerutil.genResetSettingsButton(doc_settings_or_file, close_dialog_update_callback, is_currently_opened),
|
||||||
self._manager.ui.collections:genAddToCollectionButton(file, close_dialog_callback, nil, item.dim),
|
self._manager.ui.collections:genAddToCollectionButton(file, close_dialog_callback, update_callback, item.dim),
|
||||||
})
|
})
|
||||||
table.insert(buttons, {
|
table.insert(buttons, {
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ local DocumentRegistry = require("document/documentregistry")
|
|||||||
local FileManagerShortcuts = require("apps/filemanager/filemanagershortcuts")
|
local FileManagerShortcuts = require("apps/filemanager/filemanagershortcuts")
|
||||||
local filemanagerutil = require("apps/filemanager/filemanagerutil")
|
local filemanagerutil = require("apps/filemanager/filemanagerutil")
|
||||||
local Menu = require("ui/widget/menu")
|
local Menu = require("ui/widget/menu")
|
||||||
|
local ReadCollection = require("readcollection")
|
||||||
local UIManager = require("ui/uimanager")
|
local UIManager = require("ui/uimanager")
|
||||||
local ffi = require("ffi")
|
local ffi = require("ffi")
|
||||||
local ffiUtil = require("ffi/util")
|
local ffiUtil = require("ffi/util")
|
||||||
@@ -475,6 +476,9 @@ function FileChooser:getMenuItemMandatory(item, collate)
|
|||||||
else
|
else
|
||||||
text = util.getFriendlySize(item.attr.size or 0)
|
text = util.getFriendlySize(item.attr.size or 0)
|
||||||
end
|
end
|
||||||
|
if ReadCollection:isFileInCollections(item.path) then
|
||||||
|
text = "☆ " .. text
|
||||||
|
end
|
||||||
else -- folder, count number of folders and files inside it
|
else -- folder, count number of folders and files inside it
|
||||||
local sub_dirs, dir_files = self:getList(item.path)
|
local sub_dirs, dir_files = self:getList(item.path)
|
||||||
text = T("%1 \u{F016}", #dir_files)
|
text = T("%1 \u{F016}", #dir_files)
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ local IconWidget = require("ui/widget/iconwidget")
|
|||||||
local ImageWidget = require("ui/widget/imagewidget")
|
local ImageWidget = require("ui/widget/imagewidget")
|
||||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||||
local LeftContainer = require("ui/widget/container/leftcontainer")
|
local LeftContainer = require("ui/widget/container/leftcontainer")
|
||||||
local ProgressWidget = require("ui/widget/progresswidget")
|
|
||||||
local OverlapGroup = require("ui/widget/overlapgroup")
|
local OverlapGroup = require("ui/widget/overlapgroup")
|
||||||
|
local ProgressWidget = require("ui/widget/progresswidget")
|
||||||
|
local ReadCollection = require("readcollection")
|
||||||
local Size = require("ui/size")
|
local Size = require("ui/size")
|
||||||
local TextBoxWidget = require("ui/widget/textboxwidget")
|
local TextBoxWidget = require("ui/widget/textboxwidget")
|
||||||
local TextWidget = require("ui/widget/textwidget")
|
local TextWidget = require("ui/widget/textwidget")
|
||||||
@@ -37,13 +38,14 @@ local BookInfoManager = require("bookinfomanager")
|
|||||||
|
|
||||||
-- We will show a rotated dogear at bottom right corner of cover widget for
|
-- We will show a rotated dogear at bottom right corner of cover widget for
|
||||||
-- opened files (the dogear will make it look like a "used book")
|
-- opened files (the dogear will make it look like a "used book")
|
||||||
-- The ImageWidget Will be created when we know the available height (and
|
-- The ImageWidget will be created when we know the available height (and
|
||||||
-- recreated if height changes)
|
-- recreated if height changes)
|
||||||
local corner_mark_size = -1
|
local corner_mark_size
|
||||||
local corner_mark
|
local corner_mark
|
||||||
local reading_mark
|
local reading_mark
|
||||||
local abandoned_mark
|
local abandoned_mark
|
||||||
local complete_mark
|
local complete_mark
|
||||||
|
local collection_mark
|
||||||
local progress_widget
|
local progress_widget
|
||||||
|
|
||||||
-- ItemShortCutIcon (for keyboard navigation) is private to menu.lua and can't be accessed,
|
-- ItemShortCutIcon (for keyboard navigation) is private to menu.lua and can't be accessed,
|
||||||
@@ -89,10 +91,9 @@ function ItemShortCutIcon:init()
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- We may find a better algorithm, or just a set of
|
-- We may find a better algorithm, or just a set of
|
||||||
-- nice looking combinations of 3 sizes to iterate thru
|
-- nice looking combinations of 3 sizes to iterate thru
|
||||||
-- The rendering of the TextBoxWidget we're doing below
|
-- the rendering of the TextBoxWidget we're doing below
|
||||||
-- with decreasing font sizes till it fits is quite expensive.
|
-- with decreasing font sizes till it fits is quite expensive.
|
||||||
|
|
||||||
local FakeCover = FrameContainer:extend{
|
local FakeCover = FrameContainer:extend{
|
||||||
@@ -349,8 +350,6 @@ local MosaicMenuItem = InputContainer:extend{
|
|||||||
text = nil,
|
text = nil,
|
||||||
show_parent = nil,
|
show_parent = nil,
|
||||||
dimen = nil,
|
dimen = nil,
|
||||||
shortcut = nil,
|
|
||||||
shortcut_style = "square",
|
|
||||||
_underline_container = nil,
|
_underline_container = nil,
|
||||||
do_cover_image = false,
|
do_cover_image = false,
|
||||||
do_hint_opened = false,
|
do_hint_opened = false,
|
||||||
@@ -737,16 +736,35 @@ function MosaicMenuItem:paintTo(bb, x, y)
|
|||||||
self.shortcut_icon:paintTo(bb, x+ix, y+iy)
|
self.shortcut_icon:paintTo(bb, x+ix, y+iy)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- other paintings are anchored to the sub-widget (cover image)
|
||||||
|
local target = self[1][1][1]
|
||||||
|
|
||||||
|
if self.entry.order == nil -- File manager, History
|
||||||
|
and ReadCollection:isFileInCollections(self.filepath) then
|
||||||
|
-- top right corner
|
||||||
|
local ix, rect_ix
|
||||||
|
if BD.mirroredUILayout() then
|
||||||
|
ix = math.floor((self.width - target.dimen.w)/2)
|
||||||
|
rect_ix = target.bordersize
|
||||||
|
else
|
||||||
|
ix = self.width - math.ceil((self.width - target.dimen.w)/2) - corner_mark_size
|
||||||
|
rect_ix = 0
|
||||||
|
end
|
||||||
|
local iy = 0
|
||||||
|
local rect_size = corner_mark_size - target.bordersize
|
||||||
|
bb:paintRect(x+ix+rect_ix, y+target.bordersize, rect_size, rect_size, Blitbuffer.COLOR_GRAY)
|
||||||
|
collection_mark:paintTo(bb, x+ix, y+iy)
|
||||||
|
end
|
||||||
|
|
||||||
if self.do_hint_opened and self.been_opened then
|
if self.do_hint_opened and self.been_opened then
|
||||||
-- align it on bottom right corner of sub-widget
|
-- bottom right corner
|
||||||
local target = self[1][1][1]
|
|
||||||
local ix
|
local ix
|
||||||
if BD.mirroredUILayout() then
|
if BD.mirroredUILayout() then
|
||||||
ix = math.floor((self.width - target.dimen.w)/2)
|
ix = math.floor((self.width - target.dimen.w)/2)
|
||||||
else
|
else
|
||||||
ix = self.width - math.ceil((self.width - target.dimen.w)/2) - corner_mark:getSize().w
|
ix = self.width - math.ceil((self.width - target.dimen.w)/2) - corner_mark_size
|
||||||
end
|
end
|
||||||
local iy = self.height - math.ceil((self.height - target.dimen.h)/2) - corner_mark:getSize().h
|
local iy = self.height - math.ceil((self.height - target.dimen.h)/2) - corner_mark_size
|
||||||
-- math.ceil() makes it looks better than math.floor()
|
-- math.ceil() makes it looks better than math.floor()
|
||||||
if self.status == "abandoned" then
|
if self.status == "abandoned" then
|
||||||
corner_mark = abandoned_mark
|
corner_mark = abandoned_mark
|
||||||
@@ -759,9 +777,8 @@ function MosaicMenuItem:paintTo(bb, x, y)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if self.show_progress_bar then
|
if self.show_progress_bar then
|
||||||
local cover_item = self[1][1][1]
|
|
||||||
local progress_widget_margin = math.floor((corner_mark_size - progress_widget.height) / 2)
|
local progress_widget_margin = math.floor((corner_mark_size - progress_widget.height) / 2)
|
||||||
progress_widget.width = cover_item.width - 2*progress_widget_margin
|
progress_widget.width = target.width - 2*progress_widget_margin
|
||||||
local pos_x = x + math.ceil((self.width - progress_widget.width) / 2)
|
local pos_x = x + math.ceil((self.width - progress_widget.width) / 2)
|
||||||
if self.do_hint_opened then
|
if self.do_hint_opened then
|
||||||
progress_widget.width = progress_widget.width - corner_mark_size
|
progress_widget.width = progress_widget.width - corner_mark_size
|
||||||
@@ -769,7 +786,7 @@ function MosaicMenuItem:paintTo(bb, x, y)
|
|||||||
pos_x = pos_x + corner_mark_size
|
pos_x = pos_x + corner_mark_size
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local pos_y = y + self.height - math.ceil((self.height - cover_item.height) / 2) - corner_mark_size + progress_widget_margin
|
local pos_y = y + self.height - math.ceil((self.height - target.height) / 2) - corner_mark_size + progress_widget_margin
|
||||||
if self.status == "abandoned" then
|
if self.status == "abandoned" then
|
||||||
progress_widget.fillcolor = Blitbuffer.COLOR_GRAY_6
|
progress_widget.fillcolor = Blitbuffer.COLOR_GRAY_6
|
||||||
else
|
else
|
||||||
@@ -782,7 +799,6 @@ function MosaicMenuItem:paintTo(bb, x, y)
|
|||||||
-- to which we paint a small indicator if this book has a description
|
-- to which we paint a small indicator if this book has a description
|
||||||
if self.has_description and not BookInfoManager:getSetting("no_hint_description") then
|
if self.has_description and not BookInfoManager:getSetting("no_hint_description") then
|
||||||
-- On book's right (for similarity to ListMenuItem)
|
-- On book's right (for similarity to ListMenuItem)
|
||||||
local target = self[1][1][1]
|
|
||||||
local d_w = Screen:scaleBySize(3)
|
local d_w = Screen:scaleBySize(3)
|
||||||
local d_h = math.ceil(target.dimen.h / 8)
|
local d_h = math.ceil(target.dimen.h / 8)
|
||||||
-- Paint it directly relative to target.dimen.x/y which has been computed at this point
|
-- Paint it directly relative to target.dimen.x/y which has been computed at this point
|
||||||
@@ -907,7 +923,15 @@ function MosaicMenu:_recalculateDimen()
|
|||||||
width = corner_mark_size,
|
width = corner_mark_size,
|
||||||
height = corner_mark_size,
|
height = corner_mark_size,
|
||||||
}
|
}
|
||||||
corner_mark = reading_mark
|
if collection_mark then
|
||||||
|
collection_mark:free()
|
||||||
|
end
|
||||||
|
collection_mark = IconWidget:new{
|
||||||
|
icon = "star.white",
|
||||||
|
width = corner_mark_size,
|
||||||
|
height = corner_mark_size,
|
||||||
|
alpha = true,
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Create or replace progress_widget if needed
|
-- Create or replace progress_widget if needed
|
||||||
|
|||||||
9
resources/icons/mdlight/star.white.svg
Normal file
9
resources/icons/mdlight/star.white.svg
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<svg width="48.636189" height="48" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" enable-background="new 0 0 76.00 76.00" version="1.1" xml:space="preserve">
|
||||||
|
<metadata id="metadata2009">image/svg+xml</metadata>
|
||||||
|
|
||||||
|
<g class="layer">
|
||||||
|
<title>Layer 1</title>
|
||||||
|
<path d="m6.32,20.09l13.75,0l4.25,-12.67l4.25,12.67l13.75,0l-11.13,7.82l4.25,12.67l-11.12,-7.83l-11.13,7.83l4.25,-12.67l-11.12,-7.82z" fill="#ffffff" id="path2001" stroke="#000000" stroke-width="2"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 520 B |
Reference in New Issue
Block a user