diff --git a/plugins/coverbrowser.koplugin/covermenu.lua b/plugins/coverbrowser.koplugin/covermenu.lua index 00bd14784..db069c4e0 100644 --- a/plugins/coverbrowser.koplugin/covermenu.lua +++ b/plugins/coverbrowser.koplugin/covermenu.lua @@ -59,7 +59,9 @@ function CoverMenu:updateCache(file, status, do_create, pages) local percent_finished = doc_settings:readSetting("percent_finished") local summary = doc_settings:readSetting("summary") status = summary and summary.status - self.cover_info_cache[file] = {pages, percent_finished, status} + local highlight = doc_settings:readSetting("highlight") + local has_highlight = highlight and next(highlight) and true + self.cover_info_cache[file] = {pages, percent_finished, status, has_highlight} else if self.cover_info_cache and self.cover_info_cache[file] then if status then diff --git a/plugins/coverbrowser.koplugin/listmenu.lua b/plugins/coverbrowser.koplugin/listmenu.lua index e2b8688e9..842f73a49 100644 --- a/plugins/coverbrowser.koplugin/listmenu.lua +++ b/plugins/coverbrowser.koplugin/listmenu.lua @@ -26,6 +26,7 @@ local UnderlineContainer = require("ui/widget/container/underlinecontainer") local VerticalGroup = require("ui/widget/verticalgroup") local VerticalSpan = require("ui/widget/verticalspan") local WidgetContainer = require("ui/widget/container/widgetcontainer") +local filemanagerutil = require("apps/filemanager/filemanagerutil") local lfs = require("libs/libkoreader-lfs") local logger = require("logger") local util = require("util") @@ -225,7 +226,7 @@ function ListMenuItem:update() self.is_directory = true -- nb items on the right, directory name on the left local wright = TextWidget:new{ - text = self.mandatory_func and self.mandatory_func() or (self.mandatory and self.mandatory or ""), + text = self.mandatory or "", face = Font:getFace("infont", _fontSize(14, 18)), } local pad_width = Screen:scaleBySize(10) -- on the left, in between, and on the right @@ -358,26 +359,6 @@ function ListMenuItem:update() -- file size (self.mandatory) (not available with History) -- file type -- pages read / nb of pages (not available for crengine doc not opened) - local directory, filename = util.splitFilePathName(self.filepath) -- luacheck: no unused - local filename_without_suffix, filetype = util.splitFileNameSuffix(filename) - local fileinfo_str - if self.mandatory_func then - -- Currently only provided by History, giving the last time read. - -- Just show this date, without the file extension - fileinfo_str = self.mandatory_func() - else - if self.mandatory then - fileinfo_str = BD.wrap(self.mandatory) .. " " .. BD.wrap(filetype) - else - fileinfo_str = filetype - end - if bookinfo._no_provider then - -- for unspported files: don't show extension on the right, - -- keep it in filename - filename_without_suffix = filename - fileinfo_str = self.mandatory - end - end -- Current page / pages are available or more accurate in .sdr/metadata.lua -- We use a cache (cleaned at end of this browsing session) to store -- page, percent read and book status from sidecar files, to avoid @@ -387,12 +368,26 @@ function ListMenuItem:update() end local pages_str = "" local pages = bookinfo.pages -- default to those in bookinfo db - local percent_finished, status + local percent_finished, status, has_highlight if DocSettings:hasSidecarFile(self.filepath) then self.been_opened = true self.menu:updateCache(self.filepath, nil, true, pages) -- create new cache entry if absent - pages, percent_finished, status = unpack(self.menu.cover_info_cache[self.filepath]) + pages, percent_finished, status, has_highlight = unpack(self.menu.cover_info_cache[self.filepath]) end + -- right widget, first line + local directory, filename = util.splitFilePathName(self.filepath) -- luacheck: no unused + local filename_without_suffix, filetype = filemanagerutil.splitFileNameType(filename) + local fileinfo_str + if bookinfo._no_provider then + -- for unspported files: don't show extension on the right, + -- keep it in filename + filename_without_suffix = filename + fileinfo_str = self.mandatory + else + local mark = has_highlight and "\u{2592} " or "" -- "medium shade" + fileinfo_str = mark .. BD.wrap(filetype) .. " " .. BD.wrap(self.mandatory) + end + -- right widget, second line if status == "complete" or status == "abandoned" then -- Display these instead of the read % if pages then @@ -675,11 +670,11 @@ function ListMenuItem:update() local wright local wright_width = 0 local wright_right_padding = 0 - if self.mandatory_func then + if self.mandatory then -- Currently only provided by History, giving the last time read. -- If we have it, we need to build a more complex widget with -- this date on the right - local fileinfo_str = self.mandatory_func() + local fileinfo_str = self.mandatory local fontsize_info = _fontSize(14, 18) local wfileinfo = TextWidget:new{ text = fileinfo_str, @@ -955,11 +950,11 @@ end function ListMenu:_updateItemsBuildUI() -- Build our list - table.insert(self.item_group, LineWidget:new{ - dimen = Geom:new{ w = self.width, h = Size.line.thin }, - background = Blitbuffer.COLOR_DARK_GRAY, - style = "solid", - }) + local line_widget = LineWidget:new{ + dimen = Geom:new{ w = self.width or self.screen_w, h = Size.line.thin }, + background = Blitbuffer.COLOR_DARK_GRAY, + } + table.insert(self.item_group, line_widget) local idx_offset = (self.page - 1) * self.perpage for idx = 1, self.perpage do local entry = self.item_table[idx_offset + idx] @@ -984,7 +979,6 @@ function ListMenu:_updateItemsBuildUI() text = getMenuText(entry), show_parent = self.show_parent, mandatory = entry.mandatory, - mandatory_func = entry.mandatory_func, dimen = self.item_dimen:new(), shortcut = item_shortcut, shortcut_style = shortcut_style, @@ -994,11 +988,7 @@ function ListMenu:_updateItemsBuildUI() do_filename_only = self._do_filename_only, } table.insert(self.item_group, item_tmp) - table.insert(self.item_group, LineWidget:new{ - dimen = Geom:new{ w = self.width, h = Size.line.thin }, - background = Blitbuffer.COLOR_DARK_GRAY, - style = "solid", - }) + table.insert(self.item_group, line_widget) -- this is for focus manager table.insert(self.layout, {item_tmp})