Update linting for main code
This commit is contained in:
@@ -20,7 +20,7 @@ General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
""" # noqa
|
||||
from __future__ import annotations
|
||||
|
||||
from PyQt6.QtCore import QPropertyAnimation, Qt, pyqtProperty, pyqtSlot # pyright: ignore
|
||||
@@ -32,6 +32,7 @@ from novelwriter.types import QtNoPen, QtPaintAntiAlias, QtSizeFixed
|
||||
|
||||
|
||||
class NSwitch(QAbstractButton):
|
||||
"""Custom: Toggle Switch."""
|
||||
|
||||
__slots__ = ("_cOff", "_cOn", "_offset", "_rH", "_rR", "_xH", "_xR", "_xW")
|
||||
|
||||
@@ -55,8 +56,6 @@ class NSwitch(QAbstractButton):
|
||||
|
||||
self.clicked.connect(self._onClick)
|
||||
|
||||
return
|
||||
|
||||
##
|
||||
# Properties
|
||||
##
|
||||
@@ -69,7 +68,6 @@ class NSwitch(QAbstractButton):
|
||||
def offset(self, offset: int) -> None:
|
||||
self._offset = offset
|
||||
self.update()
|
||||
return
|
||||
|
||||
##
|
||||
# Getters and Setters
|
||||
@@ -79,7 +77,6 @@ class NSwitch(QAbstractButton):
|
||||
"""Overload setChecked to also alter the offset."""
|
||||
super().setChecked(checked)
|
||||
self._offset = (self._xW - self._xR) if checked else self._xR
|
||||
return
|
||||
|
||||
##
|
||||
# Events
|
||||
@@ -89,7 +86,6 @@ class NSwitch(QAbstractButton):
|
||||
"""Overload resize to ensure correct offset."""
|
||||
super().resizeEvent(event)
|
||||
self._offset = (self._xW - self._xR) if self.isChecked() else self._xR
|
||||
return
|
||||
|
||||
def paintEvent(self, event: QPaintEvent) -> None:
|
||||
"""Drawing the switch itself."""
|
||||
@@ -109,13 +105,10 @@ class NSwitch(QAbstractButton):
|
||||
|
||||
painter.end()
|
||||
|
||||
return
|
||||
|
||||
def enterEvent(self, event: QEnterEvent) -> None:
|
||||
"""Change the cursor when hovering the button."""
|
||||
self.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
super().enterEvent(event)
|
||||
return
|
||||
|
||||
@pyqtSlot(bool)
|
||||
def _onClick(self, checked: bool) -> None:
|
||||
@@ -125,4 +118,3 @@ class NSwitch(QAbstractButton):
|
||||
anim.setStartValue(self._offset)
|
||||
anim.setEndValue((self._xW - self._xR) if checked else self._xR)
|
||||
anim.start()
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user