Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update packaging #1826

Merged
merged 7 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions docs/source/tech_source.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ The following Python packages are needed to run all features of novelWriter:
* ``PyQt5`` – needed for connecting with the Qt5 libraries.
* ``PyEnchant`` – needed for spell checking (optional).

PyQt/Qt should be at least 5.10, but ideally 5.13 or higher for all features to work. For instance,
searching using regular expressions with full Unicode support requires 5.13.

If you want spell checking, you must install the ``PyEnchant`` package. The spell check library
must be at least 3.0 to work with Windows. On Linux, 2.0 also works fine.
PyQt/Qt must be at least 5.15.0. If you want spell checking, you must install the ``PyEnchant``
package. The spell check library must be at least 3.0 to work with Windows. On Linux, 2.0 also
works fine.

If you install from PyPi, these dependencies should be installed automatically. If you install from
source, dependencies can still be installed from PyPi with:
Expand All @@ -55,7 +53,7 @@ source, dependencies can still be installed from PyPi with:
.. note::
On Linux distros, the Qt library is usually split up into multiple packages. In some cases,
secondary dependencies may not be installed automatically. For novelWriter, the library files
for renderring the SVG icons may be left out and needs to be installed manually. This is the
for rendering the SVG icons may be left out and needs to be installed manually. This is the
case on for instance Arch Linux.


Expand Down
8 changes: 4 additions & 4 deletions novelwriter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 1 addition & 11 deletions novelwriter/core/coretools.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,17 +370,7 @@ def searchText(self, text: str) -> tuple[list[tuple[int, int, str]], bool]:
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
Expand Down
32 changes: 9 additions & 23 deletions novelwriter/gui/doceditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
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,
Expand Down Expand Up @@ -2538,32 +2538,18 @@ def replaceText(self) -> str:
# 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

##
Expand Down
5 changes: 2 additions & 3 deletions novelwriter/gui/docviewerpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,8 @@ def _toggleHideInactive(self, state: bool) -> None:

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:
Expand Down
Loading