Drop the trinary enum
This commit is contained in:
@@ -68,13 +68,6 @@ class nwComment(Enum):
|
|||||||
STORY = 7
|
STORY = 7
|
||||||
|
|
||||||
|
|
||||||
class nwTrinary(Enum):
|
|
||||||
|
|
||||||
NEGATIVE = -1
|
|
||||||
NEUTRAL = 0
|
|
||||||
POSITIVE = 1
|
|
||||||
|
|
||||||
|
|
||||||
class nwChange(Enum):
|
class nwChange(Enum):
|
||||||
|
|
||||||
CREATE = 0
|
CREATE = 0
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ from PyQt5.QtGui import QColor, QPainter, QPaintEvent
|
|||||||
from PyQt5.QtWidgets import QAbstractButton, QWidget
|
from PyQt5.QtWidgets import QAbstractButton, QWidget
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG
|
||||||
from novelwriter.enum import nwTrinary
|
|
||||||
from novelwriter.types import QtBlack, QtPaintAntiAlias
|
from novelwriter.types import QtBlack, QtPaintAntiAlias
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -47,14 +46,14 @@ class StatusLED(QAbstractButton):
|
|||||||
self._postitve = QtBlack
|
self._postitve = QtBlack
|
||||||
self._negative = QtBlack
|
self._negative = QtBlack
|
||||||
self._color = QtBlack
|
self._color = QtBlack
|
||||||
self._state = nwTrinary.NEUTRAL
|
self._state = None
|
||||||
self._bPx = CONFIG.pxInt(1)
|
self._bPx = CONFIG.pxInt(1)
|
||||||
self.setFixedWidth(sW)
|
self.setFixedWidth(sW)
|
||||||
self.setFixedHeight(sH)
|
self.setFixedHeight(sH)
|
||||||
return
|
return
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self) -> nwTrinary:
|
def state(self) -> bool | None:
|
||||||
"""The current state of the LED."""
|
"""The current state of the LED."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
@@ -66,11 +65,11 @@ class StatusLED(QAbstractButton):
|
|||||||
self.setState(self._state)
|
self.setState(self._state)
|
||||||
return
|
return
|
||||||
|
|
||||||
def setState(self, state: nwTrinary) -> None:
|
def setState(self, state: bool | None) -> None:
|
||||||
"""Set the colour state."""
|
"""Set the colour state."""
|
||||||
if state == nwTrinary.POSITIVE:
|
if state is True:
|
||||||
self._color = self._postitve
|
self._color = self._postitve
|
||||||
elif state == nwTrinary.NEGATIVE:
|
elif state is False:
|
||||||
self._color = self._negative
|
self._color = self._negative
|
||||||
else:
|
else:
|
||||||
self._color = self._neutral
|
self._color = self._neutral
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ from PyQt5.QtWidgets import QApplication, QLabel, QStatusBar, QWidget
|
|||||||
from novelwriter import CONFIG, SHARED
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.common import formatTime
|
from novelwriter.common import formatTime
|
||||||
from novelwriter.constants import nwConst
|
from novelwriter.constants import nwConst
|
||||||
from novelwriter.enum import nwTrinary
|
|
||||||
from novelwriter.extensions.modified import NClickableLabel
|
from novelwriter.extensions.modified import NClickableLabel
|
||||||
from novelwriter.extensions.statusled import StatusLED
|
from novelwriter.extensions.statusled import StatusLED
|
||||||
|
|
||||||
@@ -121,8 +120,8 @@ class GuiMainStatus(QStatusBar):
|
|||||||
self.setRefTime(-1.0)
|
self.setRefTime(-1.0)
|
||||||
self.setLanguage(*SHARED.spelling.describeDict())
|
self.setLanguage(*SHARED.spelling.describeDict())
|
||||||
self.setProjectStats(0, 0)
|
self.setProjectStats(0, 0)
|
||||||
self.setProjectStatus(nwTrinary.NEUTRAL)
|
self.setProjectStatus(None)
|
||||||
self.setDocumentStatus(nwTrinary.NEUTRAL)
|
self.setDocumentStatus(None)
|
||||||
self.updateTime()
|
self.updateTime()
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -152,12 +151,12 @@ class GuiMainStatus(QStatusBar):
|
|||||||
self._refTime = refTime
|
self._refTime = refTime
|
||||||
return
|
return
|
||||||
|
|
||||||
def setProjectStatus(self, state: nwTrinary) -> None:
|
def setProjectStatus(self, state: bool | None) -> None:
|
||||||
"""Set the project status colour icon."""
|
"""Set the project status colour icon."""
|
||||||
self.projIcon.setState(state)
|
self.projIcon.setState(state)
|
||||||
return
|
return
|
||||||
|
|
||||||
def setDocumentStatus(self, state: nwTrinary) -> None:
|
def setDocumentStatus(self, state: bool | None) -> None:
|
||||||
"""Set the document status colour icon."""
|
"""Set the document status colour icon."""
|
||||||
self.docIcon.setState(state)
|
self.docIcon.setState(state)
|
||||||
return
|
return
|
||||||
@@ -220,13 +219,13 @@ class GuiMainStatus(QStatusBar):
|
|||||||
@pyqtSlot(bool)
|
@pyqtSlot(bool)
|
||||||
def updateProjectStatus(self, status: bool) -> None:
|
def updateProjectStatus(self, status: bool) -> None:
|
||||||
"""Update the project status."""
|
"""Update the project status."""
|
||||||
self.setProjectStatus(nwTrinary.NEGATIVE if status else nwTrinary.POSITIVE)
|
self.setProjectStatus(not status)
|
||||||
return
|
return
|
||||||
|
|
||||||
@pyqtSlot(bool)
|
@pyqtSlot(bool)
|
||||||
def updateDocumentStatus(self, status: bool) -> None:
|
def updateDocumentStatus(self, status: bool) -> None:
|
||||||
"""Update the document status."""
|
"""Update the document status."""
|
||||||
self.setDocumentStatus(nwTrinary.NEGATIVE if status else nwTrinary.POSITIVE)
|
self.setDocumentStatus(not status)
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import time
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from novelwriter import CONFIG, SHARED
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.enum import nwTrinary
|
|
||||||
|
|
||||||
from tests.tools import C, buildTestProject
|
from tests.tools import C, buildTestProject
|
||||||
|
|
||||||
@@ -47,20 +46,20 @@ def testGuiStatusBar_Main(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
|||||||
assert status._refTime == refTime
|
assert status._refTime == refTime
|
||||||
|
|
||||||
# Project Status
|
# Project Status
|
||||||
status.setProjectStatus(nwTrinary.NEUTRAL)
|
status.setProjectStatus(None)
|
||||||
assert status.projIcon.state == nwTrinary.NEUTRAL
|
assert status.projIcon.state is None
|
||||||
status.setProjectStatus(nwTrinary.NEGATIVE)
|
status.setProjectStatus(False)
|
||||||
assert status.projIcon.state == nwTrinary.NEGATIVE
|
assert status.projIcon.state is False
|
||||||
status.setProjectStatus(nwTrinary.POSITIVE)
|
status.setProjectStatus(True)
|
||||||
assert status.projIcon.state == nwTrinary.POSITIVE
|
assert status.projIcon.state is True
|
||||||
|
|
||||||
# Document Status
|
# Document Status
|
||||||
status.setDocumentStatus(nwTrinary.NEUTRAL)
|
status.setDocumentStatus(None)
|
||||||
assert status.docIcon.state == nwTrinary.NEUTRAL
|
assert status.docIcon.state is None
|
||||||
status.setDocumentStatus(nwTrinary.NEGATIVE)
|
status.setDocumentStatus(False)
|
||||||
assert status.docIcon.state == nwTrinary.NEGATIVE
|
assert status.docIcon.state is False
|
||||||
status.setDocumentStatus(nwTrinary.POSITIVE)
|
status.setDocumentStatus(True)
|
||||||
assert status.docIcon.state == nwTrinary.POSITIVE
|
assert status.docIcon.state is True
|
||||||
|
|
||||||
# Idle Status
|
# Idle Status
|
||||||
CONFIG.stopWhenIdle = False
|
CONFIG.stopWhenIdle = False
|
||||||
|
|||||||
Reference in New Issue
Block a user