From 2bd2c81eaebafe0b6efb2026a6f914479424e749 Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Tue, 2 Jun 2020 09:23:23 +0200
Subject: [PATCH 01/10] Drop the hidden column in the project tree that holds
the item handle, and use the data setting instead
---
nw/gui/doctree.py | 29 ++++++++++++++---------------
nw/guimain.py | 2 +-
2 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/nw/gui/doctree.py b/nw/gui/doctree.py
index 2f4477af..f75724a9 100644
--- a/nw/gui/doctree.py
+++ b/nw/gui/doctree.py
@@ -47,7 +47,6 @@ class GuiDocTree(QTreeWidget):
C_COUNT = 1
C_EXPORT = 2
C_FLAGS = 3
- C_HANDLE = 4
def __init__(self, theParent, theProject):
QTreeWidget.__init__(self, theParent)
@@ -69,9 +68,8 @@ class GuiDocTree(QTreeWidget):
self.setIconSize(QSize(iPx, iPx))
self.setExpandsOnDoubleClick(True)
self.setIndentation(iPx)
- self.setColumnCount(5)
- self.setHeaderLabels(["Label", "Words", "Inc", "Flags", "Handle"])
- self.hideColumn(self.C_HANDLE)
+ self.setColumnCount(4)
+ self.setHeaderLabels(["Label", "Words", "Inc", "Flags"])
treeHead = self.headerItem()
treeHead.setTextAlignment(self.C_COUNT, Qt.AlignRight)
@@ -479,7 +477,7 @@ class GuiDocTree(QTreeWidget):
pCount = 0
for i in range(pItem.childCount()):
pCount += int(pItem.child(i).text(self.C_COUNT))
- pHandle = pItem.text(self.C_HANDLE)
+ pHandle = pItem.data(self.C_NAME, Qt.UserRole)
if not nDepth > 200 and pHandle != "":
self.propagateCount(pHandle, pCount, nDepth+1)
return
@@ -521,17 +519,17 @@ class GuiDocTree(QTreeWidget):
if len(selItem) == 0:
return None
if isinstance(selItem[0], QTreeWidgetItem):
- return selItem[0].text(self.C_HANDLE)
+ return selItem[0].data(self.C_NAME, Qt.UserRole)
return None
def getSelectedHandles(self):
"""Return a list of all currently selected item handles.
"""
- selItems = self.selectedItems()
+ selItems = self.selectedItems()
selHandles = []
for n in range(len(selItems)):
if isinstance(selItems[n], QTreeWidgetItem):
- selHandles.append(selItems[n].text(self.C_HANDLE))
+ selHandles.append(selItems[n].data(self.C_NAME, Qt.UserRole))
return selHandles
def setSelectedHandle(self, tHandle):
@@ -563,8 +561,8 @@ class GuiDocTree(QTreeWidget):
"""This is a recursive function returning all items in a tree
starting at a given QTreeWidgetItem.
"""
- tHandle = theItem.text(self.C_HANDLE)
- nwItem = self.theProject.projTree[tHandle]
+ tHandle = theItem.data(self.C_NAME, Qt.UserRole)
+ nwItem = self.theProject.projTree[tHandle]
nwItem.setExpanded(theItem.isExpanded())
nwItem.setOrder(theIndex)
theList.append(tHandle)
@@ -585,7 +583,6 @@ class GuiDocTree(QTreeWidget):
newItem.setText(self.C_COUNT, "0")
newItem.setText(self.C_EXPORT, "")
newItem.setText(self.C_FLAGS, "")
- newItem.setText(self.C_HANDLE, tHandle)
newItem.setTextAlignment(self.C_NAME, Qt.AlignLeft | Qt.AlignVCenter)
newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight | Qt.AlignVCenter)
@@ -596,6 +593,8 @@ class GuiDocTree(QTreeWidget):
newItem.setFont(self.C_COUNT, self.theTheme.guiFont)
newItem.setFont(self.C_FLAGS, self.theTheme.guiFont)
+ newItem.setData(self.C_NAME, Qt.UserRole, tHandle)
+
self.theMap[tHandle] = newItem
if pHandle is None:
if nwItem.itemType == nwItemType.ROOT:
@@ -649,10 +648,10 @@ class GuiDocTree(QTreeWidget):
newItem.setText(self.C_COUNT, "")
newItem.setText(self.C_EXPORT, "")
newItem.setText(self.C_FLAGS, "")
- newItem.setText(self.C_HANDLE, "")
self.addTopLevelItem(newItem)
self.orphRoot = newItem
newItem.setExpanded(True)
+ newItem.setData(self.C_NAME, "")
newItem.setIcon(self.C_NAME, self.theTheme.getIcon("warning"))
return
@@ -677,7 +676,7 @@ class GuiDocTree(QTreeWidget):
logger.error("Failed to find new parent item of %s" % tHandle)
return False
- pHandle = trItemP.text(self.C_HANDLE)
+ pHandle = trItemP.data(self.C_NAME, Qt.UserRole)
wC = int(trItemS.text(self.C_COUNT))
self.propagateCount(tHandle, -wC)
nwItemS.setParent(pHandle)
@@ -702,7 +701,7 @@ class GuiDocTree(QTreeWidget):
if trItemP is None:
logger.error("Failed to find new parent item of %s" % tHandle)
return
- pHandle = trItemP.text(self.C_HANDLE)
+ pHandle = trItemP.data(self.C_NAME, Qt.UserRole)
nwItemS.setParent(pHandle)
self.setTreeItemValues(tHandle)
self.theProject.setProjectChanged(True)
@@ -737,7 +736,7 @@ class GuiDocTree(QTreeWidget):
return
dItem = self.itemFromIndex(dIndex)
- dHandle = dItem.text(self.C_HANDLE)
+ dHandle = dItem.data(self.C_NAME, Qt.UserRole)
snItem = self.theProject.projTree[sHandle]
dnItem = self.theProject.projTree[dHandle]
if dnItem is None:
diff --git a/nw/guimain.py b/nw/guimain.py
index bfc98c71..1ae36848 100644
--- a/nw/guimain.py
+++ b/nw/guimain.py
@@ -1022,7 +1022,7 @@ class GuiMain(QMainWindow):
"""The user double-clicked an item in the tree. If it is a file,
we open it. Otherwise, we do nothing.
"""
- tHandle = tItem.text(self.treeView.C_HANDLE)
+ tHandle = tItem.data(self.treeView.C_NAME, Qt.UserRole)
logger.verbose("User double clicked tree item with handle %s" % tHandle)
nwItem = self.theProject.projTree[tHandle]
if nwItem is not None:
From 6cd76ff60b7a624d8e365bc472e81d286713521f Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Tue, 2 Jun 2020 09:25:52 +0200
Subject: [PATCH 02/10] Don't change focus from project tree to editor when
selecting file with enter key
---
nw/guimain.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/nw/guimain.py b/nw/guimain.py
index 1ae36848..ec00ea5c 100644
--- a/nw/guimain.py
+++ b/nw/guimain.py
@@ -466,14 +466,15 @@ class GuiMain(QMainWindow):
self.docEditor.clearEditor()
return True
- def openDocument(self, tHandle, tLine=None):
+ def openDocument(self, tHandle, tLine=None, changeFocus=True):
"""Open a specific document, optionally at a given line.
"""
if self.hasProject:
self.closeDocument()
self.tabWidget.setCurrentWidget(self.splitView)
if self.docEditor.loadText(tHandle, tLine):
- self.docEditor.setFocus()
+ if changeFocus:
+ self.docEditor.setFocus()
self.theProject.setLastEdited(tHandle)
self.treeView.setSelectedHandle(tHandle)
else:
@@ -1035,7 +1036,8 @@ class GuiMain(QMainWindow):
def _treeKeyPressReturn(self):
"""The user pressed return an item in the tree. If it is a file,
- we open it. Otherwise, we do nothing.
+ we open it. Otherwise, we do nothing. Pressing return does not
+ change focus to the editor as double click does.
"""
tHandle = self.treeView.getSelectedHandle()
logger.verbose("User pressed return on tree item with handle %s" % tHandle)
@@ -1043,7 +1045,7 @@ class GuiMain(QMainWindow):
if nwItem is not None:
if nwItem.itemType == nwItemType.FILE:
logger.verbose("Requested item %s is a file" % tHandle)
- self.openDocument(tHandle)
+ self.openDocument(tHandle, changeFocus=False)
else:
logger.verbose("Requested item %s is a folder" % tHandle)
return
From d2616c8af88f6f9bd9552c7d278821cb48bce994 Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Tue, 2 Jun 2020 10:05:15 +0200
Subject: [PATCH 03/10] Fix faulty column width calculation by Qt for the
Ubunut font
---
nw/gui/doctree.py | 38 ++++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/nw/gui/doctree.py b/nw/gui/doctree.py
index f75724a9..7449d5c3 100644
--- a/nw/gui/doctree.py
+++ b/nw/gui/doctree.py
@@ -31,7 +31,8 @@ import nw
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QFont, QColor, QIcon
from PyQt5.QtWidgets import (
- qApp, QTreeWidget, QTreeWidgetItem, QAbstractItemView, QMessageBox
+ qApp, QTreeWidget, QTreeWidgetItem, QAbstractItemView, QMessageBox,
+ QHeaderView
)
from nw.core import NWDoc
@@ -71,20 +72,27 @@ class GuiDocTree(QTreeWidget):
self.setColumnCount(4)
self.setHeaderLabels(["Label", "Words", "Inc", "Flags"])
- treeHead = self.headerItem()
- treeHead.setTextAlignment(self.C_COUNT, Qt.AlignRight)
- treeHead.setToolTip(self.C_NAME, "Item label")
- treeHead.setToolTip(self.C_COUNT, "Word count")
- treeHead.setToolTip(self.C_EXPORT, "Include in build")
- treeHead.setToolTip(self.C_FLAGS, "Status, class, and layout flags")
+ treeHeadItem = self.headerItem()
+ treeHeadItem.setTextAlignment(self.C_COUNT, Qt.AlignRight)
+ treeHeadItem.setToolTip(self.C_NAME, "Item label")
+ treeHeadItem.setToolTip(self.C_COUNT, "Word count")
+ treeHeadItem.setToolTip(self.C_EXPORT, "Include in build")
+ treeHeadItem.setToolTip(self.C_FLAGS, "Status, class, and layout flags")
# Force the font to fix font sizing issues on some platforms
# like Ubuntu. This must also be set when the rows are added.
self.setFont(self.theTheme.guiFont)
- treeHead.setFont(self.C_NAME, self.theTheme.guiFont)
- treeHead.setFont(self.C_COUNT,self.theTheme.guiFont)
- treeHead.setFont(self.C_EXPORT, self.theTheme.guiFont)
- treeHead.setFont(self.C_FLAGS, self.theTheme.guiFont)
+ treeHeadItem.setFont(self.C_NAME, self.theTheme.guiFont)
+ treeHeadItem.setFont(self.C_COUNT,self.theTheme.guiFont)
+ treeHeadItem.setFont(self.C_EXPORT, self.theTheme.guiFont)
+ treeHeadItem.setFont(self.C_FLAGS, self.theTheme.guiFont)
+
+ # Let the last column stretch, and set the minimum size to the
+ # size of the icon as the default Qt font metrics approach fails
+ # for some fonts like the Ubuntu font.
+ treeHeader = self.header()
+ treeHeader.setStretchLastSection(True)
+ treeHeader.setMinimumSectionSize(iPx+6)
# Allow Move by Drag & Drop
self.setDragEnabled(True)
@@ -100,10 +108,11 @@ class GuiDocTree(QTreeWidget):
# self.setSelectionBehavior(QAbstractItemView.SelectRows)
# Get user's column width preferences for NAME and COUNT
- for colN, colW in enumerate(self.mainConf.treeColWidth):
- self.setColumnWidth(colN, colW)
+ if len(self.mainConf.treeColWidth) <= 4:
+ for colN, colW in enumerate(self.mainConf.treeColWidth):
+ self.setColumnWidth(colN, colW)
- self.resizeColumnToContents(self.C_EXPORT)
+ # The last column should just auto-scale
self.resizeColumnToContents(self.C_FLAGS)
logger.debug("GuiDocTree initialisation complete")
@@ -284,6 +293,7 @@ class GuiDocTree(QTreeWidget):
retVals = [
self.columnWidth(0),
self.columnWidth(1),
+ self.columnWidth(2),
]
return retVals
From 91ad4bb07dc67a6880312d69510df0ef3692910f Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Tue, 2 Jun 2020 11:54:59 +0200
Subject: [PATCH 04/10] Renamed docdetails file to itemdetails
---
nw/__init__.py | 6 +++---
nw/gui/__init__.py | 4 ++--
nw/gui/{docdetails.py => itemdetails.py} | 8 ++++----
nw/guimain.py | 4 ++--
4 files changed, 11 insertions(+), 11 deletions(-)
rename nw/gui/{docdetails.py => itemdetails.py} (98%)
diff --git a/nw/__init__.py b/nw/__init__.py
index 61aa56bb..ce005764 100644
--- a/nw/__init__.py
+++ b/nw/__init__.py
@@ -172,7 +172,7 @@ def main(sysArgs=None):
debugLevel = logging.INFO
elif inOpt == "--debug":
debugLevel = logging.DEBUG
- logFormat = "[{asctime:}] {name:>30}:{lineno:<4d} {levelname:8} {message:}"
+ logFormat = "[{asctime:}] {name:>22}:{lineno:<4d} {levelname:8} {message:}"
elif inOpt == "--logfile":
logFile = inArg
toFile = True
@@ -180,7 +180,7 @@ def main(sysArgs=None):
toStd = False
elif inOpt == "--verbose":
debugLevel = VERBOSE
- logFormat = "[{asctime:}] {name:>30}:{lineno:<4d} {levelname:8} {message:}"
+ logFormat = "[{asctime:}] {name:>22}:{lineno:<4d} {levelname:8} {message:}"
elif inOpt == "--style":
qtStyle = inArg
elif inOpt == "--config":
@@ -196,7 +196,7 @@ def main(sysArgs=None):
CONFIG.cmdOpen = cmdOpen
# Set Logging
- logFmt = logging.Formatter(fmt=logFormat,datefmt="%Y-%m-%d %H:%M:%S",style="{")
+ logFmt = logging.Formatter(fmt=logFormat, datefmt="%Y-%m-%d %H:%M:%S", style="{")
if not logFile == "" and toFile:
if path.isfile(logFile+".bak"):
diff --git a/nw/gui/__init__.py b/nw/gui/__init__.py
index 28a7a654..1156abc0 100644
--- a/nw/gui/__init__.py
+++ b/nw/gui/__init__.py
@@ -5,12 +5,12 @@ from nw.gui.build import GuiBuildNovel
from nw.gui.docbars import GuiDocTitleBar
from nw.gui.docbars import GuiNoticeBar
from nw.gui.docbars import GuiSearchBar
-from nw.gui.docdetails import GuiDocDetails
from nw.gui.doceditor import GuiDocEditor
from nw.gui.docmerge import GuiDocMerge
from nw.gui.docsplit import GuiDocSplit
from nw.gui.doctree import GuiDocTree
from nw.gui.docviewer import GuiDocViewer
+from nw.gui.itemdetails import GuiItemDetails
from nw.gui.itemeditor import GuiItemEditor
from nw.gui.mainmenu import GuiMainMenu
from nw.gui.outline import GuiProjectOutline
@@ -29,12 +29,12 @@ __all__ = [
"GuiDocTitleBar",
"GuiNoticeBar",
"GuiSearchBar",
- "GuiDocDetails",
"GuiDocEditor",
"GuiDocMerge",
"GuiDocSplit",
"GuiDocTree",
"GuiDocViewer",
+ "GuiItemDetails",
"GuiItemEditor",
"GuiMainMenu",
"GuiProjectOutline",
diff --git a/nw/gui/docdetails.py b/nw/gui/itemdetails.py
similarity index 98%
rename from nw/gui/docdetails.py
rename to nw/gui/itemdetails.py
index 39bc6fe6..93ffb788 100644
--- a/nw/gui/docdetails.py
+++ b/nw/gui/itemdetails.py
@@ -38,12 +38,12 @@ from nw.constants import (
logger = logging.getLogger(__name__)
-class GuiDocDetails(QFrame):
+class GuiItemDetails(QFrame):
def __init__(self, theParent, theProject):
QFrame.__init__(self, theParent)
- logger.debug("Initialising DocDetails ...")
+ logger.debug("Initialising GuiItemDetails ...")
self.mainConf = nw.CONFIG
self.theParent = theParent
self.theProject = theProject
@@ -182,7 +182,7 @@ class GuiDocDetails(QFrame):
self.mainBox.setColumnMinimumWidth(1, flagWidth)
self.mainBox.setColumnMinimumWidth(4, countWidth)
- logger.debug("DocDetails initialisation complete")
+ logger.debug("GuiItemDetails initialisation complete")
return
@@ -262,4 +262,4 @@ class GuiDocDetails(QFrame):
return
-# END Class GuiDocDetails
+# END Class GuiItemDetails
diff --git a/nw/guimain.py b/nw/guimain.py
index ec00ea5c..6c547a9b 100644
--- a/nw/guimain.py
+++ b/nw/guimain.py
@@ -41,7 +41,7 @@ from PyQt5.QtWidgets import (
from nw.gui import (
GuiMainMenu, GuiMainStatus, GuiTheme, GuiDocTree, GuiDocEditor,
- GuiDocViewer, GuiDocDetails, GuiSearchBar, GuiNoticeBar, GuiDocViewDetails,
+ GuiDocViewer, GuiItemDetails, GuiSearchBar, GuiNoticeBar, GuiDocViewDetails,
GuiPreferences, GuiProjectSettings, GuiItemEditor, GuiProjectOutline,
GuiSessionLogView, GuiDocMerge, GuiDocSplit, GuiProjectLoad, GuiBuildNovel
)
@@ -96,7 +96,7 @@ class GuiMain(QMainWindow):
self.docViewer = GuiDocViewer(self, self.theProject)
self.viewMeta = GuiDocViewDetails(self, self.theProject)
self.searchBar = GuiSearchBar(self)
- self.treeMeta = GuiDocDetails(self, self.theProject)
+ self.treeMeta = GuiItemDetails(self, self.theProject)
self.projView = GuiProjectOutline(self, self.theProject)
self.mainMenu = GuiMainMenu(self, self.theProject)
From 73b02be9b36cc4f73ab929dd5310bd538b14ea8b Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Tue, 2 Jun 2020 11:55:21 +0200
Subject: [PATCH 05/10] Removed handle column from outline
---
nw/constants/constants.py | 1 -
nw/constants/enum.py | 31 +++++++++++++++----------------
nw/gui/outline.py | 18 ++++++++++--------
3 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/nw/constants/constants.py b/nw/constants/constants.py
index 92378a73..66b026fc 100644
--- a/nw/constants/constants.py
+++ b/nw/constants/constants.py
@@ -136,7 +136,6 @@ class nwLabels():
}
OUTLINE_COLS = {
nwOutline.TITLE : "Title",
- nwOutline.HANDLE : "Handle",
nwOutline.LEVEL : "Level",
nwOutline.LABEL : "Document",
nwOutline.LINE : "Line",
diff --git a/nw/constants/enum.py b/nw/constants/enum.py
index c4a0f031..ee33c575 100644
--- a/nw/constants/enum.py
+++ b/nw/constants/enum.py
@@ -107,21 +107,20 @@ class nwAlert(Enum):
class nwOutline(Enum):
TITLE = 0
- HANDLE = 1
- LEVEL = 2
- LABEL = 3
- LINE = 4
- CCOUNT = 5
- WCOUNT = 6
- PCOUNT = 7
- POV = 8
- CHAR = 9
- PLOT = 10
- TIME = 11
- WORLD = 12
- OBJECT = 13
- ENTITY = 14
- CUSTOM = 15
- SYNOP = 16
+ LEVEL = 1
+ LABEL = 2
+ LINE = 3
+ CCOUNT = 4
+ WCOUNT = 5
+ PCOUNT = 6
+ POV = 7
+ CHAR = 8
+ PLOT = 9
+ TIME = 10
+ WORLD = 11
+ OBJECT = 12
+ ENTITY = 13
+ CUSTOM = 14
+ SYNOP = 15
# END Enum nwOutline
diff --git a/nw/gui/outline.py b/nw/gui/outline.py
index 982f21c9..0636cddc 100644
--- a/nw/gui/outline.py
+++ b/nw/gui/outline.py
@@ -30,7 +30,7 @@ import nw
from time import time
-from PyQt5.QtCore import Qt
+from PyQt5.QtCore import Qt, QSize
from PyQt5.QtWidgets import (
QTreeWidget, QTreeWidgetItem, QMenu, QAction, QAbstractItemView
)
@@ -43,7 +43,6 @@ class GuiProjectOutline(QTreeWidget):
DEF_WIDTH = {
nwOutline.TITLE : 200,
- nwOutline.HANDLE : 0,
nwOutline.LEVEL : 40,
nwOutline.LABEL : 150,
nwOutline.LINE : 40,
@@ -63,7 +62,6 @@ class GuiProjectOutline(QTreeWidget):
DEF_HIDDEN = {
nwOutline.TITLE : False,
- nwOutline.HANDLE : True,
nwOutline.LEVEL : True,
nwOutline.LABEL : False,
nwOutline.LINE : True,
@@ -103,6 +101,10 @@ class GuiProjectOutline(QTreeWidget):
self.setDragEnabled(False)
self.itemDoubleClicked.connect(self._treeDoubleClick)
+ iPx = self.theTheme.textIconSize
+ self.setIconSize(QSize(iPx, iPx))
+ self.setIndentation(iPx)
+
self.treeHead = self.header()
self.treeHead.setContextMenuPolicy(Qt.CustomContextMenu)
self.treeHead.customContextMenuRequested.connect(self._headerRightClick)
@@ -187,7 +189,7 @@ class GuiProjectOutline(QTreeWidget):
clicked, and send it to the main gui class for opening in the
document editor.
"""
- tHandle = tItem.text(self.colIndex[nwOutline.HANDLE])
+ tHandle = tItem.data(self.colIndex[nwOutline.TITLE], Qt.UserRole)
try:
tLine = int(tItem.text(self.colIndex[nwOutline.LINE]))
except:
@@ -332,7 +334,6 @@ class GuiProjectOutline(QTreeWidget):
# Make sure title column is always visible,
# and handle column always hidden
self.setColumnHidden(self.colIndex[nwOutline.TITLE], False)
- self.setColumnHidden(self.colIndex[nwOutline.HANDLE], True)
headItem = self.headerItem()
headItem.setTextAlignment(self.colIndex[nwOutline.CCOUNT], Qt.AlignRight)
@@ -408,7 +409,8 @@ class GuiProjectOutline(QTreeWidget):
newItem = QTreeWidgetItem()
newItem.setText(self.colIndex[nwOutline.TITLE], novIdx["title"])
- newItem.setText(self.colIndex[nwOutline.HANDLE], tHandle)
+ newItem.setData(self.colIndex[nwOutline.TITLE], Qt.UserRole, tHandle)
+ newItem.setIcon(self.colIndex[nwOutline.TITLE], self.theTheme.getIcon("proj_document"))
newItem.setText(self.colIndex[nwOutline.LEVEL], novIdx["level"])
newItem.setText(self.colIndex[nwOutline.LABEL], nwItem.itemName)
newItem.setText(self.colIndex[nwOutline.LINE], sTitle[1:].lstrip("0"))
@@ -451,7 +453,7 @@ class GuiOutlineHeaderMenu(QMenu):
self.actionMap = {}
for hItem in nwOutline:
- if hItem == nwOutline.TITLE or hItem == nwOutline.HANDLE:
+ if hItem == nwOutline.TITLE:
continue
self.actionMap[hItem] = QAction(nwLabels.OUTLINE_COLS[hItem], self)
self.actionMap[hItem].setCheckable(True)
@@ -469,7 +471,7 @@ class GuiOutlineHeaderMenu(QMenu):
self.acceptToggle = False
for hItem in nwOutline:
- if hItem == nwOutline.TITLE or hItem == nwOutline.HANDLE or hItem not in hiddenState:
+ if hItem == nwOutline.TITLE or hItem not in hiddenState:
continue
self.actionMap[hItem].setChecked(not hiddenState[hItem])
From 1dff34779e46a6dd229a0d400852e6c28747c26a Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Tue, 2 Jun 2020 11:58:08 +0200
Subject: [PATCH 06/10] Renamed tje two project dialog files to something a bit
shorter
---
nw/__init__.py | 4 ++--
nw/gui/__init__.py | 4 ++--
nw/gui/{projectload.py => projload.py} | 0
nw/gui/{projectsettings.py => projsettings.py} | 0
4 files changed, 4 insertions(+), 4 deletions(-)
rename nw/gui/{projectload.py => projload.py} (100%)
rename nw/gui/{projectsettings.py => projsettings.py} (100%)
diff --git a/nw/__init__.py b/nw/__init__.py
index ce005764..e0696373 100644
--- a/nw/__init__.py
+++ b/nw/__init__.py
@@ -172,7 +172,7 @@ def main(sysArgs=None):
debugLevel = logging.INFO
elif inOpt == "--debug":
debugLevel = logging.DEBUG
- logFormat = "[{asctime:}] {name:>22}:{lineno:<4d} {levelname:8} {message:}"
+ logFormat = "[{asctime:}] {name:>20}:{lineno:<4d} {levelname:8} {message:}"
elif inOpt == "--logfile":
logFile = inArg
toFile = True
@@ -180,7 +180,7 @@ def main(sysArgs=None):
toStd = False
elif inOpt == "--verbose":
debugLevel = VERBOSE
- logFormat = "[{asctime:}] {name:>22}:{lineno:<4d} {levelname:8} {message:}"
+ logFormat = "[{asctime:}] {name:>20}:{lineno:<4d} {levelname:8} {message:}"
elif inOpt == "--style":
qtStyle = inArg
elif inOpt == "--config":
diff --git a/nw/gui/__init__.py b/nw/gui/__init__.py
index 1156abc0..335c6b8f 100644
--- a/nw/gui/__init__.py
+++ b/nw/gui/__init__.py
@@ -15,8 +15,8 @@ from nw.gui.itemeditor import GuiItemEditor
from nw.gui.mainmenu import GuiMainMenu
from nw.gui.outline import GuiProjectOutline
from nw.gui.preferences import GuiPreferences
-from nw.gui.projectload import GuiProjectLoad
-from nw.gui.projectsettings import GuiProjectSettings
+from nw.gui.projload import GuiProjectLoad
+from nw.gui.projsettings import GuiProjectSettings
from nw.gui.sessionlog import GuiSessionLogView
from nw.gui.statusbar import GuiMainStatus
from nw.gui.theme import GuiIcons
diff --git a/nw/gui/projectload.py b/nw/gui/projload.py
similarity index 100%
rename from nw/gui/projectload.py
rename to nw/gui/projload.py
diff --git a/nw/gui/projectsettings.py b/nw/gui/projsettings.py
similarity index 100%
rename from nw/gui/projectsettings.py
rename to nw/gui/projsettings.py
From 0ca197e283f713699575f5653964c960d4d848b9 Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Tue, 2 Jun 2020 12:00:12 +0200
Subject: [PATCH 07/10] Also renamed viewdetails to docdetails for consistency
---
nw/gui/__init__.py | 4 ++--
nw/gui/{viewdetails.py => docdetails.py} | 0
2 files changed, 2 insertions(+), 2 deletions(-)
rename nw/gui/{viewdetails.py => docdetails.py} (100%)
diff --git a/nw/gui/__init__.py b/nw/gui/__init__.py
index 335c6b8f..6079c676 100644
--- a/nw/gui/__init__.py
+++ b/nw/gui/__init__.py
@@ -5,6 +5,7 @@ from nw.gui.build import GuiBuildNovel
from nw.gui.docbars import GuiDocTitleBar
from nw.gui.docbars import GuiNoticeBar
from nw.gui.docbars import GuiSearchBar
+from nw.gui.docdetails import GuiDocViewDetails
from nw.gui.doceditor import GuiDocEditor
from nw.gui.docmerge import GuiDocMerge
from nw.gui.docsplit import GuiDocSplit
@@ -21,7 +22,6 @@ from nw.gui.sessionlog import GuiSessionLogView
from nw.gui.statusbar import GuiMainStatus
from nw.gui.theme import GuiIcons
from nw.gui.theme import GuiTheme
-from nw.gui.viewdetails import GuiDocViewDetails
__all__ = [
"GuiAbout",
@@ -29,6 +29,7 @@ __all__ = [
"GuiDocTitleBar",
"GuiNoticeBar",
"GuiSearchBar",
+ "GuiDocViewDetails",
"GuiDocEditor",
"GuiDocMerge",
"GuiDocSplit",
@@ -45,5 +46,4 @@ __all__ = [
"GuiMainStatus",
"GuiIcons",
"GuiTheme",
- "GuiDocViewDetails",
]
diff --git a/nw/gui/viewdetails.py b/nw/gui/docdetails.py
similarity index 100%
rename from nw/gui/viewdetails.py
rename to nw/gui/docdetails.py
From 807937caa9a32fb6937e40371e2bb2a117a87e23 Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Tue, 2 Jun 2020 12:02:36 +0200
Subject: [PATCH 08/10] And renamed doctree to projecttree
---
nw/gui/__init__.py | 4 ++--
nw/gui/{doctree.py => projtree.py} | 8 ++++----
nw/guimain.py | 4 ++--
3 files changed, 8 insertions(+), 8 deletions(-)
rename nw/gui/{doctree.py => projtree.py} (99%)
diff --git a/nw/gui/__init__.py b/nw/gui/__init__.py
index 6079c676..4df869b5 100644
--- a/nw/gui/__init__.py
+++ b/nw/gui/__init__.py
@@ -9,7 +9,6 @@ from nw.gui.docdetails import GuiDocViewDetails
from nw.gui.doceditor import GuiDocEditor
from nw.gui.docmerge import GuiDocMerge
from nw.gui.docsplit import GuiDocSplit
-from nw.gui.doctree import GuiDocTree
from nw.gui.docviewer import GuiDocViewer
from nw.gui.itemdetails import GuiItemDetails
from nw.gui.itemeditor import GuiItemEditor
@@ -18,6 +17,7 @@ from nw.gui.outline import GuiProjectOutline
from nw.gui.preferences import GuiPreferences
from nw.gui.projload import GuiProjectLoad
from nw.gui.projsettings import GuiProjectSettings
+from nw.gui.projtree import GuiProjectTree
from nw.gui.sessionlog import GuiSessionLogView
from nw.gui.statusbar import GuiMainStatus
from nw.gui.theme import GuiIcons
@@ -33,7 +33,6 @@ __all__ = [
"GuiDocEditor",
"GuiDocMerge",
"GuiDocSplit",
- "GuiDocTree",
"GuiDocViewer",
"GuiItemDetails",
"GuiItemEditor",
@@ -42,6 +41,7 @@ __all__ = [
"GuiPreferences",
"GuiProjectLoad",
"GuiProjectSettings",
+ "GuiProjectTree",
"GuiSessionLogView",
"GuiMainStatus",
"GuiIcons",
diff --git a/nw/gui/doctree.py b/nw/gui/projtree.py
similarity index 99%
rename from nw/gui/doctree.py
rename to nw/gui/projtree.py
index 7449d5c3..72246c3a 100644
--- a/nw/gui/doctree.py
+++ b/nw/gui/projtree.py
@@ -42,7 +42,7 @@ from nw.constants import (
logger = logging.getLogger(__name__)
-class GuiDocTree(QTreeWidget):
+class GuiProjectTree(QTreeWidget):
C_NAME = 0
C_COUNT = 1
@@ -52,7 +52,7 @@ class GuiDocTree(QTreeWidget):
def __init__(self, theParent, theProject):
QTreeWidget.__init__(self, theParent)
- logger.debug("Initialising GuiDocTree ...")
+ logger.debug("Initialising GuiProjectTree ...")
self.mainConf = nw.CONFIG
self.theParent = theParent
self.theTheme = theParent.theTheme
@@ -115,7 +115,7 @@ class GuiDocTree(QTreeWidget):
# The last column should just auto-scale
self.resizeColumnToContents(self.C_FLAGS)
- logger.debug("GuiDocTree initialisation complete")
+ logger.debug("GuiProjectTree initialisation complete")
# Internal Mapping
self.makeAlert = self.theParent.makeAlert
@@ -782,4 +782,4 @@ class GuiDocTree(QTreeWidget):
return
-# END Class GuiDocTree
+# END Class GuiProjectTree
diff --git a/nw/guimain.py b/nw/guimain.py
index 6c547a9b..ea6c050e 100644
--- a/nw/guimain.py
+++ b/nw/guimain.py
@@ -40,7 +40,7 @@ from PyQt5.QtWidgets import (
)
from nw.gui import (
- GuiMainMenu, GuiMainStatus, GuiTheme, GuiDocTree, GuiDocEditor,
+ GuiMainMenu, GuiMainStatus, GuiTheme, GuiProjectTree, GuiDocEditor,
GuiDocViewer, GuiItemDetails, GuiSearchBar, GuiNoticeBar, GuiDocViewDetails,
GuiPreferences, GuiProjectSettings, GuiItemEditor, GuiProjectOutline,
GuiSessionLogView, GuiDocMerge, GuiDocSplit, GuiProjectLoad, GuiBuildNovel
@@ -91,7 +91,7 @@ class GuiMain(QMainWindow):
# Main GUI Elements
self.statusBar = GuiMainStatus(self)
self.noticeBar = GuiNoticeBar(self)
- self.treeView = GuiDocTree(self, self.theProject)
+ self.treeView = GuiProjectTree(self, self.theProject)
self.docEditor = GuiDocEditor(self, self.theProject)
self.docViewer = GuiDocViewer(self, self.theProject)
self.viewMeta = GuiDocViewDetails(self, self.theProject)
From 9af412e29a055dcfabfe9292f6f83c5c1392d086 Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Tue, 2 Jun 2020 20:32:47 +0200
Subject: [PATCH 09/10] Added some icons to the outline view
---
nw/assets/icons/fallback/hash-dark.svg | 55 +++++++++++++++++++
nw/assets/icons/fallback/hash.svg | 55 +++++++++++++++++++
nw/assets/icons/typicons_colour_dark/hash.svg | 55 +++++++++++++++++++
.../icons/typicons_colour_dark/icons.conf | 10 ++--
.../icons/typicons_colour_light/hash.svg | 55 +++++++++++++++++++
.../icons/typicons_colour_light/icons.conf | 10 ++--
nw/assets/icons/typicons_grey_dark/hash.svg | 55 +++++++++++++++++++
nw/assets/icons/typicons_grey_dark/icons.conf | 9 ++-
nw/assets/icons/typicons_grey_light/hash.svg | 55 +++++++++++++++++++
.../icons/typicons_grey_light/icons.conf | 9 ++-
nw/gui/outline.py | 3 +-
nw/gui/theme.py | 1 +
12 files changed, 357 insertions(+), 15 deletions(-)
create mode 100644 nw/assets/icons/fallback/hash-dark.svg
create mode 100644 nw/assets/icons/fallback/hash.svg
create mode 100644 nw/assets/icons/typicons_colour_dark/hash.svg
create mode 100644 nw/assets/icons/typicons_colour_light/hash.svg
create mode 100644 nw/assets/icons/typicons_grey_dark/hash.svg
create mode 100644 nw/assets/icons/typicons_grey_light/hash.svg
diff --git a/nw/assets/icons/fallback/hash-dark.svg b/nw/assets/icons/fallback/hash-dark.svg
new file mode 100644
index 00000000..551d7993
--- /dev/null
+++ b/nw/assets/icons/fallback/hash-dark.svg
@@ -0,0 +1,55 @@
+
+
diff --git a/nw/assets/icons/fallback/hash.svg b/nw/assets/icons/fallback/hash.svg
new file mode 100644
index 00000000..1553201b
--- /dev/null
+++ b/nw/assets/icons/fallback/hash.svg
@@ -0,0 +1,55 @@
+
+
diff --git a/nw/assets/icons/typicons_colour_dark/hash.svg b/nw/assets/icons/typicons_colour_dark/hash.svg
new file mode 100644
index 00000000..b1c34da8
--- /dev/null
+++ b/nw/assets/icons/typicons_colour_dark/hash.svg
@@ -0,0 +1,55 @@
+
+
diff --git a/nw/assets/icons/typicons_colour_dark/icons.conf b/nw/assets/icons/typicons_colour_dark/icons.conf
index f3c96935..76290410 100644
--- a/nw/assets/icons/typicons_colour_dark/icons.conf
+++ b/nw/assets/icons/typicons_colour_dark/icons.conf
@@ -1,8 +1,9 @@
##
-# Icons: Typicons Colour Dark
-# Source: https://github.com/stephenhutchings/typicons.font
-# Credit: Stephen Hutchings
-# Modified: Veronica Berglyd Olsen
+# Icons: Typicons Colour Dark
+# Source: https://github.com/stephenhutchings/typicons.font
+# Credit: Stephen Hutchings
+# Modified: Veronica Berglyd Olsen
+# Additions: hash.svg
##
[Main]
@@ -39,3 +40,4 @@ save = download.svg
edit = pencil.svg
check = tick.svg
cross = times.svg
+hash = hash.svg
diff --git a/nw/assets/icons/typicons_colour_light/hash.svg b/nw/assets/icons/typicons_colour_light/hash.svg
new file mode 100644
index 00000000..e191e8b4
--- /dev/null
+++ b/nw/assets/icons/typicons_colour_light/hash.svg
@@ -0,0 +1,55 @@
+
+
diff --git a/nw/assets/icons/typicons_colour_light/icons.conf b/nw/assets/icons/typicons_colour_light/icons.conf
index d3df7d01..08042fc9 100644
--- a/nw/assets/icons/typicons_colour_light/icons.conf
+++ b/nw/assets/icons/typicons_colour_light/icons.conf
@@ -1,8 +1,9 @@
##
-# Icons: Typicons Colour Light
-# Source: https://github.com/stephenhutchings/typicons.font
-# Credit: Stephen Hutchings
-# Modified: Veronica Berglyd Olsen
+# Icons: Typicons Colour Light
+# Source: https://github.com/stephenhutchings/typicons.font
+# Credit: Stephen Hutchings
+# Modified: Veronica Berglyd Olsen
+# Additions: hash.svg
##
[Main]
@@ -39,3 +40,4 @@ save = download.svg
edit = pencil.svg
check = tick.svg
cross = times.svg
+hash = hash.svg
diff --git a/nw/assets/icons/typicons_grey_dark/hash.svg b/nw/assets/icons/typicons_grey_dark/hash.svg
new file mode 100644
index 00000000..a6b9a654
--- /dev/null
+++ b/nw/assets/icons/typicons_grey_dark/hash.svg
@@ -0,0 +1,55 @@
+
+
diff --git a/nw/assets/icons/typicons_grey_dark/icons.conf b/nw/assets/icons/typicons_grey_dark/icons.conf
index 75268e23..d81f4adf 100644
--- a/nw/assets/icons/typicons_grey_dark/icons.conf
+++ b/nw/assets/icons/typicons_grey_dark/icons.conf
@@ -1,7 +1,9 @@
##
-# Icons: Typicons Grey Dark
-# Source: https://github.com/stephenhutchings/typicons.font
-# Credit: Stephen Hutchings
+# Icons: Typicons Grey Dark
+# Source: https://github.com/stephenhutchings/typicons.font
+# Credit: Stephen Hutchings
+# Modified: Veronica Berglyd Olsen
+# Additions: hash.svg
##
[Main]
@@ -38,3 +40,4 @@ save = download.svg
edit = pencil.svg
check = tick.svg
cross = times.svg
+hash = hash.svg
diff --git a/nw/assets/icons/typicons_grey_light/hash.svg b/nw/assets/icons/typicons_grey_light/hash.svg
new file mode 100644
index 00000000..1553201b
--- /dev/null
+++ b/nw/assets/icons/typicons_grey_light/hash.svg
@@ -0,0 +1,55 @@
+
+
diff --git a/nw/assets/icons/typicons_grey_light/icons.conf b/nw/assets/icons/typicons_grey_light/icons.conf
index 766aed98..2b26abc8 100644
--- a/nw/assets/icons/typicons_grey_light/icons.conf
+++ b/nw/assets/icons/typicons_grey_light/icons.conf
@@ -1,7 +1,9 @@
##
-# Icons: Typicons Grey Light
-# Source: https://github.com/stephenhutchings/typicons.font
-# Credit: Stephen Hutchings
+# Icons: Typicons Grey Light
+# Source: https://github.com/stephenhutchings/typicons.font
+# Credit: Stephen Hutchings
+# Modified: Veronica Berglyd Olsen
+# Additions: hash.svg
##
[Main]
@@ -38,3 +40,4 @@ save = download.svg
edit = pencil.svg
check = tick.svg
cross = times.svg
+hash = hash.svg
diff --git a/nw/gui/outline.py b/nw/gui/outline.py
index 0636cddc..12c26383 100644
--- a/nw/gui/outline.py
+++ b/nw/gui/outline.py
@@ -410,9 +410,10 @@ class GuiProjectOutline(QTreeWidget):
newItem.setText(self.colIndex[nwOutline.TITLE], novIdx["title"])
newItem.setData(self.colIndex[nwOutline.TITLE], Qt.UserRole, tHandle)
- newItem.setIcon(self.colIndex[nwOutline.TITLE], self.theTheme.getIcon("proj_document"))
+ newItem.setIcon(self.colIndex[nwOutline.TITLE], self.theTheme.getIcon("hash"))
newItem.setText(self.colIndex[nwOutline.LEVEL], novIdx["level"])
newItem.setText(self.colIndex[nwOutline.LABEL], nwItem.itemName)
+ newItem.setIcon(self.colIndex[nwOutline.LABEL], self.theTheme.getIcon("proj_document"))
newItem.setText(self.colIndex[nwOutline.LINE], sTitle[1:].lstrip("0"))
newItem.setText(self.colIndex[nwOutline.SYNOP], novIdx["synopsis"])
newItem.setText(self.colIndex[nwOutline.CCOUNT], str(novIdx["cCount"]))
diff --git a/nw/gui/theme.py b/nw/gui/theme.py
index 8613c683..49ea367c 100644
--- a/nw/gui/theme.py
+++ b/nw/gui/theme.py
@@ -516,6 +516,7 @@ class GuiIcons:
"edit" : (None, None),
"check" : (None, None),
"cross" : (None, None),
+ "hash" : (None, None),
## Other Icons
"warning" : (QStyle.SP_MessageBoxWarning, "dialog-warning"),
From e8db673db8cb6001dc072c5457593d9455d42831 Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Tue, 2 Jun 2020 20:46:52 +0200
Subject: [PATCH 10/10] Reorganised the options on the Build tool a little bit
so they're more reasonably grouped
---
nw/gui/build.py | 110 +++++++++++++++++++++++-----------------------
tests/test_gui.py | 2 +-
2 files changed, 56 insertions(+), 56 deletions(-)
diff --git a/nw/gui/build.py b/nw/gui/build.py
index 791dff67..f072b6ea 100644
--- a/nw/gui/build.py
+++ b/nw/gui/build.py
@@ -93,7 +93,7 @@ class GuiBuildNovel(QDialog):
# Title Formats
# =============
- self.titleGroup = QGroupBox("Novel Title Formats", self)
+ self.titleGroup = QGroupBox("Title Formats for Novel Files", self)
self.titleForm = QGridLayout(self)
self.titleGroup.setLayout(self.titleForm)
@@ -169,9 +169,9 @@ class GuiBuildNovel(QDialog):
# Text Options
# =============
- self.textGroup = QGroupBox("Text Options", self)
- self.textForm = QGridLayout(self)
- self.textGroup.setLayout(self.textForm)
+ self.formatGroup = QGroupBox("Formatting Options", self)
+ self.formatForm = QGridLayout(self)
+ self.formatGroup.setLayout(self.formatForm)
## Font Family
self.textFont = QLineEdit()
@@ -212,29 +212,29 @@ class GuiBuildNovel(QDialog):
self.optState.getBool("GuiBuildNovel", "noStyling", False)
)
- self.textForm.addWidget(QLabel("Font family"), 0, 0, 1, 1, Qt.AlignLeft)
- self.textForm.addWidget(self.textFont, 0, 1, 1, 1, Qt.AlignRight)
- self.textForm.addWidget(self.fontButton, 0, 2, 1, 1, Qt.AlignRight)
- self.textForm.addWidget(QLabel("Font size"), 1, 0, 1, 1, Qt.AlignLeft)
- self.textForm.addWidget(self.textSize, 1, 1, 1, 2, Qt.AlignRight)
- self.textForm.addWidget(QLabel("Justify text"), 2, 0, 1, 1, Qt.AlignLeft)
- self.textForm.addWidget(self.justifyText, 2, 1, 1, 2, Qt.AlignRight)
- self.textForm.addWidget(QLabel("Disable styling"), 3, 0, 1, 1, Qt.AlignLeft)
- self.textForm.addWidget(self.noStyling, 3, 1, 1, 2, Qt.AlignRight)
+ self.formatForm.addWidget(QLabel("Font family"), 0, 0, 1, 1, Qt.AlignLeft)
+ self.formatForm.addWidget(self.textFont, 0, 1, 1, 1, Qt.AlignRight)
+ self.formatForm.addWidget(self.fontButton, 0, 2, 1, 1, Qt.AlignRight)
+ self.formatForm.addWidget(QLabel("Font size"), 1, 0, 1, 1, Qt.AlignLeft)
+ self.formatForm.addWidget(self.textSize, 1, 1, 1, 2, Qt.AlignRight)
+ self.formatForm.addWidget(QLabel("Justify text"), 2, 0, 1, 1, Qt.AlignLeft)
+ self.formatForm.addWidget(self.justifyText, 2, 1, 1, 2, Qt.AlignRight)
+ self.formatForm.addWidget(QLabel("Disable styling"), 3, 0, 1, 1, Qt.AlignLeft)
+ self.formatForm.addWidget(self.noStyling, 3, 1, 1, 2, Qt.AlignRight)
- self.textForm.setColumnStretch(0, 1)
- self.textForm.setColumnStretch(1, 0)
- self.textForm.setColumnStretch(2, 0)
+ self.formatForm.setColumnStretch(0, 1)
+ self.formatForm.setColumnStretch(1, 0)
+ self.formatForm.setColumnStretch(2, 0)
# Include Switches
# ================
- self.includeGroup = QGroupBox("Include Non-Text Elements", self)
- self.includeForm = QGridLayout(self)
- self.includeGroup.setLayout(self.includeForm)
+ self.textGroup = QGroupBox("Text Options", self)
+ self.textForm = QGridLayout(self)
+ self.textGroup.setLayout(self.textForm)
self.includeSynopsis = QSwitch()
self.includeSynopsis.setToolTip(
- "Include synopsis type comments in the output."
+ "Include synopsis comments in the output."
)
self.includeSynopsis.setChecked(self.theProject.titleFormat["withSynopsis"])
@@ -250,21 +250,31 @@ class GuiBuildNovel(QDialog):
)
self.includeKeywords.setChecked(self.theProject.titleFormat["withKeywords"])
- self.includeForm.addWidget(QLabel("Include synopsis"), 0, 0, 1, 1, Qt.AlignLeft)
- self.includeForm.addWidget(self.includeSynopsis, 0, 1, 1, 1, Qt.AlignRight)
- self.includeForm.addWidget(QLabel("Include comments"), 1, 0, 1, 1, Qt.AlignLeft)
- self.includeForm.addWidget(self.includeComments, 1, 1, 1, 1, Qt.AlignRight)
- self.includeForm.addWidget(QLabel("Include keywords"), 2, 0, 1, 1, Qt.AlignLeft)
- self.includeForm.addWidget(self.includeKeywords, 2, 1, 1, 1, Qt.AlignRight)
+ self.includeBody = QSwitch()
+ self.includeBody.setToolTip(
+ "Include body text in the output."
+ )
+ self.includeBody.setChecked(
+ self.optState.getBool("GuiBuildNovel", "includeBody", True)
+ )
- self.includeForm.setColumnStretch(0, 1)
- self.includeForm.setColumnStretch(1, 0)
+ self.textForm.addWidget(QLabel("Include synopsis"), 0, 0, 1, 1, Qt.AlignLeft)
+ self.textForm.addWidget(self.includeSynopsis, 0, 1, 1, 1, Qt.AlignRight)
+ self.textForm.addWidget(QLabel("Include comments"), 1, 0, 1, 1, Qt.AlignLeft)
+ self.textForm.addWidget(self.includeComments, 1, 1, 1, 1, Qt.AlignRight)
+ self.textForm.addWidget(QLabel("Include keywords"), 2, 0, 1, 1, Qt.AlignLeft)
+ self.textForm.addWidget(self.includeKeywords, 2, 1, 1, 1, Qt.AlignRight)
+ self.textForm.addWidget(QLabel("Include body text"), 3, 0, 1, 1, Qt.AlignLeft)
+ self.textForm.addWidget(self.includeBody, 3, 1, 1, 1, Qt.AlignRight)
+
+ self.textForm.setColumnStretch(0, 1)
+ self.textForm.setColumnStretch(1, 0)
# Additional Options
# ==================
- self.addsGroup = QGroupBox("Additional Options", self)
- self.addsForm = QGridLayout(self)
- self.addsGroup.setLayout(self.addsForm)
+ self.fileGroup = QGroupBox("File Options", self)
+ self.fileForm = QGridLayout(self)
+ self.fileGroup.setLayout(self.fileForm)
self.novelFiles = QSwitch()
self.novelFiles.setToolTip(
@@ -290,26 +300,15 @@ class GuiBuildNovel(QDialog):
self.optState.getBool("GuiBuildNovel", "ignoreFlag", False)
)
- self.excludeBody = QSwitch()
- self.excludeBody.setToolTip(
- "Exclude body text in the output. Combine with 'Include synopsis' "
- "for making outline."
- )
- self.excludeBody.setChecked(
- self.optState.getBool("GuiBuildNovel", "excludeBody", False)
- )
+ self.fileForm.addWidget(QLabel("Include novel files"), 0, 0, 1, 1, Qt.AlignLeft)
+ self.fileForm.addWidget(self.novelFiles, 0, 1, 1, 1, Qt.AlignRight)
+ self.fileForm.addWidget(QLabel("Include note files"), 1, 0, 1, 1, Qt.AlignLeft)
+ self.fileForm.addWidget(self.noteFiles, 1, 1, 1, 1, Qt.AlignRight)
+ self.fileForm.addWidget(QLabel("Ignore export flag"), 2, 0, 1, 1, Qt.AlignLeft)
+ self.fileForm.addWidget(self.ignoreFlag, 2, 1, 1, 1, Qt.AlignRight)
- self.addsForm.addWidget(QLabel("Include novel files"), 0, 0, 1, 1, Qt.AlignLeft)
- self.addsForm.addWidget(self.novelFiles, 0, 1, 1, 1, Qt.AlignRight)
- self.addsForm.addWidget(QLabel("Include note files"), 1, 0, 1, 1, Qt.AlignLeft)
- self.addsForm.addWidget(self.noteFiles, 1, 1, 1, 1, Qt.AlignRight)
- self.addsForm.addWidget(QLabel("Ignore export flag"), 2, 0, 1, 1, Qt.AlignLeft)
- self.addsForm.addWidget(self.ignoreFlag, 2, 1, 1, 1, Qt.AlignRight)
- self.addsForm.addWidget(QLabel("Exclude body text"), 3, 0, 1, 1, Qt.AlignLeft)
- self.addsForm.addWidget(self.excludeBody, 3, 1, 1, 1, Qt.AlignRight)
-
- self.addsForm.setColumnStretch(0, 1)
- self.addsForm.setColumnStretch(1, 0)
+ self.fileForm.setColumnStretch(0, 1)
+ self.fileForm.setColumnStretch(1, 0)
# Build Button
# ============
@@ -373,9 +372,9 @@ class GuiBuildNovel(QDialog):
# Assemble GUI
# ============
self.toolsBox.addWidget(self.titleGroup)
+ self.toolsBox.addWidget(self.formatGroup)
self.toolsBox.addWidget(self.textGroup)
- self.toolsBox.addWidget(self.includeGroup)
- self.toolsBox.addWidget(self.addsGroup)
+ self.toolsBox.addWidget(self.fileGroup)
self.toolsBox.addStretch(1)
self.toolsBox.addWidget(self.buildProgress)
self.toolsBox.addWidget(self.buildNovel)
@@ -388,6 +387,7 @@ class GuiBuildNovel(QDialog):
self.outerBox.setStretch(1, 1)
self.setLayout(self.outerBox)
+ self.buildNovel.setFocus()
self.show()
@@ -436,7 +436,7 @@ class GuiBuildNovel(QDialog):
novelFiles = self.novelFiles.isChecked()
noteFiles = self.noteFiles.isChecked()
ignoreFlag = self.ignoreFlag.isChecked()
- excludeBody = self.excludeBody.isChecked()
+ includeBody = self.includeBody.isChecked()
makeHtml = ToHtml(self.theProject, self.theParent)
makeHtml.setTitleFormat(fmtTitle)
@@ -444,7 +444,7 @@ class GuiBuildNovel(QDialog):
makeHtml.setUnNumberedFormat(fmtUnnumbered)
makeHtml.setSceneFormat(fmtScene, fmtScene == "")
makeHtml.setSectionFormat(fmtSection, fmtSection == "")
- makeHtml.setBodyText(not excludeBody)
+ makeHtml.setBodyText(includeBody)
makeHtml.setSynopsis(incSynopsis)
makeHtml.setComments(incComments)
makeHtml.setKeywords(incKeywords)
@@ -867,7 +867,7 @@ class GuiBuildNovel(QDialog):
self.optState.setValue("GuiBuildNovel", "addNovel", self.novelFiles.isChecked())
self.optState.setValue("GuiBuildNovel", "addNotes", self.noteFiles.isChecked())
self.optState.setValue("GuiBuildNovel", "ignoreFlag", self.ignoreFlag.isChecked())
- self.optState.setValue("GuiBuildNovel", "excludeBody", self.excludeBody.isChecked())
+ self.optState.setValue("GuiBuildNovel", "includeBody", self.includeBody.isChecked())
self.optState.saveSettings()
return
diff --git a/tests/test_gui.py b/tests/test_gui.py
index e006cabb..fe52cabd 100644
--- a/tests/test_gui.py
+++ b/tests/test_gui.py
@@ -485,7 +485,7 @@ def testBuildTool(qtbot, nwTempBuild, nwLipsum, nwRef, nwTemp):
qtbot.wait(stepDelay)
qtbot.mouseClick(nwBuild.ignoreFlag, Qt.LeftButton)
qtbot.wait(stepDelay)
- qtbot.mouseClick(nwBuild.excludeBody, Qt.LeftButton)
+ qtbot.mouseClick(nwBuild.includeBody, Qt.LeftButton)
qtbot.wait(stepDelay)
qtbot.mouseClick(nwBuild.buildNovel, Qt.LeftButton)