Added details tab to the Project Settings dialog

This commit is contained in:
Veronica K. B. Olsen
2020-05-27 18:09:55 +02:00
parent 8a98123735
commit 12aa25cc54
6 changed files with 165 additions and 34 deletions
+27 -2
View File
@@ -68,8 +68,8 @@ class NWProject():
self.projChanged = False # The project has unsaved changes self.projChanged = False # The project has unsaved changes
self.projAltered = False # The project has been altered this session self.projAltered = False # The project has been altered this session
self.lockedBy = None # Data on which computer has the project open self.lockedBy = None # Data on which computer has the project open
self.saveCount = None # Meta data: number of saves self.saveCount = 0 # Meta data: number of saves
self.autoCount = None # Meta data: number of automatic saves self.autoCount = 0 # Meta data: number of automatic saves
# Class Settings # Class Settings
self.projPath = None # The full path to where the currently open project is saved self.projPath = None # The full path to where the currently open project is saved
@@ -167,6 +167,7 @@ class NWProject():
"""Create a new project by populating the project tree with a """Create a new project by populating the project tree with a
few starter items. few starter items.
""" """
self.projName = "New Project"
hNovel = self.newRoot("Novel", nwItemClass.NOVEL) hNovel = self.newRoot("Novel", nwItemClass.NOVEL)
hChars = self.newRoot("Characters", nwItemClass.CHARACTER) hChars = self.newRoot("Characters", nwItemClass.CHARACTER)
hWorld = self.newRoot("Plot", nwItemClass.PLOT) hWorld = self.newRoot("Plot", nwItemClass.PLOT)
@@ -1233,6 +1234,30 @@ class NWTree():
self._handleSeed = theSeed self._handleSeed = theSeed
return return
##
# Getters
##
def countTypes(self):
"""Count the number of files, folders and roots in the project.
"""
nRoot = 0
nFolder = 0
nFile = 0
for tHandle in self._treeOrder:
tItem = self.__getitem__(tHandle)
if tItem is None:
continue
elif tItem.itemType == nwItemType.ROOT:
nRoot += 1
elif tItem.itemType == nwItemType.FOLDER:
nFolder += 1
elif tItem.itemType == nwItemType.FILE:
nFile += 1
return nRoot, nFolder, nFile
## ##
# Meta Methods # Meta Methods
## ##
+1 -1
View File
@@ -13,7 +13,7 @@ from nw.gui.dialogs.configeditor import GuiConfigEditor
from nw.gui.dialogs.docmerge import GuiDocMerge from nw.gui.dialogs.docmerge import GuiDocMerge
from nw.gui.dialogs.docsplit import GuiDocSplit from nw.gui.dialogs.docsplit import GuiDocSplit
from nw.gui.dialogs.itemeditor import GuiItemEditor from nw.gui.dialogs.itemeditor import GuiItemEditor
from nw.gui.dialogs.projecteditor import GuiProjectSettings from nw.gui.dialogs.projectsettings import GuiProjectSettings
from nw.gui.dialogs.projectload import GuiProjectLoad from nw.gui.dialogs.projectload import GuiProjectLoad
from nw.gui.dialogs.sessionlog import GuiSessionLogView from nw.gui.dialogs.sessionlog import GuiSessionLogView
+1 -1
View File
@@ -97,7 +97,7 @@ class QConfigLayout(QGridLayout):
qLabel = None qLabel = None
raise ValueError("theLabel must be a QLabel") raise ValueError("theLabel must be a QLabel")
qLabel.setContentsMargins(0,4,0,4) qLabel.setContentsMargins(0, 4, 0, 4)
self.addWidget(qLabel, self._nextRow, 0, 1, 2, Qt.AlignLeft) self.addWidget(qLabel, self._nextRow, 0, 1, 2, Qt.AlignLeft)
self.setRowStretch(self._nextRow, 0) self.setRowStretch(self._nextRow, 0)
+1 -1
View File
@@ -5,7 +5,7 @@ from nw.gui.dialogs.configeditor import GuiConfigEditor
from nw.gui.dialogs.docmerge import GuiDocMerge from nw.gui.dialogs.docmerge import GuiDocMerge
from nw.gui.dialogs.docsplit import GuiDocSplit from nw.gui.dialogs.docsplit import GuiDocSplit
from nw.gui.dialogs.itemeditor import GuiItemEditor from nw.gui.dialogs.itemeditor import GuiItemEditor
from nw.gui.dialogs.projecteditor import GuiProjectSettings from nw.gui.dialogs.projectsettings import GuiProjectSettings
from nw.gui.dialogs.projectload import GuiProjectLoad from nw.gui.dialogs.projectload import GuiProjectLoad
from nw.gui.dialogs.sessionlog import GuiSessionLogView from nw.gui.dialogs.sessionlog import GuiSessionLogView
+132 -26
View File
@@ -38,7 +38,7 @@ from PyQt5.QtWidgets import (
) )
from nw.constants import nwAlert from nw.constants import nwAlert
from nw.gui.additions import QSwitch, PagedDialog from nw.gui.additions import QSwitch, PagedDialog, QConfigLayout
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -57,11 +57,13 @@ class GuiProjectSettings(PagedDialog):
self.setWindowTitle("Project Settings") self.setWindowTitle("Project Settings")
self.tabMain = GuiProjectEditMain(self.theParent, self.theProject) self.tabMain = GuiProjectEditMain(self.theParent, self.theProject)
self.tabStatus = GuiProjectEditStatus(self.theParent, self.theProject.statusItems) self.tabMeta = GuiProjectEditMeta(self.theParent, self.theProject)
self.tabImport = GuiProjectEditStatus(self.theParent, self.theProject.importItems) self.tabStatus = GuiProjectEditStatus(self.theParent, self.theProject, True)
self.tabImport = GuiProjectEditStatus(self.theParent, self.theProject, False)
self.tabReplace = GuiProjectEditReplace(self.theParent, self.theProject) self.tabReplace = GuiProjectEditReplace(self.theParent, self.theProject)
self.addTab(self.tabMain, "Settings") self.addTab(self.tabMain, "Settings")
self.addTab(self.tabMeta, "Details")
self.addTab(self.tabStatus, "Status") self.addTab(self.tabStatus, "Status")
self.addTab(self.tabImport, "Importance") self.addTab(self.tabImport, "Importance")
self.addTab(self.tabReplace,"Auto-Replace") self.addTab(self.tabReplace,"Auto-Replace")
@@ -117,58 +119,155 @@ class GuiProjectEditMain(QWidget):
def __init__(self, theParent, theProject): def __init__(self, theParent, theProject):
QWidget.__init__(self, theParent) QWidget.__init__(self, theParent)
self.theParent = theParent self.theParent = theParent
self.theProject = theProject self.theProject = theProject
self.mainForm = QGridLayout()
self.backupBox = QHBoxLayout()
self.editName = QLineEdit() # The Form
self.mainForm = QConfigLayout()
self.mainForm.setHelpTextStyle(self.theParent.theTheme.helpText)
self.setLayout(self.mainForm)
self.mainForm.addGroupLabel("Project Settings")
self.editName = QLineEdit()
self.editName.setMaxLength(200) self.editName.setMaxLength(200)
self.editName.setFixedWidth(250)
self.editName.setText(self.theProject.projName) self.editName.setText(self.theProject.projName)
self.mainForm.addRow(
"Working title",
self.editName,
"Should be set only once."
)
self.editTitle = QLineEdit() self.editTitle = QLineEdit()
self.editTitle.setMaxLength(200) self.editTitle.setMaxLength(200)
self.editTitle.setFixedWidth(250)
self.editTitle.setText(self.theProject.bookTitle) self.editTitle.setText(self.theProject.bookTitle)
self.mainForm.addRow(
"Novel title",
self.editTitle,
"Change whenever you want!"
)
self.editAuthors = QPlainTextEdit() self.editAuthors = QPlainTextEdit()
bookAuthors = "" bookAuthors = ""
for bookAuthor in self.theProject.bookAuthors: for bookAuthor in self.theProject.bookAuthors:
bookAuthors += bookAuthor+"\n" bookAuthors += bookAuthor+"\n"
self.editAuthors.setPlainText(bookAuthors) self.editAuthors.setPlainText(bookAuthors)
self.editAuthors.setMaximumHeight(120) self.editAuthors.setFixedHeight(100)
self.editAuthors.setFixedWidth(250)
self.mainForm.addRow(
"Author(s)",
self.editAuthors,
"One name per line."
)
self.doBackup = QSwitch(self) self.doBackup = QSwitch(self)
self.doBackup.setChecked(not self.theProject.doBackup) self.doBackup.setChecked(not self.theProject.doBackup)
self.backupBox.addStretch(1) self.mainForm.addRow(
self.backupBox.addWidget(QLabel("Disable backup on close")) "No backup on close",
self.backupBox.addWidget(self.doBackup) self.doBackup,
"Overrides main preferences."
self.mainForm.addWidget(QLabel("Working title"), 0, 0, 1, 1, Qt.AlignTop) )
self.mainForm.addWidget(self.editName, 0, 1, 1, 1, Qt.AlignTop)
self.mainForm.addWidget(QLabel("Book title"), 1, 0, 1, 1, Qt.AlignTop)
self.mainForm.addWidget(self.editTitle, 1, 1, 1, 1, Qt.AlignTop)
self.mainForm.addWidget(QLabel("Book authors"), 2, 0, 1, 1, Qt.AlignTop)
self.mainForm.addWidget(self.editAuthors, 2, 1, 1, 1, Qt.AlignTop)
self.mainForm.addLayout(self.backupBox, 3, 0, 1, 2, Qt.AlignTop)
self.setLayout(self.mainForm)
return return
# END Class GuiProjectEditMain # END Class GuiProjectEditMain
class GuiProjectEditStatus(QWidget): class GuiProjectEditMeta(QWidget):
def __init__(self, theParent, theStatus): def __init__(self, theParent, theProject):
QWidget.__init__(self, theParent) QWidget.__init__(self, theParent)
self.theParent = theParent self.theParent = theParent
self.theStatus = theStatus self.theProject = theProject
# The Form
self.mainForm = QGridLayout()
self.setLayout(self.mainForm)
self.headLabel = QLabel("<b>Project Details</b>")
self.nameLabel = QLabel("Working title:")
self.nameLabel.setIndent(8)
self.nameValue = QLabel(self.theProject.projName)
self.nameValue.setWordWrap(True)
self.pathLabel = QLabel("Project path:")
self.pathLabel.setIndent(8)
self.pathValue = QLabel(self.theProject.projPath)
self.pathValue.setWordWrap(True)
self.revLabel = QLabel("Revision count:")
self.revLabel.setIndent(8)
self.revValue = QLabel("{:n}".format(self.theProject.saveCount))
self.statsLabel = QLabel("<b>Project Stats</b>")
nR, nD, nF = self.theProject.projTree.countTypes()
self.nRootLabel = QLabel("Root folders:")
self.nRootLabel.setIndent(8)
self.nRootValue = QLabel("{:n}".format(nR))
self.nDirLabel = QLabel("Folders:")
self.nDirLabel.setIndent(8)
self.nDirValue = QLabel("{:n}".format(nD))
self.nFileLabel = QLabel("Documents:")
self.nFileLabel.setIndent(8)
self.nFileValue = QLabel("{:n}".format(nF))
self.wordsLabel = QLabel("Word count:")
self.wordsLabel.setIndent(8)
self.wordsValue = QLabel("{:n}".format(self.theProject.currWCount))
self.mainForm.addWidget(self.headLabel, 0, 0, 1, 2, Qt.AlignTop)
self.mainForm.addWidget(self.nameLabel, 1, 0, 1, 1, Qt.AlignTop)
self.mainForm.addWidget(self.nameValue, 1, 1, 1, 1, Qt.AlignTop)
self.mainForm.addWidget(self.pathLabel, 2, 0, 1, 1, Qt.AlignTop)
self.mainForm.addWidget(self.pathValue, 2, 1, 1, 1, Qt.AlignTop)
self.mainForm.addWidget(self.revLabel, 3, 0, 1, 1, Qt.AlignTop)
self.mainForm.addWidget(self.revValue, 3, 1, 1, 1, Qt.AlignTop)
self.mainForm.addWidget(self.statsLabel, 4, 0, 1, 2, Qt.AlignTop)
self.mainForm.addWidget(self.nRootLabel, 5, 0, 1, 1, Qt.AlignTop)
self.mainForm.addWidget(self.nRootValue, 5, 1, 1, 1, Qt.AlignTop)
self.mainForm.addWidget(self.nDirLabel, 6, 0, 1, 1, Qt.AlignTop)
self.mainForm.addWidget(self.nDirValue, 6, 1, 1, 1, Qt.AlignTop)
self.mainForm.addWidget(self.nFileLabel, 7, 0, 1, 1, Qt.AlignTop)
self.mainForm.addWidget(self.nFileValue, 7, 1, 1, 1, Qt.AlignTop)
self.mainForm.addWidget(self.wordsLabel, 8, 0, 1, 1, Qt.AlignTop)
self.mainForm.addWidget(self.wordsValue, 8, 1, 1, 1, Qt.AlignTop)
self.mainForm.setVerticalSpacing(6)
self.mainForm.setHorizontalSpacing(12)
self.mainForm.setColumnStretch(0, 0)
self.mainForm.setColumnStretch(1, 1)
self.mainForm.setRowStretch(10, 1)
return
# END Class GuiProjectEditMeta
class GuiProjectEditStatus(QWidget):
def __init__(self, theParent, theProject, isStatus):
QWidget.__init__(self, theParent)
self.theParent = theParent
self.theProject = theProject
if isStatus:
self.theStatus = self.theProject.statusItems
else:
self.theStatus = self.theProject.importItems
self.colData = [] self.colData = []
self.colCounts = [] self.colCounts = []
self.colChanged = False self.colChanged = False
self.selColour = None self.selColour = None
self.outerBox = QVBoxLayout()
self.mainBox = QHBoxLayout() self.mainBox = QHBoxLayout()
self.mainForm = QVBoxLayout() self.mainForm = QVBoxLayout()
@@ -208,7 +307,13 @@ class GuiProjectEditStatus(QWidget):
self.mainBox.addWidget(self.listBox) self.mainBox.addWidget(self.listBox)
self.mainBox.addLayout(self.mainForm) self.mainBox.addLayout(self.mainForm)
self.setLayout(self.mainBox) if isStatus:
self.outerBox.addWidget(QLabel("<b>Novel File Status Levels</b>"))
else:
self.outerBox.addWidget(QLabel("<b>Note File Importance Levels</b>"))
self.outerBox.addLayout(self.mainBox)
self.setLayout(self.outerBox)
return return
@@ -374,6 +479,7 @@ class GuiProjectEditReplace(QWidget):
self.bottomBox.addWidget(self.addButton) self.bottomBox.addWidget(self.addButton)
self.bottomBox.addWidget(self.delButton) self.bottomBox.addWidget(self.delButton)
self.outerBox.addWidget(QLabel("<b>Text Replace List for Preview and Export</b>"))
self.outerBox.addWidget(self.listBox) self.outerBox.addWidget(self.listBox)
self.outerBox.addLayout(self.bottomBox) self.outerBox.addLayout(self.bottomBox)
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
+3 -3
View File
@@ -8,7 +8,7 @@ from nwtools import *
from os import path, unlink from os import path, unlink
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from nw.gui.dialogs.projecteditor import GuiProjectEditor from nw.gui.dialogs.projecteditor import GuiProjectSettings
from nw.gui.dialogs.itemeditor import GuiItemEditor from nw.gui.dialogs.itemeditor import GuiItemEditor
from nw.constants import * from nw.constants import *
@@ -262,7 +262,7 @@ def testProjectEditor(qtbot, nwTempGUI, nwRef, nwTemp):
assert nwGUI.newProject(nwTempGUI, True) assert nwGUI.newProject(nwTempGUI, True)
nwGUI.mainConf.backupPath = nwTempGUI nwGUI.mainConf.backupPath = nwTempGUI
projEdit = GuiProjectEditor(nwGUI, nwGUI.theProject) projEdit = GuiProjectSettings(nwGUI, nwGUI.theProject)
qtbot.addWidget(projEdit) qtbot.addWidget(projEdit)
for c in "Project Name": for c in "Project Name":
@@ -314,7 +314,7 @@ def testProjectEditor(qtbot, nwTempGUI, nwRef, nwTemp):
projEdit._doSave() projEdit._doSave()
# Open again, and check project settings # Open again, and check project settings
projEdit = GuiProjectEditor(nwGUI, nwGUI.theProject) projEdit = GuiProjectSettings(nwGUI, nwGUI.theProject)
qtbot.addWidget(projEdit) qtbot.addWidget(projEdit)
assert projEdit.tabMain.editName.text() == "Project Name" assert projEdit.tabMain.editName.text() == "Project Name"
assert projEdit.tabMain.editTitle.text() == "Project Title" assert projEdit.tabMain.editTitle.text() == "Project Title"