Merge branch 'main' into features/footnotes

This commit is contained in:
Veronica Berglyd Olsen
2024-04-18 00:01:48 +02:00
16 changed files with 149 additions and 533 deletions
+6 -6
View File
@@ -47,9 +47,9 @@ __license__ = "GPLv3"
__author__ = "Veronica Berglyd Olsen"
__maintainer__ = "Veronica Berglyd Olsen"
__email__ = "code@vkbo.net"
__version__ = "2.5a1"
__version__ = "2.5a2"
__hexversion__ = "0x020500a1"
__date__ = "2024-04-13"
__date__ = "2024-04-16"
__status__ = "Stable"
__domain__ = "novelwriter.io"
@@ -167,14 +167,14 @@ def main(sysArgs: list | None = None) -> GuiMain | None:
"At least Python 3.8 is required, found %s" % CONFIG.verPyString
)
errorCode |= 0x04
if CONFIG.verQtValue < 0x050a00:
if CONFIG.verQtValue < 0x050f00:
errorData.append(
"At least Qt5 version 5.10 is required, found %s" % CONFIG.verQtString
"At least Qt5 version 5.15.0 is required, found %s" % CONFIG.verQtString
)
errorCode |= 0x08
if CONFIG.verPyQtValue < 0x050a00:
if CONFIG.verPyQtValue < 0x050f00:
errorData.append(
"At least PyQt5 version 5.10 is required, found %s" % CONFIG.verPyQtString
"At least PyQt5 version 5.15.0 is required, found %s" % CONFIG.verPyQtString
)
errorCode |= 0x10
+1 -11
View File
@@ -370,17 +370,7 @@ class DocSearch:
def _buildPattern(self, search: str) -> str:
"""Build the search pattern string."""
if self._escape:
if CONFIG.verQtValue >= 0x050f00:
search = QRegularExpression.escape(search)
else:
# For older Qt versions, we escape manually
escaped = ""
for c in search:
if c.isalnum() or c == "_":
escaped += c
else:
escaped += f"\\{c}"
search = escaped
search = QRegularExpression.escape(search)
if self._words:
search = f"(?:^|\\b){search}(?:$|\\b)"
return search
+9 -23
View File
@@ -39,8 +39,8 @@ from time import time
from typing import TYPE_CHECKING
from PyQt5.QtCore import (
pyqtSignal, pyqtSlot, QObject, QPoint, QRegExp, QRegularExpression,
QRunnable, Qt, QTimer
pyqtSignal, pyqtSlot, QObject, QPoint, QRegularExpression, QRunnable, Qt,
QTimer
)
from PyQt5.QtGui import (
QColor, QCursor, QFont, QKeyEvent, QKeySequence, QMouseEvent, QPalette,
@@ -2568,32 +2568,18 @@ class GuiDocEditSearch(QFrame):
# Getters
##
def getSearchObject(self) -> str | QRegularExpression | QRegExp:
def getSearchObject(self) -> str | QRegularExpression:
"""Return the current search text either as text or as a regular
expression object.
"""
text = self.searchBox.text()
if CONFIG.searchRegEx:
# Using the Unicode-capable QRegularExpression class was
# only added in Qt 5.13. Otherwise, 5.3 and up supports
# only the QRegExp class.
if CONFIG.verQtValue >= 0x050d00:
rxOpt = QRegularExpression.PatternOption.UseUnicodePropertiesOption
if not CONFIG.searchCase:
rxOpt |= QRegularExpression.PatternOption.CaseInsensitiveOption
regEx = QRegularExpression(text, rxOpt)
self._alertSearchValid(regEx.isValid())
return regEx
else: # pragma: no cover
# >= 50300 to < 51300
if CONFIG.searchCase:
rxOpt = Qt.CaseSensitivity.CaseSensitive
else:
rxOpt = Qt.CaseSensitivity.CaseInsensitive
regEx = QRegExp(text, rxOpt)
self._alertSearchValid(regEx.isValid())
return regEx
rxOpt = QRegularExpression.PatternOption.UseUnicodePropertiesOption
if not CONFIG.searchCase:
rxOpt |= QRegularExpression.PatternOption.CaseInsensitiveOption
regEx = QRegularExpression(text, rxOpt)
self._alertSearchValid(regEx.isValid())
return regEx
return text
##
+2 -3
View File
@@ -209,9 +209,8 @@ class GuiDocViewerPanel(QWidget):
def _updateTabVisibility(self) -> None:
"""Hide class tabs with no content."""
if CONFIG.verQtValue >= 0x050f00:
for tClass, cTab in self.kwTabs.items():
self.mainTabs.setTabVisible(self.idTabs[tClass], cTab.countEntries() > 0)
for tClass, cTab in self.kwTabs.items():
self.mainTabs.setTabVisible(self.idTabs[tClass], cTab.countEntries() > 0)
return
def _loadAllTags(self) -> None: