Merge branch 'master' into dev_0.6

This commit is contained in:
Veronica K. B. Olsen
2020-05-14 18:57:55 +02:00
106 changed files with 5060 additions and 274 deletions
+26 -7
View File
@@ -58,8 +58,11 @@ class GuiConfigEditor(QDialog):
self.innerBox = QVBoxLayout()
self.setWindowTitle("Preferences")
self.guiDeco = self.theParent.theTheme.loadDecoration("settings",(64,64))
self.guiDeco = self.theParent.theTheme.loadDecoration("settings", (64,64))
self.outerBox.addWidget(self.guiDeco, 0, Qt.AlignTop)
self.outerBox.addLayout(self.innerBox)
self.outerBox.setSpacing(16)
self.setLayout(self.outerBox)
self.tabGeneral = GuiConfigEditGeneralTab(self.theParent)
self.tabLayout = GuiConfigEditLayoutTab(self.theParent)
@@ -73,10 +76,6 @@ class GuiConfigEditor(QDialog):
self.tabWidget.addTab(self.tabEditing, "Editing")
self.tabWidget.addTab(self.tabAutoRep, "Auto-Replace")
self.setLayout(self.outerBox)
self.outerBox.addWidget(self.guiDeco, 0, Qt.AlignTop)
self.outerBox.addLayout(self.innerBox)
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttonBox.accepted.connect(self._doSave)
self.buttonBox.rejected.connect(self._doClose)
@@ -170,6 +169,22 @@ class GuiConfigEditGeneralTab(QWidget):
"Changing this requires restarting %s." % nw.__package__
)
## Select Icon Theme
self.selectIcons = QComboBox()
self.selectIcons.setMinimumWidth(200)
self.theIcons = self.theTheme.theIcons.listThemes()
for iconDir, iconName in self.theIcons:
self.selectIcons.addItem(iconName, iconDir)
iconIdx = self.selectIcons.findData(self.mainConf.guiIcons)
if iconIdx != -1:
self.selectIcons.setCurrentIndex(iconIdx)
self.mainForm.addRow(
"Main icon theme",
self.selectIcons,
"Changing this requires restarting %s." % nw.__package__
)
## Syntax Highlighting
self.selectSyntax = QComboBox()
self.selectSyntax.setMinimumWidth(200)
@@ -182,7 +197,8 @@ class GuiConfigEditGeneralTab(QWidget):
self.mainForm.addRow(
"Syntax highlight theme",
self.selectSyntax
self.selectSyntax,
""
)
## Dark Icons
@@ -239,7 +255,7 @@ class GuiConfigEditGeneralTab(QWidget):
## Backup Path
self.backupPath = self.mainConf.backupPath
self.backupGetPath = QPushButton(self.theTheme.getIcon("folder"),"Select Folder")
self.backupGetPath = QPushButton(self.theTheme.getIcon("folder-open"),"Select Folder")
self.backupGetPath.clicked.connect(self._backupFolder)
self.backupPathRow = self.mainForm.addRow(
"Backup storage location",
@@ -276,6 +292,7 @@ class GuiConfigEditGeneralTab(QWidget):
guiTheme = self.selectTheme.currentData()
guiSyntax = self.selectSyntax.currentData()
guiIcons = self.selectIcons.currentData()
guiDark = self.preferDarkIcons.isChecked()
showFullPath = self.showFullPath.isChecked()
autoSaveDoc = self.autoSaveDoc.value()
@@ -286,9 +303,11 @@ class GuiConfigEditGeneralTab(QWidget):
# Check if restart is needed
needsRestart |= self.mainConf.guiTheme != guiTheme
needsRestart |= self.mainConf.guiIcons != guiIcons
self.mainConf.guiTheme = guiTheme
self.mainConf.guiSyntax = guiSyntax
self.mainConf.guiIcons = guiIcons
self.mainConf.guiDark = guiDark
self.mainConf.showFullPath = showFullPath
self.mainConf.autoSaveDoc = autoSaveDoc
+8 -4
View File
@@ -57,12 +57,16 @@ class GuiItemEditor(QDialog):
self._doClose()
self.setWindowTitle("Item Settings")
self.guiDeco = self.theParent.theTheme.loadDecoration("settings",(64,64))
self.outerBox.setSpacing(16)
self.setLayout(self.outerBox)
self.guiDeco = QLabel()
self.guiDeco.setPixmap(
self.theParent.theTheme.getPixmap(
nwLabels.CLASS_ICON[self.theItem.itemClass], (64,64)
)
)
self.outerBox.addWidget(self.guiDeco, 0, Qt.AlignTop)
self.outerBox.addLayout(self.innerBox)
self.outerBox.setSpacing(16)
self.setLayout(self.outerBox)
self.mainGroup = QGroupBox("Item Settings")
self.mainForm = QGridLayout()
+13 -8
View File
@@ -52,12 +52,18 @@ class GuiProjectEditor(QDialog):
self.theParent = theParent
self.theProject = theProject
self.outerBox = QHBoxLayout()
self.innerBox = QVBoxLayout()
self.outerBox = QHBoxLayout()
self.innerBox = QVBoxLayout()
self.setWindowTitle("Project Settings")
self.guiDeco = self.theParent.theTheme.loadDecoration("settings",(64,64))
self.guiDeco = QLabel()
self.guiDeco.setPixmap(
self.theParent.theTheme.getPixmap("cls_novel", (64,64))
)
self.outerBox.addWidget(self.guiDeco, 0, Qt.AlignTop)
self.outerBox.addLayout(self.innerBox)
self.outerBox.setSpacing(16)
self.setLayout(self.outerBox)
self.theProject.countStatus()
self.tabMain = GuiProjectEditMain(self.theParent, self.theProject)
@@ -71,14 +77,10 @@ class GuiProjectEditor(QDialog):
self.tabWidget.addTab(self.tabImport, "Importance")
self.tabWidget.addTab(self.tabReplace,"Auto-Replace")
self.outerBox.addWidget(self.guiDeco, 0, Qt.AlignTop)
self.outerBox.addLayout(self.innerBox)
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttonBox.accepted.connect(self._doSave)
self.buttonBox.rejected.connect(self._doClose)
self.setLayout(self.outerBox)
self.innerBox.addWidget(self.tabWidget)
self.innerBox.addWidget(self.buttonBox)
@@ -361,9 +363,12 @@ class GuiProjectEditReplace(QWidget):
self.editKey = QLineEdit()
self.editValue = QLineEdit()
self.saveButton = QPushButton(self.theTheme.getIcon("save"),"")
self.saveButton = QPushButton(self.theTheme.getIcon("done"),"")
self.addButton = QPushButton(self.theTheme.getIcon("add"),"")
self.delButton = QPushButton(self.theTheme.getIcon("remove"),"")
self.saveButton.setToolTip("Save entry")
self.addButton.setToolTip("Add new entry")
self.delButton.setToolTip("Delete selected entry")
self.editKey.setEnabled(False)
self.editKey.setMaxLength(40)
+8 -7
View File
@@ -31,7 +31,7 @@ import nw
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QFont, QColor
from PyQt5.QtWidgets import (
QTreeWidget, QTreeWidgetItem, QAbstractItemView, QApplication, QMessageBox
qApp, QTreeWidget, QTreeWidgetItem, QAbstractItemView, QMessageBox
)
from nw.core import NWDoc
@@ -207,7 +207,7 @@ class GuiDocTree(QTreeWidget):
"""Move an item up or down in the tree, but only if the treeView
has focus. This also applies when the menu is used.
"""
if QApplication.focusWidget() == self and self.theParent.hasProject:
if qApp.focusWidget() == self and self.theParent.hasProject:
tHandle = self.getSelectedHandle()
tItem = self._getTreeItem(tHandle)
pItem = tItem.parent()
@@ -524,6 +524,7 @@ class GuiDocTree(QTreeWidget):
tHandle = nwItem.itemHandle
pHandle = nwItem.parHandle
tClass = nwItem.itemClass
newItem = QTreeWidgetItem([""]*4)
newItem.setText(self.C_NAME, "")
@@ -553,13 +554,13 @@ class GuiDocTree(QTreeWidget):
newItem.setExpanded(nwItem.isExpanded)
if nwItem.itemType == nwItemType.ROOT:
newItem.setIcon(self.C_NAME, self.theTheme.getIcon("root"))
newItem.setIcon(self.C_NAME, self.theTheme.getIcon(nwLabels.CLASS_ICON[tClass]))
elif nwItem.itemType == nwItemType.FOLDER:
newItem.setIcon(self.C_NAME, self.theTheme.getIcon("folder"))
newItem.setIcon(self.C_NAME, self.theTheme.getIcon("proj_folder"))
elif nwItem.itemType == nwItemType.FILE:
newItem.setIcon(self.C_NAME, self.theTheme.getIcon("document"))
newItem.setIcon(self.C_NAME, self.theTheme.getIcon("proj_document"))
elif nwItem.itemType == nwItemType.TRASH:
newItem.setIcon(self.C_NAME, self.theTheme.getIcon("trash"))
newItem.setIcon(self.C_NAME, self.theTheme.getIcon(nwLabels.CLASS_ICON[tClass]))
return newItem
@@ -588,7 +589,7 @@ class GuiDocTree(QTreeWidget):
self.addTopLevelItem(newItem)
self.orphRoot = newItem
newItem.setExpanded(True)
newItem.setIcon(self.C_NAME, self.theTheme.getIcon("orphan"))
newItem.setIcon(self.C_NAME, self.theTheme.getIcon("warning"))
return
def _cleanOrphanedRoot(self):
+3 -3
View File
@@ -30,7 +30,7 @@ import nw
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (
QFrame, QGridLayout, QLabel, QLineEdit, QPushButton, QApplication
qApp, QFrame, QGridLayout, QLabel, QLineEdit, QPushButton
)
from nw.constants import nwDocAction
@@ -60,7 +60,7 @@ class GuiSearchBar(QFrame):
self.replaceLabel = QLabel("Replace")
self.closeButton = QPushButton(self.theTheme.getIcon("close"),"")
self.searchButton = QPushButton(self.theTheme.getIcon("search"),"")
self.replaceButton = QPushButton(self.theTheme.getIcon("replace"),"")
self.replaceButton = QPushButton(self.theTheme.getIcon("search-replace"),"")
self.closeButton.clicked.connect(self._doClose)
self.searchButton.clicked.connect(self._doSearch)
@@ -127,7 +127,7 @@ class GuiSearchBar(QFrame):
return
def _doSearch(self):
modKey = QApplication.keyboardModifiers()
modKey = qApp.keyboardModifiers()
if modKey == Qt.ShiftModifier:
self.theParent.docEditor.docAction(nwDocAction.GO_PREV)
else:
+167 -69
View File
@@ -26,13 +26,15 @@
"""
import logging
import configparser
import nw
from os import path
from os import path, listdir
from PyQt5.QtCore import QSize
from PyQt5.QtSvg import QSvgWidget
from PyQt5.QtGui import QIcon, QPixmap
from PyQt5.QtWidgets import QStyle, qApp
logger = logging.getLogger(__name__)
@@ -44,19 +46,34 @@ class GuiIcons:
# https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
# or, if there is no fallback, the variable should be None.
ICON_MAP = {
"root" : "drive-harddisk",
"folder" : "folder",
"document" : "x-office-document",
"trash" : "user-trash",
"orphan" : "dialog-warning",
"save" : "document-save",
"add" : "list-add",
"remove" : "list-remove",
"close" : "edit-delete",
"search" : "edit-find",
"replace" : "edit-find-replace",
"time" : None,
"globe" : None,
"cls_none" : (QStyle.SP_DriveHDIcon, "drive-harddisk"),
"cls_novel" : (QStyle.SP_DriveHDIcon, "drive-harddisk"),
"cls_plot" : (QStyle.SP_DriveHDIcon, "drive-harddisk"),
"cls_character" : (QStyle.SP_DriveHDIcon, "drive-harddisk"),
"cls_world" : (QStyle.SP_DriveHDIcon, "drive-harddisk"),
"cls_timeline" : (QStyle.SP_DriveHDIcon, "drive-harddisk"),
"cls_object" : (QStyle.SP_DriveHDIcon, "drive-harddisk"),
"cls_entity" : (QStyle.SP_DriveHDIcon, "drive-harddisk"),
"cls_custom" : (QStyle.SP_DriveHDIcon, "drive-harddisk"),
"cls_trash" : (QStyle.SP_DriveHDIcon, "drive-harddisk"),
"proj_document" : (QStyle.SP_FileIcon, "x-office-document"),
"proj_folder" : (QStyle.SP_DirIcon, "folder"),
"status_lang" : (None, None),
"status_time" : (None, None),
## Button Icons
"folder-open" : (QStyle.SP_DirOpenIcon, "folder-open"),
"delete" : (QStyle.SP_DialogDiscardButton, "edit-delete"),
"add" : (None, "list-add"),
"remove" : (None, "list-remove"),
"close" : (QStyle.SP_DialogCloseButton, "window-close"),
"done" : (QStyle.SP_DialogApplyButton, None),
"search" : (None, "edit-find"),
"search-replace" : (None, "edit-find-replace"),
"clear" : (QStyle.SP_LineEditClearButton, "clear_left"),
"save" : (QStyle.SP_DialogSaveButton, "document-save"),
"edit" : (None, None),
## Other Icons
"warning" : (QStyle.SP_MessageBoxWarning, "dialog-warning"),
}
DECO_MAP = {
@@ -73,34 +90,89 @@ class GuiIcons:
self.theParent = theParent
# Storage
self.qIcons = {}
self.qIcons = {}
self.themeMap = {}
self.themeList = []
self.fbackName = "fallback"
self.confName = "icons.conf"
# Look for files in
self.priPath = "" # The gui theme's icon folder
self.secPath = "" # The main assets icon folder
self.prefDark = False # Load dark icons, if available
# Icon Theme Path
self.iconPath = None
self.confFile = None
# Icon Theme Meta
self.themeName = ""
self.themeDescription = ""
self.themeAuthor = ""
self.themeCredit = ""
self.themeUrl = ""
self.themeLicense = ""
self.themeLicenseUrl = ""
return
def initIcons(self, priPath):
"""Load all icons listed in the icon map. Can be overridden by
the selected theme.
"""
##
# Actions
##
self.priPath = priPath
self.secPath = self.mainConf.iconPath
self.prefDark = self.mainConf.guiDark
def updateTheme(self):
for iconKey in self.ICON_MAP.keys():
self.qIcons[iconKey] = self._loadIcon(iconKey)
logger.debug("Loading icon theme files")
return
self.themeMap = {}
checkPath = path.join(self.mainConf.iconPath, self.mainConf.guiIcons)
if path.isdir(checkPath):
logger.debug("Loading icon theme '%s'" % self.mainConf.guiIcons)
self.iconPath = checkPath
self.confFile = path.join(checkPath, self.confName)
else:
return False
# Config File
confParser = configparser.ConfigParser()
try:
confParser.read_file(open(self.confFile, mode="r", encoding="utf8"))
except Exception as e:
logger.error("Could not load icon theme settings from: %s" % self.confFile)
return False
## Main
cnfSec = "Main"
if confParser.has_section(cnfSec):
self.themeName = self._parseLine( confParser, cnfSec, "name", "")
self.themeDescription = self._parseLine( confParser, cnfSec, "description", "")
self.themeAuthor = self._parseLine( confParser, cnfSec, "author", "")
self.themeCredit = self._parseLine( confParser, cnfSec, "credit", "")
self.themeUrl = self._parseLine( confParser, cnfSec, "url", "")
self.themeLicense = self._parseLine( confParser, cnfSec, "license", "")
self.themeLicenseUrl = self._parseLine( confParser, cnfSec, "licenseurl", "")
## Palette
cnfSec = "Map"
if confParser.has_section(cnfSec):
for iconName, iconFile in confParser.items(cnfSec):
if iconName not in self.ICON_MAP:
logger.error("Unknown icon name '%s' in config file" % iconName)
else:
iconPath = path.join(self.iconPath, iconFile)
if path.isfile(iconPath):
self.themeMap[iconName] = iconPath
logger.verbose("Icon slot '%s' using file '%s'" % (iconName, iconFile))
else:
logger.error("Icon file '%s' not in theme folder" % iconFile)
logger.info("Loaded icon theme '%s'" % self.mainConf.guiIcons)
return True
##
# Access Functions
##
def loadDecoration(self, decoKey, decoSize=None):
"""Load graphical decoration element based on the decoration
map. This function always returns a QSwgWidget.
"""
if decoKey not in self.DECO_MAP:
logger.error("Decoration with name '%s' does not exist" % decoKey)
return QSvgWidget()
@@ -122,19 +194,53 @@ class GuiIcons:
def getIcon(self, iconKey, iconSize=None):
"""Return an icon from the icon buffer. If it doesn't exist,
return an empty icon.
return, load it, and if it still doesn't exist, return an empty
icon.
"""
if iconKey in self.qIcons:
return self.qIcons[iconKey]
return QIcon()
else:
qIcon = self._loadIcon(iconKey)
self.qIcons[iconKey] = qIcon
return qIcon
def getPixmap(self, iconKey, iconSize):
"""Return an icon from the icon buffer as a QPixmap. If it
doesn't exist, return an empty QPixmap.
"""
if iconKey in self.qIcons:
return self.qIcons[iconKey].pixmap(iconSize[0], iconSize[1], QIcon.Normal)
return QPixmap()
qIcon = self.getIcon(iconKey)
return qIcon.pixmap(iconSize[0], iconSize[1], QIcon.Normal)
def listThemes(self):
"""Scan the icons themes folder and list all themes.
"""
if self.themeList:
return self.themeList
confParser = configparser.ConfigParser()
for themeDir in listdir(self.mainConf.iconPath):
themePath = path.join(self.mainConf.iconPath, themeDir)
if not path.isdir(themePath) or themeDir == self.fbackName:
continue
themeConf = path.join(themePath, self.confName)
logger.verbose("Checking icon theme config for '%s'" % themeDir)
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)
continue
themeName = ""
if confParser.has_section("Main"):
if confParser.has_option("Main", "name"):
themeName = confParser.get("Main", "name")
logger.verbose("Theme name is '%s'" % themeName)
if themeName != "":
self.themeList.append((themeDir, themeName))
self.themeList = sorted(self.themeList, key=lambda x: x[1])
self.themeList.insert(0, ("default", "System Icons"))
return self.themeList
##
# Internal Functions
@@ -148,49 +254,41 @@ class GuiIcons:
"""
if iconKey not in self.ICON_MAP:
logger.error("Icon with name '%s' does not exist" % iconKey)
logger.error("Requested unknown icon name '%s'" % iconKey)
return QIcon()
if self.prefDark:
iconSuffix = "dark"
else:
iconSuffix = "light"
if iconKey in self.themeMap:
logger.verbose("Loading: %s" % path.relpath(self.themeMap[iconKey]))
return QIcon(self.themeMap[iconKey])
iconNames = []
iconNames.append("%s-%s.svg" % (iconKey, iconSuffix))
iconNames.append("%s-%s.png" % (iconKey, iconSuffix))
iconNames.append("%s.svg" % iconKey)
iconNames.append("%s.png" % iconKey)
# Check theme folder
loadFrom = None
for iconName in iconNames:
checkPath = path.join(self.priPath, iconName)
if path.isfile(checkPath):
loadFrom = checkPath
logger.verbose("Loading icon '%s' from theme" % iconName)
break
if loadFrom is not None:
return QIcon(loadFrom)
# Check assets folder
for iconName in iconNames:
checkPath = path.join(self.secPath, iconName)
if path.isfile(checkPath):
loadFrom = checkPath
logger.verbose("Loading icon '%s' from assets" % iconName)
break
if loadFrom is not None:
return QIcon(loadFrom)
# Next, we try to load the Qt style icons
if self.ICON_MAP[iconKey][0] is not None:
logger.verbose("Loading icon '%s' from Qt QStyle.standardIcon" % iconKey)
return qApp.style().standardIcon(self.ICON_MAP[iconKey][0])
# If we're still here, try to set from system theme
if self.ICON_MAP[iconKey] is not None:
if self.ICON_MAP[iconKey][1] is not None:
logger.verbose("Loading icon '%s' from system theme" % iconKey)
return QIcon().fromTheme(self.ICON_MAP[iconKey])
return QIcon().fromTheme(self.ICON_MAP[iconKey][1])
# Give up and return an empty icomn
# Finally. we check if we have a fallback icon
if self.mainConf.guiDark:
fbackIcon = path.join(self.mainConf.iconPath, self.fbackName, "%s-dark.svg" % iconKey)
else:
fbackIcon = path.join(self.mainConf.iconPath, self.fbackName, "%s.svg" % iconKey)
if path.isfile(fbackIcon):
logger.verbose("Loading icon '%s' from fallback theme" % iconKey)
return QIcon(fbackIcon)
# Give up and return an empty icon
logger.warning("Did not load an icon for '%s'" % iconKey)
return QIcon()
def _parseLine(self, confParser, cnfSec, cnfName, cnfDefault):
if confParser.has_section(cnfSec):
if confParser.has_option(cnfSec, cnfName):
return confParser.get(cnfSec, cnfName)
return cnfDefault
# END Class GuiIcons
+5
View File
@@ -148,6 +148,7 @@ class GuiMainMenu(QMenuBar):
credits = "<br/>".join(["%s%s" % (listPrefix, x) for x in nw.__credits__]),
)
theTheme = self.theParent.theTheme
theIcons = self.theParent.theTheme.theIcons
if theTheme.themeCredit != "" or theTheme.syntaxCredit != "":
aboutMsg += "<h4>GUI Theme and Syntax Highlighting</h4>"
aboutMsg += "<p>"
@@ -155,6 +156,10 @@ class GuiMainMenu(QMenuBar):
aboutMsg += "%s\"%s\" by %s<br/>" % (
listPrefix, theTheme.themeName, theTheme.themeCredit
)
if theIcons.themeCredit != "":
aboutMsg += "%s\"%s\" by %s<br/>" % (
listPrefix, theIcons.themeName, theIcons.themeCredit
)
if theTheme.syntaxCredit != "":
aboutMsg += "%s\"%s\" by %s<br/>" % (
listPrefix, theTheme.syntaxName, theTheme.syntaxCredit
+2 -2
View File
@@ -68,7 +68,7 @@ class GuiMainStatus(QStatusBar):
self.timeBox.setFont(self.monoFont)
self.timeIcon = QLabel()
self.timeIcon.setPixmap(self.theParent.theTheme.getPixmap("time",(14,14)))
self.timeIcon.setPixmap(self.theParent.theTheme.getPixmap("status_time",(14,14)))
self.boxCounts = QLabel()
self.boxCounts.setToolTip("Document Character | Word | Paragraph Count")
@@ -85,7 +85,7 @@ class GuiMainStatus(QStatusBar):
self.langBox = QLabel("None")
self.langIcon = QLabel("")
self.langIcon.setPixmap(self.theParent.theTheme.getPixmap("globe",(14,14)))
self.langIcon.setPixmap(self.theParent.theTheme.getPixmap("status_lang",(14,14)))
# Add Them
self.addPermanentWidget(self.langIcon)
+12 -9
View File
@@ -106,6 +106,7 @@ class GuiTheme:
self.cssFile = None
self.updateTheme()
self.theIcons.updateTheme()
self.getIcon = self.theIcons.getIcon
self.getPixmap = self.theIcons.getPixmap
@@ -133,8 +134,6 @@ class GuiTheme:
self.confFile = path.join(self.themePath,self.confName)
self.cssFile = path.join(self.themePath,self.cssName)
self.theIcons.initIcons(path.join(self.themePath,self.iconPath))
self.loadTheme()
self.loadSyntax()
@@ -261,8 +260,9 @@ class GuiTheme:
return True
def listThemes(self):
if len(self.themeList) > 0:
"""Scan the gui themes folder and list all themes.
"""
if self.themeList:
return self.themeList
confParser = configparser.ConfigParser()
@@ -276,8 +276,9 @@ class GuiTheme:
continue
themeName = ""
if confParser.has_section("Main"):
themeName = confParser.get("Main","name")
logger.verbose("Theme name is '%s'" % themeName)
if confParser.has_option("Main", "name"):
themeName = confParser.get("Main", "name")
logger.verbose("Theme name is '%s'" % themeName)
if themeName != "":
self.themeList.append((themeDir, themeName))
@@ -286,8 +287,9 @@ class GuiTheme:
return self.themeList
def listSyntax(self):
if len(self.syntaxList) > 0:
"""Scan the syntax themes folder and list all themes.
"""
if self.syntaxList:
return self.syntaxList
confParser = configparser.ConfigParser()
@@ -304,7 +306,8 @@ class GuiTheme:
return []
syntaxName = ""
if confParser.has_section("Main"):
syntaxName = confParser.get("Main","name")
if confParser.has_option("Main", "name"):
syntaxName = confParser.get("Main", "name")
if len(syntaxFile) > 5 and syntaxName != "":
self.syntaxList.append((syntaxFile[:-5], syntaxName))
logger.verbose("Syntax name is '%s'" % syntaxName)