Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icon cleanup #53

Merged
merged 4 commits into from
Oct 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions nw/gui/configeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def __init__(self, theParent):

self.mainConf = nw.CONFIG
self.theParent = theParent
self.theTheme = theParent.theTheme
self.outerBox = QGridLayout()

# User Interface
Expand All @@ -122,7 +123,7 @@ def __init__(self, theParent):

self.guiLookTheme = QComboBox()
self.guiLookTheme.setMinimumWidth(200)
self.theThemes = self.theParent.theTheme.listThemes()
self.theThemes = self.theTheme.listThemes()
for themeDir, themeName in self.theThemes:
self.guiLookTheme.addItem(themeName, themeDir)
themeIdx = self.guiLookTheme.findData(self.mainConf.guiTheme)
Expand All @@ -131,7 +132,7 @@ def __init__(self, theParent):

self.guiLookSyntax = QComboBox()
self.guiLookSyntax.setMinimumWidth(200)
self.theSyntaxes = self.theParent.theTheme.listSyntax()
self.theSyntaxes = self.theTheme.listSyntax()
for syntaxFile, syntaxName in self.theSyntaxes:
self.guiLookSyntax.addItem(syntaxName, syntaxFile)
syntaxIdx = self.guiLookSyntax.findData(self.mainConf.guiSyntax)
Expand Down Expand Up @@ -192,7 +193,7 @@ def __init__(self, theParent):
if path.isdir(self.mainConf.backupPath):
self.projBackupPath.setText(self.mainConf.backupPath)

self.projBackupGetPath = QPushButton(QIcon.fromTheme("folder"),"")
self.projBackupGetPath = QPushButton(self.theTheme.getIcon("folder"),"")
self.projBackupGetPath.clicked.connect(self._backupFolder)

self.projBackupClose = QCheckBox(self)
Expand Down
3 changes: 1 addition & 2 deletions nw/gui/doceditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,7 @@ def _openContextMenu(self, thePos):
return

mnuSuggest = QMenu()
spIcon = QIcon.fromTheme("tools-check-spelling")
mnuHead = QAction(spIcon,"Spelling Suggestion", mnuSuggest)
mnuHead = QAction("Spelling Suggestion(s)", mnuSuggest)
mnuSuggest.addAction(mnuHead)
mnuSuggest.addSeparator()
theSuggest = self.theDict.suggestWords(theWord)
Expand Down
11 changes: 6 additions & 5 deletions nw/gui/doctree.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, theParent, theProject):
self.mainConf = nw.CONFIG
self.debugGUI = self.mainConf.debugGUI
self.theParent = theParent
self.theTheme = theParent.theTheme
self.theProject = theProject

# Tree Settings
Expand Down Expand Up @@ -382,13 +383,13 @@ def _addTreeItem(self, nwItem):
newItem.setExpanded(nwItem.isExpanded)

if nwItem.itemType == nwItemType.ROOT:
newItem.setIcon(self.C_NAME, QIcon.fromTheme("drive-harddisk"))
newItem.setIcon(self.C_NAME, self.theTheme.getIcon("root"))
elif nwItem.itemType == nwItemType.FOLDER:
newItem.setIcon(self.C_NAME, QIcon.fromTheme("folder"))
newItem.setIcon(self.C_NAME, self.theTheme.getIcon("folder"))
elif nwItem.itemType == nwItemType.FILE:
newItem.setIcon(self.C_NAME, QIcon.fromTheme("x-office-document"))
newItem.setIcon(self.C_NAME, self.theTheme.getIcon("document"))
elif nwItem.itemType == nwItemType.TRASH:
newItem.setIcon(self.C_NAME, QIcon.fromTheme("user-trash"))
newItem.setIcon(self.C_NAME, self.theTheme.getIcon("trash"))

return newItem

Expand All @@ -413,7 +414,7 @@ def _addOrphanedRoot(self):
self.addTopLevelItem(newItem)
self.orphRoot = newItem
newItem.setExpanded(True)
newItem.setIcon(self.C_NAME, QIcon.fromTheme("dialog-warning"))
newItem.setIcon(self.C_NAME, self.theTheme.getIcon("orphan"))
return

def _cleanOrphanedRoot(self):
Expand Down
114 changes: 57 additions & 57 deletions nw/gui/mainmenu.py

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions nw/gui/projecteditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ def __init__(self, theParent, theProject):
QWidget.__init__(self, theParent)

self.theParent = theParent
self.theTheme = theParent.theTheme
self.theProject = theProject
self.arChanged = False

Expand All @@ -341,9 +342,9 @@ def __init__(self, theParent, theProject):

self.editKey = QLineEdit()
self.editValue = QLineEdit()
self.saveButton = QPushButton(QIcon.fromTheme("document-save"),"")
self.addButton = QPushButton(QIcon.fromTheme("list-add"),"")
self.delButton = QPushButton(QIcon.fromTheme("list-remove"),"")
self.saveButton = QPushButton(self.theTheme.getIcon("save"),"")
self.addButton = QPushButton(self.theTheme.getIcon("add"),"")
self.delButton = QPushButton(self.theTheme.getIcon("remove"),"")

self.editKey.setEnabled(False)
self.editValue.setEnabled(False)
Expand Down
7 changes: 4 additions & 3 deletions nw/gui/searchbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(self, theParent):

