Conversion dialog: Regex builder: Workaround bug in Qt that prevented searching for non breaking spaces in the wizard used to test search expressions

This commit is contained in:
Kovid Goyal 2023-01-14 11:57:59 +05:30
parent 092bafbe7e
commit 1adeef4743
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 5 deletions

View File

@ -4,8 +4,7 @@
import os import os
from contextlib import suppress from contextlib import suppress
from qt.core import ( from qt.core import (
QBrush, QDialog, QDialogButtonBox, Qt, QTextCursor, QBrush, QDialog, QDialogButtonBox, Qt, QTextCursor, QTextEdit, pyqtSignal,
QTextEdit, pyqtSignal
) )
from calibre.constants import iswindows from calibre.constants import iswindows
@ -14,6 +13,7 @@ from calibre.gui2 import choose_files, error_dialog, gprefs
from calibre.gui2.convert.regex_builder_ui import Ui_RegexBuilder from calibre.gui2.convert.regex_builder_ui import Ui_RegexBuilder
from calibre.gui2.convert.xpath_wizard import XPathEdit from calibre.gui2.convert.xpath_wizard import XPathEdit
from calibre.gui2.dialogs.choose_format import ChooseFormatDialog from calibre.gui2.dialogs.choose_format import ChooseFormatDialog
from calibre.gui2.widgets2 import to_plain_text
from calibre.ptempfile import TemporaryFile from calibre.ptempfile import TemporaryFile
from calibre.utils.icu import utf16_length from calibre.utils.icu import utf16_length
from calibre.utils.ipc.simple_worker import WorkerError, fork_job from calibre.utils.ipc.simple_worker import WorkerError, fork_job
@ -84,7 +84,7 @@ class RegexBuilder(QDialog, Ui_RegexBuilder):
qt: int = 0 qt: int = 0
if self.regex_valid(): if self.regex_valid():
text = str(self.preview.toPlainText()) text = to_plain_text(self.preview)
regex = str(self.regex.text()) regex = str(self.regex.text())
cursor = QTextCursor(self.preview.document()) cursor = QTextCursor(self.preview.document())
extsel = QTextEdit.ExtraSelection() extsel = QTextEdit.ExtraSelection()
@ -205,7 +205,7 @@ class RegexBuilder(QDialog, Ui_RegexBuilder):
self.open_book(files[0]) self.open_book(files[0])
def doc(self): def doc(self):
return str(self.preview.toPlainText()) return to_plain_text(self.preview)
class RegexEdit(XPathEdit): class RegexEdit(XPathEdit):

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Regex Builder</string> <string>Regex builder</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>