Another set of fixes (#4083)

* Make findcalibre actually useful

By setting SEARCH_LIBRARY_PATH when a Calibre tree is found, so that
book paths can properly be constructed.

Users should still very much set it themselves, but at least everything
works as intended when not, instead of mysteriously half-breaking later.

Drop the SetDefaults bits, it appeared to have been added to fix no-ops
detected by Luacheck, and it's actually non-functional, because
SetDefaults doesn't handle saving variables it did not itself assign.
So this was just causing the "Do you want to save new defaults" popup to
show up on exit, but it couldn't actually do anything useful (like, say,
save the new SEARCH_LIBRARY_PATH value).

fix #4082

* Better comments about the state of NaturalLight on the Clara, and how this might translate to the H2O²r2.

re #4015

* Make ScrolltextWidget refresh as "partial" only on actual Scroll events

Moving the cursor should stay "ui", or things gets annoying really fast
;).

re #4084

* Bump base to pickup ZMQ fixes (fix #4086)
pull/4096/head
NiLuJe 6 years ago committed by GitHub
parent d4ebcd26c9
commit fea0d8dbaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1 +1 @@
Subproject commit 3b2706a0db4133a90027e49bd994bec74919882c
Subproject commit 3d160a41b81433135fcbcf0971a4e51c571419bf

@ -6,7 +6,6 @@ local InfoMessage = require("ui/widget/infomessage")
local InputContainer = require("ui/widget/container/inputcontainer")
local Menu = require("ui/widget/menu")
local Screen = require("device").screen
local SetDefaults = require("apps/filemanager/filemanagersetdefaults")
local UIManager = require("ui/uimanager")
local lfs = require("libs/libkoreader-lfs")
local logger = require("logger")
@ -56,6 +55,12 @@ local function findcalibre(root)
if mode == "file" then
if entity == calibre or entity == "." .. calibre then
t = root .. "/" .. entity
-- If we got so far, SEARCH_LIBRARY_PATH is either empty or bogus, so, re-set it,
-- so that we actually can convert a book's relative path to its absolute path.
-- NOTE: No-one should actually rely on that, as the value is *NEVER* saved to the defaults.
-- (SetDefaults can only do that with values modified from within its own advanced menu).
_G['SEARCH_LIBRARY_PATH'] = root .. "/"
logger.info("FMSearch: Found a SEARCH_LIBRARY_PATH @", SEARCH_LIBRARY_PATH)
end
elseif mode == "directory" then
t = findcalibre(fullPath)
@ -75,12 +80,10 @@ function Search:getCalibre()
self.metafile_1 = findcalibre("/mnt")
if not self.metafile_1 then
self.error = _("SEARCH_LIBRARY_PATH should be defined in DEFAULTS.LUA.")
else
SetDefaults.settings_changed = true
end
else
if string.sub(SEARCH_LIBRARY_PATH, string.len(SEARCH_LIBRARY_PATH)) ~= "/" then
SEARCH_LIBRARY_PATH = SEARCH_LIBRARY_PATH .. "/" -- luacheck: ignore
_G['SEARCH_LIBRARY_PATH'] = SEARCH_LIBRARY_PATH .. "/"
end
if io.open(SEARCH_LIBRARY_PATH .. calibre, "r") == nil then
if io.open(SEARCH_LIBRARY_PATH .. "." .. calibre, "r") == nil then
@ -98,16 +101,13 @@ function Search:getCalibre()
UIManager:show(InfoMessage:new{text = _("You must specify at least one field to search at! (SEARCH_XXX = true in defaults.lua)")})
elseif self.metafile_1 == nil then
self.metafile_1 = findcalibre("/mnt")
if self.metafile_1 then
SetDefaults.settings_changed = true
end
end
end
-- check 2nd file
local dummy
if string.sub(SEARCH_LIBRARY_PATH2, string.len(SEARCH_LIBRARY_PATH2)) ~= "/" then
SEARCH_LIBRARY_PATH2 = SEARCH_LIBRARY_PATH2 .. "/" -- luacheck: ignore
_G['SEARCH_LIBRARY_PATH2'] = SEARCH_LIBRARY_PATH2 .. "/"
end
if io.open(SEARCH_LIBRARY_PATH2 .. calibre, "r") == nil then
if io.open(SEARCH_LIBRARY_PATH2 .. "." .. calibre, "r") ~= nil then
@ -127,13 +127,15 @@ function Search:getCalibre()
if self.metafile_1 then
pcall(lfs.mkdir("temp"))
if io.open(koreaderfile, "r") then
if lfs.attributes(koreaderfile).modification > lfs.attributes(self.metafile_1).modification then
if lfs.attributes(koreaderfile, "modification") > lfs.attributes(self.metafile_1, "modification") then
if self.metafile_2 then
if lfs.attributes(koreaderfile).modification > lfs.attributes(self.metafile_2).modification then
if lfs.attributes(koreaderfile, "modification") > lfs.attributes(self.metafile_2, "modification") then
self.use_own_metadata_file = true
logger.info("FMSearch: Using our own simplified metadata file as it's newer than", self.metafile_2)
end
else
self.use_own_metadata_file = true
logger.info("FMSearch: Using our own simplified metadata file as it's newer than", self.metafile_1)
end
end
end
@ -153,7 +155,7 @@ function Search:ShowSearch()
enabled = true,
callback = function()
self.search_value = self.search_dialog:getInputText()
if not SetDefaults.settings_changed and self.search_value == dummy and self.lastsearch == "series" then
if self.search_value == dummy and self.lastsearch == "series" then
self.use_previous_search_results = true
else
self.use_previous_search_results = false
@ -167,7 +169,7 @@ function Search:ShowSearch()
enabled = true,
callback = function()
self.search_value = self.search_dialog:getInputText()
if not SetDefaults.settings_changed and self.search_value == dummy and self.lastsearch == "tags" then
if self.search_value == dummy and self.lastsearch == "tags" then
self.use_previous_search_results = true
else
self.use_previous_search_results = false
@ -191,7 +193,7 @@ function Search:ShowSearch()
enabled = true,
callback = function()
self.search_value = self.search_dialog:getInputText()
if not SetDefaults.settings_changed and self.search_value == dummy and self.lastsearch == "find" then
if self.search_value == dummy and self.lastsearch == "find" then
self.use_previous_search_results = true
else
self.use_previous_search_results = false
@ -346,6 +348,8 @@ function Search:find(option)
self.browse_tags[string.sub(j, 2)] = (self.browse_tags[string.sub(j, 2)] or 0) + 1
end
end
-- NOTE: This skips kePubs downloaded by nickel, because they don't have a file extension,
-- they're stored as .kobo/kepub/<UUID>
if DocumentRegistry:hasProvider(self.data[i][self.path]) then
if upsearch ~= "" then
if string.find(search_content, upsearch, nil, true) then
@ -375,10 +379,11 @@ function Search:find(option)
end
end
if not self.use_own_metadata_file then
logger.info("FMSearch: Writing our own simplified metadata file . . .")
local g = io.open(koreaderfile, "w")
g:write("#metadata.koreader Version 1.1\n")
f = io.open(self.metafile_1)
f = io.open(self.metafile_1, "r")
line = f:read()
while line do
if line == " }, " or line == " }" then
@ -448,20 +453,20 @@ function Search:find(option)
firstrun = false
if self.metafile_2 then
f = io.open(self.metafile_2)
f = io.open(self.metafile_2, "r")
line = f:read()
end
end
end
g.close()
if lfs.attributes(koreaderfile).modification < lfs.attributes(self.metafile_1).modification then
if lfs.attributes(koreaderfile, "modification") < lfs.attributes(self.metafile_1, "modification") then
lfs.touch(koreaderfile,
lfs.attributes(self.metafile_1).modification + 1,
lfs.attributes(self.metafile_1).modification + 1)
lfs.attributes(self.metafile_1, "modification") + 1,
lfs.attributes(self.metafile_1, "modification") + 1)
end
if self.metafile_2 then
if lfs.attributes(koreaderfile).modification < lfs.attributes(self.metafile_2).modification then
lfs.touch(koreaderfile, lfs.attributes(self.metafile_2).modification + 1, lfs.attributes(self.metafile_2).modification + 1)
if lfs.attributes(koreaderfile, "modification") < lfs.attributes(self.metafile_2, "modification") then
lfs.touch(koreaderfile, lfs.attributes(self.metafile_2, "modification") + 1, lfs.attributes(self.metafile_2, "modification") + 1)
end
end
end
@ -487,7 +492,7 @@ function Search:onMenuHold(item)
if item.notchecked then
item.info = item.info .. item.path
local f = io.open(item.path)
local f = io.open(item.path, "r")
if f == nil then
item.info = item.info .. "\n" .. _("File not found!")
else

