Make the whole build tool dialog more dynamic in sizes and areas
This commit is contained in:
@@ -62,6 +62,8 @@ class OptionState():
|
|||||||
"GuiBuildNovel": {
|
"GuiBuildNovel": {
|
||||||
"winWidth",
|
"winWidth",
|
||||||
"winHeight",
|
"winHeight",
|
||||||
|
"boxWidth",
|
||||||
|
"docWidth",
|
||||||
"addNovel",
|
"addNovel",
|
||||||
"addNotes",
|
"addNotes",
|
||||||
"ignoreFlag",
|
"ignoreFlag",
|
||||||
|
|||||||
+96
-36
@@ -41,7 +41,8 @@ from PyQt5.QtGui import (
|
|||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialog, QVBoxLayout, QHBoxLayout, QTextBrowser, QPushButton, QLabel,
|
QDialog, QVBoxLayout, QHBoxLayout, QTextBrowser, QPushButton, QLabel,
|
||||||
QLineEdit, QGroupBox, QGridLayout, QProgressBar, QMenu, QAction,
|
QLineEdit, QGroupBox, QGridLayout, QProgressBar, QMenu, QAction,
|
||||||
QFileDialog, QFontDialog, QSpinBox
|
QFileDialog, QFontDialog, QSpinBox, QScrollArea, QSplitter, QWidget,
|
||||||
|
QSizePolicy
|
||||||
)
|
)
|
||||||
|
|
||||||
from nw.common import fuzzyTime, makeFileNameSafe
|
from nw.common import fuzzyTime, makeFileNameSafe
|
||||||
@@ -82,17 +83,14 @@ class GuiBuildNovel(QDialog):
|
|||||||
self.buildTime = 0 # The timestamp of the last build
|
self.buildTime = 0 # The timestamp of the last build
|
||||||
|
|
||||||
self.setWindowTitle("Build Novel Project")
|
self.setWindowTitle("Build Novel Project")
|
||||||
self.setMinimumWidth(self.mainConf.pxInt(900))
|
self.setMinimumWidth(self.mainConf.pxInt(700))
|
||||||
self.setMinimumHeight(self.mainConf.pxInt(800))
|
self.setMinimumHeight(self.mainConf.pxInt(600))
|
||||||
|
|
||||||
self.resize(
|
self.resize(
|
||||||
self.mainConf.pxInt(self.optState.getInt("GuiBuildNovel", "winWidth", 900)),
|
self.mainConf.pxInt(self.optState.getInt("GuiBuildNovel", "winWidth", 900)),
|
||||||
self.mainConf.pxInt(self.optState.getInt("GuiBuildNovel", "winHeight", 800))
|
self.mainConf.pxInt(self.optState.getInt("GuiBuildNovel", "winHeight", 800))
|
||||||
)
|
)
|
||||||
|
|
||||||
self.outerBox = QHBoxLayout()
|
|
||||||
self.toolsBox = QVBoxLayout()
|
|
||||||
|
|
||||||
self.docView = GuiBuildNovelDocView(self, self.theProject)
|
self.docView = GuiBuildNovelDocView(self, self.theProject)
|
||||||
|
|
||||||
# Title Formats
|
# Title Formats
|
||||||
@@ -118,11 +116,11 @@ class GuiBuildNovel(QDialog):
|
|||||||
r"be centred automatically and only appear between sections of "
|
r"be centred automatically and only appear between sections of "
|
||||||
r"the same type."
|
r"the same type."
|
||||||
)
|
)
|
||||||
xFmt = self.mainConf.pxInt(220)
|
xFmt = self.mainConf.pxInt(100)
|
||||||
|
|
||||||
self.fmtTitle = QLineEdit()
|
self.fmtTitle = QLineEdit()
|
||||||
self.fmtTitle.setMaxLength(200)
|
self.fmtTitle.setMaxLength(200)
|
||||||
self.fmtTitle.setFixedWidth(xFmt)
|
self.fmtTitle.setMinimumWidth(xFmt)
|
||||||
self.fmtTitle.setToolTip(fmtHelp)
|
self.fmtTitle.setToolTip(fmtHelp)
|
||||||
self.fmtTitle.setText(
|
self.fmtTitle.setText(
|
||||||
self._reFmtCodes(self.theProject.titleFormat["title"])
|
self._reFmtCodes(self.theProject.titleFormat["title"])
|
||||||
@@ -130,7 +128,7 @@ class GuiBuildNovel(QDialog):
|
|||||||
|
|
||||||
self.fmtChapter = QLineEdit()
|
self.fmtChapter = QLineEdit()
|
||||||
self.fmtChapter.setMaxLength(200)
|
self.fmtChapter.setMaxLength(200)
|
||||||
self.fmtChapter.setFixedWidth(xFmt)
|
self.fmtChapter.setMinimumWidth(xFmt)
|
||||||
self.fmtChapter.setToolTip(fmtHelp)
|
self.fmtChapter.setToolTip(fmtHelp)
|
||||||
self.fmtChapter.setText(
|
self.fmtChapter.setText(
|
||||||
self._reFmtCodes(self.theProject.titleFormat["chapter"])
|
self._reFmtCodes(self.theProject.titleFormat["chapter"])
|
||||||
@@ -138,7 +136,7 @@ class GuiBuildNovel(QDialog):
|
|||||||
|
|
||||||
self.fmtUnnumbered = QLineEdit()
|
self.fmtUnnumbered = QLineEdit()
|
||||||
self.fmtUnnumbered.setMaxLength(200)
|
self.fmtUnnumbered.setMaxLength(200)
|
||||||
self.fmtUnnumbered.setFixedWidth(xFmt)
|
self.fmtUnnumbered.setMinimumWidth(xFmt)
|
||||||
self.fmtUnnumbered.setToolTip(fmtHelp)
|
self.fmtUnnumbered.setToolTip(fmtHelp)
|
||||||
self.fmtUnnumbered.setText(
|
self.fmtUnnumbered.setText(
|
||||||
self._reFmtCodes(self.theProject.titleFormat["unnumbered"])
|
self._reFmtCodes(self.theProject.titleFormat["unnumbered"])
|
||||||
@@ -146,7 +144,7 @@ class GuiBuildNovel(QDialog):
|
|||||||
|
|
||||||
self.fmtScene = QLineEdit()
|
self.fmtScene = QLineEdit()
|
||||||
self.fmtScene.setMaxLength(200)
|
self.fmtScene.setMaxLength(200)
|
||||||
self.fmtScene.setFixedWidth(xFmt)
|
self.fmtScene.setMinimumWidth(xFmt)
|
||||||
self.fmtScene.setToolTip(fmtHelp + fmtScHelp)
|
self.fmtScene.setToolTip(fmtHelp + fmtScHelp)
|
||||||
self.fmtScene.setText(
|
self.fmtScene.setText(
|
||||||
self._reFmtCodes(self.theProject.titleFormat["scene"])
|
self._reFmtCodes(self.theProject.titleFormat["scene"])
|
||||||
@@ -154,25 +152,37 @@ class GuiBuildNovel(QDialog):
|
|||||||
|
|
||||||
self.fmtSection = QLineEdit()
|
self.fmtSection = QLineEdit()
|
||||||
self.fmtSection.setMaxLength(200)
|
self.fmtSection.setMaxLength(200)
|
||||||
self.fmtSection.setFixedWidth(xFmt)
|
self.fmtSection.setMinimumWidth(xFmt)
|
||||||
self.fmtSection.setToolTip(fmtHelp + fmtScHelp)
|
self.fmtSection.setToolTip(fmtHelp + fmtScHelp)
|
||||||
self.fmtSection.setText(
|
self.fmtSection.setText(
|
||||||
self._reFmtCodes(self.theProject.titleFormat["section"])
|
self._reFmtCodes(self.theProject.titleFormat["section"])
|
||||||
)
|
)
|
||||||
|
|
||||||
self.titleForm.addWidget(QLabel("Title"), 0, 0, 1, 1, Qt.AlignLeft)
|
# Dummy boxes due to QGridView and QLineEdit expand bug
|
||||||
self.titleForm.addWidget(self.fmtTitle, 0, 1, 1, 1, Qt.AlignRight)
|
self.boxTitle = QHBoxLayout()
|
||||||
self.titleForm.addWidget(QLabel("Chapter"), 1, 0, 1, 1, Qt.AlignLeft)
|
self.boxTitle.addWidget(self.fmtTitle)
|
||||||
self.titleForm.addWidget(self.fmtChapter, 1, 1, 1, 1, Qt.AlignRight)
|
self.boxChapter = QHBoxLayout()
|
||||||
self.titleForm.addWidget(QLabel("Unnumbered"), 2, 0, 1, 1, Qt.AlignLeft)
|
self.boxChapter.addWidget(self.fmtChapter)
|
||||||
self.titleForm.addWidget(self.fmtUnnumbered, 2, 1, 1, 1, Qt.AlignRight)
|
self.boxUnnumbered = QHBoxLayout()
|
||||||
self.titleForm.addWidget(QLabel("Scene"), 3, 0, 1, 1, Qt.AlignLeft)
|
self.boxUnnumbered.addWidget(self.fmtUnnumbered)
|
||||||
self.titleForm.addWidget(self.fmtScene, 3, 1, 1, 1, Qt.AlignRight)
|
self.boxScene = QHBoxLayout()
|
||||||
self.titleForm.addWidget(QLabel("Section"), 4, 0, 1, 1, Qt.AlignLeft)
|
self.boxScene.addWidget(self.fmtScene)
|
||||||
self.titleForm.addWidget(self.fmtSection, 4, 1, 1, 1, Qt.AlignRight)
|
self.boxSection = QHBoxLayout()
|
||||||
|
self.boxSection.addWidget(self.fmtSection)
|
||||||
|
|
||||||
self.titleForm.setColumnStretch(0, 1)
|
self.titleForm.addWidget(QLabel("Title"), 0, 0, 1, 1, Qt.AlignLeft)
|
||||||
self.titleForm.setColumnStretch(1, 0)
|
self.titleForm.addLayout(self.boxTitle, 0, 1, 1, 1, Qt.AlignRight)
|
||||||
|
self.titleForm.addWidget(QLabel("Chapter"), 1, 0, 1, 1, Qt.AlignLeft)
|
||||||
|
self.titleForm.addLayout(self.boxChapter, 1, 1, 1, 1, Qt.AlignRight)
|
||||||
|
self.titleForm.addWidget(QLabel("Unnumbered"), 2, 0, 1, 1, Qt.AlignLeft)
|
||||||
|
self.titleForm.addLayout(self.boxUnnumbered, 2, 1, 1, 1, Qt.AlignRight)
|
||||||
|
self.titleForm.addWidget(QLabel("Scene"), 3, 0, 1, 1, Qt.AlignLeft)
|
||||||
|
self.titleForm.addLayout(self.boxScene, 3, 1, 1, 1, Qt.AlignRight)
|
||||||
|
self.titleForm.addWidget(QLabel("Section"), 4, 0, 1, 1, Qt.AlignLeft)
|
||||||
|
self.titleForm.addLayout(self.boxSection, 4, 1, 1, 1, Qt.AlignRight)
|
||||||
|
|
||||||
|
self.titleForm.setColumnStretch(0, 0)
|
||||||
|
self.titleForm.setColumnStretch(1, 1)
|
||||||
|
|
||||||
# Text Options
|
# Text Options
|
||||||
# =============
|
# =============
|
||||||
@@ -183,7 +193,7 @@ class GuiBuildNovel(QDialog):
|
|||||||
## Font Family
|
## Font Family
|
||||||
self.textFont = QLineEdit()
|
self.textFont = QLineEdit()
|
||||||
self.textFont.setReadOnly(True)
|
self.textFont.setReadOnly(True)
|
||||||
self.textFont.setFixedWidth(self.mainConf.pxInt(182))
|
self.textFont.setMinimumWidth(xFmt)
|
||||||
self.textFont.setText(
|
self.textFont.setText(
|
||||||
self.optState.getString("GuiBuildNovel", "textFont", self.mainConf.textFont)
|
self.optState.getString("GuiBuildNovel", "textFont", self.mainConf.textFont)
|
||||||
)
|
)
|
||||||
@@ -219,8 +229,12 @@ class GuiBuildNovel(QDialog):
|
|||||||
self.optState.getBool("GuiBuildNovel", "noStyling", False)
|
self.optState.getBool("GuiBuildNovel", "noStyling", False)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Dummy box due to QGridView and QLineEdit expand bug
|
||||||
|
self.boxFont = QHBoxLayout()
|
||||||
|
self.boxFont.addWidget(self.textFont)
|
||||||
|
|
||||||
self.formatForm.addWidget(QLabel("Font family"), 0, 0, 1, 1, Qt.AlignLeft)
|
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.addLayout(self.boxFont, 0, 1, 1, 1, Qt.AlignRight)
|
||||||
self.formatForm.addWidget(self.fontButton, 0, 2, 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(QLabel("Font size"), 1, 0, 1, 1, Qt.AlignLeft)
|
||||||
self.formatForm.addWidget(self.textSize, 1, 1, 1, 2, Qt.AlignRight)
|
self.formatForm.addWidget(self.textSize, 1, 1, 1, 2, Qt.AlignRight)
|
||||||
@@ -229,8 +243,8 @@ class GuiBuildNovel(QDialog):
|
|||||||
self.formatForm.addWidget(QLabel("Disable styling"), 3, 0, 1, 1, Qt.AlignLeft)
|
self.formatForm.addWidget(QLabel("Disable styling"), 3, 0, 1, 1, Qt.AlignLeft)
|
||||||
self.formatForm.addWidget(self.noStyling, 3, 1, 1, 2, Qt.AlignRight)
|
self.formatForm.addWidget(self.noStyling, 3, 1, 1, 2, Qt.AlignRight)
|
||||||
|
|
||||||
self.formatForm.setColumnStretch(0, 1)
|
self.formatForm.setColumnStretch(0, 0)
|
||||||
self.formatForm.setColumnStretch(1, 0)
|
self.formatForm.setColumnStretch(1, 1)
|
||||||
self.formatForm.setColumnStretch(2, 0)
|
self.formatForm.setColumnStretch(2, 0)
|
||||||
|
|
||||||
# Include Switches
|
# Include Switches
|
||||||
@@ -384,20 +398,56 @@ class GuiBuildNovel(QDialog):
|
|||||||
|
|
||||||
# Assemble GUI
|
# Assemble GUI
|
||||||
# ============
|
# ============
|
||||||
|
|
||||||
|
# Splitter Position
|
||||||
|
boxWidth = self.mainConf.pxInt(350)
|
||||||
|
boxWidth = self.optState.getInt("GuiBuildNovel", "boxWidth", boxWidth)
|
||||||
|
docWidth = max(self.width() - boxWidth, 100)
|
||||||
|
docWidth = self.optState.getInt("GuiBuildNovel", "docWidth", docWidth)
|
||||||
|
|
||||||
|
# The Tool Box
|
||||||
|
self.toolsBox = QVBoxLayout()
|
||||||
self.toolsBox.addWidget(self.titleGroup)
|
self.toolsBox.addWidget(self.titleGroup)
|
||||||
self.toolsBox.addWidget(self.formatGroup)
|
self.toolsBox.addWidget(self.formatGroup)
|
||||||
self.toolsBox.addWidget(self.textGroup)
|
self.toolsBox.addWidget(self.textGroup)
|
||||||
self.toolsBox.addWidget(self.fileGroup)
|
self.toolsBox.addWidget(self.fileGroup)
|
||||||
self.toolsBox.addStretch(1)
|
self.toolsBox.addStretch(1)
|
||||||
self.toolsBox.addWidget(self.buildProgress)
|
|
||||||
self.toolsBox.addWidget(self.buildNovel)
|
|
||||||
self.toolsBox.addSpacing(8)
|
|
||||||
self.toolsBox.addLayout(self.buttonBox)
|
|
||||||
|
|
||||||
self.outerBox.addLayout(self.toolsBox)
|
# Tool Box Wrapper Widget
|
||||||
self.outerBox.addWidget(self.docView)
|
self.toolsWidget = QWidget()
|
||||||
self.outerBox.setStretch(0, 0)
|
self.toolsWidget.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)
|
||||||
self.outerBox.setStretch(1, 1)
|
self.toolsWidget.setLayout(self.toolsBox)
|
||||||
|
|
||||||
|
# Tool Box Scroll Area
|
||||||
|
self.toolsArea = QScrollArea()
|
||||||
|
self.toolsArea.setMinimumWidth(self.mainConf.pxInt(250))
|
||||||
|
self.toolsArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||||
|
self.toolsArea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||||
|
self.toolsArea.setWidgetResizable(True)
|
||||||
|
self.toolsArea.setWidget(self.toolsWidget)
|
||||||
|
|
||||||
|
# Tools and Buttons Layout
|
||||||
|
self.innerBox = QVBoxLayout()
|
||||||
|
self.innerBox.addWidget(self.toolsArea)
|
||||||
|
self.innerBox.addSpacing(8)
|
||||||
|
self.innerBox.addWidget(self.buildProgress)
|
||||||
|
self.innerBox.addWidget(self.buildNovel)
|
||||||
|
self.innerBox.addSpacing(8)
|
||||||
|
self.innerBox.addLayout(self.buttonBox)
|
||||||
|
|
||||||
|
# Tools and Buttons Wrapper Widget
|
||||||
|
self.innerWidget = QWidget()
|
||||||
|
self.innerWidget.setLayout(self.innerBox)
|
||||||
|
|
||||||
|
# Main Dialog Splitter
|
||||||
|
self.mainSplit = QSplitter(Qt.Horizontal)
|
||||||
|
self.mainSplit.addWidget(self.innerWidget)
|
||||||
|
self.mainSplit.addWidget(self.docView)
|
||||||
|
self.mainSplit.setSizes([boxWidth, docWidth])
|
||||||
|
|
||||||
|
# Outer Layout
|
||||||
|
self.outerBox = QHBoxLayout()
|
||||||
|
self.outerBox.addWidget(self.mainSplit)
|
||||||
|
|
||||||
self.setLayout(self.outerBox)
|
self.setLayout(self.outerBox)
|
||||||
self.buildNovel.setFocus()
|
self.buildNovel.setFocus()
|
||||||
@@ -897,9 +947,19 @@ class GuiBuildNovel(QDialog):
|
|||||||
incKeywords = self.includeKeywords.isChecked()
|
incKeywords = self.includeKeywords.isChecked()
|
||||||
incBodyText = self.includeBody.isChecked()
|
incBodyText = self.includeBody.isChecked()
|
||||||
|
|
||||||
|
mainSplit = self.mainSplit.sizes()
|
||||||
|
if len(mainSplit) == 2:
|
||||||
|
boxWidth = self.mainConf.rpxInt(mainSplit[0])
|
||||||
|
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", "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)
|
||||||
|
|||||||
Reference in New Issue
Block a user