Merge pull request #135 from vkbo/assets_themes

Assets and Themes
This commit is contained in:
Veronica K. Berglyd Olsen
2019-11-08 19:07:51 +01:00
committed by GitHub
41 changed files with 205 additions and 83 deletions
-2
View File
@@ -1,4 +1,2 @@
include LICENSE.md include LICENSE.md
recursive-include nw/assets * recursive-include nw/assets *
recursive-include nw/graphics *
recursive-include nw/themes *
+1 -1
View File
@@ -65,7 +65,7 @@ instOpt = [
"--onefile", "--onefile",
"--add-data=%s%s%s" % (os.path.join("nw", "themes"), dotDot,"themes"), "--add-data=%s%s%s" % (os.path.join("nw", "themes"), dotDot,"themes"),
"--add-data=%s%s%s" % (os.path.join("nw", "graphics"),dotDot,"graphics"), "--add-data=%s%s%s" % (os.path.join("nw", "graphics"),dotDot,"graphics"),
"--icon=%s" % os.path.join("nw", "graphics", "novelWriter.ico"), "--icon=%s" % os.path.join("nw", "assets", "icons", "novelWriter.ico"),
] ]
if buildWindowed: if buildWindowed:
instOpt.append("--windowed") instOpt.append("--windowed")

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Before

Width:  |  Height:  |  Size: 142 KiB

After

Width:  |  Height:  |  Size: 142 KiB

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Before

Width:  |  Height:  |  Size: 225 B

After

Width:  |  Height:  |  Size: 225 B

Before

Width:  |  Height:  |  Size: 296 B

After

Width:  |  Height:  |  Size: 296 B

Before

Width:  |  Height:  |  Size: 256 B

After

Width:  |  Height:  |  Size: 256 B

Before

Width:  |  Height:  |  Size: 280 B

After

Width:  |  Height:  |  Size: 280 B

Before

Width:  |  Height:  |  Size: 552 B

After

Width:  |  Height:  |  Size: 552 B

Before

Width:  |  Height:  |  Size: 204 B

After

Width:  |  Height:  |  Size: 204 B

Before

Width:  |  Height:  |  Size: 338 B

After

Width:  |  Height:  |  Size: 338 B

Before

Width:  |  Height:  |  Size: 375 B

After

Width:  |  Height:  |  Size: 375 B

Before

Width:  |  Height:  |  Size: 295 B

After

Width:  |  Height:  |  Size: 295 B

Before

Width:  |  Height:  |  Size: 563 B

After

Width:  |  Height:  |  Size: 563 B

Before

Width:  |  Height:  |  Size: 487 B

After

Width:  |  Height:  |  Size: 487 B

