From ad924e3c1c2d994560285c05b718d5d2ff56db11 Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Sun, 11 Apr 2021 01:08:59 +0300 Subject: [PATCH] Dict/Wiki lookup results window: improve the 'pencil' button (#7523) --- frontend/ui/widget/dictquicklookup.lua | 30 ++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/frontend/ui/widget/dictquicklookup.lua b/frontend/ui/widget/dictquicklookup.lua index 560b58b37..420ecf0b5 100644 --- a/frontend/ui/widget/dictquicklookup.lua +++ b/frontend/ui/widget/dictquicklookup.lua @@ -21,6 +21,7 @@ local ScrollTextWidget = require("ui/widget/scrolltextwidget") local Size = require("ui/size") local TextWidget = require("ui/widget/textwidget") local TimeVal = require("ui/timeval") +local Translator = require("ui/translator") local UIManager = require("ui/uimanager") local VerticalGroup = require("ui/widget/verticalgroup") local VerticalSpan = require("ui/widget/verticalspan") @@ -1211,6 +1212,27 @@ function DictQuickLookup:lookupInputWord(hint) input_hint = hint or "", input_type = "text", buttons = { + { + { + text = _("Translate"), + is_enter_default = false, + callback = function() + if self.input_dialog:getInputText() == "" then return end + self:closeInputDialog() + Translator:showTranslation(self.input_dialog:getInputText()) + end, + }, + { + text = _("Search Wikipedia"), + is_enter_default = self.is_wiki, + callback = function() + if self.input_dialog:getInputText() == "" then return end + self.is_wiki = true + self:closeInputDialog() + self:inputLookup() + end, + }, + }, { { text = _("Cancel"), @@ -1219,16 +1241,16 @@ function DictQuickLookup:lookupInputWord(hint) end, }, { - text = self.is_wiki and _("Search Wikipedia") or _("Search dictionary"), - is_enter_default = true, + text = _("Search dictionary"), + is_enter_default = not self.is_wiki, callback = function() if self.input_dialog:getInputText() == "" then return end + self.is_wiki = false self:closeInputDialog() - self:onClose() self:inputLookup() end, }, - } + }, }, } UIManager:show(self.input_dialog)