mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #564 from chrox/master
use built-in LuaJIT profiler instead of lulip
This commit is contained in:
@@ -32,6 +32,7 @@ function PageCropDialog:init()
|
||||
radius = 7,
|
||||
text_font_face = "cfont",
|
||||
text_font_size = 20,
|
||||
show_parent = self,
|
||||
}
|
||||
local cancel_button = Button:new{
|
||||
text = self.cancel_text,
|
||||
@@ -41,6 +42,7 @@ function PageCropDialog:init()
|
||||
radius = 7,
|
||||
text_font_face = "cfont",
|
||||
text_font_size = 20,
|
||||
show_parent = self,
|
||||
}
|
||||
local ok_container = RightContainer:new{
|
||||
dimen = Geom:new{ w = Screen:getWidth()*0.33, h = Screen:getHeight()/12},
|
||||
|
||||
@@ -81,6 +81,8 @@ function ReaderFooter:init()
|
||||
},
|
||||
}
|
||||
end
|
||||
self.mode = G_reader_settings:readSetting("reader_footer_mode") or self.mode
|
||||
self:applyFooterMode()
|
||||
end
|
||||
|
||||
function ReaderFooter:updateFooterPage()
|
||||
@@ -150,6 +152,7 @@ function ReaderFooter:onTapFooter(arg, ges)
|
||||
self:updateFooterPos()
|
||||
end
|
||||
UIManager:setDirty(self.view.dialog, "partial")
|
||||
G_reader_settings:saveSetting("reader_footer_mode", self.mode)
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
@@ -6,7 +6,9 @@ local Geom = require("ui/geometry")
|
||||
local GestureRange = require("ui/gesturerange")
|
||||
local FrameContainer = require("ui/widget/container/framecontainer")
|
||||
local CenterContainer = require("ui/widget/container/centercontainer")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Device = require("ui/device")
|
||||
local DEBUG = require("dbg")
|
||||
local _ = require("gettext")
|
||||
|
||||
--[[
|
||||
@@ -139,7 +141,13 @@ end
|
||||
|
||||
function Button:onTapSelect()
|
||||
if self.enabled then
|
||||
self.callback()
|
||||
self[1].invert = true
|
||||
UIManager:setDirty(self.show_parent, "partial")
|
||||
UIManager:scheduleIn(0.1, function()
|
||||
self.callback()
|
||||
self[1].invert = false
|
||||
UIManager:setDirty(self.show_parent, "partial")
|
||||
end)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -39,6 +39,7 @@ function ButtonDialog:init()
|
||||
ButtonTable:new{
|
||||
width = Screen:getWidth()*0.9,
|
||||
buttons = self.buttons,
|
||||
show_parent = self,
|
||||
},
|
||||
background = 0,
|
||||
bordersize = 2,
|
||||
|
||||
@@ -42,6 +42,7 @@ function ButtonTable:init()
|
||||
padding = 0,
|
||||
text_font_face = self.button_font_face,
|
||||
text_font_size = self.button_font_size,
|
||||
show_parent = self.show_parent,
|
||||
}
|
||||
local button_dim = button:getSize()
|
||||
local vertical_sep = LineWidget:new{
|
||||
|
||||
@@ -43,6 +43,7 @@ function ConfirmBox:init()
|
||||
self.ok_callback()
|
||||
UIManager:close(self)
|
||||
end,
|
||||
show_parent = self,
|
||||
}
|
||||
local cancel_button = Button:new{
|
||||
text = self.cancel_text,
|
||||
@@ -51,6 +52,7 @@ function ConfirmBox:init()
|
||||
self.cancel_callback()
|
||||
UIManager:close(self)
|
||||
end,
|
||||
show_parent = self,
|
||||
}
|
||||
|
||||
self.layout = { { ok_button, cancel_button } }
|
||||
|
||||
@@ -34,7 +34,7 @@ local DictQuickLookup = InputContainer:new{
|
||||
content_face = Font:getFace("cfont", DDICT_FONT_SIZE),
|
||||
width = nil,
|
||||
height = nil,
|
||||
|
||||
|
||||
title_padding = Screen:scaleByDPI(5),
|
||||
title_margin = Screen:scaleByDPI(2),
|
||||
word_padding = Screen:scaleByDPI(2),
|
||||
@@ -113,13 +113,13 @@ function DictQuickLookup:update()
|
||||
height = self.height*0.7,
|
||||
dialog = self,
|
||||
},
|
||||
}
|
||||
}
|
||||
local button_table = ButtonTable:new{
|
||||
width = math.max(self.width, definition:getSize().w),
|
||||
button_font_face = "cfont",
|
||||
button_font_size = 20,
|
||||
buttons = {
|
||||
{
|
||||
{
|
||||
{
|
||||
text = _("<<"),
|
||||
enabled = self:isPrevDictAvaiable(),
|
||||
@@ -153,6 +153,7 @@ function DictQuickLookup:update()
|
||||
},
|
||||
},
|
||||
zero_sep = true,
|
||||
show_parent = self,
|
||||
}
|
||||
local title_bar = LineWidget:new{
|
||||
--background = 8,
|
||||
@@ -161,12 +162,12 @@ function DictQuickLookup:update()
|
||||
h = Screen:scaleByDPI(2),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
self.dict_bar = OverlapGroup:new{
|
||||
dimen = {w = button_table:getSize().w, h = self.dict_title:getSize().h},
|
||||
self.dict_title,
|
||||
}
|
||||
|
||||
|
||||
self.dict_frame = FrameContainer:new{
|
||||
radius = 8,
|
||||
bordersize = 3,
|
||||
@@ -237,7 +238,7 @@ function DictQuickLookup:changeDictionary(index)
|
||||
self.dictionary = self.results[index].dict
|
||||
self.lookupword = self.results[index].word
|
||||
self.definition = self.results[index].definition
|
||||
|
||||
|
||||
local orig_dimen = self.dict_frame and self.dict_frame.dimen or Geom:new{}
|
||||
self:update()
|
||||
|
||||
@@ -248,7 +249,7 @@ function DictQuickLookup:changeDictionary(index)
|
||||
end
|
||||
end
|
||||
|
||||
function DictQuickLookup:changeToDefaultDict()
|
||||
function DictQuickLookup:changeToDefaultDict()
|
||||
if self.dictionary then
|
||||
-- dictionaries that have definition of the first word(accurate word)
|
||||
-- excluding Fuzzy queries.
|
||||
|
||||
@@ -59,6 +59,7 @@ function InputDialog:init()
|
||||
button_font_size = 20,
|
||||
buttons = self.buttons,
|
||||
zero_sep = true,
|
||||
show_parent = self,
|
||||
}
|
||||
self.title_bar = LineWidget:new{
|
||||
--background = 8,
|
||||
|
||||
@@ -355,11 +355,13 @@ function Menu:init()
|
||||
icon = "resources/icons/appbar.chevron.left.png",
|
||||
callback = function() self:onPrevPage() end,
|
||||
bordersize = 0,
|
||||
show_parent = self,
|
||||
}
|
||||
self.page_info_right_chev = Button:new{
|
||||
icon = "resources/icons/appbar.chevron.right.png",
|
||||
callback = function() self:onNextPage() end,
|
||||
bordersize = 0,
|
||||
show_parent = self,
|
||||
}
|
||||
self.page_info_left_chev:hide()
|
||||
self.page_info_right_chev:hide()
|
||||
|
||||
@@ -41,6 +41,10 @@ function TouchMenuItem:init()
|
||||
},
|
||||
}
|
||||
|
||||
local item_enabled = self.item.enabled
|
||||
if self.item.enabled_func then
|
||||
item_enabled = self.item.enabled_func()
|
||||
end
|
||||
self.item_frame = FrameContainer:new{
|
||||
width = self.dimen.w,
|
||||
bordersize = 0,
|
||||
@@ -50,6 +54,8 @@ function TouchMenuItem:init()
|
||||
HorizontalSpan:new{ width = 10 },
|
||||
TextWidget:new{
|
||||
text = self.item.text or self.item.text_func(),
|
||||
bgcolor = 0.0,
|
||||
fgcolor = item_enabled ~= false and 1.0 or 0.5,
|
||||
face = self.face,
|
||||
},
|
||||
},
|
||||
@@ -58,6 +64,12 @@ function TouchMenuItem:init()
|
||||
end
|
||||
|
||||
function TouchMenuItem:onTapSelect(arg, ges)
|
||||
local enabled = self.item.enabled
|
||||
if self.item.enabled_func then
|
||||
enabled = self.item.enabled_func()
|
||||
end
|
||||
if enabled == false then return end
|
||||
|
||||
self.item_frame.invert = true
|
||||
UIManager:setDirty(self.show_parent, "partial")
|
||||
UIManager:scheduleIn(0.5, function()
|
||||
@@ -401,18 +413,31 @@ function TouchMenu:onSwipe(arg, ges_ev)
|
||||
end
|
||||
|
||||
function TouchMenu:onMenuSelect(item)
|
||||
if item.sub_item_table == nil then
|
||||
if item.callback then
|
||||
local enabled = item.enabled
|
||||
if item.enabled_func then
|
||||
enabled = item.enabled_func()
|
||||
end
|
||||
if enabled == false then return end
|
||||
local sub_item_table = item.sub_item_table
|
||||
if item.sub_item_table_func then
|
||||
sub_item_table = item.sub_item_table_func()
|
||||
end
|
||||
if sub_item_table == nil then
|
||||
local callback = item.callback
|
||||
if item.callback_func then
|
||||
callback = item.callback_func()
|
||||
end
|
||||
if callback then
|
||||
-- put stuff in scheduler so we can See
|
||||
-- the effect of inverted menu item
|
||||
UIManager:scheduleIn(0.1, function()
|
||||
self:closeMenu()
|
||||
item.callback()
|
||||
callback()
|
||||
end)
|
||||
end
|
||||
else
|
||||
table.insert(self.item_table_stack, self.item_table)
|
||||
self.item_table = item.sub_item_table
|
||||
self.item_table = sub_item_table
|
||||
self:updateItems()
|
||||
end
|
||||
return true
|
||||
|
||||
Submodule koreader-base updated: 3b56638512...5521a8786a
@@ -9,13 +9,11 @@ local _ = require("gettext")
|
||||
|
||||
local slt2 = require('slt2')
|
||||
local MyClipping = require("clip")
|
||||
local EvernoteOAuth = require("EvernoteOAuth")
|
||||
local EvernoteClient = require("EvernoteClient")
|
||||
|
||||
local EvernoteExporter = InputContainer:new{
|
||||
login_title = _("Login to Evernote"),
|
||||
notebook_name = _("Koreader Notes"),
|
||||
--evernote_domain = "sandbox",
|
||||
evernote_domain = nil,
|
||||
|
||||
evernote_token,
|
||||
notebook_guid,
|
||||
@@ -25,6 +23,7 @@ function EvernoteExporter:init()
|
||||
self.ui.menu:registerToMainMenu(self)
|
||||
|
||||
local settings = G_reader_settings:readSetting("evernote") or {}
|
||||
self.evernote_domain = settings.domain
|
||||
self.evernote_username = settings.username or ""
|
||||
self.evernote_token = settings.token
|
||||
self.notebook_guid = settings.notebook
|
||||
@@ -37,23 +36,50 @@ function EvernoteExporter:init()
|
||||
end
|
||||
|
||||
function EvernoteExporter:addToMainMenu(tab_item_table)
|
||||
local domain = nil
|
||||
if self.evernote_domain == "sandbox" then
|
||||
domain = _("Sandbox")
|
||||
elseif self.evernote_domain == "yinxiang" then
|
||||
domain = _("Yinxiang")
|
||||
else
|
||||
domain = _("Evernote")
|
||||
end
|
||||
table.insert(tab_item_table.plugins, {
|
||||
text = _("Evernote"),
|
||||
sub_item_table = {
|
||||
{
|
||||
text_func = function()
|
||||
return self.evernote_token and _("Logout") or _("Login")
|
||||
return self.evernote_token and (_("Logout") .. " " .. domain)
|
||||
or _("Login")
|
||||
end,
|
||||
callback_func = function()
|
||||
return self.evernote_token and function() self:logout() end
|
||||
or nil
|
||||
end,
|
||||
sub_item_table_func = function()
|
||||
return not self.evernote_token and {
|
||||
{
|
||||
text = _("Evernote"),
|
||||
callback = function()
|
||||
self.evernote_domain = nil
|
||||
self:login()
|
||||
end
|
||||
},
|
||||
{
|
||||
text = _("Yinxiang"),
|
||||
callback = function()
|
||||
self.evernote_domain = "yinxiang"
|
||||
self:login()
|
||||
end
|
||||
}
|
||||
} or nil
|
||||
end,
|
||||
callback = function()
|
||||
if self.evernote_token then
|
||||
self:logout()
|
||||
else
|
||||
self:login()
|
||||
end
|
||||
end
|
||||
},
|
||||
{
|
||||
text = _("Export all notes in this book"),
|
||||
enabled_func = function()
|
||||
return self.evernote_token ~= nil
|
||||
end,
|
||||
callback = function()
|
||||
UIManager:scheduleIn(0.5, function()
|
||||
self:exportCurrentNotes(self.view)
|
||||
@@ -61,12 +87,15 @@ function EvernoteExporter:addToMainMenu(tab_item_table)
|
||||
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("This may take several seconds..."),
|
||||
timeout = 3,
|
||||
timeout = 1,
|
||||
})
|
||||
end
|
||||
},
|
||||
{
|
||||
text = _("Export all notes in your library"),
|
||||
enabled_func = function()
|
||||
return self.evernote_token ~= nil
|
||||
end,
|
||||
callback = function()
|
||||
UIManager:scheduleIn(0.5, function()
|
||||
self:exportAllNotes()
|
||||
@@ -74,7 +103,7 @@ function EvernoteExporter:addToMainMenu(tab_item_table)
|
||||
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("This may take several minutes..."),
|
||||
timeout = 3,
|
||||
timeout = 1,
|
||||
})
|
||||
end
|
||||
},
|
||||
@@ -104,6 +133,11 @@ function EvernoteExporter:login()
|
||||
UIManager:scheduleIn(0.5, function()
|
||||
self:doLogin(username, password)
|
||||
end)
|
||||
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("Logging in please wait..."),
|
||||
timeout = 1,
|
||||
})
|
||||
end,
|
||||
},
|
||||
},
|
||||
@@ -126,7 +160,8 @@ function EvernoteExporter:getCredential()
|
||||
end
|
||||
|
||||
function EvernoteExporter:doLogin(username, password)
|
||||
self:closeDialog()
|
||||
local EvernoteOAuth = require("EvernoteOAuth")
|
||||
local EvernoteClient = require("EvernoteClient")
|
||||
|
||||
local oauth = EvernoteOAuth:new{
|
||||
domain = self.evernote_domain,
|
||||
@@ -165,11 +200,13 @@ end
|
||||
function EvernoteExporter:logout()
|
||||
self.evernote_token = nil
|
||||
self.notebook_guid = nil
|
||||
self.evernote_domain = nil
|
||||
self:saveSettings()
|
||||
end
|
||||
|
||||
function EvernoteExporter:saveSettings()
|
||||
local settings = {
|
||||
domain = self.evernote_domain,
|
||||
username = self.evernote_username,
|
||||
token = self.evernote_token,
|
||||
notebook = self.notebook_guid,
|
||||
@@ -183,6 +220,7 @@ function EvernoteExporter:getExportNotebook(client)
|
||||
end
|
||||
|
||||
function EvernoteExporter:exportCurrentNotes(view)
|
||||
local EvernoteClient = require("EvernoteClient")
|
||||
local client = EvernoteClient:new{
|
||||
domain = self.evernote_domain,
|
||||
authToken = self.evernote_token,
|
||||
@@ -193,6 +231,7 @@ function EvernoteExporter:exportCurrentNotes(view)
|
||||
end
|
||||
|
||||
function EvernoteExporter:exportAllNotes()
|
||||
local EvernoteClient = require("EvernoteClient")
|
||||
local client = EvernoteClient:new{
|
||||
domain = self.evernote_domain,
|
||||
authToken = self.evernote_token,
|
||||
|
||||
18
reader.lua
18
reader.lua
@@ -26,14 +26,9 @@ local Screen = require("ui/screen")
|
||||
|
||||
local ReaderUI = require("apps/reader/readerui")
|
||||
|
||||
Profiler = nil
|
||||
local Profiler = nil
|
||||
|
||||
function exitReader()
|
||||
if Profiler ~= nil then
|
||||
Profiler:stop()
|
||||
Profiler:dump("./profile.html")
|
||||
end
|
||||
|
||||
G_reader_settings:close()
|
||||
|
||||
input.closeAll()
|
||||
@@ -56,6 +51,7 @@ function exitReader()
|
||||
end
|
||||
end
|
||||
|
||||
if Profiler then Profiler.stop() end
|
||||
os.exit(0)
|
||||
end
|
||||
|
||||
@@ -146,14 +142,8 @@ while argidx <= #ARGV do
|
||||
elseif arg == "-d" then
|
||||
DEBUG:turnOn()
|
||||
elseif arg == "-p" then
|
||||
local lulip = require("ffi/lulip")
|
||||
Profiler = lulip:new()
|
||||
pcall(function()
|
||||
-- set maxrows only if the optional arg is numeric
|
||||
Profiler:maxrows(ARGV[argidx] + 0)
|
||||
argidx = argidx + 1
|
||||
end)
|
||||
Profiler:start()
|
||||
Profiler = require("jit.p")
|
||||
Profiler.start("la")
|
||||
else
|
||||
-- not a recognized option, should be a filename
|
||||
argidx = argidx - 1
|
||||
|
||||
Reference in New Issue
Block a user