mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[UX] Gesture manager: add action - show dictionary/Wikipedia (#4699)
References #4687.
This commit is contained in:
@@ -5,6 +5,7 @@ local DictQuickLookup = require("ui/widget/dictquicklookup")
|
||||
local Geom = require("ui/geometry")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local InputDialog = require("ui/widget/inputdialog")
|
||||
local JSON = require("json")
|
||||
local KeyValuePage = require("ui/widget/keyvaluepage")
|
||||
local LuaData = require("luadata")
|
||||
@@ -173,14 +174,9 @@ end
|
||||
function ReaderDictionary:addToMainMenu(menu_items)
|
||||
menu_items.dictionary_lookup = {
|
||||
text = _("Dictionary lookup"),
|
||||
tap_input = {
|
||||
title = _("Enter a word to look up"),
|
||||
ok_text = _("Search dictionary"),
|
||||
type = "text",
|
||||
callback = function(input)
|
||||
self:onLookupWord(input)
|
||||
end,
|
||||
},
|
||||
callback = function()
|
||||
self:onShowDictionaryLookup()
|
||||
end,
|
||||
}
|
||||
menu_items.dictionary_lookup_history = {
|
||||
text = _("Dictionary lookup history"),
|
||||
@@ -556,6 +552,35 @@ function ReaderDictionary:dismissLookupInfo()
|
||||
self.lookup_progress_msg = nil
|
||||
end
|
||||
|
||||
function ReaderDictionary:onShowDictionaryLookup()
|
||||
self.dictionary_lookup_dialog = InputDialog:new{
|
||||
title = _("Enter a word to look up"),
|
||||
input = "",
|
||||
input_type = "text",
|
||||
buttons = {
|
||||
{
|
||||
{
|
||||
text = _("Cancel"),
|
||||
callback = function()
|
||||
UIManager:close(self.dictionary_lookup_dialog)
|
||||
end,
|
||||
},
|
||||
{
|
||||
text = _("Search dictionary"),
|
||||
is_enter_default = true,
|
||||
callback = function()
|
||||
UIManager:close(self.dictionary_lookup_dialog)
|
||||
self:onLookupWord(self.dictionary_lookup_dialog:getInputText())
|
||||
end,
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
UIManager:show(self.dictionary_lookup_dialog)
|
||||
self.dictionary_lookup_dialog:onShowKeyboard()
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderDictionary:startSdcv(word, dict_names, fuzzy_search)
|
||||
local final_results = {}
|
||||
local seen_results = {}
|
||||
|
||||
@@ -39,6 +39,9 @@ local action_strings = {
|
||||
open_previous_document = _("Open previous document"),
|
||||
filemanager = _("File browser"),
|
||||
|
||||
dictionary_lookup = _("Dictionary lookup"),
|
||||
wikipedia_lookup = _("Wikipedia lookup"),
|
||||
|
||||
full_refresh = _("Full screen refresh"),
|
||||
night_mode = _("Night mode"),
|
||||
suspend = _("Suspend"),
|
||||
@@ -271,6 +274,9 @@ function ReaderGesture:buildMenu(ges, default)
|
||||
{"open_previous_document", true, true},
|
||||
{"filemanager", not self.is_docless, true},
|
||||
|
||||
{"dictionary_lookup", true},
|
||||
{"wikipedia_lookup", true, true},
|
||||
|
||||
{"full_refresh", true},
|
||||
{"night_mode", true},
|
||||
{"suspend", true},
|
||||
@@ -548,6 +554,10 @@ function ReaderGesture:gestureAction(action)
|
||||
elseif self.ui.switchDocument and self.ui.menu then
|
||||
self.ui:switchDocument(self.ui.menu:getPreviousFile())
|
||||
end
|
||||
elseif action == "dictionary_lookup" then
|
||||
self.ui:handleEvent(Event:new("ShowDictionaryLookup"))
|
||||
elseif action == "wikipedia_lookup" then
|
||||
self.ui:handleEvent(Event:new("ShowWikipediaLookup"))
|
||||
elseif action == "show_menu" then
|
||||
if self.ges_mode == "gesture_fm" then
|
||||
self.ui:handleEvent(Event:new("ShowMenu"))
|
||||
|
||||
@@ -65,13 +65,7 @@ end
|
||||
function ReaderWikipedia:addToMainMenu(menu_items)
|
||||
menu_items.wikipedia_lookup = {
|
||||
text = _("Wikipedia lookup"),
|
||||
callback = function()
|
||||
if NetworkMgr:isOnline() then
|
||||
self:lookupInput()
|
||||
else
|
||||
NetworkMgr:promptWifiOn()
|
||||
end
|
||||
end
|
||||
callback = function() self:onShowWikipediaLookup() end,
|
||||
}
|
||||
menu_items.wikipedia_history = {
|
||||
text = _("Wikipedia history"),
|
||||
@@ -528,4 +522,13 @@ end
|
||||
function ReaderWikipedia:onSaveSettings()
|
||||
end
|
||||
|
||||
function ReaderWikipedia:onShowWikipediaLookup()
|
||||
if NetworkMgr:isOnline() then
|
||||
self:lookupInput()
|
||||
else
|
||||
NetworkMgr:promptWifiOn()
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
return ReaderWikipedia
|
||||
|
||||
Reference in New Issue
Block a user