mirror of
https://github.com/koreader/koreader
synced 2024-11-13 19:11:25 +00:00
Merge pull request #488 from thotypous/master
Save hyphenation algorithm as cre document setting
This commit is contained in:
commit
5fb5dc7e2f
@ -9,6 +9,14 @@ local ReaderHyphenation = InputContainer:new{
|
|||||||
cur_hyph_idx = nil,
|
cur_hyph_idx = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ReaderHyphenation:_changeSel(k)
|
||||||
|
if self.cur_hyph_idx then
|
||||||
|
self.hyph_table[self.cur_hyph_idx].selected = false
|
||||||
|
end
|
||||||
|
self.hyph_table[k].selected = true
|
||||||
|
self.cur_hyph_idx = k
|
||||||
|
end
|
||||||
|
|
||||||
function ReaderHyphenation:init()
|
function ReaderHyphenation:init()
|
||||||
self.hyph_table = {}
|
self.hyph_table = {}
|
||||||
self.hyph_alg = cre.getSelectedHyphDict()
|
self.hyph_alg = cre.getSelectedHyphDict()
|
||||||
@ -19,13 +27,11 @@ function ReaderHyphenation:init()
|
|||||||
table.insert(self.hyph_table, {
|
table.insert(self.hyph_table, {
|
||||||
text = v,
|
text = v,
|
||||||
callback = function()
|
callback = function()
|
||||||
self.cur_hyph_idx = k
|
|
||||||
self.hyph_alg = v
|
self.hyph_alg = v
|
||||||
UIManager:show(InfoMessage:new{
|
UIManager:show(InfoMessage:new{
|
||||||
text = _("Change Hyphenation to ")..v,
|
text = _("Change Hyphenation to ")..v,
|
||||||
})
|
})
|
||||||
self.hyph_table[k].selected = true
|
self:_changeSel(k)
|
||||||
self.hyph_table[self.cur_hyph_idx].selected = false
|
|
||||||
cre.setHyphDictionary(v)
|
cre.setHyphDictionary(v)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
@ -33,6 +39,23 @@ function ReaderHyphenation:init()
|
|||||||
self.ui.menu:registerToMainMenu(self)
|
self.ui.menu:registerToMainMenu(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ReaderHyphenation:onReadSettings(config)
|
||||||
|
local hyph_alg = config:readSetting("hyph_alg")
|
||||||
|
if hyph_alg then
|
||||||
|
cre.setHyphDictionary(hyph_alg)
|
||||||
|
end
|
||||||
|
self.hyph_alg = cre.getSelectedHyphDict()
|
||||||
|
for k,v in ipairs(self.hyph_table) do
|
||||||
|
if v.text == self.hyph_alg then
|
||||||
|
self:_changeSel(k)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ReaderHyphenation:onSaveSettings()
|
||||||
|
self.ui.doc_settings:saveSetting("hyph_alg", self.hyph_alg)
|
||||||
|
end
|
||||||
|
|
||||||
function ReaderHyphenation:addToMainMenu(tab_item_table)
|
function ReaderHyphenation:addToMainMenu(tab_item_table)
|
||||||
-- insert table to main reader menu
|
-- insert table to main reader menu
|
||||||
table.insert(tab_item_table.typeset, {
|
table.insert(tab_item_table.typeset, {
|
||||||
|
@ -121,6 +121,7 @@ function ReaderTypeset:toggleFloatingPunctuation()
|
|||||||
-- workaround: set again things unset by crengine after changing floating punctuation
|
-- workaround: set again things unset by crengine after changing floating punctuation
|
||||||
self.ui.document:setFontFace(self.ui.font.font_face or
|
self.ui.document:setFontFace(self.ui.font.font_face or
|
||||||
self.ui.doc_settings:readSetting("font_face"))
|
self.ui.doc_settings:readSetting("font_face"))
|
||||||
|
cre.setHyphDictionary(self.ui.hyphenation.hyph_alg)
|
||||||
self:_setPageMargins()
|
self:_setPageMargins()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -228,11 +228,13 @@ function ReaderUI:init()
|
|||||||
ui = self
|
ui = self
|
||||||
}
|
}
|
||||||
table.insert(self, self.font) -- hold reference to font menu
|
table.insert(self, self.font) -- hold reference to font menu
|
||||||
table.insert(self, ReaderHyphenation:new{
|
-- hyphenation menu
|
||||||
|
self.hyphenation = ReaderHyphenation:new{
|
||||||
dialog = self.dialog,
|
dialog = self.dialog,
|
||||||
view = self[1],
|
view = self[1],
|
||||||
ui = self
|
ui = self
|
||||||
})
|
}
|
||||||
|
table.insert(self, self.hyphenation) -- hold reference to hyphenation menu
|
||||||
-- rolling controller
|
-- rolling controller
|
||||||
table.insert(self, ReaderRolling:new{
|
table.insert(self, ReaderRolling:new{
|
||||||
dialog = self.dialog,
|
dialog = self.dialog,
|
||||||
|
Loading…
Reference in New Issue
Block a user