From 36763a1ad7ec8e3e8ccdd07335fd44a610627ff2 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sat, 24 Dec 2016 23:43:09 -0800 Subject: [PATCH 1/2] feat: new setting to show opened book name in bold --- frontend/ui/widget/filechooser.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/frontend/ui/widget/filechooser.lua b/frontend/ui/widget/filechooser.lua index 8897fdcd3..ab09108ce 100644 --- a/frontend/ui/widget/filechooser.lua +++ b/frontend/ui/widget/filechooser.lua @@ -118,6 +118,12 @@ function FileChooser:genItemTableFromPath(path) path = subdir_path }) end + + local show_new_book_in_bold = true -- show new books in bold by default + if G_reader_settings:isTrue("show_opened_doc_in_bold") then + show_new_book_in_bold = false + end + for _, file in ipairs(files) do local full_path = self.path.."/"..file.name local file_size = lfs.attributes(full_path, "size") or 0 @@ -129,11 +135,16 @@ function FileChooser:genItemTableFromPath(path) else sstr = string.format("%d B", file_size) end + local show_in_bold + if show_new_book_in_bold then + show_in_bold = not DocSettings:hasSidecarDir(full_path) + else + show_in_bold = DocSettings:hasSidecarDir(full_path) + end table.insert(item_table, { text = file.name, mandatory = sstr, - -- show new books in bold - bold = not DocSettings:hasSidecarDir(full_path), + bold = show_in_bold, path = full_path }) end From dc2746f1d7174cb8283c49ca77e1b66c62e53b2e Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sat, 24 Dec 2016 23:43:58 -0800 Subject: [PATCH 2/2] chore: various minor cleanups --- frontend/apps/reader/modules/readerfrontlight.lua | 4 +--- frontend/ui/widget/filechooser.lua | 15 +++++++++------ frontend/ui/widget/frontlightwidget.lua | 3 +-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/frontend/apps/reader/modules/readerfrontlight.lua b/frontend/apps/reader/modules/readerfrontlight.lua index 16750865f..2da0c528a 100644 --- a/frontend/apps/reader/modules/readerfrontlight.lua +++ b/frontend/apps/reader/modules/readerfrontlight.lua @@ -83,9 +83,7 @@ end function ReaderFrontLight:onShowFlDialog() local FrontLightWidget = require("ui/widget/frontlightwidget") - local fl = FrontLightWidget:new{ - } - UIManager:show(fl) + UIManager:show(FrontLightWidget:new{}) end function ReaderFrontLight:close() diff --git a/frontend/ui/widget/filechooser.lua b/frontend/ui/widget/filechooser.lua index ab09108ce..14586fdca 100644 --- a/frontend/ui/widget/filechooser.lua +++ b/frontend/ui/widget/filechooser.lua @@ -108,10 +108,13 @@ function FileChooser:genItemTableFromPath(path) local dir_files = {} local subdir_path = self.path.."/"..dir.name self.list(subdir_path, sub_dirs, dir_files) - local items = #sub_dirs + #dir_files - local istr = util.template( - items == 1 and _("1 item") - or _("%1 items"), items) + local num_items = #sub_dirs + #dir_files + local istr + if num_items == 1 then + istr = _("1 item") + else + istr = util.template(_("%1 items"), num_items) + end table.insert(item_table, { text = dir.name.."/", mandatory = istr, @@ -148,8 +151,8 @@ function FileChooser:genItemTableFromPath(path) path = full_path }) end - -- lfs.dir iterated node string may be encoded with some weird codepage on Windows - -- we need to encode them to utf-8 + -- lfs.dir iterated node string may be encoded with some weird codepage on + -- Windows we need to encode them to utf-8 if ffi.os == "Windows" then for k, v in pairs(item_table) do if v.text then diff --git a/frontend/ui/widget/frontlightwidget.lua b/frontend/ui/widget/frontlightwidget.lua index 9abc384c2..ecc8feb1c 100644 --- a/frontend/ui/widget/frontlightwidget.lua +++ b/frontend/ui/widget/frontlightwidget.lua @@ -42,7 +42,7 @@ function FrontLightWidget:init() self.fl_cur = self.fl_min end local steps_fl = self.fl_max - self.fl_min + 1 - self.one_step = math.ceil(steps_fl / 25 ) + self.one_step = math.ceil(steps_fl / 25) self.steps = math.ceil(steps_fl / self.one_step) if (self.steps - 1) * self.one_step < self.fl_max - self.fl_min then self.steps = self.steps + 1 @@ -91,7 +91,6 @@ function FrontLightWidget:generateProgressGroup(width, height, fl_level, step) end function FrontLightWidget:setProgress(num, step) - --clear previous data self.fl_container:clear() local padding_span = VerticalSpan:new{ width = self.span } local button_group_down = HorizontalGroup:new{ align = "center" }