Merge branch 'master' into fix_qt55_support
This commit is contained in:
+27
-2
@@ -68,8 +68,8 @@ class NWProject():
|
||||
self.projChanged = False # The project has unsaved changes
|
||||
self.projAltered = False # The project has been altered this session
|
||||
self.lockedBy = None # Data on which computer has the project open
|
||||
self.saveCount = None # Meta data: number of saves
|
||||
self.autoCount = None # Meta data: number of automatic saves
|
||||
self.saveCount = 0 # Meta data: number of saves
|
||||
self.autoCount = 0 # Meta data: number of automatic saves
|
||||
|
||||
# Class Settings
|
||||
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
|
||||
few starter items.
|
||||
"""
|
||||
self.projName = "New Project"
|
||||
hNovel = self.newRoot("Novel", nwItemClass.NOVEL)
|
||||
hChars = self.newRoot("Characters", nwItemClass.CHARACTER)
|
||||
hWorld = self.newRoot("Plot", nwItemClass.PLOT)
|
||||
@@ -1233,6 +1234,30 @@ class NWTree():
|
||||
self._handleSeed = theSeed
|
||||
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
|
||||
##
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ from nw.gui.dialogs.configeditor import GuiConfigEditor
|
||||
from nw.gui.dialogs.docmerge import GuiDocMerge
|
||||
from nw.gui.dialogs.docsplit import GuiDocSplit
|
||||
from nw.gui.dialogs.itemeditor import GuiItemEditor
|
||||
from nw.gui.dialogs.projecteditor import GuiProjectEditor
|
||||
from nw.gui.dialogs.projectsettings import GuiProjectSettings
|
||||
from nw.gui.dialogs.projectload import GuiProjectLoad
|
||||
from nw.gui.dialogs.sessionlog import GuiSessionLogView
|
||||
|
||||
@@ -44,7 +44,7 @@ __all__ = [
|
||||
"GuiDocMerge",
|
||||
"GuiDocSplit",
|
||||
"GuiItemEditor",
|
||||
"GuiProjectEditor",
|
||||
"GuiProjectSettings",
|
||||
"GuiProjectLoad",
|
||||
"GuiSessionLogView",
|
||||
"GuiDocDetails",
|
||||
|
||||
@@ -97,7 +97,7 @@ class QConfigLayout(QGridLayout):
|
||||
qLabel = None
|
||||
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.setRowStretch(self._nextRow, 0)
|
||||
@@ -141,19 +141,19 @@ class QConfigLayout(QGridLayout):
|
||||
labelBox.setSpacing(0)
|
||||
|
||||
thisEntry["help"] = qHelp
|
||||
self.addLayout(labelBox, self._nextRow, 0, Qt.AlignLeft)
|
||||
self.addLayout(labelBox, self._nextRow, 0, 1, 1, Qt.AlignLeft | Qt.AlignTop)
|
||||
|
||||
else:
|
||||
self.addWidget(qLabel, self._nextRow, 0, Qt.AlignLeft)
|
||||
self.addWidget(qLabel, self._nextRow, 0, 1, 1, Qt.AlignLeft | Qt.AlignTop)
|
||||
|
||||
if theUnit is not None:
|
||||
controlBox = QHBoxLayout()
|
||||
controlBox.addWidget(qWidget, 0, Qt.AlignVCenter)
|
||||
controlBox.addWidget(QLabel(theUnit), 0, Qt.AlignVCenter)
|
||||
controlBox.setSpacing(8)
|
||||
self.addLayout(controlBox, self._nextRow, 1, Qt.AlignRight)
|
||||
self.addLayout(controlBox, self._nextRow, 1, 1, 1, Qt.AlignRight | Qt.AlignVCenter)
|
||||
else:
|
||||
self.addWidget(qWidget, self._nextRow, 1, Qt.AlignRight)
|
||||
self.addWidget(qWidget, self._nextRow, 1, 1, 1, Qt.AlignRight | Qt.AlignVCenter)
|
||||
|
||||
qLabel.setBuddy(qWidget)
|
||||
|
||||
|
||||
+1
-1
@@ -205,7 +205,7 @@ class GuiBuildNovel(QDialog):
|
||||
self.novelFiles.setChecked(
|
||||
self.optState.getBool("GuiBuildNovel", "addNovel", True)
|
||||
)
|
||||
|
||||
|
||||
self.noteFiles = QSwitch()
|
||||
self.noteFiles.setChecked(
|
||||
self.optState.getBool("GuiBuildNovel", "addNotes", False)
|
||||
|
||||
@@ -5,7 +5,7 @@ from nw.gui.dialogs.configeditor import GuiConfigEditor
|
||||
from nw.gui.dialogs.docmerge import GuiDocMerge
|
||||
from nw.gui.dialogs.docsplit import GuiDocSplit
|
||||
from nw.gui.dialogs.itemeditor import GuiItemEditor
|
||||
from nw.gui.dialogs.projecteditor import GuiProjectEditor
|
||||
from nw.gui.dialogs.projectsettings import GuiProjectSettings
|
||||
from nw.gui.dialogs.projectload import GuiProjectLoad
|
||||
from nw.gui.dialogs.sessionlog import GuiSessionLogView
|
||||
|
||||
@@ -15,7 +15,7 @@ __all__ = [
|
||||
"GuiDocMerge",
|
||||
"GuiDocSplit",
|
||||
"GuiItemEditor",
|
||||
"GuiProjectEditor",
|
||||
"GuiProjectSettings",
|
||||
"GuiProjectLoad",
|
||||
"GuiSessionLogView",
|
||||
]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""novelWriter GUI Project Editor
|
||||
"""novelWriter GUI Project Settings
|
||||
|
||||
novelWriter – GUI Project Editor
|
||||
===================================
|
||||
Class holding the project editor
|
||||
novelWriter – GUI Project Settings
|
||||
====================================
|
||||
Class holding the project settings dialog
|
||||
|
||||
File History:
|
||||
Created: 2018-09-29 [0.0.1]
|
||||
@@ -38,16 +38,16 @@ from PyQt5.QtWidgets import (
|
||||
)
|
||||
|
||||
from nw.constants import nwAlert
|
||||
from nw.gui.additions import QSwitch, PagedDialog
|
||||
from nw.gui.additions import QSwitch, PagedDialog, QConfigLayout
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class GuiProjectEditor(PagedDialog):
|
||||
class GuiProjectSettings(PagedDialog):
|
||||
|
||||
def __init__(self, theParent, theProject):
|
||||
PagedDialog.__init__(self, theParent)
|
||||
|
||||
logger.debug("Initialising ProjectEditor ...")
|
||||
logger.debug("Initialising GuiProjectSettings ...")
|
||||
|
||||
self.mainConf = nw.CONFIG
|
||||
self.theParent = theParent
|
||||
@@ -57,11 +57,13 @@ class GuiProjectEditor(PagedDialog):
|
||||
self.setWindowTitle("Project Settings")
|
||||
|
||||
self.tabMain = GuiProjectEditMain(self.theParent, self.theProject)
|
||||
self.tabStatus = GuiProjectEditStatus(self.theParent, self.theProject.statusItems)
|
||||
self.tabImport = GuiProjectEditStatus(self.theParent, self.theProject.importItems)
|
||||
self.tabMeta = GuiProjectEditMeta(self.theParent, self.theProject)
|
||||
self.tabStatus = GuiProjectEditStatus(self.theParent, self.theProject, True)
|
||||
self.tabImport = GuiProjectEditStatus(self.theParent, self.theProject, False)
|
||||
self.tabReplace = GuiProjectEditReplace(self.theParent, self.theProject)
|
||||
|
||||
self.addTab(self.tabMain, "Settings")
|
||||
self.addTab(self.tabMeta, "Details")
|
||||
self.addTab(self.tabStatus, "Status")
|
||||
self.addTab(self.tabImport, "Importance")
|
||||
self.addTab(self.tabReplace,"Auto-Replace")
|
||||
@@ -73,12 +75,12 @@ class GuiProjectEditor(PagedDialog):
|
||||
|
||||
self.show()
|
||||
|
||||
logger.debug("ProjectEditor initialisation complete")
|
||||
logger.debug("GuiProjectSettings initialisation complete")
|
||||
|
||||
return
|
||||
|
||||
def _doSave(self):
|
||||
logger.verbose("ProjectEditor save button clicked")
|
||||
logger.verbose("GuiProjectSettings save button clicked")
|
||||
|
||||
projName = self.tabMain.editName.text()
|
||||
bookTitle = self.tabMain.editTitle.text()
|
||||
@@ -106,69 +108,166 @@ class GuiProjectEditor(PagedDialog):
|
||||
return
|
||||
|
||||
def _doClose(self):
|
||||
logger.verbose("ProjectEditor close button clicked")
|
||||
logger.verbose("GuiProjectSettings close button clicked")
|
||||
self.close()
|
||||
return
|
||||
|
||||
# END Class GuiProjectEditor
|
||||
# END Class GuiProjectSettings
|
||||
|
||||
class GuiProjectEditMain(QWidget):
|
||||
|
||||
def __init__(self, theParent, theProject):
|
||||
QWidget.__init__(self, theParent)
|
||||
|
||||
self.theParent = theParent
|
||||
self.theProject = theProject
|
||||
self.mainForm = QGridLayout()
|
||||
self.backupBox = QHBoxLayout()
|
||||
self.theParent = theParent
|
||||
self.theProject = theProject
|
||||
|
||||
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.setFixedWidth(250)
|
||||
self.editName.setText(self.theProject.projName)
|
||||
self.mainForm.addRow(
|
||||
"Working title",
|
||||
self.editName,
|
||||
"Should be set only once."
|
||||
)
|
||||
|
||||
self.editTitle = QLineEdit()
|
||||
self.editTitle.setMaxLength(200)
|
||||
self.editTitle.setFixedWidth(250)
|
||||
self.editTitle.setText(self.theProject.bookTitle)
|
||||
self.mainForm.addRow(
|
||||
"Novel title",
|
||||
self.editTitle,
|
||||
"Change whenever you want!"
|
||||
)
|
||||
|
||||
self.editAuthors = QPlainTextEdit()
|
||||
bookAuthors = ""
|
||||
for bookAuthor in self.theProject.bookAuthors:
|
||||
bookAuthors += bookAuthor+"\n"
|
||||
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.setChecked(not self.theProject.doBackup)
|
||||
self.backupBox.addStretch(1)
|
||||
self.backupBox.addWidget(QLabel("Disable backup on close"))
|
||||
self.backupBox.addWidget(self.doBackup)
|
||||
|
||||
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)
|
||||
self.mainForm.addRow(
|
||||
"No backup on close",
|
||||
self.doBackup,
|
||||
"Overrides main preferences."
|
||||
)
|
||||
|
||||
return
|
||||
|
||||
# END Class GuiProjectEditMain
|
||||
|
||||
class GuiProjectEditStatus(QWidget):
|
||||
class GuiProjectEditMeta(QWidget):
|
||||
|
||||
def __init__(self, theParent, theStatus):
|
||||
def __init__(self, theParent, theProject):
|
||||
QWidget.__init__(self, 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.colCounts = []
|
||||
self.colChanged = False
|
||||
self.selColour = None
|
||||
|
||||
self.outerBox = QVBoxLayout()
|
||||
self.mainBox = QHBoxLayout()
|
||||
self.mainForm = QVBoxLayout()
|
||||
|
||||
@@ -208,7 +307,13 @@ class GuiProjectEditStatus(QWidget):
|
||||
self.mainBox.addWidget(self.listBox)
|
||||
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
|
||||
|
||||
@@ -374,6 +479,7 @@ class GuiProjectEditReplace(QWidget):
|
||||
self.bottomBox.addWidget(self.addButton)
|
||||
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.addLayout(self.bottomBox)
|
||||
self.setLayout(self.outerBox)
|
||||
@@ -32,7 +32,9 @@ from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtGui import QFont
|
||||
from PyQt5.QtWidgets import QFrame, QGridLayout, QLabel
|
||||
|
||||
from nw.constants import nwLabels, nwItemClass, nwItemType, nwUnicode
|
||||
from nw.constants import (
|
||||
nwLabels, nwItemClass, nwItemType, nwItemLayout, nwUnicode
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -143,27 +145,27 @@ class GuiDocDetails(QFrame):
|
||||
self.pCountData.setAlignment(Qt.AlignRight)
|
||||
|
||||
# Assemble
|
||||
self.mainBox.addWidget(self.labelName, 0, 0, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.labelFlag, 0, 1, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.labelData, 0, 2, 1, 3, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.labelName, 0, 0, 1, 1)
|
||||
self.mainBox.addWidget(self.labelFlag, 0, 1, 1, 1)
|
||||
self.mainBox.addWidget(self.labelData, 0, 2, 1, 3)
|
||||
|
||||
self.mainBox.addWidget(self.statusName, 1, 0, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.statusFlag, 1, 1, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.statusData, 1, 2, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.cCountName, 1, 3, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.cCountData, 1, 4, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.statusName, 1, 0, 1, 1)
|
||||
self.mainBox.addWidget(self.statusFlag, 1, 1, 1, 1)
|
||||
self.mainBox.addWidget(self.statusData, 1, 2, 1, 1)
|
||||
self.mainBox.addWidget(self.cCountName, 1, 3, 1, 1)
|
||||
self.mainBox.addWidget(self.cCountData, 1, 4, 1, 1)
|
||||
|
||||
self.mainBox.addWidget(self.className, 2, 0, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.classFlag, 2, 1, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.classData, 2, 2, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.wCountName, 2, 3, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.wCountData, 2, 4, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.className, 2, 0, 1, 1)
|
||||
self.mainBox.addWidget(self.classFlag, 2, 1, 1, 1)
|
||||
self.mainBox.addWidget(self.classData, 2, 2, 1, 1)
|
||||
self.mainBox.addWidget(self.wCountName, 2, 3, 1, 1)
|
||||
self.mainBox.addWidget(self.wCountData, 2, 4, 1, 1)
|
||||
|
||||
self.mainBox.addWidget(self.layoutName, 3, 0, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.layoutFlag, 3, 1, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.layoutData, 3, 2, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.pCountName, 3, 3, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.pCountData, 3, 4, 1, 1, Qt.AlignTop)
|
||||
self.mainBox.addWidget(self.layoutName, 3, 0, 1, 1)
|
||||
self.mainBox.addWidget(self.layoutFlag, 3, 1, 1, 1)
|
||||
self.mainBox.addWidget(self.layoutData, 3, 2, 1, 1)
|
||||
self.mainBox.addWidget(self.pCountName, 3, 3, 1, 1)
|
||||
self.mainBox.addWidget(self.pCountData, 3, 4, 1, 1)
|
||||
|
||||
self.mainBox.setColumnStretch(0,0)
|
||||
self.mainBox.setColumnStretch(1,0)
|
||||
@@ -221,7 +223,10 @@ class GuiDocDetails(QFrame):
|
||||
self.labelFlag.setText(exportFlag)
|
||||
self.statusFlag.setPixmap(flagIcon.pixmap(10, 10))
|
||||
self.classFlag.setText(nwLabels.CLASS_FLAG[nwItem.itemClass])
|
||||
self.layoutFlag.setText(nwLabels.LAYOUT_FLAG[nwItem.itemLayout])
|
||||
if nwItem.itemLayout == nwItemLayout.NO_LAYOUT:
|
||||
self.layoutFlag.setText("-")
|
||||
else:
|
||||
self.layoutFlag.setText(nwLabels.LAYOUT_FLAG[nwItem.itemLayout])
|
||||
|
||||
self.labelData.setText(theLabel)
|
||||
self.statusData.setText(nwItem.itemStatus)
|
||||
|
||||
@@ -228,7 +228,6 @@ class GuiDocEditor(QTextEdit):
|
||||
tHandle = self.theHandle
|
||||
self.clearEditor()
|
||||
self.loadText(tHandle, showStatus=False)
|
||||
self.updateDocMargins()
|
||||
return
|
||||
|
||||
def loadText(self, tHandle, tLine=None, showStatus=True):
|
||||
@@ -289,6 +288,7 @@ class GuiDocEditor(QTextEdit):
|
||||
"""
|
||||
self.setPlainText(theText)
|
||||
self.setDocumentChanged(True)
|
||||
self.updateDocMargins()
|
||||
return
|
||||
|
||||
def saveText(self):
|
||||
@@ -370,6 +370,7 @@ class GuiDocEditor(QTextEdit):
|
||||
"""
|
||||
if tHandle == self.theHandle:
|
||||
self.docTitle.setTitleFromHandle(self.theHandle)
|
||||
self.updateDocMargins()
|
||||
return
|
||||
|
||||
##
|
||||
|
||||
@@ -145,6 +145,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
self.theHandle = tHandle
|
||||
self.theProject.setLastViewed(tHandle)
|
||||
self.docTitle.setTitleFromHandle(self.theHandle)
|
||||
self.updateDocMargins()
|
||||
|
||||
# Make sure the main GUI knows we changed the content
|
||||
self.theParent.viewMeta.refreshReferences(tHandle)
|
||||
@@ -199,23 +200,11 @@ class GuiDocViewer(QTextBrowser):
|
||||
return False
|
||||
return True
|
||||
|
||||
def updateDocTitle(self, tHandle):
|
||||
"""Called when an item label is changed to check if the document
|
||||
title bar needs updating,
|
||||
def updateDocMargins(self):
|
||||
"""Automatically adjust the margins so the text is centred if
|
||||
Config.textFixedW is enabled or we're in Zen mode. Otherwise,
|
||||
just ensure the margins are set correctly.
|
||||
"""
|
||||
if tHandle == self.theHandle:
|
||||
self.docTitle.setTitleFromHandle(self.theHandle)
|
||||
return
|
||||
|
||||
##
|
||||
# Events
|
||||
##
|
||||
|
||||
def resizeEvent(self, theEvent):
|
||||
"""Make sure the document title is the same width as the window.
|
||||
"""
|
||||
QTextBrowser.resizeEvent(self, theEvent)
|
||||
|
||||
tB = self.lineWidth()
|
||||
tW = self.width() - 2*tB
|
||||
tH = self.docTitle.height()
|
||||
@@ -235,6 +224,26 @@ class GuiDocViewer(QTextBrowser):
|
||||
|
||||
return
|
||||
|
||||
def updateDocTitle(self, tHandle):
|
||||
"""Called when an item label is changed to check if the document
|
||||
title bar needs updating,
|
||||
"""
|
||||
if tHandle == self.theHandle:
|
||||
self.docTitle.setTitleFromHandle(self.theHandle)
|
||||
self.updateDocMargins()
|
||||
return
|
||||
|
||||
##
|
||||
# Events
|
||||
##
|
||||
|
||||
def resizeEvent(self, theEvent):
|
||||
"""Make sure the document title is the same width as the window.
|
||||
"""
|
||||
QTextBrowser.resizeEvent(self, theEvent)
|
||||
self.updateDocMargins()
|
||||
return
|
||||
|
||||
##
|
||||
# Internal Functions
|
||||
##
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ from PyQt5.QtWidgets import (
|
||||
from nw.gui import (
|
||||
GuiMainMenu, GuiMainStatus, GuiTheme, GuiDocTree, GuiDocEditor,
|
||||
GuiDocViewer, GuiDocDetails, GuiSearchBar, GuiNoticeBar, GuiDocViewDetails,
|
||||
GuiConfigEditor, GuiProjectEditor, GuiItemEditor, GuiProjectOutline,
|
||||
GuiConfigEditor, GuiProjectSettings, GuiItemEditor, GuiProjectOutline,
|
||||
GuiSessionLogView, GuiDocMerge, GuiDocSplit, GuiProjectLoad, GuiBuildNovel
|
||||
)
|
||||
from nw.core import NWProject, NWDoc, NWIndex
|
||||
@@ -749,7 +749,7 @@ class GuiMain(QMainWindow):
|
||||
"""Open the project settings dialog.
|
||||
"""
|
||||
if self.hasProject:
|
||||
dlgProj = GuiProjectEditor(self, self.theProject)
|
||||
dlgProj = GuiProjectSettings(self, self.theProject)
|
||||
dlgProj.exec_()
|
||||
self._setWindowTitle(self.theProject.projName)
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user