diff --git a/i18n/qtbase.py b/i18n/qtbase.py index 90f6f9ae..3126bea3 100644 --- a/i18n/qtbase.py +++ b/i18n/qtbase.py @@ -10,7 +10,7 @@ If a qtbase_xx.qm file already exists, do not add a translation for the entries generated from this file. """ -from PyQt5.QtCore import QT_TRANSLATE_NOOP +from PyQt6.QtCore import QT_TRANSLATE_NOOP # QDialogButtonBox # ================ diff --git a/novelWriter.py b/novelWriter.py index 33ce3768..285cb5dd 100755 --- a/novelWriter.py +++ b/novelWriter.py @@ -7,11 +7,11 @@ import os import sys try: - import PyQt5.QtWidgets # noqa: F401 - import PyQt5.QtGui # noqa: F401 - import PyQt5.QtCore # noqa: F401 + import PyQt6.QtCore # noqa: F401 + import PyQt6.QtGui # noqa: F401 + import PyQt6.QtWidgets # noqa: F401 except Exception: - print("ERROR: Failed to load dependency PyQt5") + print("ERROR: Failed to load dependency PyQt6") sys.exit(1) os.curdir = os.path.abspath(os.path.dirname(__file__)) diff --git a/novelwriter/__init__.py b/novelwriter/__init__.py index 7e9f74f1..62305d6d 100644 --- a/novelwriter/__init__.py +++ b/novelwriter/__init__.py @@ -29,7 +29,7 @@ import sys from typing import TYPE_CHECKING -from PyQt5.QtWidgets import QApplication, QErrorMessage +from PyQt6.QtWidgets import QApplication, QErrorMessage from novelwriter.config import Config from novelwriter.error import exceptionHandler @@ -201,21 +201,21 @@ def main(sysArgs: list | None = None) -> GuiMain | None: # Check Packages and Versions errorData = [] errorCode = 0 - if sys.hexversion < 0x030a00f0: - errorData.append( - "At least Python 3.10 is required, found %s" % CONFIG.verPyString - ) - errorCode |= 0x04 - if CONFIG.verQtValue < 0x050f00: - errorData.append( - "At least Qt5 version 5.15.0 is required, found %s" % CONFIG.verQtString - ) - errorCode |= 0x08 - if CONFIG.verPyQtValue < 0x050f00: - errorData.append( - "At least PyQt5 version 5.15.0 is required, found %s" % CONFIG.verPyQtString - ) - errorCode |= 0x10 + # if sys.hexversion < 0x030a00f0: + # errorData.append( + # "At least Python 3.10 is required, found %s" % CONFIG.verPyString + # ) + # errorCode |= 0x04 + # if CONFIG.verQtValue < 0x060000: + # errorData.append( + # "At least Qt6 version 6.0 is required, found %s" % CONFIG.verQtString + # ) + # errorCode |= 0x08 + # if CONFIG.verPyQtValue < 0x060000: + # errorData.append( + # "At least PyQt6 version 6.0 is required, found %s" % CONFIG.verPyQtString + # ) + # errorCode |= 0x10 if errorData: errApp = QApplication([]) diff --git a/novelwriter/common.py b/novelwriter/common.py index 17a465ee..4731e82f 100644 --- a/novelwriter/common.py +++ b/novelwriter/common.py @@ -37,8 +37,8 @@ from typing import Any, Literal, TypeGuard, TypeVar from urllib.parse import urljoin from urllib.request import pathname2url -from PyQt5.QtCore import QCoreApplication, QMimeData, QUrl -from PyQt5.QtGui import QColor, QDesktopServices, QFont, QFontDatabase, QFontInfo +from PyQt6.QtCore import QCoreApplication, QMimeData, QUrl +from PyQt6.QtGui import QColor, QDesktopServices, QFont, QFontDatabase, QFontInfo from novelwriter.constants import nwConst, nwLabels, nwUnicode, trConst from novelwriter.enum import nwItemClass, nwItemLayout, nwItemType @@ -440,11 +440,10 @@ def fontMatcher(font: QFont) -> QFont: info = QFontInfo(font) if (famRequest := font.family()) != (famActual := info.family()): logger.warning("Font mismatch: Requested '%s', but got '%s'", famRequest, famActual) - db = QFontDatabase() - if famRequest in db.families(): + if famRequest in QFontDatabase.families(): styleRequest, sizeRequest = font.styleName(), font.pointSize() logger.info("Lookup: %s, %s, %d pt", famRequest, styleRequest, sizeRequest) - temp = db.font(famRequest, styleRequest, sizeRequest) + temp = QFontDatabase.font(famRequest, styleRequest, sizeRequest) temp.setPointSize(sizeRequest) # Make sure it isn't changed famFound, styleFound, sizeFound = temp.family(), temp.styleName(), temp.pointSize() if famFound == famRequest: diff --git a/novelwriter/config.py b/novelwriter/config.py index cd377199..8e4cded1 100644 --- a/novelwriter/config.py +++ b/novelwriter/config.py @@ -33,12 +33,12 @@ from datetime import datetime from pathlib import Path from time import time -from PyQt5.QtCore import ( +from PyQt6.QtCore import ( PYQT_VERSION, PYQT_VERSION_STR, QT_VERSION, QT_VERSION_STR, QLibraryInfo, QLocale, QStandardPaths, QSysInfo, QTranslator ) -from PyQt5.QtGui import QFont, QFontDatabase -from PyQt5.QtWidgets import QApplication +from PyQt6.QtGui import QFont, QFontDatabase +from PyQt6.QtWidgets import QApplication from novelwriter.common import ( NWConfigParser, checkInt, checkPath, describeFont, fontMatcher, @@ -91,7 +91,7 @@ class Config: # Localisation # Note that these paths must be strings self._nwLangPath = self._appPath / "assets" / "i18n" - self._qtLangPath = QLibraryInfo.location(QLibraryInfo.LibraryLocation.TranslationsPath) + self._qtLangPath = QLibraryInfo.path(QLibraryInfo.LibraryPath.TranslationsPath) hasLocale = (self._nwLangPath / f"nw_{QLocale.system().name()}.qm").exists() self._qLocale = QLocale.system() if hasLocale else QLocale("en_GB") @@ -385,13 +385,12 @@ class Config: self.guiFont = fontMatcher(font) else: font = QFont() - fontDB = QFontDatabase() - if self.osWindows and "Arial" in fontDB.families(): + if self.osWindows and "Arial" in QFontDatabase.families(): # On Windows we default to Arial if possible font.setFamily("Arial") font.setPointSize(10) else: - font = fontDB.systemFont(QFontDatabase.SystemFont.GeneralFont) + font = QFontDatabase.systemFont(QFontDatabase.SystemFont.GeneralFont) self.guiFont = fontMatcher(font) logger.debug("GUI font set to: %s", describeFont(font)) QApplication.setFont(self.guiFont) @@ -408,8 +407,7 @@ class Config: font.fromString(value) self.textFont = fontMatcher(font) else: - fontDB = QFontDatabase() - fontFam = fontDB.families() + fontFam = QFontDatabase.families() if self.osWindows and "Arial" in fontFam: font = QFont() font.setFamily("Arial") @@ -419,7 +417,7 @@ class Config: font.setFamily("Helvetica") font.setPointSize(12) else: - font = fontDB.systemFont(QFontDatabase.SystemFont.GeneralFont) + font = QFontDatabase.systemFont(QFontDatabase.SystemFont.GeneralFont) self.textFont = fontMatcher(font) logger.debug("Text font set to: %s", describeFont(self.textFont)) return diff --git a/novelwriter/constants.py b/novelwriter/constants.py index 36099c38..daf4e9e8 100644 --- a/novelwriter/constants.py +++ b/novelwriter/constants.py @@ -23,7 +23,7 @@ along with this program. If not, see . """ from __future__ import annotations -from PyQt5.QtCore import QT_TRANSLATE_NOOP, QCoreApplication +from PyQt6.QtCore import QT_TRANSLATE_NOOP, QCoreApplication from novelwriter.enum import ( nwBuildFmt, nwComment, nwItemClass, nwItemLayout, nwOutline, nwStatusShape diff --git a/novelwriter/core/buildsettings.py b/novelwriter/core/buildsettings.py index 0d2d3b44..7c62c5b9 100644 --- a/novelwriter/core/buildsettings.py +++ b/novelwriter/core/buildsettings.py @@ -32,7 +32,7 @@ from collections.abc import Iterable from enum import Enum from pathlib import Path -from PyQt5.QtCore import QT_TRANSLATE_NOOP, QCoreApplication +from PyQt6.QtCore import QT_TRANSLATE_NOOP, QCoreApplication from novelwriter import CONFIG from novelwriter.common import checkUuid, isHandle, jsonEncode diff --git a/novelwriter/core/coretools.py b/novelwriter/core/coretools.py index d8432449..f118ac7a 100644 --- a/novelwriter/core/coretools.py +++ b/novelwriter/core/coretools.py @@ -35,7 +35,7 @@ from functools import partial from pathlib import Path from zipfile import ZipFile, is_zipfile -from PyQt5.QtCore import QCoreApplication +from PyQt6.QtCore import QCoreApplication from novelwriter import CONFIG, SHARED from novelwriter.common import isHandle, minmax, simplified diff --git a/novelwriter/core/docbuild.py b/novelwriter/core/docbuild.py index b2431567..2f775fa5 100644 --- a/novelwriter/core/docbuild.py +++ b/novelwriter/core/docbuild.py @@ -28,7 +28,7 @@ import logging from collections.abc import Iterable from pathlib import Path -from PyQt5.QtGui import QFont +from PyQt6.QtGui import QFont from novelwriter import CONFIG from novelwriter.constants import nwLabels diff --git a/novelwriter/core/item.py b/novelwriter/core/item.py index 6cf0ec90..38a2dbcc 100644 --- a/novelwriter/core/item.py +++ b/novelwriter/core/item.py @@ -27,7 +27,7 @@ import logging from typing import TYPE_CHECKING, Any -from PyQt5.QtGui import QFont, QIcon +from PyQt6.QtGui import QFont, QIcon from novelwriter import CONFIG, SHARED from novelwriter.common import ( diff --git a/novelwriter/core/itemmodel.py b/novelwriter/core/itemmodel.py index 8910e2b4..82b16e3e 100644 --- a/novelwriter/core/itemmodel.py +++ b/novelwriter/core/itemmodel.py @@ -28,8 +28,8 @@ import logging from typing import TYPE_CHECKING -from PyQt5.QtCore import QAbstractItemModel, QMimeData, QModelIndex, Qt -from PyQt5.QtGui import QFont, QIcon +from PyQt6.QtCore import QAbstractItemModel, QMimeData, QModelIndex, Qt +from PyQt6.QtGui import QFont, QIcon from novelwriter.common import decodeMimeHandles, encodeMimeHandles, minmax from novelwriter.constants import nwConst diff --git a/novelwriter/core/project.py b/novelwriter/core/project.py index 50bf4a94..3999371c 100644 --- a/novelwriter/core/project.py +++ b/novelwriter/core/project.py @@ -31,7 +31,7 @@ from functools import partial from pathlib import Path from time import time -from PyQt5.QtCore import QCoreApplication +from PyQt6.QtCore import QCoreApplication from novelwriter import CONFIG, SHARED, __hexversion__, __version__ from novelwriter.common import ( diff --git a/novelwriter/core/spellcheck.py b/novelwriter/core/spellcheck.py index dea46048..87b701ba 100644 --- a/novelwriter/core/spellcheck.py +++ b/novelwriter/core/spellcheck.py @@ -31,7 +31,7 @@ from collections.abc import Iterator from pathlib import Path from typing import TYPE_CHECKING -from PyQt5.QtCore import QLocale +from PyQt6.QtCore import QLocale from novelwriter.constants import nwFiles from novelwriter.error import logException diff --git a/novelwriter/core/status.py b/novelwriter/core/status.py index 24b57aa6..92c78d50 100644 --- a/novelwriter/core/status.py +++ b/novelwriter/core/status.py @@ -31,8 +31,8 @@ import random from collections.abc import Iterable from typing import Literal, TypeGuard -from PyQt5.QtCore import QPointF, Qt -from PyQt5.QtGui import QColor, QIcon, QPainter, QPainterPath, QPixmap, QPolygonF +from PyQt6.QtCore import QPointF, Qt +from PyQt6.QtGui import QColor, QIcon, QPainter, QPainterPath, QPixmap, QPolygonF from novelwriter import SHARED from novelwriter.common import simplified diff --git a/novelwriter/core/tree.py b/novelwriter/core/tree.py index c217f942..002ff811 100644 --- a/novelwriter/core/tree.py +++ b/novelwriter/core/tree.py @@ -31,7 +31,7 @@ from collections.abc import Iterable, Iterator from pathlib import Path from typing import TYPE_CHECKING, Literal, overload -from PyQt5.QtCore import QModelIndex +from PyQt6.QtCore import QModelIndex from novelwriter import SHARED from novelwriter.constants import nwFiles, nwLabels, trConst diff --git a/novelwriter/dialogs/about.py b/novelwriter/dialogs/about.py index a7d921da..eaa91a8c 100644 --- a/novelwriter/dialogs/about.py +++ b/novelwriter/dialogs/about.py @@ -25,8 +25,8 @@ from __future__ import annotations import logging -from PyQt5.QtGui import QCloseEvent, QColor -from PyQt5.QtWidgets import ( +from PyQt6.QtGui import QCloseEvent, QColor +from PyQt6.QtWidgets import ( QDialogButtonBox, QHBoxLayout, QLabel, QTextBrowser, QVBoxLayout, QWidget ) diff --git a/novelwriter/dialogs/docmerge.py b/novelwriter/dialogs/docmerge.py index 8082e8d9..4d1d529f 100644 --- a/novelwriter/dialogs/docmerge.py +++ b/novelwriter/dialogs/docmerge.py @@ -26,8 +26,8 @@ from __future__ import annotations import logging -from PyQt5.QtCore import Qt, pyqtSlot -from PyQt5.QtWidgets import ( +from PyQt6.QtCore import Qt, pyqtSlot +from PyQt6.QtWidgets import ( QAbstractItemView, QDialogButtonBox, QGridLayout, QLabel, QListWidget, QListWidgetItem, QVBoxLayout, QWidget ) diff --git a/novelwriter/dialogs/docsplit.py b/novelwriter/dialogs/docsplit.py index 80fd6418..259125a6 100644 --- a/novelwriter/dialogs/docsplit.py +++ b/novelwriter/dialogs/docsplit.py @@ -26,8 +26,8 @@ from __future__ import annotations import logging -from PyQt5.QtCore import pyqtSlot -from PyQt5.QtWidgets import ( +from PyQt6.QtCore import pyqtSlot +from PyQt6.QtWidgets import ( QAbstractItemView, QComboBox, QDialogButtonBox, QGridLayout, QLabel, QListWidget, QListWidgetItem, QVBoxLayout, QWidget ) diff --git a/novelwriter/dialogs/editlabel.py b/novelwriter/dialogs/editlabel.py index 529caf21..9bc4c2b4 100644 --- a/novelwriter/dialogs/editlabel.py +++ b/novelwriter/dialogs/editlabel.py @@ -25,7 +25,7 @@ from __future__ import annotations import logging -from PyQt5.QtWidgets import QDialogButtonBox, QHBoxLayout, QLabel, QLineEdit, QVBoxLayout, QWidget +from PyQt6.QtWidgets import QDialogButtonBox, QHBoxLayout, QLabel, QLineEdit, QVBoxLayout, QWidget from novelwriter import CONFIG from novelwriter.extensions.modified import NDialog diff --git a/novelwriter/dialogs/preferences.py b/novelwriter/dialogs/preferences.py index a272dab5..8e3d65f1 100644 --- a/novelwriter/dialogs/preferences.py +++ b/novelwriter/dialogs/preferences.py @@ -26,9 +26,9 @@ from __future__ import annotations import logging -from PyQt5.QtCore import Qt, pyqtSignal, pyqtSlot -from PyQt5.QtGui import QCloseEvent, QKeyEvent, QKeySequence -from PyQt5.QtWidgets import ( +from PyQt6.QtCore import Qt, pyqtSignal, pyqtSlot +from PyQt6.QtGui import QCloseEvent, QKeyEvent, QKeySequence +from PyQt6.QtWidgets import ( QCompleter, QDialogButtonBox, QFileDialog, QHBoxLayout, QLineEdit, QPushButton, QVBoxLayout, QWidget ) diff --git a/novelwriter/dialogs/projectsettings.py b/novelwriter/dialogs/projectsettings.py index e9572157..222a8c77 100644 --- a/novelwriter/dialogs/projectsettings.py +++ b/novelwriter/dialogs/projectsettings.py @@ -29,9 +29,9 @@ import logging from pathlib import Path -from PyQt5.QtCore import Qt, pyqtSignal, pyqtSlot -from PyQt5.QtGui import QCloseEvent, QColor -from PyQt5.QtWidgets import ( +from PyQt6.QtCore import Qt, pyqtSignal, pyqtSlot +from PyQt6.QtGui import QCloseEvent, QColor +from PyQt6.QtWidgets import ( QAbstractItemView, QApplication, QColorDialog, QDialogButtonBox, QFileDialog, QGridLayout, QHBoxLayout, QLineEdit, QMenu, QStackedWidget, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget diff --git a/novelwriter/dialogs/quotes.py b/novelwriter/dialogs/quotes.py index 2d5c489e..373f8ca5 100644 --- a/novelwriter/dialogs/quotes.py +++ b/novelwriter/dialogs/quotes.py @@ -25,9 +25,9 @@ from __future__ import annotations import logging -from PyQt5.QtCore import QSize, pyqtSlot -from PyQt5.QtGui import QFontMetrics -from PyQt5.QtWidgets import ( +from PyQt6.QtCore import QSize, pyqtSlot +from PyQt6.QtGui import QFontMetrics +from PyQt6.QtWidgets import ( QDialogButtonBox, QFrame, QHBoxLayout, QLabel, QListWidget, QListWidgetItem, QVBoxLayout, QWidget ) diff --git a/novelwriter/dialogs/wordlist.py b/novelwriter/dialogs/wordlist.py index 5ecd8c1d..1988b79b 100644 --- a/novelwriter/dialogs/wordlist.py +++ b/novelwriter/dialogs/wordlist.py @@ -27,9 +27,9 @@ import logging from pathlib import Path -from PyQt5.QtCore import Qt, pyqtSignal, pyqtSlot -from PyQt5.QtGui import QCloseEvent -from PyQt5.QtWidgets import ( +from PyQt6.QtCore import Qt, pyqtSignal, pyqtSlot +from PyQt6.QtGui import QCloseEvent +from PyQt6.QtWidgets import ( QAbstractItemView, QApplication, QDialogButtonBox, QFileDialog, QHBoxLayout, QLineEdit, QListWidget, QVBoxLayout, QWidget ) diff --git a/novelwriter/error.py b/novelwriter/error.py index bdca704b..6f272c0b 100644 --- a/novelwriter/error.py +++ b/novelwriter/error.py @@ -29,9 +29,9 @@ import sys from typing import TYPE_CHECKING -from PyQt5.QtCore import Qt, pyqtSlot -from PyQt5.QtGui import QFont, QFontDatabase -from PyQt5.QtWidgets import ( +from PyQt6.QtCore import Qt, pyqtSlot +from PyQt6.QtGui import QFont, QFontDatabase +from PyQt6.QtWidgets import ( QApplication, QDialog, QDialogButtonBox, QGridLayout, QLabel, QPlainTextEdit, QStyle, QWidget ) @@ -118,7 +118,7 @@ class NWErrorMessage(QDialog): """ from traceback import format_tb - from PyQt5.QtCore import PYQT_VERSION_STR, QT_VERSION_STR, QSysInfo + from PyQt6.QtCore import PYQT_VERSION_STR, QT_VERSION_STR, QSysInfo from novelwriter import __version__ from novelwriter.constants import nwConst @@ -174,7 +174,7 @@ def exceptionHandler(exType: type, exValue: BaseException, exTrace: TracebackTyp """Function to catch unhandled global exceptions.""" from traceback import print_tb - from PyQt5.QtWidgets import QApplication + from PyQt6.QtWidgets import QApplication logger.critical("%s: %s", exType.__name__, str(exValue)) print_tb(exTrace) diff --git a/novelwriter/extensions/configlayout.py b/novelwriter/extensions/configlayout.py index 6582612a..47b74175 100644 --- a/novelwriter/extensions/configlayout.py +++ b/novelwriter/extensions/configlayout.py @@ -27,8 +27,8 @@ along with this program. If not, see . """ from __future__ import annotations -from PyQt5.QtGui import QColor, QFont, QPalette, QPixmap -from PyQt5.QtWidgets import ( +from PyQt6.QtGui import QColor, QFont, QPalette, QPixmap +from PyQt6.QtWidgets import ( QAbstractButton, QFrame, QHBoxLayout, QLabel, QLayout, QScrollArea, QVBoxLayout, QWidget ) diff --git a/novelwriter/extensions/eventfilters.py b/novelwriter/extensions/eventfilters.py index 3c2e2aa8..f305db6c 100644 --- a/novelwriter/extensions/eventfilters.py +++ b/novelwriter/extensions/eventfilters.py @@ -24,9 +24,9 @@ along with this program. If not, see . """ from __future__ import annotations -from PyQt5.QtCore import QEvent, QObject -from PyQt5.QtGui import QStatusTipEvent, QWheelEvent -from PyQt5.QtWidgets import QWidget +from PyQt6.QtCore import QEvent, QObject +from PyQt6.QtGui import QStatusTipEvent, QWheelEvent +from PyQt6.QtWidgets import QWidget class WheelEventFilter(QObject): diff --git a/novelwriter/extensions/modified.py b/novelwriter/extensions/modified.py index 5471da29..67aa7453 100644 --- a/novelwriter/extensions/modified.py +++ b/novelwriter/extensions/modified.py @@ -30,9 +30,9 @@ from __future__ import annotations from enum import Enum from typing import TYPE_CHECKING -from PyQt5.QtCore import QSize, Qt, pyqtSignal, pyqtSlot -from PyQt5.QtGui import QMouseEvent, QWheelEvent -from PyQt5.QtWidgets import ( +from PyQt6.QtCore import QSize, Qt, pyqtSignal, pyqtSlot +from PyQt6.QtGui import QMouseEvent, QWheelEvent +from PyQt6.QtWidgets import ( QApplication, QComboBox, QDialog, QDoubleSpinBox, QLabel, QSpinBox, QToolButton, QWidget ) diff --git a/novelwriter/extensions/novelselector.py b/novelwriter/extensions/novelselector.py index b604bd22..f568f4ea 100644 --- a/novelwriter/extensions/novelselector.py +++ b/novelwriter/extensions/novelselector.py @@ -25,8 +25,8 @@ from __future__ import annotations import logging -from PyQt5.QtCore import pyqtSignal, pyqtSlot -from PyQt5.QtWidgets import QComboBox, QWidget +from PyQt6.QtCore import pyqtSignal, pyqtSlot +from PyQt6.QtWidgets import QComboBox, QWidget from novelwriter import SHARED from novelwriter.constants import nwLabels diff --git a/novelwriter/extensions/pagedsidebar.py b/novelwriter/extensions/pagedsidebar.py index 319cfaaf..6dd835f3 100644 --- a/novelwriter/extensions/pagedsidebar.py +++ b/novelwriter/extensions/pagedsidebar.py @@ -25,11 +25,11 @@ along with this program. If not, see . """ from __future__ import annotations -from PyQt5.QtCore import QPoint, QRectF, QSize, Qt, pyqtSignal, pyqtSlot -from PyQt5.QtGui import QColor, QPainter, QPaintEvent, QPolygon -from PyQt5.QtWidgets import ( - QAbstractButton, QAction, QButtonGroup, QLabel, QStyle, - QStyleOptionToolButton, QToolBar, QToolButton, QWidget +from PyQt6.QtCore import QPoint, QRectF, QSize, Qt, pyqtSignal, pyqtSlot +from PyQt6.QtGui import QAction, QColor, QPainter, QPaintEvent, QPolygon +from PyQt6.QtWidgets import ( + QAbstractButton, QButtonGroup, QLabel, QStyle, QStyleOptionToolButton, + QToolBar, QToolButton, QWidget ) from novelwriter.types import ( diff --git a/novelwriter/extensions/progressbars.py b/novelwriter/extensions/progressbars.py index 1c7684fb..358501ac 100644 --- a/novelwriter/extensions/progressbars.py +++ b/novelwriter/extensions/progressbars.py @@ -26,9 +26,9 @@ from __future__ import annotations from math import ceil -from PyQt5.QtCore import QRect -from PyQt5.QtGui import QBrush, QColor, QPainter, QPaintEvent, QPen -from PyQt5.QtWidgets import QProgressBar, QWidget +from PyQt6.QtCore import QRect +from PyQt6.QtGui import QBrush, QColor, QPainter, QPaintEvent, QPen +from PyQt6.QtWidgets import QProgressBar, QWidget from novelwriter.types import ( QtAlignCenter, QtPaintAntiAlias, QtRoundCap, QtSizeFixed, QtSolidLine, diff --git a/novelwriter/extensions/statusled.py b/novelwriter/extensions/statusled.py index e9a88104..f4377823 100644 --- a/novelwriter/extensions/statusled.py +++ b/novelwriter/extensions/statusled.py @@ -25,8 +25,8 @@ from __future__ import annotations import logging -from PyQt5.QtGui import QColor, QPainter, QPaintEvent -from PyQt5.QtWidgets import QAbstractButton, QWidget +from PyQt6.QtGui import QColor, QPainter, QPaintEvent +from PyQt6.QtWidgets import QAbstractButton, QWidget from novelwriter import CONFIG from novelwriter.enum import nwTrinary diff --git a/novelwriter/extensions/switch.py b/novelwriter/extensions/switch.py index 43d60fc6..7b8c401d 100644 --- a/novelwriter/extensions/switch.py +++ b/novelwriter/extensions/switch.py @@ -23,13 +23,15 @@ along with this program. If not, see . """ from __future__ import annotations -from PyQt5.QtCore import QEvent, QPropertyAnimation, Qt, pyqtProperty -from PyQt5.QtGui import QMouseEvent, QPainter, QPaintEvent, QResizeEvent -from PyQt5.QtWidgets import QAbstractButton, QWidget +from PyQt6.QtCore import QByteArray, QPropertyAnimation, Qt +from PyQt6.QtGui import QEnterEvent, QMouseEvent, QPainter, QPaintEvent, QResizeEvent +from PyQt6.QtWidgets import QAbstractButton, QWidget from novelwriter import CONFIG, SHARED from novelwriter.types import QtMouseLeft, QtNoPen, QtPaintAntiAlias, QtSizeFixed +OFFSET = QByteArray(b"offset") # type: ignore + class NSwitch(QAbstractButton): @@ -57,7 +59,7 @@ class NSwitch(QAbstractButton): # Properties ## - @pyqtProperty(int) # type: ignore + @property def offset(self) -> int: # type: ignore return self._offset @@ -121,14 +123,14 @@ class NSwitch(QAbstractButton): """Animate the switch on mouse release.""" super().mouseReleaseEvent(event) if event.button() == QtMouseLeft: - anim = QPropertyAnimation(self, b"offset", self) + anim = QPropertyAnimation(self, OFFSET, self) anim.setDuration(120) anim.setStartValue(self._offset) anim.setEndValue((self._xW - self._xR) if self.isChecked() else self._xR) anim.start() return - def enterEvent(self, event: QEvent) -> None: + def enterEvent(self, event: QEnterEvent) -> None: """Change the cursor when hovering the button.""" self.setCursor(Qt.CursorShape.PointingHandCursor) super().enterEvent(event) diff --git a/novelwriter/extensions/switchbox.py b/novelwriter/extensions/switchbox.py index ac11d083..9acc0cc9 100644 --- a/novelwriter/extensions/switchbox.py +++ b/novelwriter/extensions/switchbox.py @@ -23,9 +23,9 @@ along with this program. If not, see . """ from __future__ import annotations -from PyQt5.QtCore import pyqtSignal -from PyQt5.QtGui import QIcon -from PyQt5.QtWidgets import QGridLayout, QLabel, QScrollArea, QWidget +from PyQt6.QtCore import pyqtSignal +from PyQt6.QtGui import QIcon +from PyQt6.QtWidgets import QGridLayout, QLabel, QScrollArea, QWidget from novelwriter.extensions.switch import NSwitch from novelwriter.types import ( diff --git a/novelwriter/extensions/versioninfo.py b/novelwriter/extensions/versioninfo.py index 22ecd251..c44ce820 100644 --- a/novelwriter/extensions/versioninfo.py +++ b/novelwriter/extensions/versioninfo.py @@ -31,9 +31,9 @@ from time import sleep from urllib.error import HTTPError from urllib.request import Request, urlopen -from PyQt5.QtCore import QObject, QRunnable, QUrl, pyqtSignal, pyqtSlot -from PyQt5.QtGui import QDesktopServices -from PyQt5.QtWidgets import QLabel, QVBoxLayout, QWidget +from PyQt6.QtCore import QObject, QRunnable, QUrl, pyqtSignal, pyqtSlot +from PyQt6.QtGui import QDesktopServices +from PyQt6.QtWidgets import QLabel, QVBoxLayout, QWidget from novelwriter import CONFIG, SHARED, __date__, __domain__, __version__ from novelwriter.common import formatVersion diff --git a/novelwriter/formats/shared.py b/novelwriter/formats/shared.py index b1c0f288..549f6f19 100644 --- a/novelwriter/formats/shared.py +++ b/novelwriter/formats/shared.py @@ -27,7 +27,7 @@ import re from enum import Flag, IntEnum -from PyQt5.QtGui import QColor +from PyQt6.QtGui import QColor ESCAPES = {r"\*": "*", r"\~": "~", r"\_": "_", r"\[": "[", r"\]": "]", r"\ ": ""} RX_ESC = re.compile("|".join([re.escape(k) for k in ESCAPES.keys()]), flags=re.DOTALL) diff --git a/novelwriter/formats/todocx.py b/novelwriter/formats/todocx.py index 694ffac0..f3df8a31 100644 --- a/novelwriter/formats/todocx.py +++ b/novelwriter/formats/todocx.py @@ -33,8 +33,8 @@ from pathlib import Path from typing import NamedTuple from zipfile import ZIP_DEFLATED, ZipFile -from PyQt5.QtCore import QMargins, QSize -from PyQt5.QtGui import QColor +from PyQt6.QtCore import QMargins, QSize +from PyQt6.QtGui import QColor from novelwriter import __version__ from novelwriter.common import firstFloat, xmlElement, xmlSubElem diff --git a/novelwriter/formats/tokenizer.py b/novelwriter/formats/tokenizer.py index 70d1de0c..b254400b 100644 --- a/novelwriter/formats/tokenizer.py +++ b/novelwriter/formats/tokenizer.py @@ -31,8 +31,8 @@ from abc import ABC, abstractmethod from pathlib import Path from typing import NamedTuple -from PyQt5.QtCore import QLocale -from PyQt5.QtGui import QColor, QFont +from PyQt6.QtCore import QLocale +from PyQt6.QtGui import QColor, QFont from novelwriter import CONFIG from novelwriter.common import checkInt, fontMatcher, numberToRoman diff --git a/novelwriter/formats/toodt.py b/novelwriter/formats/toodt.py index 442b8284..347c1235 100644 --- a/novelwriter/formats/toodt.py +++ b/novelwriter/formats/toodt.py @@ -35,7 +35,7 @@ from hashlib import sha256 from pathlib import Path from zipfile import ZIP_DEFLATED, ZipFile -from PyQt5.QtGui import QColor, QFont +from PyQt6.QtGui import QColor, QFont from novelwriter import __version__ from novelwriter.common import xmlElement, xmlIndent, xmlSubElem diff --git a/novelwriter/formats/toqdoc.py b/novelwriter/formats/toqdoc.py index 8d9c8f6e..13647988 100644 --- a/novelwriter/formats/toqdoc.py +++ b/novelwriter/formats/toqdoc.py @@ -27,12 +27,12 @@ import logging from pathlib import Path -from PyQt5.QtCore import QMarginsF, QSizeF -from PyQt5.QtGui import ( - QColor, QFont, QFontDatabase, QPageSize, QTextBlockFormat, QTextCharFormat, - QTextCursor, QTextDocument, QTextFrameFormat +from PyQt6.QtCore import QMarginsF, QSizeF +from PyQt6.QtGui import ( + QColor, QFont, QFontDatabase, QPageLayout, QPageSize, QTextBlockFormat, + QTextCharFormat, QTextCursor, QTextDocument, QTextFrameFormat ) -from PyQt5.QtPrintSupport import QPrinter +from PyQt6.QtPrintSupport import QPrinter from novelwriter import __version__ from novelwriter.constants import nwStyles, nwUnicode @@ -129,10 +129,9 @@ class ToQTextDocument(Tokenizer): super().initDocument() if pdf: - fontDB = QFontDatabase() family = self._textFont.family() style = self._textFont.styleName() - self._dpi = 1200 if fontDB.isScalable(family, style) else 72 + self._dpi = 1200 if QFontDatabase.isScalable(family, style) else 72 self._document.setUndoRedoEnabled(False) self._document.blockSignals(True) @@ -268,7 +267,6 @@ class ToQTextDocument(Tokenizer): def saveDocument(self, path: Path) -> None: """Save the document as a PDF file.""" - m = self._pageMargins logger.info("Writing PDF at %d DPI", self._dpi) printer = QPrinter(QPrinter.PrinterMode.HighResolution) @@ -277,11 +275,11 @@ class ToQTextDocument(Tokenizer): printer.setResolution(self._dpi) printer.setOutputFormat(QPrinter.OutputFormat.PdfFormat) printer.setPageSize(self._pageSize) - printer.setPageMargins(m.left(), m.top(), m.right(), m.bottom(), QPrinter.Unit.Millimeter) + printer.setPageMargins(self._pageMargins, QPageLayout.Unit.Millimeter) printer.setOutputFileName(str(path)) self._document.documentLayout().setPaintDevice(printer) - self._document.setPageSize(QSizeF(printer.pageRect().size())) + self._document.setPageSize(printer.pageRect(QPrinter.Unit.Millimeter).size()) self._document.print(printer) return diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py index e7abcdb2..70ab48ec 100644 --- a/novelwriter/gui/doceditor.py +++ b/novelwriter/gui/doceditor.py @@ -37,18 +37,18 @@ import logging from enum import Enum from time import time -from PyQt5.QtCore import ( +from PyQt6.QtCore import ( QObject, QPoint, QRegularExpression, QRunnable, Qt, QTimer, pyqtSignal, pyqtSlot ) -from PyQt5.QtGui import ( - QColor, QCursor, QDragEnterEvent, QDragMoveEvent, QDropEvent, QKeyEvent, - QKeySequence, QMouseEvent, QPalette, QPixmap, QResizeEvent, QTextBlock, - QTextCursor, QTextDocument, QTextOption +from PyQt6.QtGui import ( + QAction, QColor, QCursor, QDragEnterEvent, QDragMoveEvent, QDropEvent, + QKeyEvent, QKeySequence, QMouseEvent, QPalette, QPixmap, QResizeEvent, + QShortcut, QTextBlock, QTextCursor, QTextDocument, QTextOption ) -from PyQt5.QtWidgets import ( - QAction, QApplication, QFrame, QGridLayout, QHBoxLayout, QLabel, QLineEdit, - QMenu, QPlainTextEdit, QShortcut, QToolBar, QVBoxLayout, QWidget +from PyQt6.QtWidgets import ( + QApplication, QFrame, QGridLayout, QHBoxLayout, QLabel, QLineEdit, QMenu, + QPlainTextEdit, QToolBar, QVBoxLayout, QWidget ) from novelwriter import CONFIG, SHARED diff --git a/novelwriter/gui/dochighlight.py b/novelwriter/gui/dochighlight.py index b6f01928..c20c3ecf 100644 --- a/novelwriter/gui/dochighlight.py +++ b/novelwriter/gui/dochighlight.py @@ -29,8 +29,8 @@ import re from time import time -from PyQt5.QtCore import Qt -from PyQt5.QtGui import ( +from PyQt6.QtCore import Qt +from PyQt6.QtGui import ( QBrush, QColor, QFont, QSyntaxHighlighter, QTextBlockUserData, QTextCharFormat, QTextDocument ) diff --git a/novelwriter/gui/docviewer.py b/novelwriter/gui/docviewer.py index 6bda315a..f20a9840 100644 --- a/novelwriter/gui/docviewer.py +++ b/novelwriter/gui/docviewer.py @@ -30,14 +30,14 @@ import logging from enum import Enum -from PyQt5.QtCore import QPoint, Qt, QUrl, pyqtSignal, pyqtSlot -from PyQt5.QtGui import ( - QCursor, QDesktopServices, QDragEnterEvent, QDragMoveEvent, QDropEvent, - QMouseEvent, QPalette, QResizeEvent, QTextCursor +from PyQt6.QtCore import QPoint, Qt, QUrl, pyqtSignal, pyqtSlot +from PyQt6.QtGui import ( + QAction, QCursor, QDesktopServices, QDragEnterEvent, QDragMoveEvent, + QDropEvent, QMouseEvent, QPalette, QResizeEvent, QTextCursor ) -from PyQt5.QtWidgets import ( - QAction, QApplication, QFrame, QHBoxLayout, QMenu, QTextBrowser, - QToolButton, QWidget +from PyQt6.QtWidgets import ( + QApplication, QFrame, QHBoxLayout, QMenu, QTextBrowser, QToolButton, + QWidget ) from novelwriter import CONFIG, SHARED diff --git a/novelwriter/gui/docviewerpanel.py b/novelwriter/gui/docviewerpanel.py index 7bcb52b5..91723b91 100644 --- a/novelwriter/gui/docviewerpanel.py +++ b/novelwriter/gui/docviewerpanel.py @@ -27,8 +27,8 @@ import logging from enum import Enum -from PyQt5.QtCore import QModelIndex, Qt, pyqtSignal, pyqtSlot -from PyQt5.QtWidgets import ( +from PyQt6.QtCore import QModelIndex, Qt, pyqtSignal, pyqtSlot +from PyQt6.QtWidgets import ( QAbstractItemView, QFrame, QMenu, QTabWidget, QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget ) diff --git a/novelwriter/gui/editordocument.py b/novelwriter/gui/editordocument.py index e46c01b5..79754656 100644 --- a/novelwriter/gui/editordocument.py +++ b/novelwriter/gui/editordocument.py @@ -28,9 +28,9 @@ import logging from collections.abc import Iterable from time import time -from PyQt5.QtCore import QObject, pyqtSlot -from PyQt5.QtGui import QTextBlock, QTextCursor, QTextDocument -from PyQt5.QtWidgets import QApplication, QPlainTextDocumentLayout +from PyQt6.QtCore import QObject, pyqtSlot +from PyQt6.QtGui import QTextBlock, QTextCursor, QTextDocument +from PyQt6.QtWidgets import QApplication, QPlainTextDocumentLayout from novelwriter import SHARED from novelwriter.gui.dochighlight import GuiDocHighlighter, TextBlockData diff --git a/novelwriter/gui/itemdetails.py b/novelwriter/gui/itemdetails.py index d6435bdf..8cc264b7 100644 --- a/novelwriter/gui/itemdetails.py +++ b/novelwriter/gui/itemdetails.py @@ -27,8 +27,8 @@ import logging from enum import Enum -from PyQt5.QtCore import pyqtSlot -from PyQt5.QtWidgets import QGridLayout, QLabel, QWidget +from PyQt6.QtCore import pyqtSlot +from PyQt6.QtWidgets import QGridLayout, QLabel, QWidget from novelwriter import CONFIG, SHARED from novelwriter.common import elide diff --git a/novelwriter/gui/mainmenu.py b/novelwriter/gui/mainmenu.py index 02527c2b..42d7048b 100644 --- a/novelwriter/gui/mainmenu.py +++ b/novelwriter/gui/mainmenu.py @@ -28,8 +28,9 @@ import logging from pathlib import Path from typing import TYPE_CHECKING -from PyQt5.QtCore import Qt, pyqtSignal, pyqtSlot -from PyQt5.QtWidgets import QAction, QMenuBar +from PyQt6.QtCore import Qt, pyqtSignal, pyqtSlot +from PyQt6.QtGui import QAction +from PyQt6.QtWidgets import QMenuBar from novelwriter import CONFIG, SHARED from novelwriter.common import openExternalPath, qtLambda diff --git a/novelwriter/gui/noveltree.py b/novelwriter/gui/noveltree.py index 190bcafd..e2e321c5 100644 --- a/novelwriter/gui/noveltree.py +++ b/novelwriter/gui/noveltree.py @@ -30,11 +30,11 @@ import logging from enum import Enum from time import time -from PyQt5.QtCore import QModelIndex, QPoint, Qt, pyqtSignal, pyqtSlot -from PyQt5.QtGui import QFocusEvent, QFont, QMouseEvent, QPalette, QResizeEvent -from PyQt5.QtWidgets import ( - QAbstractItemView, QActionGroup, QFrame, QHBoxLayout, QInputDialog, QMenu, - QToolTip, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget +from PyQt6.QtCore import QModelIndex, QPoint, Qt, pyqtSignal, pyqtSlot +from PyQt6.QtGui import QActionGroup, QFocusEvent, QFont, QMouseEvent, QPalette, QResizeEvent +from PyQt6.QtWidgets import ( + QAbstractItemView, QFrame, QHBoxLayout, QInputDialog, QMenu, QToolTip, + QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget ) from novelwriter import CONFIG, SHARED diff --git a/novelwriter/gui/outline.py b/novelwriter/gui/outline.py index 9250f06c..a237e5fd 100644 --- a/novelwriter/gui/outline.py +++ b/novelwriter/gui/outline.py @@ -33,10 +33,10 @@ import logging from enum import Enum from time import time -from PyQt5.QtCore import QT_TRANSLATE_NOOP, Qt, pyqtSignal, pyqtSlot -from PyQt5.QtGui import QIcon -from PyQt5.QtWidgets import ( - QAbstractItemView, QAction, QFileDialog, QFrame, QGridLayout, QGroupBox, +from PyQt6.QtCore import QT_TRANSLATE_NOOP, Qt, pyqtSignal, pyqtSlot +from PyQt6.QtGui import QAction, QIcon +from PyQt6.QtWidgets import ( + QAbstractItemView, QFileDialog, QFrame, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QMenu, QScrollArea, QSplitter, QToolBar, QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget ) diff --git a/novelwriter/gui/projtree.py b/novelwriter/gui/projtree.py index b45f8f24..6acaa264 100644 --- a/novelwriter/gui/projtree.py +++ b/novelwriter/gui/projtree.py @@ -32,10 +32,10 @@ import logging from enum import Enum -from PyQt5.QtCore import QModelIndex, QPoint, Qt, pyqtSignal, pyqtSlot -from PyQt5.QtGui import QIcon, QMouseEvent, QPainter, QPalette -from PyQt5.QtWidgets import ( - QAbstractItemView, QAction, QFrame, QHBoxLayout, QLabel, QMenu, QShortcut, +from PyQt6.QtCore import QModelIndex, QPoint, Qt, pyqtSignal, pyqtSlot +from PyQt6.QtGui import QAction, QIcon, QMouseEvent, QPainter, QPalette, QShortcut +from PyQt6.QtWidgets import ( + QAbstractItemView, QFrame, QHBoxLayout, QLabel, QMenu, QStyleOptionViewItem, QTreeView, QVBoxLayout, QWidget ) diff --git a/novelwriter/gui/search.py b/novelwriter/gui/search.py index 10184d29..78f06838 100644 --- a/novelwriter/gui/search.py +++ b/novelwriter/gui/search.py @@ -27,9 +27,9 @@ import logging from time import time -from PyQt5.QtCore import Qt, pyqtSignal, pyqtSlot -from PyQt5.QtGui import QCursor, QKeyEvent -from PyQt5.QtWidgets import ( +from PyQt6.QtCore import Qt, pyqtSignal, pyqtSlot +from PyQt6.QtGui import QCursor, QKeyEvent +from PyQt6.QtWidgets import ( QApplication, QFrame, QHBoxLayout, QLabel, QLineEdit, QToolBar, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget ) diff --git a/novelwriter/gui/sidebar.py b/novelwriter/gui/sidebar.py index 8baaaa48..cf9d26bf 100644 --- a/novelwriter/gui/sidebar.py +++ b/novelwriter/gui/sidebar.py @@ -27,9 +27,9 @@ import logging from typing import TYPE_CHECKING -from PyQt5.QtCore import QEvent, QPoint, QSize, pyqtSignal -from PyQt5.QtGui import QPalette -from PyQt5.QtWidgets import QMenu, QVBoxLayout, QWidget +from PyQt6.QtCore import QEvent, QPoint, QSize, pyqtSignal +from PyQt6.QtGui import QPalette +from PyQt6.QtWidgets import QMenu, QVBoxLayout, QWidget from novelwriter import CONFIG, SHARED from novelwriter.common import qtLambda diff --git a/novelwriter/gui/statusbar.py b/novelwriter/gui/statusbar.py index a2fe5b9f..413b93df 100644 --- a/novelwriter/gui/statusbar.py +++ b/novelwriter/gui/statusbar.py @@ -28,8 +28,8 @@ import logging from datetime import datetime from time import time -from PyQt5.QtCore import QLocale, pyqtSlot -from PyQt5.QtWidgets import QApplication, QLabel, QStatusBar, QWidget +from PyQt6.QtCore import QLocale, pyqtSlot +from PyQt6.QtWidgets import QApplication, QLabel, QStatusBar, QWidget from novelwriter import CONFIG, SHARED from novelwriter.common import formatTime diff --git a/novelwriter/gui/theme.py b/novelwriter/gui/theme.py index 6fd4f198..9093bb8f 100644 --- a/novelwriter/gui/theme.py +++ b/novelwriter/gui/theme.py @@ -29,12 +29,12 @@ import logging from math import ceil from pathlib import Path -from PyQt5.QtCore import QSize, Qt -from PyQt5.QtGui import ( +from PyQt6.QtCore import QSize, Qt +from PyQt6.QtGui import ( QColor, QFont, QFontDatabase, QFontMetrics, QIcon, QPainter, QPainterPath, QPalette, QPixmap ) -from PyQt5.QtWidgets import QApplication +from PyQt6.QtWidgets import QApplication from novelwriter import CONFIG from novelwriter.common import NWConfigParser, cssCol, minmax diff --git a/novelwriter/guimain.py b/novelwriter/guimain.py index f7aef529..12d8a971 100644 --- a/novelwriter/guimain.py +++ b/novelwriter/guimain.py @@ -30,11 +30,11 @@ from datetime import datetime from pathlib import Path from time import time -from PyQt5.QtCore import Qt, QTimer, pyqtSlot -from PyQt5.QtGui import QCloseEvent, QCursor, QIcon -from PyQt5.QtWidgets import ( +from PyQt6.QtCore import Qt, QTimer, pyqtSlot +from PyQt6.QtGui import QCloseEvent, QCursor, QIcon, QShortcut +from PyQt6.QtWidgets import ( QApplication, QFileDialog, QHBoxLayout, QMainWindow, QMessageBox, - QShortcut, QSplitter, QStackedWidget, QVBoxLayout, QWidget + QSplitter, QStackedWidget, QVBoxLayout, QWidget ) from novelwriter import CONFIG, SHARED, __hexversion__, __version__ diff --git a/novelwriter/shared.py b/novelwriter/shared.py index 86ef6eca..2fd5359c 100644 --- a/novelwriter/shared.py +++ b/novelwriter/shared.py @@ -31,9 +31,9 @@ from pathlib import Path from time import time from typing import TYPE_CHECKING, TypeVar -from PyQt5.QtCore import QObject, QRunnable, QThreadPool, QTimer, QUrl, pyqtSignal, pyqtSlot -from PyQt5.QtGui import QDesktopServices, QFont -from PyQt5.QtWidgets import QFileDialog, QFontDialog, QMessageBox, QWidget +from PyQt6.QtCore import QObject, QRunnable, QThreadPool, QTimer, QUrl, pyqtSignal, pyqtSlot +from PyQt6.QtGui import QDesktopServices, QFont +from PyQt6.QtWidgets import QFileDialog, QFontDialog, QMessageBox, QWidget from novelwriter.common import formatFileFilter from novelwriter.constants import nwFiles diff --git a/novelwriter/tools/dictionaries.py b/novelwriter/tools/dictionaries.py index 057637af..ddb371e1 100644 --- a/novelwriter/tools/dictionaries.py +++ b/novelwriter/tools/dictionaries.py @@ -28,9 +28,9 @@ import logging from pathlib import Path from zipfile import ZipFile -from PyQt5.QtCore import pyqtSlot -from PyQt5.QtGui import QCloseEvent, QTextCursor -from PyQt5.QtWidgets import ( +from PyQt6.QtCore import pyqtSlot +from PyQt6.QtGui import QCloseEvent, QTextCursor +from PyQt6.QtWidgets import ( QApplication, QDialogButtonBox, QFileDialog, QFrame, QHBoxLayout, QLabel, QLineEdit, QPlainTextEdit, QPushButton, QVBoxLayout, QWidget ) diff --git a/novelwriter/tools/lipsum.py b/novelwriter/tools/lipsum.py index df02d82d..f9144d49 100644 --- a/novelwriter/tools/lipsum.py +++ b/novelwriter/tools/lipsum.py @@ -26,8 +26,8 @@ from __future__ import annotations import logging import random -from PyQt5.QtCore import pyqtSlot -from PyQt5.QtWidgets import ( +from PyQt6.QtCore import pyqtSlot +from PyQt6.QtWidgets import ( QDialogButtonBox, QGridLayout, QHBoxLayout, QLabel, QSpinBox, QVBoxLayout, QWidget ) diff --git a/novelwriter/tools/manusbuild.py b/novelwriter/tools/manusbuild.py index b636ac3c..40e6eefc 100644 --- a/novelwriter/tools/manusbuild.py +++ b/novelwriter/tools/manusbuild.py @@ -27,9 +27,9 @@ import logging from pathlib import Path -from PyQt5.QtCore import QTimer, pyqtSlot -from PyQt5.QtGui import QCloseEvent -from PyQt5.QtWidgets import ( +from PyQt6.QtCore import QTimer, pyqtSlot +from PyQt6.QtGui import QCloseEvent +from PyQt6.QtWidgets import ( QAbstractButton, QAbstractItemView, QDialogButtonBox, QFileDialog, QGridLayout, QHBoxLayout, QLabel, QLineEdit, QListWidget, QListWidgetItem, QPushButton, QSplitter, QVBoxLayout, QWidget diff --git a/novelwriter/tools/manuscript.py b/novelwriter/tools/manuscript.py index 07501af1..7238ea84 100644 --- a/novelwriter/tools/manuscript.py +++ b/novelwriter/tools/manuscript.py @@ -28,13 +28,13 @@ import logging from time import time from typing import TYPE_CHECKING -from PyQt5.QtCore import Qt, QTimer, QUrl, pyqtSignal, pyqtSlot -from PyQt5.QtGui import ( - QCloseEvent, QColor, QCursor, QDesktopServices, QFont, QPalette, - QResizeEvent, QTextDocument +from PyQt6.QtCore import Qt, QTimer, QUrl, pyqtSignal, pyqtSlot +from PyQt6.QtGui import ( + QCloseEvent, QColor, QCursor, QDesktopServices, QFont, QPageLayout, + QPalette, QResizeEvent, QTextDocument ) -from PyQt5.QtPrintSupport import QPrinter, QPrintPreviewDialog -from PyQt5.QtWidgets import ( +from PyQt6.QtPrintSupport import QPrinter, QPrintPreviewDialog +from PyQt6.QtWidgets import ( QAbstractItemView, QApplication, QFormLayout, QGridLayout, QHBoxLayout, QLabel, QListWidget, QListWidgetItem, QPushButton, QSplitter, QStackedWidget, QTabWidget, QTextBrowser, QTreeWidget, QTreeWidgetItem, @@ -42,7 +42,7 @@ from PyQt5.QtWidgets import ( ) from novelwriter import CONFIG, SHARED -from novelwriter.common import fuzzyTime +from novelwriter.common import fuzzyTime, qtLambda from novelwriter.constants import nwLabels, nwStats, trConst from novelwriter.core.buildsettings import BuildCollection, BuildSettings from novelwriter.core.docbuild import NWBuildDocument @@ -185,7 +185,7 @@ class GuiManuscript(NToolDialog): self.btnBuild.clicked.connect(self._buildManuscript) self.btnClose = QPushButton(self.tr("Close"), self) - self.btnClose.clicked.connect(self.close) + self.btnClose.clicked.connect(qtLambda(self.close)) self.processBox = QGridLayout() self.processBox.addWidget(self.btnPreview, 0, 0) @@ -884,7 +884,7 @@ class _PreviewWidget(QTextBrowser): def printPreview(self, printer: QPrinter) -> None: """Connect the print preview painter to the document viewer.""" QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor)) - printer.setOrientation(QPrinter.Orientation.Portrait) + printer.setPageOrientation(QPageLayout.Orientation.Portrait) self.document().print(printer) QApplication.restoreOverrideCursor() return diff --git a/novelwriter/tools/manussettings.py b/novelwriter/tools/manussettings.py index c0202e2f..6e0738e3 100644 --- a/novelwriter/tools/manussettings.py +++ b/novelwriter/tools/manussettings.py @@ -27,9 +27,9 @@ import logging from typing import TYPE_CHECKING -from PyQt5.QtCore import QEvent, pyqtSignal, pyqtSlot -from PyQt5.QtGui import QFont, QIcon, QSyntaxHighlighter, QTextCharFormat, QTextDocument -from PyQt5.QtWidgets import ( +from PyQt6.QtCore import QEvent, pyqtSignal, pyqtSlot +from PyQt6.QtGui import QFont, QIcon, QSyntaxHighlighter, QTextCharFormat, QTextDocument +from PyQt6.QtWidgets import ( QAbstractButton, QAbstractItemView, QDialogButtonBox, QFrame, QGridLayout, QHBoxLayout, QLabel, QLineEdit, QMenu, QPlainTextEdit, QPushButton, QSplitter, QStackedWidget, QTreeWidget, QTreeWidgetItem, QVBoxLayout, diff --git a/novelwriter/tools/noveldetails.py b/novelwriter/tools/noveldetails.py index 175462ab..a71539e5 100644 --- a/novelwriter/tools/noveldetails.py +++ b/novelwriter/tools/noveldetails.py @@ -26,9 +26,9 @@ from __future__ import annotations import logging import math -from PyQt5.QtCore import pyqtSlot -from PyQt5.QtGui import QCloseEvent -from PyQt5.QtWidgets import ( +from PyQt6.QtCore import pyqtSlot +from PyQt6.QtGui import QCloseEvent +from PyQt6.QtWidgets import ( QAbstractItemView, QDialogButtonBox, QFormLayout, QGridLayout, QHBoxLayout, QLabel, QSpinBox, QStackedWidget, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget diff --git a/novelwriter/tools/welcome.py b/novelwriter/tools/welcome.py index 85482cfe..885a7da7 100644 --- a/novelwriter/tools/welcome.py +++ b/novelwriter/tools/welcome.py @@ -28,20 +28,19 @@ import logging from datetime import datetime from pathlib import Path -from PyQt5.QtCore import ( +from PyQt6.QtCore import ( QAbstractListModel, QEvent, QModelIndex, QObject, QPoint, QSize, Qt, pyqtSignal, pyqtSlot ) -from PyQt5.QtGui import QCloseEvent, QColor, QFont, QPainter, QPaintEvent, QPen -from PyQt5.QtWidgets import ( - QAction, QApplication, QFileDialog, QFormLayout, QHBoxLayout, QLabel, - QLineEdit, QListView, QMenu, QPushButton, QScrollArea, QShortcut, - QStackedWidget, QStyledItemDelegate, QStyleOptionViewItem, QVBoxLayout, - QWidget +from PyQt6.QtGui import QAction, QCloseEvent, QColor, QFont, QPainter, QPaintEvent, QPen, QShortcut +from PyQt6.QtWidgets import ( + QApplication, QFileDialog, QFormLayout, QHBoxLayout, QLabel, QLineEdit, + QListView, QMenu, QPushButton, QScrollArea, QStackedWidget, + QStyledItemDelegate, QStyleOptionViewItem, QVBoxLayout, QWidget ) from novelwriter import CONFIG, SHARED -from novelwriter.common import cssCol, formatInt, makeFileNameSafe +from novelwriter.common import cssCol, formatInt, makeFileNameSafe, qtLambda from novelwriter.constants import nwFiles from novelwriter.core.coretools import ProjectBuilder from novelwriter.enum import nwItemClass @@ -127,7 +126,7 @@ class GuiWelcome(NDialog): self.btnCancel = QPushButton(self.tr("Cancel"), self) self.btnCancel.setIcon(SHARED.theme.getIcon("cancel", "red")) self.btnCancel.setIconSize(btnIconSize) - self.btnCancel.clicked.connect(self.close) + self.btnCancel.clicked.connect(qtLambda(self.close)) self.btnCreate = QPushButton(self.tr("Create"), self) self.btnCreate.setIcon(SHARED.theme.getIcon("star", "yellow")) diff --git a/novelwriter/tools/writingstats.py b/novelwriter/tools/writingstats.py index 69fae080..bc59ab62 100644 --- a/novelwriter/tools/writingstats.py +++ b/novelwriter/tools/writingstats.py @@ -29,12 +29,11 @@ import logging from datetime import datetime from typing import TYPE_CHECKING -from PyQt5.QtCore import Qt, pyqtSlot -from PyQt5.QtGui import QCloseEvent, QCursor, QPixmap -from PyQt5.QtWidgets import ( - QAction, QApplication, QDialogButtonBox, QFileDialog, QGridLayout, - QGroupBox, QHBoxLayout, QLabel, QMenu, QSpinBox, QTreeWidget, - QTreeWidgetItem +from PyQt6.QtCore import Qt, pyqtSlot +from PyQt6.QtGui import QAction, QCloseEvent, QCursor, QPixmap +from PyQt6.QtWidgets import ( + QApplication, QDialogButtonBox, QFileDialog, QGridLayout, QGroupBox, + QHBoxLayout, QLabel, QMenu, QSpinBox, QTreeWidget, QTreeWidgetItem ) from novelwriter import CONFIG, SHARED @@ -124,13 +123,12 @@ class GuiWritingStats(NToolDialog): hHeader.setTextAlignment(self.C_IDLE, QtAlignRight) hHeader.setTextAlignment(self.C_COUNT, QtAlignRight) - sDec = Qt.SortOrder.DescendingOrder - sAsc = Qt.SortOrder.AscendingOrder sortCol = minmax(pOptions.getInt("GuiWritingStats", "sortCol", 0), 0, 2) sortOrder = checkIntTuple( - pOptions.getInt("GuiWritingStats", "sortOrder", sDec), (sAsc, sDec), sDec + pOptions.getInt("GuiWritingStats", "sortOrder", 1), (0, 1), 1 ) - self.listBox.sortByColumn(sortCol, sortOrder) # type: ignore + sortOrders = (Qt.SortOrder.AscendingOrder, Qt.SortOrder.DescendingOrder) + self.listBox.sortByColumn(sortCol, sortOrders[sortOrder]) self.listBox.setSortingEnabled(True) # Word Bar diff --git a/novelwriter/types.py b/novelwriter/types.py index 0732f5a8..23455b97 100644 --- a/novelwriter/types.py +++ b/novelwriter/types.py @@ -23,12 +23,12 @@ along with this program. If not, see . """ from __future__ import annotations -from PyQt5.QtCore import Qt -from PyQt5.QtGui import ( +from PyQt6.QtCore import Qt +from PyQt6.QtGui import ( QColor, QFont, QPainter, QTextBlockFormat, QTextCharFormat, QTextCursor, QTextFormat ) -from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QHeaderView, QSizePolicy, QStyle +from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QHeaderView, QSizePolicy, QStyle # Qt Alignment Flags @@ -56,7 +56,7 @@ QtVAlignSuper = QTextCharFormat.VerticalAlignment.AlignSuperScript QtPageBreakBefore = QTextFormat.PageBreakFlag.PageBreak_AlwaysBefore QtPageBreakAfter = QTextFormat.PageBreakFlag.PageBreak_AlwaysAfter -QtPropLineHeight = QTextBlockFormat.LineHeightTypes.ProportionalHeight +QtPropLineHeight = 1 # QTextBlockFormat.LineHeightTypes.ProportionalHeight # Qt Painter Types