self.mainConf = nw.CONFIG
self.theParent = theParent
self.theTheme = theParent.theTheme
self.repVisible = False

self.setContentsMargins(0,0,0,0)
Expand All @@ -41,9 +42,9 @@ def __init__(self, theParent):
self.replaceBox = QLineEdit()
self.searchLabel = QLabel("Search")
self.replaceLabel = QLabel("Replace")
self.closeButton = QPushButton(QIcon.fromTheme("edit-delete"),"")
self.searchButton = QPushButton(QIcon.fromTheme("edit-find"),"")
self.replaceButton = QPushButton(QIcon.fromTheme("edit-find-replace"),"")
self.closeButton = QPushButton(self.theTheme.getIcon("close"),"")
self.searchButton = QPushButton(self.theTheme.getIcon("search"),"")
self.replaceButton = QPushButton(self.theTheme.getIcon("replace"),"")

self.closeButton.clicked.connect(self._doClose)
self.searchButton.clicked.connect(self._doSearch)
Expand Down
41 changes: 39 additions & 2 deletions nw/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,35 @@
from os import path, listdir

from PyQt5.QtWidgets import qApp
from PyQt5.QtGui import QPalette, QColor
from PyQt5.QtGui import QPalette, QColor, QIcon

from nw.enum import nwAlert

logger = logging.getLogger(__name__)

class Theme:

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):

self.mainConf = nw.CONFIG
self.theParent = theParent
self.guiPalette = QPalette()
self.guiPath = "gui"
self.iconPath = "icons"
self.syntaxPath = "syntax"
self.cssName = "style.qss"
self.confName = "theme.conf"
Expand Down Expand Up @@ -76,10 +91,16 @@ def __init__(self, theParent):
self.colTagErr = [ 0, 0, 0]
self.colRepTag = [ 0, 0, 0]

## Icons
self.themeIcons = {}

# Changeable Settings
self.guiTheme = None
self.guiSyntax = None
self.themeRoot = None
self.themePath = None
self.syntaxFile = None
self.confFile = None
self.cssFile = None

self.updateTheme()
Expand All @@ -95,11 +116,14 @@ def updateTheme(self):
self.guiTheme = self.mainConf.guiTheme
self.guiSyntax = self.mainConf.guiSyntax
self.themeRoot = self.mainConf.themeRoot
self.themePath = path.join(self.mainConf.themeRoot, self.guiPath, self.guiTheme)
self.themePath = path.join(self.mainConf.themeRoot,self.guiPath,self.guiTheme)
self.syntaxFile = path.join(self.themeRoot,self.syntaxPath,self.guiSyntax+".conf")
self.confFile = path.join(self.themePath,self.confName)
self.cssFile = path.join(self.themePath,self.cssName)

for iconName in self.ICON_MAP:
self.themeIcons[iconName] = QIcon.fromTheme(self.ICON_MAP[iconName])

self.loadTheme()
self.loadSyntax()

Expand All @@ -119,6 +143,14 @@ def loadTheme(self):
logger.error("Could not load theme css file")
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
confParser = configparser.ConfigParser()
try:
Expand Down Expand Up @@ -262,6 +294,11 @@ def listSyntax(self):

return self.syntaxList

def getIcon(self, iconName, iconSize=None):
if iconName in self.themeIcons:
return self.themeIcons[iconName]
return QIcon()

##
# Internal Functions
##
Expand Down
Binary file added nw/themes/gui/default_dark/icons/add.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added nw/themes/gui/default_dark/icons/close.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added nw/themes/gui/default_dark/icons/document.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added nw/themes/gui/default_dark/icons/folder.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added nw/themes/gui/default_dark/icons/orphan.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added nw/themes/gui/default_dark/icons/remove.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added nw/themes/gui/default_dark/icons/replace.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added nw/themes/gui/default_dark/icons/root.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added nw/themes/gui/default_dark/icons/save.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added nw/themes/gui/default_dark/icons/search.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added nw/themes/gui/default_dark/icons/trash.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 18 additions & 18 deletions nw/themes/gui/default_dark/theme.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ credit = Veronica Berglyd Olsen
url = https://github.com/vkbo/novelWriter

[Palette]
window = 54, 54, 54
windowtext = 174, 174, 174
base = 62, 62, 62
alternatebase = 67, 67, 67
text = 174, 174, 174
tooltipbase = 255, 255, 192
tooltiptext = 21, 21, 13
button = 62, 62, 62
buttontext = 174, 174, 174
brighttext = 174, 174, 174
highlight = 44, 152, 247
highlightedtex = 255, 255, 255
link = 44, 152, 247
linkvisited = 44, 152, 247
window = 54, 54, 54
windowtext = 174, 174, 174
base = 62, 62, 62
alternatebase = 67, 67, 67
text = 174, 174, 174
tooltipbase = 255, 255, 192
tooltiptext = 21, 21, 13
button = 62, 62, 62
buttontext = 174, 174, 174
brighttext = 174, 174, 174
highlight = 44, 152, 247
highlightedtext = 255, 255, 255
link = 44, 152, 247
linkvisited = 44, 152, 247

[GUI]
treewordcount = 197, 200, 198
statusnone = 150, 152, 150
statussaved = 39, 135, 78
statusunsaved = 138, 32, 32
treewordcount = 197, 200, 198
statusnone = 150, 152, 150
statussaved = 39, 135, 78
statusunsaved = 138, 32, 32