Importance colours added to the GUI

This commit is contained in:
Veronica K. B. Olsen
2019-05-12 21:54:21 +02:00
parent 8d8fc72cc1
commit 53b97e8399
5 changed files with 56 additions and 13 deletions
+11 -3
View File
@@ -71,11 +71,19 @@ class GuiDocDetails(QFrame):
colTwo = [""]*4
else:
itemStatus = nwItem.itemStatus
if itemStatus < 0 or itemStatus >= len(self.theParent.statusLabels):
itemStatus = 0
if nwItem.itemClass == nwItemClass.NOVEL:
if itemStatus < 0 or itemStatus >= len(self.theParent.statusLabels):
statusLabel = self.theParent.statusLabels[0]
else:
statusLabel = self.theParent.statusLabels[itemStatus]
else:
if itemStatus < 0 or itemStatus >= len(self.theParent.importLabels):
statusLabel = self.theParent.importLabels[0]
else:
statusLabel = self.theParent.importLabels[itemStatus]
colTwo = [
nwItem.itemName,
self.theParent.statusLabels[itemStatus],
statusLabel,
nwLabels.CLASS_NAME[nwItem.itemClass],
nwLabels.LAYOUT_NAME[nwItem.itemLayout],
]
+13 -5
View File
@@ -19,9 +19,8 @@ from PyQt5.QtGui import QIcon, QFont, QColor
from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QAbstractItemView, QInputDialog, QLineEdit, QApplication
from nw.project.item import NWItem
from nw.enum import nwItemType, nwItemClass
from nw.enum import nwItemType, nwItemClass, nwAlert
from nw.constants import nwLabels
from nw.enum import nwAlert
logger = logging.getLogger(__name__)
@@ -256,6 +255,7 @@ class GuiDocTree(QTreeWidget):
trItem = self._getTreeItem(tHandle)
nwItem = self.theProject.getItem(tHandle)
tName = nwItem.itemName
tClass = nwItem.itemClass
tHandle = nwItem.itemHandle
pHandle = nwItem.parHandle
@@ -263,12 +263,20 @@ class GuiDocTree(QTreeWidget):
if nwItem.itemType == nwItemType.FILE:
tStatus += "."+nwLabels.LAYOUT_FLAG[nwItem.itemLayout]
nStatus = nwItem.itemStatus
if nStatus < 0 or nStatus >= len(self.theParent.statusIcons):
nStatus = 0
if tClass == nwItemClass.NOVEL:
if nStatus < 0 or nStatus >= len(self.theParent.statusIcons):
flagIcon = self.theParent.statusIcons[0]
else:
flagIcon = self.theParent.statusIcons[nStatus]
else:
if nStatus < 0 or nStatus >= len(self.theParent.importIcons):
flagIcon = self.theParent.importIcons[0]
else:
flagIcon = self.theParent.importIcons[nStatus]
trItem.setText(self.C_NAME,tName)
trItem.setText(self.C_FLAGS,tStatus)
trItem.setIcon(self.C_FLAGS,self.theParent.statusIcons[nStatus])
trItem.setIcon(self.C_FLAGS,flagIcon)
return
+10 -4
View File
@@ -54,10 +54,16 @@ class GuiItemEditor(QDialog):
self.editStatus = QComboBox()
self.editLayout = QComboBox()
for n in range(len(self.theParent.statusLabels)):
self.editStatus.addItem(
self.theParent.statusIcons[n], self.theParent.statusLabels[n], n
)
if self.theItem.itemClass == nwItemClass.NOVEL:
for n in range(len(self.theParent.statusLabels)):
self.editStatus.addItem(
self.theParent.statusIcons[n], self.theParent.statusLabels[n], n
)
else:
for n in range(len(self.theParent.statusLabels)):
self.editStatus.addItem(
self.theParent.importIcons[n], self.theParent.importLabels[n], n
)
self.validLayouts = []
if self.theItem.itemType == nwItemType.FILE:
+14
View File
@@ -60,6 +60,8 @@ class GuiMain(QMainWindow):
# Minor Gui Elements
self.statusIcons = []
self.statusLabels = []
self.importIcons = []
self.importLabels = []
# Assemble Main Window
self.stackPane = QStackedWidget()
@@ -87,6 +89,7 @@ class GuiMain(QMainWindow):
self.treeView.itemDoubleClicked.connect(self._treeDoubleClick)
self.treeView.buildTree()
self._makeStatusIcons()
self._makeImportIcons()
# Set Main Window Elements
self.setMenuBar(self.mainMenu)
@@ -179,6 +182,7 @@ class GuiMain(QMainWindow):
self.treeView.buildTree()
self._setWindowTitle(self.theProject.projName)
self._makeStatusIcons()
self._makeImportIcons()
self.docEditor.setPwl(path.join(self.theProject.projMeta,"wordlist.txt"))
self.docEditor.setSpellCheck(self.theProject.spellCheck)
self.mainMenu.updateMenu()
@@ -370,6 +374,16 @@ class GuiMain(QMainWindow):
self.statusLabels.append(sLabel)
return
def _makeImportIcons(self):
self.importIcons = []
self.importLabels = []
for sLabel, sR, sG, sB in self.theProject.importCols:
theIcon = QPixmap(32,32)
theIcon.fill(QColor(sR,sG,sB))
self.importIcons.append(QIcon(theIcon))
self.importLabels.append(sLabel)
return
##
# Events
##
+8 -1
View File
@@ -46,7 +46,6 @@ class NWProject():
self.projMeta = None
self.projCache = None
self.projFile = None
self.statusCols = None
# Project Meta
self.projName = None
@@ -55,6 +54,8 @@ class NWProject():
# Project Settings
self.spellCheck = False
self.statusCols = None
self.importCols = None
# Set Defaults
self.clearProject()
@@ -147,6 +148,12 @@ class NWProject():
("Draft", 200,150, 0),
("Finished", 50,200, 0),
]
self.importCols = [
("None", 100,100,100),
("Minor", 200, 45, 60),
("Major", 160, 67,130),
("Main", 120, 90,200),
]
return