+10 -3
View File
@@ -54,6 +54,7 @@ class Config:
self.themeRoot = None self.themeRoot = None
self.graphPath = None self.graphPath = None
self.dictPath = None self.dictPath = None
self.iconPath = None
# Set default values # Set default values
self.confChanged = False self.confChanged = False
@@ -61,6 +62,7 @@ class Config:
## General ## General
self.guiTheme = "default" self.guiTheme = "default"
self.guiSyntax = "default_light" self.guiSyntax = "default_light"
self.guiDark = False
## Sizes ## Sizes
self.winGeometry = [1100, 650] self.winGeometry = [1100, 650]
@@ -172,10 +174,11 @@ class Config:
self.appPath = getattr(sys, "_MEIPASS", path.abspath(path.dirname(__file__))) self.appPath = getattr(sys, "_MEIPASS", path.abspath(path.dirname(__file__)))
self.appRoot = path.join(self.appPath,path.pardir) self.appRoot = path.join(self.appPath,path.pardir)
self.assetPath = path.join(self.appPath,"assets") self.assetPath = path.join(self.appPath,"assets")
self.themeRoot = path.join(self.appPath,"themes") self.themeRoot = path.join(self.assetPath,"themes")
self.graphPath = path.join(self.appPath,"graphics") self.graphPath = path.join(self.assetPath,"graphics")
self.dictPath = path.join(self.assetPath,"dict") self.dictPath = path.join(self.assetPath,"dict")
self.appIcon = path.join(self.graphPath, nwFiles.APP_ICON) self.iconPath = path.join(self.assetPath,"icons")
self.appIcon = path.join(self.iconPath, nwFiles.APP_ICON)
# If config folder does not exist, make it. # If config folder does not exist, make it.
# This assumes that the os config folder itself exists. # This assumes that the os config folder itself exists.
@@ -224,6 +227,9 @@ class Config:
self.guiSyntax = self._parseLine( self.guiSyntax = self._parseLine(
cnfParse, cnfSec, "syntax", self.CNF_STR, self.guiSyntax cnfParse, cnfSec, "syntax", self.CNF_STR, self.guiSyntax
) )
self.guiDark = self._parseLine(
cnfParse, cnfSec, "guidark", self.CNF_BOOL, self.guiDark
)
## Sizes ## Sizes
cnfSec = "Sizes" cnfSec = "Sizes"
@@ -358,6 +364,7 @@ class Config:
cnfParse.set(cnfSec,"timestamp", datetime.now().strftime("%Y-%m-%d %H:%M:%S")) cnfParse.set(cnfSec,"timestamp", datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
cnfParse.set(cnfSec,"theme", str(self.guiTheme)) cnfParse.set(cnfSec,"theme", str(self.guiTheme))
cnfParse.set(cnfSec,"syntax", str(self.guiSyntax)) cnfParse.set(cnfSec,"syntax", str(self.guiSyntax))
cnfParse.set(cnfSec,"guidark", str(self.guiDark))
## Sizes ## Sizes
cnfSec = "Sizes" cnfSec = "Sizes"
+4
View File
@@ -1,8 +1,10 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Main Window Elements # Main Window Elements
from nw.gui.icons import GuiIcons
from nw.gui.mainmenu import GuiMainMenu from nw.gui.mainmenu import GuiMainMenu
from nw.gui.statusbar import GuiMainStatus from nw.gui.statusbar import GuiMainStatus
from nw.gui.theme import GuiTheme
# Dialogs # Dialogs
from nw.gui.dialogs.configeditor import GuiConfigEditor from nw.gui.dialogs.configeditor import GuiConfigEditor
@@ -26,8 +28,10 @@ from nw.gui.tools.dochighlight import GuiDocHighlighter
from nw.gui.tools.wordcounter import WordCounter from nw.gui.tools.wordcounter import WordCounter
__all__ = [ __all__ = [
"GuiIcons",
"GuiMainMenu", "GuiMainMenu",
"GuiMainStatus", "GuiMainStatus",
"GuiTheme",
"GuiConfigEditor", "GuiConfigEditor",
"GuiExport", "GuiExport",
"GuiItemEditor", "GuiItemEditor",
+13 -16
View File
@@ -15,8 +15,7 @@ import nw
from os import path from os import path
from PyQt5.QtCore import Qt, QSize from PyQt5.QtCore import Qt
from PyQt5.QtSvg import QSvgWidget
from PyQt5.QtGui import ( from PyQt5.QtGui import (
QIcon, QPixmap, QColor, QBrush, QStandardItemModel, QFont QIcon, QPixmap, QColor, QBrush, QStandardItemModel, QFont
) )
@@ -46,10 +45,7 @@ class GuiConfigEditor(QDialog):
self.innerBox = QVBoxLayout() self.innerBox = QVBoxLayout()
self.setWindowTitle("Preferences") self.setWindowTitle("Preferences")
self.guiDeco = self.theParent.theTheme.loadDecoration("settings",(64,64))
self.gradPath = path.abspath(path.join(self.mainConf.graphPath,"gear.svg"))
self.svgGradient = QSvgWidget(path.join(self.gradPath))
self.svgGradient.setFixedSize(QSize(64,64))
self.theProject.countStatus() self.theProject.countStatus()
self.tabMain = GuiConfigEditGeneral(self.theParent) self.tabMain = GuiConfigEditGeneral(self.theParent)
@@ -60,7 +56,7 @@ class GuiConfigEditor(QDialog):
self.tabWidget.addTab(self.tabEditor, "Editor") self.tabWidget.addTab(self.tabEditor, "Editor")
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
self.outerBox.addWidget(self.svgGradient, 0, Qt.AlignTop) self.outerBox.addWidget(self.guiDeco, 0, Qt.AlignTop)
self.outerBox.addLayout(self.innerBox) self.outerBox.addLayout(self.innerBox)
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
@@ -147,11 +143,16 @@ class GuiConfigEditGeneral(QWidget):
if syntaxIdx != -1: if syntaxIdx != -1:
self.guiLookSyntax.setCurrentIndex(syntaxIdx) self.guiLookSyntax.setCurrentIndex(syntaxIdx)
self.guiDarkIcons = QCheckBox("Prefer icons for dark backgrounds", self)
self.guiDarkIcons.setToolTip("This may improve the look of icons if the system theme is dark.")
self.guiDarkIcons.setChecked(self.mainConf.guiDark)
self.guiLookForm.addWidget(QLabel("Theme"), 0, 0) self.guiLookForm.addWidget(QLabel("Theme"), 0, 0)
self.guiLookForm.addWidget(self.guiLookTheme, 0, 1) self.guiLookForm.addWidget(self.guiLookTheme, 0, 1)
self.guiLookForm.addWidget(QLabel("Syntax"), 1, 0) self.guiLookForm.addWidget(QLabel("Syntax"), 1, 0)
self.guiLookForm.addWidget(self.guiLookSyntax, 1, 1) self.guiLookForm.addWidget(self.guiLookSyntax, 1, 1)
self.guiLookForm.setColumnStretch(2, 1) self.guiLookForm.addWidget(self.guiDarkIcons, 2, 0, 1, 2)
self.guiLookForm.setColumnStretch(3, 1)
# Spell Checking # Spell Checking
self.spellLang = QGroupBox("Spell Checker", self) self.spellLang = QGroupBox("Spell Checker", self)
@@ -221,17 +222,11 @@ class GuiConfigEditGeneral(QWidget):
self.projBackupClose = QCheckBox("Run on close",self) self.projBackupClose = QCheckBox("Run on close",self)
self.projBackupClose.setToolTip("Backup automatically on project close.") self.projBackupClose.setToolTip("Backup automatically on project close.")
if self.mainConf.backupOnClose: self.projBackupClose.setChecked(self.mainConf.backupOnClose)
self.projBackupClose.setCheckState(Qt.Checked)
else:
self.projBackupClose.setCheckState(Qt.Unchecked)
self.projBackupAsk = QCheckBox("Ask before backup",self) self.projBackupAsk = QCheckBox("Ask before backup",self)
self.projBackupAsk.setToolTip("Ask before backup.") self.projBackupAsk.setToolTip("Ask before backup.")
if self.mainConf.askBeforeBackup: self.projBackupAsk.setChecked(self.mainConf.askBeforeBackup)
self.projBackupAsk.setCheckState(Qt.Checked)
else:
self.projBackupAsk.setCheckState(Qt.Unchecked)
self.projBackupForm.addWidget(self.projBackupPath, 0, 0, 1, 2) self.projBackupForm.addWidget(self.projBackupPath, 0, 0, 1, 2)
self.projBackupForm.addWidget(self.projBackupGetPath, 0, 2) self.projBackupForm.addWidget(self.projBackupGetPath, 0, 2)
@@ -257,6 +252,7 @@ class GuiConfigEditGeneral(QWidget):
guiTheme = self.guiLookTheme.currentData() guiTheme = self.guiLookTheme.currentData()
guiSyntax = self.guiLookSyntax.currentData() guiSyntax = self.guiLookSyntax.currentData()
guiDark = self.guiDarkIcons.isChecked()
spellTool = self.spellToolList.currentData() spellTool = self.spellToolList.currentData()
spellLanguage = self.spellLangList.currentData() spellLanguage = self.spellLangList.currentData()
autoSaveDoc = self.autoSaveDoc.value() autoSaveDoc = self.autoSaveDoc.value()
@@ -270,6 +266,7 @@ class GuiConfigEditGeneral(QWidget):
self.mainConf.guiTheme = guiTheme self.mainConf.guiTheme = guiTheme
self.mainConf.guiSyntax = guiSyntax self.mainConf.guiSyntax = guiSyntax
self.mainConf.guiDark = guiDark
self.mainConf.spellTool = spellTool self.mainConf.spellTool = spellTool
self.mainConf.spellLanguage = spellLanguage self.mainConf.spellLanguage = spellLanguage
self.mainConf.autoSaveDoc = autoSaveDoc self.mainConf.autoSaveDoc = autoSaveDoc
+3 -6
View File
@@ -16,8 +16,7 @@ import nw
from os import path from os import path
from PyQt5.QtCore import Qt, QSize from PyQt5.QtCore import Qt
from PyQt5.QtSvg import QSvgWidget
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
QDialog, QHBoxLayout, QVBoxLayout, QWidget, QTabWidget, QGridLayout, QDialog, QHBoxLayout, QVBoxLayout, QWidget, QTabWidget, QGridLayout,
QGroupBox, QCheckBox, QLabel, QComboBox, QLineEdit, QPushButton, QGroupBox, QCheckBox, QLabel, QComboBox, QLineEdit, QPushButton,
@@ -50,9 +49,7 @@ class GuiExport(QDialog):
self.setWindowTitle("Export Project") self.setWindowTitle("Export Project")
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
self.gradPath = path.abspath(path.join(self.mainConf.graphPath,"export.svg")) self.guiDeco = self.theParent.theTheme.loadDecoration("export",(64,64))
self.svgGradient = QSvgWidget(self.gradPath)
self.svgGradient.setFixedSize(QSize(64,64))
self.theProject.countStatus() self.theProject.countStatus()
self.tabMain = GuiExportMain(self.theParent, self.theProject, self.optState) self.tabMain = GuiExportMain(self.theParent, self.theProject, self.optState)
@@ -62,7 +59,7 @@ class GuiExport(QDialog):
self.tabWidget.addTab(self.tabMain, "Settings") self.tabWidget.addTab(self.tabMain, "Settings")
self.tabWidget.addTab(self.tabPandoc, "Pandoc") self.tabWidget.addTab(self.tabPandoc, "Pandoc")
self.outerBox.addWidget(self.svgGradient, 0, Qt.AlignTop) self.outerBox.addWidget(self.guiDeco, 0, Qt.AlignTop)
self.outerBox.addLayout(self.innerBox) self.outerBox.addLayout(self.innerBox)
self.doExportForm = QGridLayout() self.doExportForm = QGridLayout()
+3 -7
View File
@@ -15,8 +15,7 @@ import nw
from os import path from os import path
from PyQt5.QtCore import Qt, QSize from PyQt5.QtCore import Qt
from PyQt5.QtSvg import QSvgWidget
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
QDialog, QHBoxLayout, QVBoxLayout, QGroupBox, QFormLayout, QDialog, QHBoxLayout, QVBoxLayout, QGroupBox, QFormLayout,
QLineEdit, QPushButton, QComboBox QLineEdit, QPushButton, QComboBox
@@ -42,13 +41,10 @@ class GuiItemEditor(QDialog):
self.innerBox = QVBoxLayout() self.innerBox = QVBoxLayout()
self.setWindowTitle("Item Settings") self.setWindowTitle("Item Settings")
self.guiDeco = self.theParent.theTheme.loadDecoration("settings",(64,64))
self.gradPath = path.abspath(path.join(self.mainConf.graphPath,"gear.svg"))
self.svgGradient = QSvgWidget(self.gradPath)
self.svgGradient.setFixedSize(QSize(64,64))
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
self.outerBox.addWidget(self.svgGradient, 0, Qt.AlignTop) self.outerBox.addWidget(self.guiDeco, 0, Qt.AlignTop)
self.outerBox.addLayout(self.innerBox) self.outerBox.addLayout(self.innerBox)
self.mainGroup = QGroupBox("Item Settings") self.mainGroup = QGroupBox("Item Settings")
+4 -7
View File
@@ -15,9 +15,8 @@ import nw
from os import path from os import path
from PyQt5.QtCore import Qt, QSize from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIcon, QPixmap, QColor, QBrush, QStandardItemModel from PyQt5.QtGui import QIcon, QPixmap, QColor, QBrush
from PyQt5.QtSvg import QSvgWidget
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
QDialog, QHBoxLayout, QVBoxLayout, QFormLayout, QLineEdit, QPlainTextEdit, QDialog, QHBoxLayout, QVBoxLayout, QFormLayout, QLineEdit, QPlainTextEdit,
QLabel, QWidget, QTabWidget, QDialogButtonBox, QListWidget, QLabel, QWidget, QTabWidget, QDialogButtonBox, QListWidget,
@@ -45,9 +44,7 @@ class GuiProjectEditor(QDialog):
self.setWindowTitle("Project Settings") self.setWindowTitle("Project Settings")
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
self.gradPath = path.abspath(path.join(self.mainConf.graphPath,"gear.svg")) self.guiDeco = self.theParent.theTheme.loadDecoration("settings",(64,64))
self.svgGradient = QSvgWidget(self.gradPath)
self.svgGradient.setFixedSize(QSize(64,64))
self.theProject.countStatus() self.theProject.countStatus()
self.tabMain = GuiProjectEditMain(self.theParent, self.theProject) self.tabMain = GuiProjectEditMain(self.theParent, self.theProject)
@@ -61,7 +58,7 @@ class GuiProjectEditor(QDialog):
self.tabWidget.addTab(self.tabImport, "Importance") self.tabWidget.addTab(self.tabImport, "Importance")
self.tabWidget.addTab(self.tabReplace,"Auto-Replace") self.tabWidget.addTab(self.tabReplace,"Auto-Replace")
self.outerBox.addWidget(self.svgGradient, 0, Qt.AlignTop) self.outerBox.addWidget(self.guiDeco, 0, Qt.AlignTop)
self.outerBox.addLayout(self.innerBox) self.outerBox.addLayout(self.innerBox)
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
+151
View File
@@ -0,0 +1,151 @@
# -*- coding: utf-8 -*-
"""novelWriter Icons Class
novelWriter Icons Class
===========================
This class manages the GUI icons
File History:
Created: 2019-11-08 [0.4.0]
"""
import logging
import nw
from os import path
from PyQt5.QtCore import QSize
from PyQt5.QtSvg import QSvgWidget
from PyQt5.QtGui import QIcon
logger = logging.getLogger(__name__)
class GuiIcons:
# Icon keys should either be a .svg or .png file under the gui
# theme folder, or have a fallback that is either compatible with
# QIcon.fromTheme, as specified here:
# 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,
}
DECO_MAP = {
"export" : "export.svg",
"settings" : "settings.svg",
}
def __init__(self, theParent):
self.mainConf = nw.CONFIG
self.theParent = theParent
# Storage
self.qIcons = {}
# 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
return
def initIcons(self, priPath):
self.priPath = priPath
self.secPath = self.mainConf.iconPath
self.prefDark = self.mainConf.guiDark
for iconKey in self.ICON_MAP.keys():
self.qIcons[iconKey] = self._loadIcon(iconKey)
return
def loadDecoration(self, decoKey, decoSize=None):
if decoKey not in self.DECO_MAP:
logger.error("Decoration with name '%s' does not exist" % decoKey)
return QSvgWidget()
svgPath = path.join(self.mainConf.graphPath, self.DECO_MAP[decoKey])
if not path.isfile(svgPath):
logger.error("Decoration file '%s' not in assets folder" % self.DECO_MAP[decoKey])
return QSvgWidget()
svgDeco = QSvgWidget(svgPath)
if decoSize is not None:
svgDeco.setFixedSize(QSize(decoSize[0],decoSize[1]))
return svgDeco
def getIcon(self, iconKey, iconSize=None):
if iconKey in self.qIcons:
return self.qIcons[iconKey]
return QIcon()
##
# Internal Functions
##
def _loadIcon(self, iconKey):
if iconKey not in self.ICON_MAP:
logger.error("Icon with name '%s' does not exist" % iconKey)
return QIcon()
if self.prefDark:
iconSuffix = "dark"
else:
iconSuffix = "light"
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)
# If we're still here, try to set from system theme
if self.ICON_MAP[iconKey] is not None:
logger.verbose("Loading icon '%s' from system theme" % iconKey)
return QIcon().fromTheme(self.ICON_MAP[iconKey])
# Give up and return an empty icomn
logger.warning("Did not load an icon for '%s'" % iconKey)
return QIcon()
# END Class GuiIcons
+9 -34
View File
@@ -20,29 +20,17 @@ from PyQt5.QtWidgets import qApp
from PyQt5.QtGui import QPalette, QColor, QIcon from PyQt5.QtGui import QPalette, QColor, QIcon
from nw.constants import nwAlert from nw.constants import nwAlert
from nw.gui.icons import GuiIcons
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class Theme: class GuiTheme:
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",
}
def __init__(self, theParent): def __init__(self, theParent):
self.mainConf = nw.CONFIG self.mainConf = nw.CONFIG
self.theParent = theParent self.theParent = theParent
self.theIcons = GuiIcons(self.theParent)
self.guiPalette = QPalette() self.guiPalette = QPalette()
self.guiPath = "gui" self.guiPath = "gui"
self.iconPath = "icons" self.iconPath = "icons"
@@ -91,9 +79,6 @@ class Theme:
self.colTagErr = [ 0, 0, 0] self.colTagErr = [ 0, 0, 0]
self.colRepTag = [ 0, 0, 0] self.colRepTag = [ 0, 0, 0]
## Icons
self.themeIcons = {}
# Changeable Settings # Changeable Settings
self.guiTheme = None self.guiTheme = None
self.guiSyntax = None self.guiSyntax = None
@@ -105,6 +90,9 @@ class Theme:
self.updateTheme() self.updateTheme()
self.getIcon = self.theIcons.getIcon
self.loadDecoration = self.theIcons.loadDecoration
return return
## ##
@@ -121,8 +109,7 @@ class Theme:
self.confFile = path.join(self.themePath,self.confName) self.confFile = path.join(self.themePath,self.confName)
self.cssFile = path.join(self.themePath,self.cssName) self.cssFile = path.join(self.themePath,self.cssName)
for iconName in self.ICON_MAP: self.theIcons.initIcons(path.join(self.themePath,self.iconPath))
self.themeIcons[iconName] = QIcon.fromTheme(self.ICON_MAP[iconName])
self.loadTheme() self.loadTheme()
self.loadSyntax() self.loadSyntax()
@@ -132,6 +119,7 @@ class Theme:
def loadTheme(self): def loadTheme(self):
logger.debug("Loading theme files") logger.debug("Loading theme files")
logger.debug("System icon theme is '%s'" % str(QIcon.themeName()))
# CSS File # CSS File
cssData = "" cssData = ""
@@ -143,14 +131,6 @@ class Theme:
logger.error("Could not load theme css file") logger.error("Could not load theme css file")
return False return False
# Icon Files
iconsDir = path.join(self.themePath,self.iconPath)
if path.isdir(iconsDir):
for iconName in self.ICON_MAP:
iconFile = path.join(iconsDir,iconName+".png")
if path.isfile(iconFile):
self.themeIcons[iconName] = QIcon(iconFile)
# Config File # Config File
confParser = configparser.ConfigParser() confParser = configparser.ConfigParser()
try: try:
@@ -294,11 +274,6 @@ class Theme:
return self.syntaxList return self.syntaxList
def getIcon(self, iconName, iconSize=None):
if iconName in self.themeIcons:
return self.themeIcons[iconName]
return QIcon()
## ##
# Internal Functions # Internal Functions
## ##
@@ -340,4 +315,4 @@ class Theme:
return confParser.get(cnfSec, cnfName) return confParser.get(cnfSec, cnfName)
return cnfDefault return cnfDefault
# End Class Theme # End Class GuiTheme
+5 -6
View File
@@ -24,14 +24,13 @@ from PyQt5.QtWidgets import (
) )
from nw.gui import ( from nw.gui import (
GuiMainMenu, GuiMainStatus, GuiDocTree, GuiDocEditor, GuiDocViewer, GuiMainMenu, GuiMainStatus, GuiTheme, GuiDocTree, GuiDocEditor,
GuiDocDetails, GuiSearchBar, GuiNoticeBar, GuiDocViewDetails, GuiDocViewer, GuiDocDetails, GuiSearchBar, GuiNoticeBar,
GuiConfigEditor, GuiProjectEditor, GuiExport, GuiItemEditor, GuiDocViewDetails, GuiConfigEditor, GuiProjectEditor, GuiExport,
GuiTimeLineView, GuiSessionLogView GuiItemEditor, GuiTimeLineView, GuiSessionLogView
) )
from nw.project import NWProject, NWDoc, NWItem, NWIndex, NWBackup from nw.project import NWProject, NWDoc, NWItem, NWIndex, NWBackup
from nw.tools import countWords from nw.tools import countWords
from nw.theme import Theme
from nw.constants import nwFiles, nwItemType, nwAlert from nw.constants import nwFiles, nwItemType, nwAlert
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -44,7 +43,7 @@ class GuiMain(QMainWindow):
logger.info("Starting %s" % nw.__package__) logger.info("Starting %s" % nw.__package__)
logger.debug("Initialising GUI ...") logger.debug("Initialising GUI ...")
self.mainConf = nw.CONFIG self.mainConf = nw.CONFIG
self.theTheme = Theme(self) self.theTheme = GuiTheme(self)
self.theProject = NWProject(self) self.theProject = NWProject(self)
self.theIndex = NWIndex(self.theProject, self) self.theIndex = NWIndex(self.theProject, self)
self.hasProject = False self.hasProject = False
+2 -1
View File
@@ -1,7 +1,8 @@
[Main] [Main]
timestamp = 2019-11-08 00:27:54 timestamp = 2019-11-08 18:43:21
theme = default theme = default
syntax = default_light syntax = default_light
guidark = False
[Sizes] [Sizes]
geometry = 1100, 650 geometry = 1100, 650