Switch app code to PyQt6
This commit is contained in:
@@ -27,8 +27,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
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
|
||||
)
|
||||
|
||||
@@ -24,9 +24,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
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):
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -25,11 +25,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
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 (
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -23,13 +23,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
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)
|
||||
|
||||
@@ -23,9 +23,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
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 (
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user