From 9bcad05e8c9103b9986ea6aaf5ccbdc045d85e67 Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Tue, 12 May 2026 20:41:01 +0300 Subject: [PATCH] QR from clipboard: enable highlight button on devices without clipboard (#15363) --- plugins/qrclipboard.koplugin/main.lua | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/plugins/qrclipboard.koplugin/main.lua b/plugins/qrclipboard.koplugin/main.lua index f900a015c..958bbb4ff 100644 --- a/plugins/qrclipboard.koplugin/main.lua +++ b/plugins/qrclipboard.koplugin/main.lua @@ -13,14 +13,15 @@ local _ = require("gettext") local QRClipboard = WidgetContainer:extend{ name = "qrclipboard", - is_doc_only = false, } function QRClipboard:init() - self.ui.menu:registerToMainMenu(self) - if self.ui.highlight then + if self.document then self:addToHighlightDialog() end + if Device:hasClipboard() then + self.ui.menu:registerToMainMenu(self) + end end function QRClipboard:addToHighlightDialog() @@ -29,11 +30,18 @@ function QRClipboard:addToHighlightDialog() 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)) + -- 'this' is self.ui.highlight. Do as ReaderHighlight:saveHighlight() does. + this:highlightFromHoldPos() + if not (this.selected_text and this.selected_text.pos0 and this.selected_text.pos1) then return end + local text = this.ui.rolling + and this.document:extendXPointersToSentenceSegment(this.selected_text.pos0, this.selected_text.pos1) + text = util.cleanupSelectedText(text or this.selected_text.text) + if Device:hasClipboard() then -- let the text to be reused via menu + Device.input.setClipboardText(text) + end UIManager:show(QRMessage:new{ - text = Device.input.getClipboardText(), + text = text, width = Device.screen:getWidth(), height = Device.screen:getHeight(), dismiss_callback = function() @@ -57,7 +65,7 @@ function QRClipboard:addToMainMenu(menu_items) UIManager:show(QRMessage:new{ text = Device.input.getClipboardText(), width = Device.screen:getWidth(), - height = Device.screen:getHeight() + height = Device.screen:getHeight(), }) end, }