@ -123,7 +123,7 @@ local KoboSnow = Kobo:new{
}
-- Kobo Aura H2O2, Rev2:
-- FIXME: Shares FL/NaturalLight issues with the Clara (#4015)
-- FIXME: Check if the Clara fix actually helps here... (#4015)
local KoboSnowRev2 = Kobo:new{
model = "Kobo_snow",
hasFrontlight = yes,
@ -134,8 +134,8 @@ local KoboSnowRev2 = Kobo:new{
hasNaturalLight = yes,
frontlight_settings = {
frontlight_white = "/sys/class/backlight/lm3630a_ledb",
frontlight_red = "/sys/class/backlight/lm3630a_led",
frontlight_green = "/sys/class/backlight/lm3630a_leda",
frontlight_red = "/sys/class/backlight/lm3630a_leda",
frontlight_green = "/dev/null",
},
}
@ -179,7 +179,6 @@ local KoboPika = Kobo:new{
}
-- Kobo Clara HD:
-- FIXME: Check that NaturalLight behaves properly (c.f., #4015)
local KoboNova = Kobo:new{
model = "Kobo_nova",
hasFrontlight = yes,
@ -189,7 +188,11 @@ local KoboNova = Kobo:new{
frontlight_settings = {
frontlight_white = "/sys/class/backlight/lm3630a_ledb",
frontlight_red = "/sys/class/backlight/lm3630a_leda",
frontlight_green = "/sys/class/backlight/lm3630a_led1b",
-- NOTE: There doesn't appear to be a dedicated "green" LED, instead,
-- there's a knob that mixes the white & red ones together (/sys/class/backlight/lm3630a_led).
-- c.f., https://www.mobileread.com/forums/showpost.php?p=3728236&postcount=2947
-- Because I'm not familiar with sysfs_light.lua, just throw green into the void, and hope for the best...
frontlight_green = "/dev/null",
},
}

@ -108,14 +108,18 @@ function ScrollTextWidget:getCharPos()
return self.text_widget:getCharPos()
end
function ScrollTextWidget:updateScrollBar()
function ScrollTextWidget:updateScrollBar(is_partial)
local low, high = self.text_widget:getVisibleHeightRatios()
if low ~= self.prev_low or high ~= self.prev_high then
self.prev_low = low
self.prev_high = high
self.v_scroll_bar:set(low, high)
local refreshfunc = "ui"
if is_partial then
refreshfunc = "partial"
end
UIManager:setDirty(self.dialog, function()
return "partial", self.dimen
return refreshfunc, self.dimen
end)
end
end
@ -152,22 +156,22 @@ end
function ScrollTextWidget:scrollDown()
self.text_widget:scrollDown();
self:updateScrollBar()
self:updateScrollBar(true)
end
function ScrollTextWidget:scrollUp()
self.text_widget:scrollUp();
self:updateScrollBar()
self:updateScrollBar(true)
end
function ScrollTextWidget:scrollToTop()
self.text_widget:scrollToTop();
self:updateScrollBar()
self:updateScrollBar(true)
end
function ScrollTextWidget:scrollToBottom()
self.text_widget:scrollToBottom();
self:updateScrollBar()
self:updateScrollBar(true)
end
function ScrollTextWidget:scrollText(direction)
@ -177,12 +181,12 @@ function ScrollTextWidget:scrollText(direction)
else
self.text_widget:scrollUp()
end
self:updateScrollBar()
self:updateScrollBar(true)
end
function ScrollTextWidget:scrollToRatio(ratio)
self.text_widget:scrollToRatio(ratio)
self:updateScrollBar()
self:updateScrollBar(true)
end
function ScrollTextWidget:onScrollText(arg, ges)

Loading…
Cancel
Save