Clean up the Build dialog and connect new options

This commit is contained in:
Veronica K. B. Olsen
2021-02-10 16:57:15 +01:00
parent f67a50c064
commit ec189a4867
2 changed files with 63 additions and 51 deletions
+1
View File
@@ -80,6 +80,7 @@ class OptionState():
"incKeywords", "incKeywords",
"incBodyText", "incBodyText",
"replaceTabs", "replaceTabs",
"replaceUCode",
}, },
"GuiOutline": { "GuiOutline": {
"headerOrder", "headerOrder",
+62 -51
View File
@@ -55,15 +55,17 @@ logger = logging.getLogger(__name__)
class GuiBuildNovel(QDialog): class GuiBuildNovel(QDialog):
FMT_ODT = 1 FMT_PDF = 1 # Print to PDF
FMT_FODT = 2
FMT_PDF = 3 FMT_ODT = 2 # Open Document file
FMT_HTM = 4 FMT_FODT = 3 # Flat Open Document file
FMT_MD = 5 FMT_HTM = 4 # HTML5
FMT_GH = 6 FMT_NWD = 5 # nW Markdown
FMT_NWD = 7 FMT_MD = 6 # Standard Markdown
FMT_JSON_H = 8 FMT_GH = 7 # GitHub Markdown
FMT_JSON_M = 9
FMT_JSON_H = 8 # HTML5 wrapped in JSON
FMT_JSON_M = 9 # nW Markdown wrapped in JSON
def __init__(self, theParent, theProject): def __init__(self, theParent, theProject):
QDialog.__init__(self, theParent) QDialog.__init__(self, theParent)
@@ -379,10 +381,18 @@ class GuiBuildNovel(QDialog):
self.optState.getBool("GuiBuildNovel", "replaceTabs", False) self.optState.getBool("GuiBuildNovel", "replaceTabs", False)
) )
tabsLabel = QLabel("Replace tabs with spaces") self.replaceUCode = QSwitch(width=wS, height=hS)
self.replaceUCode.setChecked(
self.optState.getBool("GuiBuildNovel", "replaceUCode", False)
)
self.exportForm.addWidget(tabsLabel, 0, 0, 1, 1, Qt.AlignLeft) tabsLabel = QLabel("Replace tabs with spaces")
self.exportForm.addWidget(self.replaceTabs, 0, 1, 1, 1, Qt.AlignRight) uCodeLabel = QLabel("Replace Unicode in HTML")
self.exportForm.addWidget(tabsLabel, 0, 0, 1, 1, Qt.AlignLeft)
self.exportForm.addWidget(self.replaceTabs, 0, 1, 1, 1, Qt.AlignRight)
self.exportForm.addWidget(uCodeLabel, 1, 0, 1, 1, Qt.AlignLeft)
self.exportForm.addWidget(self.replaceUCode, 1, 1, 1, 1, Qt.AlignRight)
self.exportForm.setColumnStretch(0, 1) self.exportForm.setColumnStretch(0, 1)
self.exportForm.setColumnStretch(1, 0) self.exportForm.setColumnStretch(1, 0)
@@ -643,6 +653,7 @@ class GuiBuildNovel(QDialog):
noteFiles = self.noteFiles.isChecked() noteFiles = self.noteFiles.isChecked()
ignoreFlag = self.ignoreFlag.isChecked() ignoreFlag = self.ignoreFlag.isChecked()
includeBody = self.includeBody.isChecked() includeBody = self.includeBody.isChecked()
replaceUCode = self.replaceUCode.isChecked()
# Get font information # Get font information
fontInfo = QFontInfo(QFont(textFont, textSize)) fontInfo = QFontInfo(QFont(textFont, textSize))
@@ -668,6 +679,7 @@ class GuiBuildNovel(QDialog):
if isHtml: if isHtml:
bldObj.setStyles(not noStyling) bldObj.setStyles(not noStyling)
bldObj.setReplaceUnicode(replaceUCode)
if isOdt: if isOdt:
bldObj.setColourHeaders(not noStyling) bldObj.setColourHeaders(not noStyling)
@@ -696,7 +708,7 @@ class GuiBuildNovel(QDialog):
elif self._checkInclude(tItem, noteFiles, novelFiles, ignoreFlag): elif self._checkInclude(tItem, noteFiles, novelFiles, ignoreFlag):
bldObj.setText(tItem.itemHandle) bldObj.setText(tItem.itemHandle)
bldObj.doAutoReplace() bldObj.doPreProcessing()
bldObj.tokenizeText() bldObj.tokenizeText()
bldObj.doHeaders() bldObj.doHeaders()
if doConvert: if doConvert:
@@ -1107,48 +1119,47 @@ class GuiBuildNovel(QDialog):
"section" : self.fmtSection.text().strip(), "section" : self.fmtSection.text().strip(),
}) })
winWidth = self.mainConf.rpxInt(self.width()) winWidth = self.mainConf.rpxInt(self.width())
winHeight = self.mainConf.rpxInt(self.height()) winHeight = self.mainConf.rpxInt(self.height())
justifyText = self.justifyText.isChecked() justifyText = self.justifyText.isChecked()
noStyling = self.noStyling.isChecked() noStyling = self.noStyling.isChecked()
textFont = self.textFont.text() textFont = self.textFont.text()
textSize = self.textSize.value() textSize = self.textSize.value()
lineHeight = self.lineHeight.value() lineHeight = self.lineHeight.value()
novelFiles = self.novelFiles.isChecked() novelFiles = self.novelFiles.isChecked()
noteFiles = self.noteFiles.isChecked() noteFiles = self.noteFiles.isChecked()
ignoreFlag = self.ignoreFlag.isChecked() ignoreFlag = self.ignoreFlag.isChecked()
incSynopsis = self.includeSynopsis.isChecked() incSynopsis = self.includeSynopsis.isChecked()
incComments = self.includeComments.isChecked() incComments = self.includeComments.isChecked()
incKeywords = self.includeKeywords.isChecked() incKeywords = self.includeKeywords.isChecked()
incBodyText = self.includeBody.isChecked() incBodyText = self.includeBody.isChecked()
replaceTabs = self.replaceTabs.isChecked() replaceTabs = self.replaceTabs.isChecked()
replaceUCode = self.replaceUCode.isChecked()
mainSplit = self.mainSplit.sizes() mainSplit = self.mainSplit.sizes()
if len(mainSplit) == 2: boxWidth = self.mainConf.rpxInt(mainSplit[0])
boxWidth = self.mainConf.rpxInt(mainSplit[0]) docWidth = self.mainConf.rpxInt(mainSplit[1])
docWidth = self.mainConf.rpxInt(mainSplit[1])
else:
boxWidth = 100
docWidth = 100
# GUI Settings # GUI Settings
self.optState.setValue("GuiBuildNovel", "winWidth", winWidth) self.optState.setValue("GuiBuildNovel", "winWidth", winWidth)
self.optState.setValue("GuiBuildNovel", "winHeight", winHeight) self.optState.setValue("GuiBuildNovel", "winHeight", winHeight)
self.optState.setValue("GuiBuildNovel", "boxWidth", boxWidth) self.optState.setValue("GuiBuildNovel", "boxWidth", boxWidth)
self.optState.setValue("GuiBuildNovel", "docWidth", docWidth) self.optState.setValue("GuiBuildNovel", "docWidth", docWidth)
self.optState.setValue("GuiBuildNovel", "justifyText", justifyText) self.optState.setValue("GuiBuildNovel", "justifyText", justifyText)
self.optState.setValue("GuiBuildNovel", "noStyling", noStyling) self.optState.setValue("GuiBuildNovel", "noStyling", noStyling)
self.optState.setValue("GuiBuildNovel", "textFont", textFont) self.optState.setValue("GuiBuildNovel", "textFont", textFont)
self.optState.setValue("GuiBuildNovel", "textSize", textSize) self.optState.setValue("GuiBuildNovel", "textSize", textSize)
self.optState.setValue("GuiBuildNovel", "lineHeight", lineHeight) self.optState.setValue("GuiBuildNovel", "lineHeight", lineHeight)
self.optState.setValue("GuiBuildNovel", "addNovel", novelFiles) self.optState.setValue("GuiBuildNovel", "addNovel", novelFiles)
self.optState.setValue("GuiBuildNovel", "addNotes", noteFiles) self.optState.setValue("GuiBuildNovel", "addNotes", noteFiles)
self.optState.setValue("GuiBuildNovel", "ignoreFlag", ignoreFlag) self.optState.setValue("GuiBuildNovel", "ignoreFlag", ignoreFlag)
self.optState.setValue("GuiBuildNovel", "incSynopsis", incSynopsis) self.optState.setValue("GuiBuildNovel", "incSynopsis", incSynopsis)
self.optState.setValue("GuiBuildNovel", "incComments", incComments) self.optState.setValue("GuiBuildNovel", "incComments", incComments)
self.optState.setValue("GuiBuildNovel", "incKeywords", incKeywords) self.optState.setValue("GuiBuildNovel", "incKeywords", incKeywords)
self.optState.setValue("GuiBuildNovel", "incBodyText", incBodyText) self.optState.setValue("GuiBuildNovel", "incBodyText", incBodyText)
self.optState.setValue("GuiBuildNovel", "replaceTabs", replaceTabs) self.optState.setValue("GuiBuildNovel", "replaceTabs", replaceTabs)
self.optState.setValue("GuiBuildNovel", "replaceUCode", replaceUCode)
self.optState.saveSettings() self.optState.saveSettings()
return return