From aef6b339e10375ccd3d83cbb9b4cedf50b39320a Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Fri, 8 Nov 2019 13:38:08 +0100
Subject: [PATCH 1/4] Minor changes to statusbar layout
---
nw/gui/statusbar.py | 25 +++++++++++++++----------
nw/theme.py | 11 ++++++++---
2 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/nw/gui/statusbar.py b/nw/gui/statusbar.py
index ef082e2f..b7cc621a 100644
--- a/nw/gui/statusbar.py
+++ b/nw/gui/statusbar.py
@@ -16,7 +16,7 @@ import nw
from time import time
from PyQt5.QtCore import Qt, QTimer
-from PyQt5.QtGui import QIcon, QColor, QPixmap
+from PyQt5.QtGui import QIcon, QColor, QPixmap, QFont
from PyQt5.QtWidgets import QStatusBar, QLabel, QFrame
logger = logging.getLogger(__name__)
@@ -28,14 +28,16 @@ class GuiMainStatus(QStatusBar):
logger.debug("Initialising MainStatus ...")
- self.mainConf = nw.CONFIG
- self.theParent = theParent
- self.refTime = None
+ self.mainConf = nw.CONFIG
+ self.theParent = theParent
+ self.refTime = None
self.iconGrey = QPixmap(16,16)
self.iconYellow = QPixmap(16,16)
self.iconGreen = QPixmap(16,16)
+ self.monoFont = QFont("Monospace",10)
+
self.iconGrey.fill(QColor(*self.theParent.theTheme.statNone))
self.iconYellow.fill(QColor(*self.theParent.theTheme.statUnsaved))
self.iconGreen.fill(QColor(*self.theParent.theTheme.statSaved))
@@ -45,28 +47,31 @@ class GuiMainStatus(QStatusBar):
self.boxTime = QLabel("")
self.boxTime.setToolTip("Session Time")
- self.boxTime.setAlignment(Qt.AlignRight)
- self.boxTime.setMinimumWidth(80)
+ self.boxTime.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
+ self.boxTime.setFont(self.monoFont)
self.boxCounts = QLabel()
self.boxCounts.setToolTip("Document Character | Word | Paragraph Count")
self.projChanged = QLabel("")
- self.projChanged.setFixedHeight(16)
- self.projChanged.setFixedWidth(16)
+ self.projChanged.setFixedHeight(14)
+ self.projChanged.setFixedWidth(14)
self.projChanged.setToolTip("Project Changes Saved")
self.docChanged = QLabel("")
- self.docChanged.setFixedHeight(16)
- self.docChanged.setFixedWidth(16)
+ self.docChanged.setFixedHeight(14)
+ self.docChanged.setFixedWidth(14)
self.docChanged.setToolTip("Document Changes Saved")
+ self.docLanguage = QLabel("")
+
# Add Them
self.addPermanentWidget(self.docChanged)
self.addPermanentWidget(self.boxCounts)
self.addPermanentWidget(QLabel(" "))
self.addPermanentWidget(self.projChanged)
self.addPermanentWidget(self.boxStats)
+ self.addPermanentWidget(QLabel(" "))
self.addPermanentWidget(self.boxTime)
self.setSizeGripEnabled(True)
diff --git a/nw/theme.py b/nw/theme.py
index 157b26a3..5c05c0dd 100644
--- a/nw/theme.py
+++ b/nw/theme.py
@@ -17,7 +17,7 @@ import nw
from os import path, listdir
from PyQt5.QtWidgets import qApp
-from PyQt5.QtGui import QPalette, QColor, QIcon
+from PyQt5.QtGui import QPalette, QColor, QIcon, QPixmap
from nw.constants import nwAlert
@@ -253,7 +253,7 @@ class Theme:
try:
confParser.read_file(open(themeConf, mode="r", encoding="utf8"))
except Exception as e:
- self.theParent.makeAlert(["Could not load theme config file",str(e)],nwAlert.ERROR)
+ self.theParent.makeAlert(["Could not load theme config file.",str(e)],nwAlert.ERROR)
continue
themeName = ""
if confParser.has_section("Main"):
@@ -281,7 +281,7 @@ class Theme:
try:
confParser.read_file(open(syntaxPath, mode="r", encoding="utf8"))
except Exception as e:
- self.theParent.makeAlert(["Could not load syntax file",str(e)],nwAlert.ERROR)
+ self.theParent.makeAlert(["Could not load syntax file.",str(e)],nwAlert.ERROR)
return []
syntaxName = ""
if confParser.has_section("Main"):
@@ -299,6 +299,11 @@ class Theme:
return self.themeIcons[iconName]
return QIcon()
+ def getIconPixmap(self, iconName, iconSize=None):
+ if iconName in self.themeIcons:
+ return self.themeIcons[iconName].pixmap()
+ return QPixmap()
+
##
# Internal Functions
##
From 79aa33da94b540fef19c5fee0957c8a39bb99b85 Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Fri, 8 Nov 2019 19:55:29 +0100
Subject: [PATCH 2/4] Added more GUi icons
---
nw/assets/icons/globe-dark.svg | 56 +++++++++++++++++
nw/assets/icons/globe.svg | 56 +++++++++++++++++
nw/assets/icons/time-dark.svg | 61 +++++++++++++++++++
nw/assets/icons/time.svg | 61 +++++++++++++++++++
nw/assets/themes/gui/default_dark/README.md | 8 +++
.../themes/gui/default_dark/icons/globe.svg | 56 +++++++++++++++++
.../themes/gui/default_dark/icons/time.svg | 61 +++++++++++++++++++
7 files changed, 359 insertions(+)
create mode 100644 nw/assets/icons/globe-dark.svg
create mode 100644 nw/assets/icons/globe.svg
create mode 100644 nw/assets/icons/time-dark.svg
create mode 100644 nw/assets/icons/time.svg
create mode 100644 nw/assets/themes/gui/default_dark/README.md
create mode 100644 nw/assets/themes/gui/default_dark/icons/globe.svg
create mode 100644 nw/assets/themes/gui/default_dark/icons/time.svg
diff --git a/nw/assets/icons/globe-dark.svg b/nw/assets/icons/globe-dark.svg
new file mode 100644
index 00000000..bde909f3
--- /dev/null
+++ b/nw/assets/icons/globe-dark.svg
@@ -0,0 +1,56 @@
+
+
diff --git a/nw/assets/icons/globe.svg b/nw/assets/icons/globe.svg
new file mode 100644
index 00000000..ef97e998
--- /dev/null
+++ b/nw/assets/icons/globe.svg
@@ -0,0 +1,56 @@
+
+
diff --git a/nw/assets/icons/time-dark.svg b/nw/assets/icons/time-dark.svg
new file mode 100644
index 00000000..bdb740c1
--- /dev/null
+++ b/nw/assets/icons/time-dark.svg
@@ -0,0 +1,61 @@
+
+
diff --git a/nw/assets/icons/time.svg b/nw/assets/icons/time.svg
new file mode 100644
index 00000000..920d9bd7
--- /dev/null
+++ b/nw/assets/icons/time.svg
@@ -0,0 +1,61 @@
+
+
diff --git a/nw/assets/themes/gui/default_dark/README.md b/nw/assets/themes/gui/default_dark/README.md
new file mode 100644
index 00000000..36d11bcf
--- /dev/null
+++ b/nw/assets/themes/gui/default_dark/README.md
@@ -0,0 +1,8 @@
+# Default Dark Theme
+
+## Icons
+
+The following icons are from the typicons.font package on [GitHub](https://github.com/stephenhutchings/typicons.font):
+
+* globe.svg
+* time.svg
diff --git a/nw/assets/themes/gui/default_dark/icons/globe.svg b/nw/assets/themes/gui/default_dark/icons/globe.svg
new file mode 100644
index 00000000..d56050b5
--- /dev/null
+++ b/nw/assets/themes/gui/default_dark/icons/globe.svg
@@ -0,0 +1,56 @@
+
+
diff --git a/nw/assets/themes/gui/default_dark/icons/time.svg b/nw/assets/themes/gui/default_dark/icons/time.svg
new file mode 100644
index 00000000..bdb740c1
--- /dev/null
+++ b/nw/assets/themes/gui/default_dark/icons/time.svg
@@ -0,0 +1,61 @@
+
+
From 7fcd0731bfc01b328bc3b8331a42e2349b5d5117 Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Fri, 8 Nov 2019 19:56:08 +0100
Subject: [PATCH 3/4] Added a function to create a readable spell language
string for the status bar
---
nw/tools/spellcheck.py | 13 +++++++++++++
nw/tools/spellenchant.py | 11 +----------
nw/tools/spellsimple.py | 14 ++------------
3 files changed, 16 insertions(+), 22 deletions(-)
diff --git a/nw/tools/spellcheck.py b/nw/tools/spellcheck.py
index 94227b29..fd5142c8 100644
--- a/nw/tools/spellcheck.py
+++ b/nw/tools/spellcheck.py
@@ -13,6 +13,8 @@
import logging
import nw
+from nw.constants import isoLanguage
+
logger = logging.getLogger(__name__)
class NWSpellCheck():
@@ -54,6 +56,17 @@ class NWSpellCheck():
def listDictionaries(self):
return []
+ @staticmethod
+ def expandLanguage(spTag):
+ spBits = spTag.split("_")
+ if spBits[0] in isoLanguage.ISO_639_1:
+ spLang = isoLanguage.ISO_639_1[spBits[0]]
+ else:
+ spLang = spBits[0]
+ if len(spBits) > 1:
+ spLang += " (%s)" % spBits[1]
+ return spLang
+
##
# Internal Functions
##
diff --git a/nw/tools/spellenchant.py b/nw/tools/spellenchant.py
index e4116580..1bff2329 100644
--- a/nw/tools/spellenchant.py
+++ b/nw/tools/spellenchant.py
@@ -15,7 +15,6 @@ import enchant
import nw
from nw.tools.spellcheck import NWSpellCheck
-from nw.constants import isoLanguage
logger = logging.getLogger(__name__)
@@ -58,15 +57,7 @@ class NWSpellEnchant(NWSpellCheck):
def listDictionaries(self):
retList = []
for spTag, spProvider in enchant.list_dicts():
- spList = []
- if spTag[:2] in isoLanguage.ISO_639_1:
- spList.append(isoLanguage.ISO_639_1[spTag[:2]])
- else:
- spList.append(spTag[:2])
- if len(spTag) > 3:
- spList.append("(%s)" % spTag[3:])
- spList.append("[%s]" % spProvider.name)
- spName = " ".join(spList)
+ spName = "%s [%s]" % (self.expandLanguage(spTag), spProvider.name)
retList.append((spTag, spName))
return retList
diff --git a/nw/tools/spellsimple.py b/nw/tools/spellsimple.py
index db7c38af..d98947e5 100644
--- a/nw/tools/spellsimple.py
+++ b/nw/tools/spellsimple.py
@@ -19,7 +19,6 @@ from difflib import get_close_matches
logger = logging.getLogger(__name__)
from nw.tools.spellcheck import NWSpellCheck
-from nw.constants import isoLanguage
class NWSpellSimple(NWSpellCheck):
@@ -105,17 +104,8 @@ class NWSpellSimple(NWSpellCheck):
if theBits[1] != ".dict":
continue
- spTag = theBits[0]
- spList = []
- if spTag[:2] in isoLanguage.ISO_639_1:
- spList.append(isoLanguage.ISO_639_1[spTag[:2]])
- else:
- spList.append(spTag[:2])
- if len(spTag) > 3:
- spList.append("(%s)" % spTag[3:])
- spList.append("[internal]")
- spName = " ".join(spList)
- retList.append((spTag, spName))
+ spName = "%s [nternal]" % self.expandLanguage(theBits[0])
+ retList.append((theBits[0], spName))
return retList
From f01c2f9dee20ee0bc59273a26a225e09f4c0e511 Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Fri, 8 Nov 2019 19:56:38 +0100
Subject: [PATCH 4/4] Updated icon and font for session timer, and added
language info for status bar
---
nw/gui/elements/doceditor.py | 1 +
nw/gui/icons.py | 8 +++++++-
nw/gui/statusbar.py | 29 ++++++++++++++++++++++-------
nw/gui/theme.py | 1 +
4 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/nw/gui/elements/doceditor.py b/nw/gui/elements/doceditor.py
index 30db23d0..db15998c 100644
--- a/nw/gui/elements/doceditor.py
+++ b/nw/gui/elements/doceditor.py
@@ -280,6 +280,7 @@ class GuiDocEditor(QTextEdit):
def setDictionaries(self):
self.theDict.setLanguage(self.mainConf.spellLanguage, self.theProject.projDict)
+ self.theParent.statusBar.setLanguage(self.mainConf.spellLanguage)
return True
def setSpellCheck(self, theMode):
diff --git a/nw/gui/icons.py b/nw/gui/icons.py
index c44f84e5..34b9f529 100644
--- a/nw/gui/icons.py
+++ b/nw/gui/icons.py
@@ -17,7 +17,7 @@ from os import path
from PyQt5.QtCore import QSize
from PyQt5.QtSvg import QSvgWidget
-from PyQt5.QtGui import QIcon
+from PyQt5.QtGui import QIcon, QPixmap
logger = logging.getLogger(__name__)
@@ -41,6 +41,7 @@ class GuiIcons:
"search" : "edit-find",
"replace" : "edit-find-replace",
"time" : None,
+ "globe" : None,
}
DECO_MAP = {
@@ -96,6 +97,11 @@ class GuiIcons:
return self.qIcons[iconKey]
return QIcon()
+ def getPixmap(self, iconKey, iconSize):
+ if iconKey in self.qIcons:
+ return self.qIcons[iconKey].pixmap(iconSize[0], iconSize[1], QIcon.Normal)
+ return QPixmap()
+
##
# Internal Functions
##
diff --git a/nw/gui/statusbar.py b/nw/gui/statusbar.py
index b7cc621a..002fe39b 100644
--- a/nw/gui/statusbar.py
+++ b/nw/gui/statusbar.py
@@ -19,6 +19,8 @@ from PyQt5.QtCore import Qt, QTimer
from PyQt5.QtGui import QIcon, QColor, QPixmap, QFont
from PyQt5.QtWidgets import QStatusBar, QLabel, QFrame
+from nw.tools import NWSpellCheck
+
logger = logging.getLogger(__name__)
class GuiMainStatus(QStatusBar):
@@ -45,10 +47,13 @@ class GuiMainStatus(QStatusBar):
self.boxStats = QLabel()
self.boxStats.setToolTip("Project Word Count | Session Word Count")
- self.boxTime = QLabel("")
- self.boxTime.setToolTip("Session Time")
- self.boxTime.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
- self.boxTime.setFont(self.monoFont)
+ self.timeBox = QLabel("")
+ self.timeBox.setToolTip("Session Time")
+ self.timeBox.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
+ self.timeBox.setFont(self.monoFont)
+
+ self.timeIcon = QLabel()
+ self.timeIcon.setPixmap(self.theParent.theTheme.getPixmap("time",(14,14)))
self.boxCounts = QLabel()
self.boxCounts.setToolTip("Document Character | Word | Paragraph Count")
@@ -63,16 +68,22 @@ class GuiMainStatus(QStatusBar):
self.docChanged.setFixedWidth(14)
self.docChanged.setToolTip("Document Changes Saved")
- self.docLanguage = QLabel("")
+ self.langBox = QLabel("None")
+ self.langIcon = QLabel("")
+ self.langIcon.setPixmap(self.theParent.theTheme.getPixmap("globe",(14,14)))
# Add Them
+ self.addPermanentWidget(self.langIcon)
+ self.addPermanentWidget(self.langBox)
+ self.addPermanentWidget(QLabel(" "))
self.addPermanentWidget(self.docChanged)
self.addPermanentWidget(self.boxCounts)
self.addPermanentWidget(QLabel(" "))
self.addPermanentWidget(self.projChanged)
self.addPermanentWidget(self.boxStats)
self.addPermanentWidget(QLabel(" "))
- self.addPermanentWidget(self.boxTime)
+ self.addPermanentWidget(self.timeIcon)
+ self.addPermanentWidget(self.timeBox)
self.setSizeGripEnabled(True)
@@ -104,6 +115,10 @@ class GuiMainStatus(QStatusBar):
self.showMessage(theMessage, int(timeOut*1000))
return
+ def setLanguage(self, theLanguage):
+ self.langBox.setText(NWSpellCheck.expandLanguage(theLanguage))
+ return
+
def setProjectStatus(self, isChanged):
if isChanged is None:
self.projChanged.setPixmap(self.iconGrey)
@@ -149,7 +164,7 @@ class GuiMainStatus(QStatusBar):
tM = tM - tH*60
tS = tS - tM*60 - tH*3600
theTime = "%02d:%02d:%02d" % (tH,tM,tS)
- self.boxTime.setText(theTime)
+ self.timeBox.setText(theTime)
return
# END Class GuiMainStatus
diff --git a/nw/gui/theme.py b/nw/gui/theme.py
index bf6a0121..ecfb6d04 100644
--- a/nw/gui/theme.py
+++ b/nw/gui/theme.py
@@ -91,6 +91,7 @@ class GuiTheme:
self.updateTheme()
self.getIcon = self.theIcons.getIcon
+ self.getPixmap = self.theIcons.getPixmap
self.loadDecoration = self.theIcons.loadDecoration
return