mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
Add faster option to export text selections via QR codes (#12746)
Closes https://github.com/koreader/koreader/issues/11909.
This commit is contained in:
@@ -8,6 +8,7 @@ local Device = require("device")
|
||||
local QRMessage = require("ui/widget/qrmessage")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
local util = require("util")
|
||||
local _ = require("gettext")
|
||||
|
||||
local QRClipboard = WidgetContainer:extend{
|
||||
@@ -17,6 +18,27 @@ local QRClipboard = WidgetContainer:extend{
|
||||
|
||||
function QRClipboard:init()
|
||||
self.ui.menu:registerToMainMenu(self)
|
||||
self:addToHighlightDialog()
|
||||
end
|
||||
|
||||
function QRClipboard:addToHighlightDialog()
|
||||
-- 12_search is the last item in the highlight dialog. We want to sneak in the 'Generate QR code' item
|
||||
-- second to last, thus name '12_generate' so the alphabetical sort keeps '12_search' last.
|
||||
self.ui.highlight:addToHighlightDialog("12_generate_qr_code", function(this)
|
||||
return {
|
||||
text = _("Generate QR code"),
|
||||
enabled = Device:hasClipboard(),
|
||||
callback = function()
|
||||
Device.input.setClipboardText(util.cleanupSelectedText(this.selected_text.text))
|
||||
UIManager:show(QRMessage:new{
|
||||
text = Device.input.getClipboardText(),
|
||||
width = Device.screen:getWidth(),
|
||||
height = Device.screen:getHeight()
|
||||
})
|
||||
this:onClose()
|
||||
end,
|
||||
}
|
||||
end)
|
||||
end
|
||||
|
||||
function QRClipboard:addToMainMenu(menu_items)
|
||||
|
||||
Reference in New Issue
Block a user