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 @@ + + + + + + image/svg+xml + + + + + + + + + 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 @@ + + + + + + image/svg+xml + + + + + + + + + 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 @@ + + + + + + image/svg+xml + + + + + + + + + + + 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 @@ + + + + + + image/svg+xml + + + + + + + + + + + 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 @@ + + + + + + image/svg+xml + + + + + + + + + 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 @@ + + + + + + image/svg+xml + + + + + + + + + + + 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 ef082e2f..002fe39b 100644 --- a/nw/gui/statusbar.py +++ b/nw/gui/statusbar.py @@ -16,9 +16,11 @@ 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 +from nw.tools import NWSpellCheck + logger = logging.getLogger(__name__) class GuiMainStatus(QStatusBar): @@ -28,14 +30,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)) @@ -43,31 +47,43 @@ 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.AlignRight) - self.boxTime.setMinimumWidth(80) + 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") 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.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(self.boxTime) + self.addPermanentWidget(QLabel(" ")) + self.addPermanentWidget(self.timeIcon) + self.addPermanentWidget(self.timeBox) self.setSizeGripEnabled(True) @@ -99,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) @@ -144,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 681fc6ff..ecfb6d04 100644 --- a/nw/gui/theme.py +++ b/nw/gui/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 from nw.gui.icons import GuiIcons @@ -91,6 +91,7 @@ class GuiTheme: self.updateTheme() self.getIcon = self.theIcons.getIcon + self.getPixmap = self.theIcons.getPixmap self.loadDecoration = self.theIcons.loadDecoration return @@ -233,7 +234,7 @@ class GuiTheme: 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"): @@ -261,7 +262,7 @@ class GuiTheme: 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"): 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