mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #1804 from houqp/houqp-master
enable luacheck in travis build
This commit is contained in:
@@ -90,3 +90,7 @@ read_globals = {
|
||||
"lfs",
|
||||
"lipc",
|
||||
}
|
||||
|
||||
exclude_files = {
|
||||
"frontend/luxl.lua",
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ install:
|
||||
- git clone https://github.com/torch/luajit-rocks.git
|
||||
- pushd luajit-rocks
|
||||
- git checkout 6529891
|
||||
- cmake . -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/install
|
||||
- cmake . -DWITH_LUAJIT21=ON -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/install
|
||||
- make install
|
||||
- popd
|
||||
- export PATH=$PATH:${TRAVIS_BUILD_DIR}/install/bin
|
||||
@@ -61,6 +61,8 @@ install:
|
||||
# luasec doesn't automatically detect 64-bit libs
|
||||
- travis_retry luarocks --local install luasec OPENSSL_LIBDIR=/usr/lib/x86_64-linux-gnu
|
||||
- travis_retry luarocks --local install luacov-coveralls --server=http://rocks.moonscript.org/dev
|
||||
- travis_retry luarocks --local install luacheck
|
||||
- travis_retry luarocks --local install lanes # for parallel luacheck
|
||||
# add local rocks to $PATH
|
||||
- eval $(luarocks path --bin)
|
||||
|
||||
@@ -68,6 +70,8 @@ script:
|
||||
- travis_retry make fetchthirdparty
|
||||
- make all
|
||||
- travis_retry make testfront
|
||||
- luajit $(which luacheck) --no-color -q frontend | tee ./luacheck.out
|
||||
- test $(grep Total ./luacheck.out | awk '{print $2}') -le 238
|
||||
|
||||
after_success:
|
||||
- make coverage
|
||||
|
||||
2
Makefile
2
Makefile
@@ -321,7 +321,7 @@ po:
|
||||
$(MAKE) -i -C l10n bootstrap pull
|
||||
|
||||
static-check:
|
||||
@if which luacheck > /dev/null; then luacheck frontend; else \
|
||||
@if which luacheck > /dev/null; then luacheck -q frontend; else \
|
||||
echo "[!] luacheck not found. "\
|
||||
"you can install it with 'luarocks install luacheck'"; fi
|
||||
|
||||
|
||||
21
README.md
21
README.md
@@ -43,7 +43,7 @@ Highlights for developers
|
||||
* running on multi-platform with only one code-base maintained
|
||||
* developing koreader in any editor without compilation
|
||||
* high runtime efficiency by LuaJIT acceleration
|
||||
* light-weight widget toolkit for small memory footprint
|
||||
* light-weight self-contained widget toolkit with small memory footprint
|
||||
* extensible with plugin system
|
||||
* interfaced backends for documents parsing and rendering
|
||||
* high quality document backend libraries like MuPDF, DjvuLibre and CREngine
|
||||
@@ -51,7 +51,7 @@ Highlights for developers
|
||||
* in active development
|
||||
* contributed by developers around the world
|
||||
* continuous integration with Travis CI
|
||||
* with unit tests and code coverage test
|
||||
* with unit tests, static analysis and code coverage test
|
||||
* automatic release of nightly builds
|
||||
* free as in free speech
|
||||
* licensed under Affero GPL v3
|
||||
@@ -147,8 +147,8 @@ package from scratch.
|
||||
For Android devices
|
||||
-------------------
|
||||
|
||||
Make sure the "android" and "ndk-build" tools are in your PATH variable
|
||||
and the NDK variable points to the root directory of the Android NDK.
|
||||
Make sure the "android" and "ndk-build" tools are in your PATH environment
|
||||
variable and the NDK variable points to the root directory of the Android NDK.
|
||||
|
||||
Then, run this command to build installable package for Android:
|
||||
```
|
||||
@@ -163,22 +163,23 @@ To build an emulator on current Linux machine just run:
|
||||
./kodev build
|
||||
```
|
||||
|
||||
If you want to compile the emulator for Windows you need to run:
|
||||
If you want to compile the emulator for Windows run:
|
||||
```
|
||||
./kodev build win32
|
||||
```
|
||||
|
||||
To run Koreader on your developing machine
|
||||
To run Koreader on your developing machine:
|
||||
```
|
||||
./kodev run ./test
|
||||
./kodev run
|
||||
```
|
||||
|
||||
To run unit tests:
|
||||
```
|
||||
make test
|
||||
./kodev test base
|
||||
./kodev test front
|
||||
```
|
||||
|
||||
To run Lua static-analysis for KOReader:
|
||||
To run Lua static analysis:
|
||||
```
|
||||
make static-check
|
||||
```
|
||||
@@ -203,7 +204,7 @@ modifications with kroeader frontend. NOTE: only support relative path for now.
|
||||
|
||||
|
||||
Translation
|
||||
========
|
||||
===========
|
||||
|
||||
Please refer to [l10n's README][l10n-readme] to grab the latest translations
|
||||
from [the Koreader project on Transifex][koreader-transifex] with this command:
|
||||
|
||||
@@ -144,7 +144,7 @@ local function MD5Update(ctx, buf, len)
|
||||
t = band(rshift(t, 3), 0x3f)
|
||||
|
||||
if (t > 0) then
|
||||
p = ffi.cast("unsigned char *", ctx.input + t)
|
||||
local p = ffi.cast("unsigned char *", ctx.input + t)
|
||||
|
||||
t = 64 - t
|
||||
if (len < t) then
|
||||
|
||||
@@ -22,7 +22,9 @@ function ReaderStatus:init()
|
||||
return
|
||||
end
|
||||
self.total_pages = self.document:getPageCount()
|
||||
UIManager:scheduleIn(0.1, function() self.ui.menu:registerToMainMenu(self) end)
|
||||
self.ui:registerPostInitCallback(function()
|
||||
self.ui.menu:registerToMainMenu(self)
|
||||
end)
|
||||
end
|
||||
|
||||
function ReaderStatus:addToMainMenu(tab_item_table)
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
local ReaderDictionary = require("apps/reader/modules/readerdictionary")
|
||||
local EventListener = require("ui/widget/eventlistener")
|
||||
local NetworkMgr = require("ui/networkmgr")
|
||||
local Translator = require("ui/translator")
|
||||
local Wikipedia = require("ui/wikipedia")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Geom = require("ui/geometry")
|
||||
local Screen = require("device").screen
|
||||
local DEBUG = require("dbg")
|
||||
local _ = require("gettext")
|
||||
|
||||
@@ -10,16 +10,15 @@ end
|
||||
function Configurable:reset()
|
||||
for key,value in pairs(self) do
|
||||
if type(value) == "number" or type(value) == "string" then
|
||||
self[key] = nil
|
||||
self[key] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Configurable:hash(sep)
|
||||
local hash = ""
|
||||
local excluded = {multi_threads = true,}
|
||||
for key,value in pairs(self) do
|
||||
if type(value) == "number" or type(value) == "string" then
|
||||
if type(value) == "number" or type(value) == "string" then
|
||||
hash = hash..sep..value
|
||||
end
|
||||
end
|
||||
@@ -31,13 +30,13 @@ function Configurable:loadDefaults(config_options)
|
||||
self:reset()
|
||||
for i=1,#config_options do
|
||||
local options = config_options[i].options
|
||||
for j=1,#config_options[i].options do
|
||||
local key = config_options[i].options[j].name
|
||||
for j=1,#options do
|
||||
local key = options[j].name
|
||||
local settings_key = config_options.prefix.."_"..key
|
||||
local default = G_reader_settings:readSetting(settings_key)
|
||||
self[key] = default or config_options[i].options[j].default_value
|
||||
self[key] = default or options[j].default_value
|
||||
if not self[key] then
|
||||
self[key] = config_options[i].options[j].default_arg
|
||||
self[key] = options[j].default_arg
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -49,7 +48,7 @@ function Configurable:loadSettings(settings, prefix)
|
||||
or type(value) == "table" then
|
||||
local saved_value = settings:readSetting(prefix..key)
|
||||
self[key] = (saved_value == nil) and self[key] or saved_value
|
||||
--Debug("Configurable:loadSettings", "key", key, "saved value",
|
||||
--Debug("Configurable:loadSettings", "key", key, "saved value",
|
||||
--saved_value,"Configurable.key", self[key])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -27,9 +27,10 @@ local function probeDevice()
|
||||
end
|
||||
|
||||
-- add new ports here:
|
||||
if --[[ implement a proper test instead --]] false then
|
||||
return require("device/newport/device")
|
||||
end
|
||||
--
|
||||
-- if --[[ implement a proper test instead --]] false then
|
||||
-- return require("device/newport/device")
|
||||
-- end
|
||||
|
||||
error("did not find a hardware abstraction for this platform")
|
||||
end
|
||||
|
||||
@@ -30,8 +30,8 @@ function DocSettings:getNameFromHistory(hist_name)
|
||||
end
|
||||
|
||||
function DocSettings:open(docfile)
|
||||
local history_path = nil
|
||||
local sidecar_path = nil
|
||||
local history_path
|
||||
local sidecar_path
|
||||
if docfile == ".reader" then
|
||||
-- we handle reader setting as special case
|
||||
history_path = DataStorage:getDataDir() .. "/settings.reader.lua"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
local UIManager = require("ui/uimanager")
|
||||
local DEBUG = require("dbg")
|
||||
|
||||
local HTTPClient = {
|
||||
input_timeouts = 0,
|
||||
|
||||
@@ -5,7 +5,6 @@ local FocusManager = require("ui/widget/focusmanager")
|
||||
local LineWidget = require("ui/widget/linewidget")
|
||||
local Blitbuffer = require("ffi/blitbuffer")
|
||||
local Button = require("ui/widget/button")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Geom = require("ui/geometry")
|
||||
local Device = require("device")
|
||||
local Screen = Device.screen
|
||||
|
||||
@@ -7,12 +7,9 @@ local ImageWidget = require("ui/widget/imagewidget")
|
||||
local TextBoxWidget = require("ui/widget/textboxwidget")
|
||||
local HorizontalSpan = require("ui/widget/horizontalspan")
|
||||
local ButtonTable = require("ui/widget/buttontable")
|
||||
local GestureRange = require("ui/gesturerange")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Device = require("device")
|
||||
local Geom = require("ui/geometry")
|
||||
local Input = require("device").input
|
||||
local Screen = require("device").screen
|
||||
local Screen = Device.screen
|
||||
local Font = require("ui/font")
|
||||
local DEBUG = require("dbg")
|
||||
local _ = require("gettext")
|
||||
|
||||
@@ -9,10 +9,11 @@ local BottomContainer = WidgetContainer:new()
|
||||
|
||||
function BottomContainer:paintTo(bb, x, y)
|
||||
local contentSize = self[1]:getSize()
|
||||
if contentSize.w > self.dimen.w or contentSize.h > self.dimen.h then
|
||||
-- FIXME
|
||||
-- if contentSize.w > self.dimen.w or contentSize.h > self.dimen.h then
|
||||
-- throw error? paint to scrap buffer and blit partially?
|
||||
-- for now, we ignore this
|
||||
end
|
||||
-- end
|
||||
self[1]:paintTo(bb,
|
||||
x + math.floor((self.dimen.w - contentSize.w)/2),
|
||||
y + (self.dimen.h - contentSize.h))
|
||||
|
||||
@@ -7,10 +7,11 @@ local CenterContainer = WidgetContainer:new()
|
||||
|
||||
function CenterContainer:paintTo(bb, x, y)
|
||||
local content_size = self[1]:getSize()
|
||||
if content_size.w > self.dimen.w or content_size.h > self.dimen.h then
|
||||
-- FIXME
|
||||
-- if content_size.w > self.dimen.w or content_size.h > self.dimen.h then
|
||||
-- throw error? paint to scrap buffer and blit partially?
|
||||
-- for now, we ignore this
|
||||
end
|
||||
-- end
|
||||
local x_pos = x
|
||||
local y_pos = y
|
||||
if self.ignore ~= "height" then
|
||||
|
||||
@@ -7,10 +7,11 @@ local LeftContainer = WidgetContainer:new()
|
||||
|
||||
function LeftContainer:paintTo(bb, x, y)
|
||||
local contentSize = self[1]:getSize()
|
||||
if contentSize.w > self.dimen.w or contentSize.h > self.dimen.h then
|
||||
-- FIXME
|
||||
-- if contentSize.w > self.dimen.w or contentSize.h > self.dimen.h then
|
||||
-- throw error? paint to scrap buffer and blit partially?
|
||||
-- for now, we ignore this
|
||||
end
|
||||
-- end
|
||||
self[1]:paintTo(bb, x , y + math.floor((self.dimen.h - contentSize.h)/2))
|
||||
end
|
||||
|
||||
|
||||
@@ -7,10 +7,11 @@ local RightContainer = WidgetContainer:new()
|
||||
|
||||
function RightContainer:paintTo(bb, x, y)
|
||||
local contentSize = self[1]:getSize()
|
||||
if contentSize.w > self.dimen.w or contentSize.h > self.dimen.h then
|
||||
-- FIXME
|
||||
-- if contentSize.w > self.dimen.w or contentSize.h > self.dimen.h then
|
||||
-- throw error? paint to scrap buffer and blit partially?
|
||||
-- for now, we ignore this
|
||||
end
|
||||
-- end
|
||||
self[1]:paintTo(bb,
|
||||
x + (self.dimen.w - contentSize.w),
|
||||
y + math.floor((self.dimen.h - contentSize.h)/2))
|
||||
|
||||
@@ -5,7 +5,6 @@ local CenterContainer = require("ui/widget/container/centercontainer")
|
||||
local LeftContainer = require("ui/widget/container/leftcontainer")
|
||||
local ScrollTextWidget = require("ui/widget/scrolltextwidget")
|
||||
local VerticalGroup = require("ui/widget/verticalgroup")
|
||||
local TextBoxWidget = require("ui/widget/textboxwidget")
|
||||
local OverlapGroup = require("ui/widget/overlapgroup")
|
||||
local CloseButton = require("ui/widget/closebutton")
|
||||
local ButtonTable = require("ui/widget/buttontable")
|
||||
|
||||
@@ -7,8 +7,8 @@ will call a method "onEventName" for an event with name
|
||||
--]]
|
||||
local EventListener = {}
|
||||
|
||||
function EventListener:new(o)
|
||||
local o = o or {}
|
||||
function EventListener:new(new_o)
|
||||
local o = new_o or {}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
if o.init then o:init() end
|
||||
|
||||
@@ -168,7 +168,7 @@ end
|
||||
|
||||
function OPDSBrowser:genItemTableFromRoot()
|
||||
local item_table = {}
|
||||
for i, server in ipairs(self.opds_servers) do
|
||||
for _, server in ipairs(self.opds_servers) do
|
||||
table.insert(item_table, {
|
||||
text = server.title,
|
||||
content = server.subtitle,
|
||||
@@ -176,7 +176,7 @@ function OPDSBrowser:genItemTableFromRoot()
|
||||
})
|
||||
end
|
||||
local added_servers = G_reader_settings:readSetting("opds_servers") or {}
|
||||
for i, server in ipairs(added_servers) do
|
||||
for _, server in ipairs(added_servers) do
|
||||
table.insert(item_table, {
|
||||
text = server.title,
|
||||
content = server.subtitle,
|
||||
@@ -375,7 +375,7 @@ function OPDSBrowser:genItemTableFromCatalog(catalog, item_url)
|
||||
end
|
||||
local hrefs = {}
|
||||
if feed.link then
|
||||
for i, link in ipairs(feed.link) do
|
||||
for _, link in ipairs(feed.link) do
|
||||
if link.type:find(self.catalog_type) or
|
||||
link.type:find(self.search_type) then
|
||||
if link.rel and link.href then
|
||||
@@ -386,11 +386,11 @@ function OPDSBrowser:genItemTableFromCatalog(catalog, item_url)
|
||||
end
|
||||
item_table.hrefs = hrefs
|
||||
if feed.entry then
|
||||
for i, entry in ipairs(feed.entry) do
|
||||
for _, entry in ipairs(feed.entry) do
|
||||
local item = {}
|
||||
item.acquisitions = {}
|
||||
if entry.link then
|
||||
for i, link in ipairs(entry.link) do
|
||||
for _, link in ipairs(entry.link) do
|
||||
if link.type:find(self.catalog_type) and (not link.rel or link.rel == "subsection" or link.rel == "http://opds-spec.org/sort/popular" or link.rel == "http://opds-spec.org/sort/new") then
|
||||
item.url = build_href(link.href)
|
||||
end
|
||||
@@ -451,7 +451,7 @@ end
|
||||
|
||||
function OPDSBrowser:appendCatalog(item_table_url)
|
||||
local new_table = self:genItemTableFromURL(item_table_url)
|
||||
for i, item in ipairs(new_table) do
|
||||
for _, item in ipairs(new_table) do
|
||||
table.insert(self.item_table, item)
|
||||
end
|
||||
self.item_table.hrefs = new_table.hrefs
|
||||
@@ -566,7 +566,7 @@ end
|
||||
function OPDSBrowser:editServerFromInput(item, fields)
|
||||
DEBUG("input catalog", fields)
|
||||
local servers = {}
|
||||
for i, server in ipairs(G_reader_settings:readSetting("opds_servers") or {}) do
|
||||
for _, server in ipairs(G_reader_settings:readSetting("opds_servers") or {}) do
|
||||
if server.title == item.text or server.url == item.url then
|
||||
server.title = fields[1]
|
||||
server.url = (fields[2]:match("^%a+://") and fields[2] or "http://" .. fields[2])
|
||||
@@ -620,7 +620,7 @@ end
|
||||
function OPDSBrowser:deleteOPDSServer(item)
|
||||
DEBUG("delete", item)
|
||||
local servers = {}
|
||||
for i, server in ipairs(G_reader_settings:readSetting("opds_servers") or {}) do
|
||||
for _, server in ipairs(G_reader_settings:readSetting("opds_servers") or {}) do
|
||||
if server.title ~= item.text or server.url ~= item.url then
|
||||
table.insert(servers, server)
|
||||
end
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local FrameContainer = require("ui/widget/container/framecontainer")
|
||||
local CenterContainer = require("ui/widget/container/centercontainer")
|
||||
local RightContainer = require("ui/widget/container/rightcontainer")
|
||||
local LeftContainer = require("ui/widget/container/leftcontainer")
|
||||
local HorizontalGroup = require("ui/widget/horizontalgroup")
|
||||
local VerticalGroup = require("ui/widget/verticalgroup")
|
||||
@@ -27,8 +26,7 @@ local Font = require("ui/font")
|
||||
local TimeVal = require("ui/timeval")
|
||||
local RenderText = require("ui/rendertext")
|
||||
|
||||
local DocSettings = require("docsettings")
|
||||
local DEBUG = require("dbg")
|
||||
local template = require("ffi/util").template
|
||||
local util = require("util")
|
||||
local _ = require("gettext")
|
||||
|
||||
@@ -40,7 +38,7 @@ local _ = require("gettext")
|
||||
["status"] = "Reading"
|
||||
["modified"] = "24.01.2016"
|
||||
},]]
|
||||
local StatusWidget = InputContainer:new {
|
||||
local StatusWidget = InputContainer:new{
|
||||
settings = nil,
|
||||
thumbnail = nil,
|
||||
props = nil,
|
||||
@@ -69,7 +67,7 @@ function StatusWidget:init()
|
||||
self.medium_font_face = Font:getFace("ffont", 20)
|
||||
self.large_font_face = Font:getFace("ffont", 25)
|
||||
|
||||
self.star = Button:new {
|
||||
self.star = Button:new{
|
||||
icon = "resources/icons/stats.star.empty.png",
|
||||
bordersize = 0,
|
||||
radius = 0,
|
||||
@@ -78,7 +76,7 @@ function StatusWidget:init()
|
||||
show_parent = self,
|
||||
}
|
||||
|
||||
local statusContainer = FrameContainer:new {
|
||||
local statusContainer = FrameContainer:new{
|
||||
dimen = Screen:getSize(),
|
||||
background = Blitbuffer.COLOR_WHITE,
|
||||
bordersize = 0,
|
||||
@@ -89,7 +87,7 @@ function StatusWidget:init()
|
||||
end
|
||||
|
||||
function StatusWidget:showStatus()
|
||||
local main_group = VerticalGroup:new { align = "left" }
|
||||
local main_group = VerticalGroup:new{ align = "left" }
|
||||
|
||||
local img_width = Screen:scaleBySize(132 * 1.5)
|
||||
local img_height = Screen:scaleBySize(184 * 1.5)
|
||||
@@ -101,7 +99,7 @@ function StatusWidget:showStatus()
|
||||
|
||||
local thumb = nil
|
||||
if self.thumbnail then
|
||||
thumb = ImageWidget:new {
|
||||
thumb = ImageWidget:new{
|
||||
image = self.thumbnail,
|
||||
width = img_width,
|
||||
height = img_height,
|
||||
@@ -111,13 +109,13 @@ function StatusWidget:showStatus()
|
||||
|
||||
local screen_width = Screen:getWidth()
|
||||
|
||||
local cover_with_title_and_author_container = CenterContainer:new {
|
||||
dimen = Geom:new { w = screen_width, h = img_height },
|
||||
local cover_with_title_and_author_container = CenterContainer:new{
|
||||
dimen = Geom:new{ w = screen_width, h = img_height },
|
||||
}
|
||||
|
||||
local cover_with_title_and_author_group = HorizontalGroup:new { align = "top" }
|
||||
local cover_with_title_and_author_group = HorizontalGroup:new{ align = "top" }
|
||||
|
||||
local span = HorizontalSpan:new { width = screen_width * 0.05 }
|
||||
local span = HorizontalSpan:new{ width = screen_width * 0.05 }
|
||||
|
||||
table.insert(cover_with_title_and_author_group, span)
|
||||
|
||||
@@ -145,10 +143,10 @@ function StatusWidget:showStatus()
|
||||
statusHeight = Screen:scaleBySize(60)
|
||||
end
|
||||
|
||||
local header_group = HorizontalGroup:new {
|
||||
local header_group = HorizontalGroup:new{
|
||||
align = "center",
|
||||
self:addHeader(screen_width * 0.95, Screen:scaleBySize(15), _("Progress")),
|
||||
CloseButton:new { window = self }
|
||||
CloseButton:new{ window = self }
|
||||
}
|
||||
|
||||
table.insert(main_group, header_group)
|
||||
@@ -193,14 +191,14 @@ function StatusWidget:getReadPages(stats)
|
||||
end
|
||||
|
||||
function StatusWidget:addHeader(width, height, title)
|
||||
local group = HorizontalGroup:new {
|
||||
local group = HorizontalGroup:new{
|
||||
align = "center",
|
||||
bordersize = 0
|
||||
bordersize = 0,
|
||||
}
|
||||
|
||||
local bold = false
|
||||
|
||||
local titleWidget = TextWidget:new {
|
||||
local titleWidget = TextWidget:new{
|
||||
text = title,
|
||||
face = self.large_font_face,
|
||||
bold = bold,
|
||||
@@ -208,19 +206,19 @@ function StatusWidget:addHeader(width, height, title)
|
||||
local titleSize = RenderText:sizeUtf8Text(0, Screen:getWidth(), self.large_font_face, title, true, bold)
|
||||
local lineWidth = ((width - titleSize.x) * 0.5)
|
||||
|
||||
local line_container = LeftContainer:new {
|
||||
dimen = Geom:new { w = lineWidth, h = height },
|
||||
LineWidget:new {
|
||||
local line_container = LeftContainer:new{
|
||||
dimen = Geom:new{ w = lineWidth, h = height },
|
||||
LineWidget:new{
|
||||
background = Blitbuffer.gray(0.2),
|
||||
dimen = Geom:new {
|
||||
dimen = Geom:new{
|
||||
w = lineWidth,
|
||||
h = 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
local text_container = CenterContainer:new {
|
||||
dimen = Geom:new { w = titleSize.x, h = height },
|
||||
local text_container = CenterContainer:new{
|
||||
dimen = Geom:new{ w = titleSize.x, h = height },
|
||||
titleWidget,
|
||||
}
|
||||
|
||||
@@ -231,8 +229,8 @@ function StatusWidget:addHeader(width, height, title)
|
||||
end
|
||||
|
||||
function StatusWidget:generateSwitchGroup(width, height, book_status)
|
||||
local switch_container = CenterContainer:new {
|
||||
dimen = Geom:new { w = width, h = height },
|
||||
local switch_container = CenterContainer:new{
|
||||
dimen = Geom:new{ w = width, h = height },
|
||||
}
|
||||
|
||||
local args = {
|
||||
@@ -268,7 +266,7 @@ function StatusWidget:generateSwitchGroup(width, height, book_status)
|
||||
enabled = true,
|
||||
}
|
||||
|
||||
local switch = ToggleSwitch:new {
|
||||
local switch = ToggleSwitch:new{
|
||||
width = width * 0.6,
|
||||
default_value = config.default_value,
|
||||
name = config.name,
|
||||
@@ -321,7 +319,7 @@ end
|
||||
|
||||
function StatusWidget:generateSummaryGroup(width, height, text)
|
||||
|
||||
self.input_note = InputText:new {
|
||||
self.input_note = InputText:new{
|
||||
text = text,
|
||||
face = self.medium_font_face,
|
||||
width = width * 0.95,
|
||||
@@ -334,16 +332,16 @@ function StatusWidget:generateSummaryGroup(width, height, text)
|
||||
hint = _("A few words about the book"),
|
||||
}
|
||||
|
||||
local note_container = CenterContainer:new {
|
||||
dimen = Geom:new { w = width, h = height },
|
||||
local note_container = CenterContainer:new{
|
||||
dimen = Geom:new{ w = width, h = height },
|
||||
self.input_note
|
||||
}
|
||||
return note_container
|
||||
end
|
||||
|
||||
function StatusWidget:generateRateGroup(width, height, rating)
|
||||
self.stars_container = CenterContainer:new {
|
||||
dimen = Geom:new { w = width, h = height },
|
||||
self.stars_container = CenterContainer:new{
|
||||
dimen = Geom:new{ w = width, h = height },
|
||||
}
|
||||
|
||||
self:setStar(rating)
|
||||
@@ -354,20 +352,23 @@ function StatusWidget:setStar(num)
|
||||
--clear previous data
|
||||
self.stars_container:clear()
|
||||
|
||||
local stars_group = HorizontalGroup:new { align = "center" }
|
||||
local stars_group = HorizontalGroup:new{ align = "center" }
|
||||
if num then
|
||||
self.summary.rating = num
|
||||
self:saveSummary()
|
||||
|
||||
for i = 1, num do
|
||||
table.insert(stars_group, self.star:new { icon = "resources/icons/stats.star.full.png", callback = function() self:setStar(i) end })
|
||||
table.insert(stars_group, self.star:new{
|
||||
icon = "resources/icons/stats.star.full.png",
|
||||
callback = function() self:setStar(i) end
|
||||
})
|
||||
end
|
||||
else
|
||||
num = 0
|
||||
end
|
||||
|
||||
for i = num + 1, 5 do
|
||||
table.insert(stars_group, self.star:new { callback = function() self:setStar(i) end })
|
||||
table.insert(stars_group, self.star:new{ callback = function() self:setStar(i) end })
|
||||
end
|
||||
|
||||
table.insert(self.stars_container, stars_group)
|
||||
@@ -377,34 +378,34 @@ function StatusWidget:setStar(num)
|
||||
end
|
||||
|
||||
function StatusWidget:generateStatisticsGroup(width, height, days, average, pages)
|
||||
local statistics_container = CenterContainer:new {
|
||||
dimen = Geom:new { w = width, h = height },
|
||||
local statistics_container = CenterContainer:new{
|
||||
dimen = Geom:new{ w = width, h = height },
|
||||
}
|
||||
|
||||
local statistics_group = VerticalGroup:new { align = "left" }
|
||||
local statistics_group = VerticalGroup:new{ align = "left" }
|
||||
|
||||
local tile_width = width / 3
|
||||
local tile_height = height / 2
|
||||
|
||||
local titles_group = HorizontalGroup:new {
|
||||
local titles_group = HorizontalGroup:new{
|
||||
align = "center",
|
||||
CenterContainer:new {
|
||||
dimen = Geom:new { w = tile_width, h = tile_height },
|
||||
TextWidget:new {
|
||||
CenterContainer:new{
|
||||
dimen = Geom:new{ w = tile_width, h = tile_height },
|
||||
TextWidget:new{
|
||||
text = _("Days"),
|
||||
face = self.small_font_face,
|
||||
},
|
||||
},
|
||||
CenterContainer:new {
|
||||
dimen = Geom:new { w = tile_width, h = tile_height },
|
||||
TextWidget:new {
|
||||
CenterContainer:new{
|
||||
dimen = Geom:new{ w = tile_width, h = tile_height },
|
||||
TextWidget:new{
|
||||
text = _("Time"),
|
||||
face = self.small_font_face,
|
||||
},
|
||||
},
|
||||
CenterContainer:new {
|
||||
dimen = Geom:new { w = tile_width, h = tile_height },
|
||||
TextWidget:new {
|
||||
CenterContainer:new{
|
||||
dimen = Geom:new{ w = tile_width, h = tile_height },
|
||||
TextWidget:new{
|
||||
text = _("Read pages"),
|
||||
face = self.small_font_face,
|
||||
}
|
||||
@@ -412,25 +413,25 @@ function StatusWidget:generateStatisticsGroup(width, height, days, average, page
|
||||
}
|
||||
|
||||
|
||||
local data_group = HorizontalGroup:new {
|
||||
local data_group = HorizontalGroup:new{
|
||||
align = "center",
|
||||
CenterContainer:new {
|
||||
dimen = Geom:new { w = tile_width, h = tile_height },
|
||||
TextWidget:new {
|
||||
CenterContainer:new{
|
||||
dimen = Geom:new{ w = tile_width, h = tile_height },
|
||||
TextWidget:new{
|
||||
text = days,
|
||||
face = self.medium_font_face,
|
||||
},
|
||||
},
|
||||
CenterContainer:new {
|
||||
dimen = Geom:new { w = tile_width, h = tile_height },
|
||||
TextWidget:new {
|
||||
CenterContainer:new{
|
||||
dimen = Geom:new{ w = tile_width, h = tile_height },
|
||||
TextWidget:new{
|
||||
text = average,
|
||||
face = self.medium_font_face,
|
||||
},
|
||||
},
|
||||
CenterContainer:new {
|
||||
dimen = Geom:new { w = tile_width, h = tile_height },
|
||||
TextWidget:new {
|
||||
CenterContainer:new{
|
||||
dimen = Geom:new{ w = tile_width, h = tile_height },
|
||||
TextWidget:new{
|
||||
text = pages,
|
||||
face = self.medium_font_face,
|
||||
}
|
||||
@@ -446,55 +447,59 @@ end
|
||||
|
||||
function StatusWidget:generateTitleAuthorProgressGroup(width, height, title, authors, current_page, total_pages)
|
||||
|
||||
local title_author_container = CenterContainer:new {
|
||||
dimen = Geom:new { w = width, h = height },
|
||||
local title_author_container = CenterContainer:new{
|
||||
dimen = Geom:new{ w = width, h = height },
|
||||
}
|
||||
|
||||
local title_author_progressbar_group = VerticalGroup:new {
|
||||
local title_author_progressbar_group = VerticalGroup:new{
|
||||
align = "center",
|
||||
VerticalSpan:new { width = height * 0.2 },
|
||||
TextBoxWidget:new {
|
||||
VerticalSpan:new{ width = height * 0.2 },
|
||||
TextBoxWidget:new{
|
||||
text = title,
|
||||
width = width,
|
||||
face = self.medium_font_face,
|
||||
alignment = "center",
|
||||
}
|
||||
}
|
||||
local text_author = TextWidget:new {
|
||||
local text_author = TextWidget:new{
|
||||
text = authors,
|
||||
face = self.small_font_face,
|
||||
padding = 2,
|
||||
}
|
||||
|
||||
local author_container = CenterContainer:new {
|
||||
dimen = Geom:new { w = width, h = text_author:getSize().h },
|
||||
local author_container = CenterContainer:new{
|
||||
dimen = Geom:new{ w = width, h = text_author:getSize().h },
|
||||
text_author
|
||||
}
|
||||
|
||||
table.insert(title_author_progressbar_group, author_container)
|
||||
|
||||
local progressWidget = ProgressWidget:new {
|
||||
local read_percentage = current_page / total_pages
|
||||
local progress_height = Screen:scaleBySize(10)
|
||||
|
||||
local progress_bar = ProgressWidget:new{
|
||||
width = width * 0.7,
|
||||
height = Screen:scaleBySize(10),
|
||||
percentage = current_page / total_pages,
|
||||
height = progress_height,
|
||||
percentage = read_percentage,
|
||||
ticks = {},
|
||||
tick_width = 0,
|
||||
last = total_pages,
|
||||
}
|
||||
|
||||
local progress_bar_container = CenterContainer:new {
|
||||
dimen = Geom:new { w = width, h = progressWidget:getSize().h },
|
||||
progressWidget
|
||||
}
|
||||
|
||||
table.insert(title_author_progressbar_group, progress_bar_container)
|
||||
local text_complete = TextWidget:new {
|
||||
text = string.format("%1.f", progressWidget.percentage * 100) .. "% " .. _("Completed"),
|
||||
table.insert(title_author_progressbar_group,
|
||||
CenterContainer:new{
|
||||
dimen = Geom:new{ w = width, h = progress_bar:getSize().h },
|
||||
progress_bar
|
||||
}
|
||||
)
|
||||
local text_complete = TextWidget:new{
|
||||
text = template(_("%1% Completed"),
|
||||
string.format("%1.f", read_percentage * 100)),
|
||||
face = self.small_font_face,
|
||||
}
|
||||
|
||||
local progress_bar_text_container = CenterContainer:new {
|
||||
dimen = Geom:new { w = width, h = text_complete:getSize().h },
|
||||
local progress_bar_text_container = CenterContainer:new{
|
||||
dimen = Geom:new{ w = width, h = text_complete:getSize().h },
|
||||
text_complete
|
||||
}
|
||||
|
||||
@@ -529,7 +534,7 @@ end
|
||||
|
||||
|
||||
function StatusWidget:onSwitchFocus(inputbox)
|
||||
self.note_dialog = InputDialog:new {
|
||||
self.note_dialog = InputDialog:new{
|
||||
title = "Note",
|
||||
input = self.input_note:getText(),
|
||||
input_hint = "",
|
||||
|
||||
Reference in New Issue
Block a user