From 27696d65e4d23041ed84820da0e4298e2a9c6fdf Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Sat, 12 Dec 2020 19:22:38 +0100
Subject: [PATCH] Remove some unnecessary branches and unused functions
---
nw/gui/dochighlight.py | 3 +--
nw/gui/preferences.py | 8 --------
nw/gui/projload.py | 6 +++---
nw/gui/statusbar.py | 12 ++++++------
.../reference/guiEditor_Main_Final_0e17daca5f3e1.nwd | 2 +-
tests/reference/guiEditor_Main_Final_nwProject.nwx | 10 +++++-----
tests/test_gui_doceditor.py | 2 +-
tests/test_gui_preferences.py | 1 +
8 files changed, 18 insertions(+), 26 deletions(-)
diff --git a/nw/gui/dochighlight.py b/nw/gui/dochighlight.py
index 309b74a8..51a00f02 100644
--- a/nw/gui/dochighlight.py
+++ b/nw/gui/dochighlight.py
@@ -102,10 +102,9 @@ class GuiDocHighlighter(QSyntaxHighlighter):
self.colTrail = QColor(*self.theTheme.colEmph)
self.colTrail.setAlpha(64)
+ self.colEmph = None
if self.mainConf.highlightEmph:
self.colEmph = QColor(*self.theTheme.colEmph)
- else:
- self.colEmph = None
self.hStyles = {
"header1" : self._makeFormat(self.colHead, "bold", 1.8),
diff --git a/nw/gui/preferences.py b/nw/gui/preferences.py
index 389c9f6f..4ae78a98 100644
--- a/nw/gui/preferences.py
+++ b/nw/gui/preferences.py
@@ -806,14 +806,6 @@ class GuiConfigEditEditingTab(QWidget):
# Internal Functions
##
- def _disableComboItem(self, theList, theValue):
- """Disable a list item in the combo box.
- """
- theModel = theList.model()
- anItem = theModel.item(1)
- anItem.setFlags(anItem.flags() ^ Qt.ItemIsEnabled)
- return theModel
-
def _doUpdateSpellTool(self, currIdx):
"""Update the list of dictionaries based on spell tool selected.
"""
diff --git a/nw/gui/projload.py b/nw/gui/projload.py
index 35621032..15fe2825 100644
--- a/nw/gui/projload.py
+++ b/nw/gui/projload.py
@@ -155,14 +155,14 @@ class GuiProjectLoad(QDialog):
logger.verbose("GuiProjectLoad open button clicked")
self._saveSettings()
+ self.openPath = None
+ self.openState = self.NONE_STATE
+
selItems = self.listBox.selectedItems()
if selItems:
self.openPath = selItems[0].data(self.C_NAME, Qt.UserRole)
self.openState = self.OPEN_STATE
self.accept()
- else:
- self.openPath = None
- self.openState = self.NONE_STATE
return
diff --git a/nw/gui/statusbar.py b/nw/gui/statusbar.py
index ace755ae..c430da8c 100644
--- a/nw/gui/statusbar.py
+++ b/nw/gui/statusbar.py
@@ -130,6 +130,7 @@ class GuiMainStatus(QStatusBar):
"""Reset all widgets on the status bar to default values.
"""
self.setRefTime(None)
+ self.setLanguage(None)
self.setStats(0, 0)
self.setProjectStatus(None)
self.setDocumentStatus(None)
@@ -234,15 +235,14 @@ class StatusLED(QAbstractButton):
def setState(self, theState):
"""Set the colour state.
"""
- if theState is None:
- self._theCol = self.colNone
- elif theState:
+ self._theCol = self.colNone
+ if theState is True:
self._theCol = self.colTrue
- elif not theState:
+ elif theState is False:
self._theCol = self.colFalse
- else:
- self._theCol = self.colNone
+
self.update()
+
return
##
diff --git a/tests/reference/guiEditor_Main_Final_0e17daca5f3e1.nwd b/tests/reference/guiEditor_Main_Final_0e17daca5f3e1.nwd
index bf24dbe6..54fef623 100644
--- a/tests/reference/guiEditor_Main_Final_0e17daca5f3e1.nwd
+++ b/tests/reference/guiEditor_Main_Final_0e17daca5f3e1.nwd
@@ -21,7 +21,7 @@
This is a paragraph of dummy text.
-This is another paragraph of much longer dummy text. It is in fact very very dumb dummy text! We can also try replacing “quotes”, even single ‘quotes’ are replaced. Isn’t that nice? We can hyphen-ate, make dashes – and even longer dashes — if we want. Ellipsis? Not a problem either … How about three hyphens — for long dash? It works too.
+This is another paragraph of much longer dummy text. It is in fact 1 very very DUMB dummy text! We can also try replacing “quotes”, even single ‘quotes’ are replaced. Isn’t that nice? We can hyphen-ate, make dashes – and even longer dashes — if we want. Ellipsis? Not a problem either … How about three hyphens — for long dash? It works too.
“Full line double quoted text.”
diff --git a/tests/reference/guiEditor_Main_Final_nwProject.nwx b/tests/reference/guiEditor_Main_Final_nwProject.nwx
index 1174c04c..21011e03 100644
--- a/tests/reference/guiEditor_Main_Final_nwProject.nwx
+++ b/tests/reference/guiEditor_Main_Final_nwProject.nwx
@@ -14,8 +14,8 @@
True
0e17daca5f3e1
None
- 113
- 86
+ 114
+ 87
27
@@ -84,10 +84,10 @@
New
True
SCENE
- 464
- 82
+ 466
+ 83
4
- 602
+ 604
-
Plot
diff --git a/tests/test_gui_doceditor.py b/tests/test_gui_doceditor.py
index 5b09ca95..9ef62951 100644
--- a/tests/test_gui_doceditor.py
+++ b/tests/test_gui_doceditor.py
@@ -230,7 +230,7 @@ def testGuiEditor_Main(qtbot, monkeypatch, nwGUI, fncDir, fncProj, refDir, outDi
for c in (
"This is another paragraph of much longer dummy text. "
- "It is in fact very very dumb dummy text! "
+ "It is in fact 1 very very DUMB dummy text! "
):
qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
for c in "We can also try replacing \"quotes\", even single 'quotes' are replaced. ":
diff --git a/tests/test_gui_preferences.py b/tests/test_gui_preferences.py
index c1f4f0b2..4c8b17ea 100644
--- a/tests/test_gui_preferences.py
+++ b/tests/test_gui_preferences.py
@@ -209,6 +209,7 @@ def testGuiPreferences_Main(qtbot, monkeypatch, fncDir, outDir, refDir):
# Save and Check Config
qtbot.mouseClick(nwPrefs.buttonBox.button(QDialogButtonBox.Ok), Qt.LeftButton)
+ nwPrefs._doClose()
assert theConf.confChanged
theConf.lastPath = ""