From a14b39eb4c5c3681d648125204fbe2a4f0e26bc8 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Sat, 23 Mar 2024 17:51:59 -0500 Subject: [PATCH] Paste into ini edit as plain text only. --- calibre-plugin/dialogs.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/calibre-plugin/dialogs.py b/calibre-plugin/dialogs.py index 10d6472a..310629d9 100644 --- a/calibre-plugin/dialogs.py +++ b/calibre-plugin/dialogs.py @@ -1320,6 +1320,17 @@ class EditTextDialog(SizePersistedDialog): def get_reason_text(self): return unicode(self.reason_edit.currentText()).strip() +class QTextEditPlainPaste(QTextEdit): + def insertFromMimeData(self, mimeData): + # logger.debug("insertFromMimeData called") + #Ensure it is text. + if (mimeData.hasText()): + text = mimeData.text() + self.insertPlainText(text) + #In case not text. + else: + QTextEdit.insertFromMimeData(self, mimeData) + class IniTextDialog(SizePersistedDialog): def __init__(self, parent, text, @@ -1341,7 +1352,7 @@ class IniTextDialog(SizePersistedDialog): self.setWindowIcon(icon) self.l.addWidget(self.label) - self.textedit = QTextEdit(self) + self.textedit = QTextEditPlainPaste(self) highlighter = IniHighlighter(self.textedit, sections=get_valid_sections(), @@ -1512,7 +1523,6 @@ class IniTextDialog(SizePersistedDialog): # And finally we set this new cursor as the parent's self.textedit.setTextCursor(cursor) - class ViewLog(SizePersistedDialog): def label_clicked(self, event, lineno=None):