diff --git a/novelwriter/dialogs/preferences.py b/novelwriter/dialogs/preferences.py index 7653734ea..698d63763 100644 --- a/novelwriter/dialogs/preferences.py +++ b/novelwriter/dialogs/preferences.py @@ -134,6 +134,9 @@ def buildForm(self) -> None: minWidth = CONFIG.pxInt(200) mIcon = SHARED.theme.getIcon("more") + # Label + self.sidebar.addLabel(self.tr("General")) + # Appearance # ========== @@ -151,9 +154,8 @@ def buildForm(self) -> None: self.guiLocale.setCurrentIndex(idx) self.mainForm.addRow( - self.tr("Display language"), - self.guiLocale, - self.tr("Requires restart to take effect.") + self.tr("Display language"), self.guiLocale, + self.tr("Requires restart to take effect."), stretch=(3, 2) ) # Colour Theme @@ -165,23 +167,21 @@ def buildForm(self) -> None: self.guiTheme.setCurrentIndex(idx) self.mainForm.addRow( - self.tr("Colour theme"), - self.guiTheme, - self.tr("General colour theme and icons.") + self.tr("Colour theme"), self.guiTheme, + self.tr("General colour theme and icons."), stretch=(3, 2) ) # Application Font Family self.guiFont = QLineEdit(self) self.guiFont.setReadOnly(True) - self.guiFont.setFixedWidth(CONFIG.pxInt(162)) + self.guiFont.setMinimumWidth(CONFIG.pxInt(162)) self.guiFont.setText(CONFIG.guiFont) self.guiFontButton = QToolButton(self) self.guiFontButton.setIcon(mIcon) self.guiFontButton.clicked.connect(self._selectGuiFont) self.mainForm.addRow( - self.tr("Application font family"), - self.guiFont, - self.tr("Requires restart to take effect."), + self.tr("Application font family"), self.guiFont, + self.tr("Requires restart to take effect."), stretch=(3, 2), button=self.guiFontButton ) @@ -192,18 +192,15 @@ def buildForm(self) -> None: self.guiFontSize.setSingleStep(1) self.guiFontSize.setValue(CONFIG.guiFontSize) self.mainForm.addRow( - self.tr("Application font size"), - self.guiFontSize, - self.tr("Requires restart to take effect."), - unit=self.tr("pt") + self.tr("Application font size"), self.guiFontSize, + self.tr("Requires restart to take effect."), unit=self.tr("pt") ) # Vertical Scrollbars self.hideVScroll = NSwitch(self) self.hideVScroll.setChecked(CONFIG.hideVScroll) self.mainForm.addRow( - self.tr("Hide vertical scroll bars in main windows"), - self.hideVScroll, + self.tr("Hide vertical scroll bars in main windows"), self.hideVScroll, self.tr("Scrolling available with mouse wheel and keys only.") ) @@ -211,8 +208,7 @@ def buildForm(self) -> None: self.hideHScroll = NSwitch(self) self.hideHScroll.setChecked(CONFIG.hideHScroll) self.mainForm.addRow( - self.tr("Hide horizontal scroll bars in main windows"), - self.hideHScroll, + self.tr("Hide horizontal scroll bars in main windows"), self.hideHScroll, self.tr("Scrolling available with mouse wheel and keys only.") ) @@ -233,23 +229,21 @@ def buildForm(self) -> None: self.guiSyntax.setCurrentIndex(idx) self.mainForm.addRow( - self.tr("Document colour theme"), - self.guiSyntax, - self.tr("Colour theme for the editor and viewer.") + self.tr("Document colour theme"), self.guiSyntax, + self.tr("Colour theme for the editor and viewer."), stretch=(3, 2) ) # Document Font Family self.textFont = QLineEdit(self) self.textFont.setReadOnly(True) - self.textFont.setFixedWidth(CONFIG.pxInt(162)) + self.textFont.setMinimumWidth(CONFIG.pxInt(162)) self.textFont.setText(CONFIG.textFont) self.textFontButton = QToolButton(self) self.textFontButton.setIcon(mIcon) self.textFontButton.clicked.connect(self._selectTextFont) self.mainForm.addRow( - self.tr("Document font family"), - self.textFont, - self.tr("Applies to both document editor and viewer."), + self.tr("Document font family"), self.textFont, + self.tr("Applies to both document editor and viewer."), stretch=(3, 2), button=self.textFontButton ) @@ -260,18 +254,15 @@ def buildForm(self) -> None: self.textSize.setSingleStep(1) self.textSize.setValue(CONFIG.textSize) self.mainForm.addRow( - self.tr("Document font size"), - self.textSize, - self.tr("Applies to both document editor and viewer."), - unit=self.tr("pt") + self.tr("Document font size"), self.textSize, + self.tr("Applies to both document editor and viewer."), unit=self.tr("pt") ) # Emphasise Labels self.emphLabels = NSwitch(self) self.emphLabels.setChecked(CONFIG.emphLabels) self.mainForm.addRow( - self.tr("Emphasise partition and chapter labels"), - self.emphLabels, + self.tr("Emphasise partition and chapter labels"), self.emphLabels, self.tr("Makes them stand out in the project tree."), ) @@ -279,8 +270,7 @@ def buildForm(self) -> None: self.showFullPath = NSwitch(self) self.showFullPath.setChecked(CONFIG.showFullPath) self.mainForm.addRow( - self.tr("Show full path in document header"), - self.showFullPath, + self.tr("Show full path in document header"), self.showFullPath, self.tr("Add the parent folder names to the header.") ) @@ -288,8 +278,7 @@ def buildForm(self) -> None: self.incNotesWCount = NSwitch(self) self.incNotesWCount.setChecked(CONFIG.incNotesWCount) self.mainForm.addRow( - self.tr("Include project notes in status bar word count"), - self.incNotesWCount + self.tr("Include project notes in status bar word count"), self.incNotesWCount ) # Auto Save @@ -307,10 +296,8 @@ def buildForm(self) -> None: self.autoSaveDoc.setSingleStep(1) self.autoSaveDoc.setValue(CONFIG.autoSaveDoc) self.mainForm.addRow( - self.tr("Save document interval"), - self.autoSaveDoc, - self.tr("How often the document is automatically saved."), - unit=self.tr("seconds") + self.tr("Save document interval"), self.autoSaveDoc, + self.tr("How often the document is automatically saved."), unit=self.tr("seconds") ) # Project Save Timer @@ -320,10 +307,8 @@ def buildForm(self) -> None: self.autoSaveProj.setSingleStep(1) self.autoSaveProj.setValue(CONFIG.autoSaveProj) self.mainForm.addRow( - self.tr("Save project interval"), - self.autoSaveProj, - self.tr("How often the project is automatically saved."), - unit=self.tr("seconds") + self.tr("Save project interval"), self.autoSaveProj, + self.tr("How often the project is automatically saved."), unit=self.tr("seconds") ) # Project Backup @@ -339,10 +324,8 @@ def buildForm(self) -> None: self.backupGetPath = QPushButton(SHARED.theme.getIcon("browse"), self.tr("Browse"), self) self.backupGetPath.clicked.connect(self._backupFolder) self.mainForm.addRow( - self.tr("Backup storage location"), - self.backupGetPath, - self.tr("Path: {0}").format(self.backupPath), - editable="backupPath" + self.tr("Backup storage location"), self.backupGetPath, + self.tr("Path: {0}").format(self.backupPath), editable="backupPath" ) # Run When Closing @@ -350,8 +333,7 @@ def buildForm(self) -> None: self.backupOnClose.setChecked(CONFIG.backupOnClose) self.backupOnClose.toggled.connect(self._toggledBackupOnClose) self.mainForm.addRow( - self.tr("Run backup when the project is closed"), - self.backupOnClose, + self.tr("Run backup when the project is closed"), self.backupOnClose, self.tr("Can be overridden for individual projects in Project Settings.") ) @@ -361,8 +343,7 @@ def buildForm(self) -> None: self.askBeforeBackup.setChecked(CONFIG.askBeforeBackup) self.askBeforeBackup.setEnabled(CONFIG.backupOnClose) self.mainForm.addRow( - self.tr("Ask before running backup"), - self.askBeforeBackup, + self.tr("Ask before running backup"), self.askBeforeBackup, self.tr("If off, backups will run in the background.") ) @@ -378,8 +359,7 @@ def buildForm(self) -> None: self.stopWhenIdle = NSwitch(self) self.stopWhenIdle.setChecked(CONFIG.stopWhenIdle) self.mainForm.addRow( - self.tr("Pause the session timer when not writing"), - self.stopWhenIdle, + self.tr("Pause the session timer when not writing"), self.stopWhenIdle, self.tr("Also pauses when the application window does not have focus.") ) @@ -391,12 +371,14 @@ def buildForm(self) -> None: self.userIdleTime.setDecimals(1) self.userIdleTime.setValue(CONFIG.userIdleTime/60.0) self.mainForm.addRow( - self.tr("Editor inactive time before pausing timer"), - self.userIdleTime, + self.tr("Editor inactive time before pausing timer"), self.userIdleTime, self.tr("User activity includes typing and changing the content."), unit=self.tr("minutes") ) + # Label + self.sidebar.addLabel(self.tr("Writing")) + # Text Flow # ========= @@ -412,10 +394,8 @@ def buildForm(self) -> None: self.textWidth.setSingleStep(10) self.textWidth.setValue(CONFIG.textWidth) self.mainForm.addRow( - self.tr("Maximum text width in \"Normal Mode\""), - self.textWidth, - self.tr("Set to 0 to disable this feature."), - unit=self.tr("px") + self.tr("Maximum text width in \"Normal Mode\""), self.textWidth, + self.tr("Set to 0 to disable this feature."), unit=self.tr("px") ) # Max Text Width in Focus Mode @@ -425,18 +405,15 @@ def buildForm(self) -> None: self.focusWidth.setSingleStep(10) self.focusWidth.setValue(CONFIG.focusWidth) self.mainForm.addRow( - self.tr("Maximum text width in \"Focus Mode\""), - self.focusWidth, - self.tr("The maximum width cannot be disabled."), - unit=self.tr("px") + self.tr("Maximum text width in \"Focus Mode\""), self.focusWidth, + self.tr("The maximum width cannot be disabled."), unit=self.tr("px") ) # Focus Mode Footer self.hideFocusFooter = NSwitch(self) self.hideFocusFooter.setChecked(CONFIG.hideFocusFooter) self.mainForm.addRow( - self.tr("Hide document footer in \"Focus Mode\""), - self.hideFocusFooter, + self.tr("Hide document footer in \"Focus Mode\""), self.hideFocusFooter, self.tr("Hide the information bar in the document editor.") ) @@ -444,8 +421,7 @@ def buildForm(self) -> None: self.doJustify = NSwitch(self) self.doJustify.setChecked(CONFIG.doJustify) self.mainForm.addRow( - self.tr("Justify the text margins"), - self.doJustify, + self.tr("Justify the text margins"), self.doJustify, self.tr("Applies to both document editor and viewer."), ) @@ -456,8 +432,7 @@ def buildForm(self) -> None: self.textMargin.setSingleStep(1) self.textMargin.setValue(CONFIG.textMargin) self.mainForm.addRow( - self.tr("Minimum text margin"), - self.textMargin, + self.tr("Minimum text margin"), self.textMargin, self.tr("Applies to both document editor and viewer."), unit=self.tr("px") ) @@ -469,8 +444,7 @@ def buildForm(self) -> None: self.tabWidth.setSingleStep(1) self.tabWidth.setValue(CONFIG.tabWidth) self.mainForm.addRow( - self.tr("Tab width"), - self.tabWidth, + self.tr("Tab width"), self.tabWidth, self.tr("The width of a tab key press in the editor and viewer."), unit=self.tr("px") ) @@ -498,17 +472,15 @@ def buildForm(self) -> None: self.spellLanguage.setCurrentIndex(idx) self.mainForm.addRow( - self.tr("Spell check language"), - self.spellLanguage, - self.tr("Available languages are determined by your system.") + self.tr("Spell check language"), self.spellLanguage, + self.tr("Available languages are determined by your system."), stretch=(3, 2) ) # Auto-Select Word Under Cursor self.autoSelect = NSwitch(self) self.autoSelect.setChecked(CONFIG.autoSelect) self.mainForm.addRow( - self.tr("Auto-select word under cursor"), - self.autoSelect, + self.tr("Auto-select word under cursor"), self.autoSelect, self.tr("Apply formatting to word under cursor if no selection is made.") ) @@ -516,16 +488,14 @@ def buildForm(self) -> None: self.showTabsNSpaces = NSwitch(self) self.showTabsNSpaces.setChecked(CONFIG.showTabsNSpaces) self.mainForm.addRow( - self.tr("Show tabs and spaces"), - self.showTabsNSpaces + self.tr("Show tabs and spaces"), self.showTabsNSpaces ) # Show Line Endings self.showLineEndings = NSwitch(self) self.showLineEndings.setChecked(CONFIG.showLineEndings) self.mainForm.addRow( - self.tr("Show line endings"), - self.showLineEndings + self.tr("Show line endings"), self.showLineEndings ) # Editor Scrolling @@ -540,8 +510,7 @@ def buildForm(self) -> None: self.scrollPastEnd = NSwitch(self) self.scrollPastEnd.setChecked(CONFIG.scrollPastEnd) self.mainForm.addRow( - self.tr("Scroll past end of the document"), - self.scrollPastEnd, + self.tr("Scroll past end of the document"), self.scrollPastEnd, self.tr("Also centres the cursor when scrolling.") ) @@ -549,8 +518,7 @@ def buildForm(self) -> None: self.autoScroll = NSwitch(self) self.autoScroll.setChecked(CONFIG.autoScroll) self.mainForm.addRow( - self.tr("Typewriter style scrolling when you type"), - self.autoScroll, + self.tr("Typewriter style scrolling when you type"), self.autoScroll, self.tr("Keeps the cursor at a fixed vertical position.") ) @@ -561,10 +529,8 @@ def buildForm(self) -> None: self.autoScrollPos.setSingleStep(1) self.autoScrollPos.setValue(int(CONFIG.autoScrollPos)) self.mainForm.addRow( - self.tr("Minimum position for Typewriter scrolling"), - self.autoScrollPos, - self.tr("Percentage of the editor height from the top."), - unit="%" + self.tr("Minimum position for Typewriter scrolling"), self.autoScrollPos, + self.tr("Percentage of the editor height from the top."), unit="%" ) # Text Highlighting @@ -579,40 +545,35 @@ def buildForm(self) -> None: self.highlightQuotes.setChecked(CONFIG.highlightQuotes) self.highlightQuotes.toggled.connect(self._toggleHighlightQuotes) self.mainForm.addRow( - self.tr("Highlight text wrapped in quotes"), - self.highlightQuotes, + self.tr("Highlight text wrapped in quotes"), self.highlightQuotes, self.tr("Applies to the document editor only.") ) self.allowOpenSQuote = NSwitch(self) self.allowOpenSQuote.setChecked(CONFIG.allowOpenSQuote) self.mainForm.addRow( - self.tr("Allow open-ended single quotes"), - self.allowOpenSQuote, + self.tr("Allow open-ended single quotes"), self.allowOpenSQuote, self.tr("Highlight single-quoted line with no closing quote.") ) self.allowOpenDQuote = NSwitch(self) self.allowOpenDQuote.setChecked(CONFIG.allowOpenDQuote) self.mainForm.addRow( - self.tr("Allow open-ended double quotes"), - self.allowOpenDQuote, + self.tr("Allow open-ended double quotes"), self.allowOpenDQuote, self.tr("Highlight double-quoted line with no closing quote.") ) self.highlightEmph = NSwitch(self) self.highlightEmph.setChecked(CONFIG.highlightEmph) self.mainForm.addRow( - self.tr("Add highlight colour to emphasised text"), - self.highlightEmph, + self.tr("Add highlight colour to emphasised text"), self.highlightEmph, self.tr("Applies to the document editor only.") ) self.showMultiSpaces = NSwitch(self) self.showMultiSpaces.setChecked(CONFIG.showMultiSpaces) self.mainForm.addRow( - self.tr("Highlight multiple or trailing spaces"), - self.showMultiSpaces, + self.tr("Highlight multiple or trailing spaces"), self.showMultiSpaces, self.tr("Applies to the document editor only.") ) @@ -631,8 +592,7 @@ def buildForm(self) -> None: self.doReplace.setChecked(CONFIG.doReplace) self.doReplace.toggled.connect(self._toggleAutoReplaceMain) self.mainForm.addRow( - self.tr("Auto-replace text as you type"), - self.doReplace, + self.tr("Auto-replace text as you type"), self.doReplace, self.tr("Allow the editor to replace symbols as you type.") ) @@ -641,8 +601,7 @@ def buildForm(self) -> None: self.doReplaceSQuote.setChecked(CONFIG.doReplaceSQuote) self.doReplaceSQuote.setEnabled(CONFIG.doReplace) self.mainForm.addRow( - self.tr("Auto-replace single quotes"), - self.doReplaceSQuote, + self.tr("Auto-replace single quotes"), self.doReplaceSQuote, self.tr("Try to guess which is an opening or a closing quote.") ) @@ -651,8 +610,7 @@ def buildForm(self) -> None: self.doReplaceDQuote.setChecked(CONFIG.doReplaceDQuote) self.doReplaceDQuote.setEnabled(CONFIG.doReplace) self.mainForm.addRow( - self.tr("Auto-replace double quotes"), - self.doReplaceDQuote, + self.tr("Auto-replace double quotes"), self.doReplaceDQuote, self.tr("Try to guess which is an opening or a closing quote.") ) @@ -661,8 +619,7 @@ def buildForm(self) -> None: self.doReplaceDash.setChecked(CONFIG.doReplaceDash) self.doReplaceDash.setEnabled(CONFIG.doReplace) self.mainForm.addRow( - self.tr("Auto-replace dashes"), - self.doReplaceDash, + self.tr("Auto-replace dashes"), self.doReplaceDash, self.tr("Double and triple hyphens become short and long dashes.") ) @@ -671,31 +628,28 @@ def buildForm(self) -> None: self.doReplaceDots.setChecked(CONFIG.doReplaceDots) self.doReplaceDots.setEnabled(CONFIG.doReplace) self.mainForm.addRow( - self.tr("Auto-replace dots"), - self.doReplaceDots, + self.tr("Auto-replace dots"), self.doReplaceDots, self.tr("Three consecutive dots become ellipsis.") ) # Pad Before self.fmtPadBefore = QLineEdit(self) self.fmtPadBefore.setMaxLength(32) - self.fmtPadBefore.setMaximumWidth(boxWidth) + self.fmtPadBefore.setMinimumWidth(boxWidth) self.fmtPadBefore.setText(CONFIG.fmtPadBefore) self.mainForm.addRow( - self.tr("Insert non-breaking space before"), - self.fmtPadBefore, - self.tr("Automatically add space before any of these symbols."), + self.tr("Insert non-breaking space before"), self.fmtPadBefore, + self.tr("Automatically add space before any of these symbols."), stretch=(2, 1) ) # Pad After self.fmtPadAfter = QLineEdit(self) self.fmtPadAfter.setMaxLength(32) - self.fmtPadAfter.setMaximumWidth(boxWidth) + self.fmtPadAfter.setMinimumWidth(boxWidth) self.fmtPadAfter.setText(CONFIG.fmtPadAfter) self.mainForm.addRow( - self.tr("Insert non-breaking space after"), - self.fmtPadAfter, - self.tr("Automatically add space after any of these symbols."), + self.tr("Insert non-breaking space after"), self.fmtPadAfter, + self.tr("Automatically add space after any of these symbols."), stretch=(2, 1) ) # Use Thin Space @@ -703,8 +657,7 @@ def buildForm(self) -> None: self.fmtPadThin.setChecked(CONFIG.fmtPadThin) self.fmtPadThin.setEnabled(CONFIG.doReplace) self.mainForm.addRow( - self.tr("Use thin space instead"), - self.fmtPadThin, + self.tr("Use thin space instead"), self.fmtPadThin, self.tr("Inserts a thin space instead of a regular space.") ) @@ -730,8 +683,7 @@ def buildForm(self) -> None: self.btnSingleStyleO.setIcon(mIcon) self.btnSingleStyleO.clicked.connect(lambda: self._getQuote("SO")) self.mainForm.addRow( - self.tr("Single quote open style"), - self.quoteSym["SO"], + self.tr("Single quote open style"), self.quoteSym["SO"], self.tr("The symbol to use for a leading single quote."), button=self.btnSingleStyleO ) @@ -746,8 +698,7 @@ def buildForm(self) -> None: self.btnSingleStyleC.setIcon(mIcon) self.btnSingleStyleC.clicked.connect(lambda: self._getQuote("SC")) self.mainForm.addRow( - self.tr("Single quote close style"), - self.quoteSym["SC"], + self.tr("Single quote close style"), self.quoteSym["SC"], self.tr("The symbol to use for a trailing single quote."), button=self.btnSingleStyleC ) @@ -763,8 +714,7 @@ def buildForm(self) -> None: self.btnDoubleStyleO.setIcon(mIcon) self.btnDoubleStyleO.clicked.connect(lambda: self._getQuote("DO")) self.mainForm.addRow( - self.tr("Double quote open style"), - self.quoteSym["DO"], + self.tr("Double quote open style"), self.quoteSym["DO"], self.tr("The symbol to use for a leading double quote."), button=self.btnDoubleStyleO ) @@ -779,8 +729,7 @@ def buildForm(self) -> None: self.btnDoubleStyleC.setIcon(mIcon) self.btnDoubleStyleC.clicked.connect(lambda: self._getQuote("DC")) self.mainForm.addRow( - self.tr("Double quote close style"), - self.quoteSym["DC"], + self.tr("Double quote close style"), self.quoteSym["DC"], self.tr("The symbol to use for a trailing double quote."), button=self.btnDoubleStyleC ) diff --git a/novelwriter/extensions/configlayout.py b/novelwriter/extensions/configlayout.py index 99d38c037..fb4cd37d1 100644 --- a/novelwriter/extensions/configlayout.py +++ b/novelwriter/extensions/configlayout.py @@ -3,8 +3,7 @@ ========================================== File History: -Created: 2020-05-03 [0.4.5] NConfigLayout, NColourLabel -Created: 2023-05-23 [2.1b1] NSimpleLayout +Created: 2020-05-03 [0.4.5] NColourLabel Created: 2024-01-08 [2.3b1] NScrollableForm Created: 2024-01-26 [2.3b1] NScrollablePage Created: 2024-01-26 [2.3b1] NFixedPage @@ -30,8 +29,8 @@ from PyQt5.QtGui import QColor, QPalette from PyQt5.QtCore import Qt from PyQt5.QtWidgets import ( - QAbstractButton, QFrame, QGridLayout, QHBoxLayout, QLabel, QLayout, - QScrollArea, QSizePolicy, QVBoxLayout, QWidget + QAbstractButton, QFrame, QHBoxLayout, QLabel, QLayout, QScrollArea, + QVBoxLayout, QWidget ) from novelwriter import CONFIG @@ -52,7 +51,18 @@ def __init__(self, parent: QWidget) -> None: super().__init__(parent=parent) self.setFrameShadow(QFrame.Shadow.Sunken) self.setFrameShape(QFrame.Shape.StyledPanel) - self.setCentralLayout = self.setLayout + return + + def setCentralLayout(self, layout: QLayout) -> None: + """Set a layout as the central object.""" + self.setLayout(layout) + return + + def setCentralWidget(self, widget: QWidget) -> None: + """Set a layout as the central object.""" + layout = QHBoxLayout() + layout.addWidget(widget) + self.setLayout(layout) return # END Class NFixedPage @@ -162,7 +172,7 @@ def scrollToLabel(self, label: str) -> None: self.verticalScrollBar().setValue(yPos) return - def addGroupLabel(self, label: str, identifier: int) -> None: + def addGroupLabel(self, label: str, identifier: int | None = None) -> None: """Add a text label to separate groups of settings.""" hM = CONFIG.pxInt(4) qLabel = QLabel(f"{label}", self) @@ -170,13 +180,14 @@ def addGroupLabel(self, label: str, identifier: int) -> None: if not self._first: self._layout.addSpacing(5*hM) self._layout.addWidget(qLabel) - self._sections[identifier] = qLabel self._first = False + if identifier is not None: + self._sections[identifier] = qLabel return def addRow(self, label: str, widget: QWidget, helpText: str = "", unit: str | None = None, button: QWidget | None = None, editable: str | None = None, - stretch: tuple[int, int] = (0, 0)) -> None: + stretch: tuple[int, int] = (1, 0)) -> None: """Add a label and a widget as a new row of the form.""" row = QHBoxLayout() row.setSpacing(CONFIG.pxInt(12)) @@ -191,8 +202,8 @@ def addRow(self, label: str, widget: QWidget, helpText: str = "", unit: str | No scale=self._fontScale, wrap=True, indent=self._indent ) labelBox = QVBoxLayout() - labelBox.addWidget(qLabel) - labelBox.addWidget(qHelp) + labelBox.addWidget(qLabel, 0) + labelBox.addWidget(qHelp, 1) labelBox.setSpacing(0) row.addLayout(labelBox, stretch[0]) if editable: @@ -202,13 +213,13 @@ def addRow(self, label: str, widget: QWidget, helpText: str = "", unit: str | No if isinstance(unit, str): box = QHBoxLayout() - box.addWidget(widget) - box.addWidget(QLabel(unit, self)) + box.addWidget(widget, 1) + box.addWidget(QLabel(unit, self), 0) row.addLayout(box, stretch[1]) elif isinstance(button, QAbstractButton): box = QHBoxLayout() - box.addWidget(widget) - box.addWidget(button) + box.addWidget(widget, 1) + box.addWidget(button, 0) row.addLayout(box, stretch[1]) else: row.addWidget(widget, stretch[1]) @@ -228,125 +239,6 @@ def finalise(self) -> None: # END Class NScrollableForm -class NConfigLayout(QGridLayout): - - def __init__(self) -> None: - super().__init__() - - self._nextRow = 0 - self._helpCol = QColor(0, 0, 0) - self._fontScale = DEFAULT_SCALE - self._itemMap = {} - - wSp = CONFIG.pxInt(8) - self.setHorizontalSpacing(wSp) - self.setVerticalSpacing(wSp) - self.setColumnStretch(0, 1) - - return - - ## - # Class Methods - ## - - def addGroupLabel(self, label: str) -> None: - """Add a text label to separate groups of settings.""" - hM = CONFIG.pxInt(4) - qLabel = QLabel("%s" % label) - qLabel.setContentsMargins(0, hM, 0, hM) - self.addWidget(qLabel, self._nextRow, 0, 1, 2, Qt.AlignLeft) - self.setRowStretch(self._nextRow, 0) - self.setRowStretch(self._nextRow + 1, 1) - self._nextRow += 1 - return - - def addRow(self, label: str, widget: QWidget, unit: str | None = None, - button: QWidget | None = None) -> int: - """Add a label and a widget as a new row of the grid.""" - wSp = CONFIG.pxInt(8) - qLabel = QLabel(label) - qLabel.setIndent(wSp) - qLabel.setBuddy(widget) - - qHelp = None - self.addWidget(qLabel, self._nextRow, 0, 1, 1, LEFT_TOP) - - if isinstance(unit, str): - controlBox = QHBoxLayout() - controlBox.addWidget(widget, 0, Qt.AlignVCenter) - controlBox.addWidget(QLabel(unit), 0, Qt.AlignVCenter) - controlBox.setSpacing(wSp) - self.addLayout(controlBox, self._nextRow, 1, 1, 1, RIGHT_TOP) - - elif isinstance(button, QAbstractButton): - controlBox = QHBoxLayout() - controlBox.addWidget(widget, 0, Qt.AlignVCenter) - controlBox.addWidget(button, 0, Qt.AlignVCenter) - controlBox.setSpacing(wSp) - self.addLayout(controlBox, self._nextRow, 1, 1, 1, RIGHT_TOP) - - else: - self.addWidget(widget, self._nextRow, 1, 1, 1, RIGHT_TOP) - - self.setRowStretch(self._nextRow, 0) - self.setRowStretch(self._nextRow+1, 1) - - self._itemMap[self._nextRow] = (qLabel, qHelp, widget) - self._nextRow += 1 - - return self._nextRow - 1 - -# END Class NConfigLayout - - -class NSimpleLayout(QGridLayout): - """Similar to NConfigLayout, but only has a label + widget two - column layout. - """ - - def __init__(self, stretcColumn: int = 0) -> None: - super().__init__() - self._nextRow = 0 - - wSp = CONFIG.pxInt(8) - self.setHorizontalSpacing(wSp) - self.setVerticalSpacing(wSp) - self.setColumnStretch(stretcColumn, 1) - - return - - ## - # Methods - ## - - def addGroupLabel(self, label: str) -> None: - """Add a text label to separate groups of settings.""" - hM = CONFIG.pxInt(4) - qLabel = QLabel("%s" % label) - qLabel.setContentsMargins(0, hM, 0, hM) - self.addWidget(qLabel, self._nextRow, 0, 1, 2, Qt.AlignLeft) - self.setRowStretch(self._nextRow, 0) - self.setRowStretch(self._nextRow + 1, 1) - self._nextRow += 1 - return - - def addRow(self, label: str, widget: QWidget) -> None: - """Add a label and a widget as a new row of the grid.""" - wSp = CONFIG.pxInt(8) - qLabel = QLabel(label) - qLabel.setIndent(wSp) - qLabel.setBuddy(widget) - self.addWidget(qLabel, self._nextRow, 0, 1, 1, LEFT_TOP) - self.addWidget(widget, self._nextRow, 1, 1, 1, RIGHT_TOP) - self.setRowStretch(self._nextRow, 0) - self.setRowStretch(self._nextRow+1, 1) - self._nextRow += 1 - - return - -# END Class NSimpleLayout - - class NColourLabel(QLabel): """Extension: A Coloured Label @@ -369,10 +261,7 @@ def __init__(self, text: str, color: QColor, parent: QWidget | None = None, self.setPalette(colour) self.setFont(font) self.setIndent(indent) - - if wrap: - self.setWordWrap(True) - self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) + self.setWordWrap(wrap) return diff --git a/novelwriter/extensions/pagedsidebar.py b/novelwriter/extensions/pagedsidebar.py index 082e8a2a5..86a08fe21 100644 --- a/novelwriter/extensions/pagedsidebar.py +++ b/novelwriter/extensions/pagedsidebar.py @@ -71,14 +71,6 @@ def setLabelColor(self, color: QColor) -> None: self._labelCol = color return - def addSeparator(self) -> None: - """Add a spacer widget.""" - spacer = QWidget(self) - spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) - spacer.setFixedHeight(self._spacerHeight) - self.insertWidget(self._stretchAction, spacer) - return - def addLabel(self, text: str) -> None: """Add a new label to the toolbar.""" label = _NPagedToolLabel(self, self._labelCol) diff --git a/novelwriter/tools/manussettings.py b/novelwriter/tools/manussettings.py index e0c034af8..8160d78b5 100644 --- a/novelwriter/tools/manussettings.py +++ b/novelwriter/tools/manussettings.py @@ -42,7 +42,9 @@ from novelwriter.core.buildsettings import BuildSettings, FilterMode from novelwriter.extensions.switch import NSwitch from novelwriter.extensions.switchbox import NSwitchBox -from novelwriter.extensions.configlayout import NConfigLayout, NSimpleLayout +from novelwriter.extensions.configlayout import ( + NColourLabel, NFixedPage, NScrollableForm, NScrollablePage +) from novelwriter.extensions.pagedsidebar import NPagedSideBar if TYPE_CHECKING: # pragma: no cover @@ -90,34 +92,37 @@ def __init__(self, mainGui: GuiMain, build: BuildSettings) -> None: CONFIG.pxInt(pOptions.getInt("GuiBuildSettings", "winHeight", hWin)) ) - # Options SideBar - # =============== + # Title + self.titleLabel = NColourLabel( + self.tr("Manuscript Build Settings"), SHARED.theme.helpText, + parent=self, scale=NColourLabel.HEADER_SCALE, indent=CONFIG.pxInt(4) + ) - self.optSideBar = NPagedSideBar(self) - self.optSideBar.setMinimumWidth(mPx) - self.optSideBar.setMaximumWidth(mPx) - self.optSideBar.setLabelColor(SHARED.theme.helpText) + # Settings Name + self.lblBuildName = QLabel(self.tr("Name")) + self.editBuildName = QLineEdit(self) - self.optSideBar.addLabel(self.tr("Options")) - self.optSideBar.addButton(self.tr("Selection"), self.OPT_FILTERS) - self.optSideBar.addButton(self.tr("Headings"), self.OPT_HEADINGS) - self.optSideBar.addButton(self.tr("Content"), self.OPT_CONTENT) - self.optSideBar.addButton(self.tr("Format"), self.OPT_FORMAT) - self.optSideBar.addButton(self.tr("Output"), self.OPT_OUTPUT) + # SideBar + self.sidebar = NPagedSideBar(self) + self.sidebar.setMinimumWidth(mPx) + self.sidebar.setMaximumWidth(mPx) + self.sidebar.setLabelColor(SHARED.theme.helpText) - self.optSideBar.buttonClicked.connect(self._stackPageSelected) + self.sidebar.addButton(self.tr("Selection"), self.OPT_FILTERS) + self.sidebar.addButton(self.tr("Headings"), self.OPT_HEADINGS) + self.sidebar.addButton(self.tr("Content"), self.OPT_CONTENT) + self.sidebar.addButton(self.tr("Format"), self.OPT_FORMAT) + self.sidebar.addButton(self.tr("Output"), self.OPT_OUTPUT) - # Options Area - # ============ + self.sidebar.buttonClicked.connect(self._stackPageSelected) - # Create Tabs + # Content self.optTabSelect = _FilterTab(self, self._build) self.optTabHeadings = _HeadingsTab(self, self._build) self.optTabContent = _ContentTab(self, self._build) self.optTabFormat = _FormatTab(self, self._build) self.optTabOutput = _OutputTab(self, self._build) - # Add Tabs self.toolStack = QStackedWidget(self) self.toolStack.addWidget(self.optTabSelect) self.toolStack.addWidget(self.optTabHeadings) @@ -125,38 +130,36 @@ def __init__(self, mainGui: GuiMain, build: BuildSettings) -> None: self.toolStack.addWidget(self.optTabContent) self.toolStack.addWidget(self.optTabOutput) - # Main Settings + Buttons - # ======================= - - self.lblBuildName = QLabel(self.tr("Name")) - self.editBuildName = QLineEdit() - self.dlgButtons = QDialogButtonBox( - QDialogButtonBox.Apply | QDialogButtonBox.Save | QDialogButtonBox.Close + # Buttons + self.buttonBox = QDialogButtonBox( + QDialogButtonBox.StandardButton.Apply + | QDialogButtonBox.StandardButton.Save + | QDialogButtonBox.StandardButton.Close ) - self.dlgButtons.clicked.connect(self._dialogButtonClicked) - - self.buttonBox = QHBoxLayout() - self.buttonBox.addWidget(self.lblBuildName) - self.buttonBox.addWidget(self.editBuildName) - self.buttonBox.addWidget(self.dlgButtons) + self.buttonBox.clicked.connect(self._dialogButtonClicked) - # Assemble GUI - # ============ + # Assemble + self.topBox = QHBoxLayout() + self.topBox.addWidget(self.titleLabel) + self.topBox.addStretch(1) + self.topBox.addWidget(self.lblBuildName) + self.topBox.addWidget(self.editBuildName, 1) self.mainBox = QHBoxLayout() - self.mainBox.addWidget(self.optSideBar) + self.mainBox.addWidget(self.sidebar) self.mainBox.addWidget(self.toolStack) self.mainBox.setContentsMargins(0, 0, 0, 0) self.outerBox = QVBoxLayout() + self.outerBox.addLayout(self.topBox) self.outerBox.addLayout(self.mainBox) - self.outerBox.addLayout(self.buttonBox) + self.outerBox.addWidget(self.buttonBox) self.outerBox.setSpacing(CONFIG.pxInt(12)) self.setLayout(self.outerBox) # Set Default Tab - self.optSideBar.setSelected(self.OPT_FILTERS) + self.sidebar.setSelected(self.OPT_FILTERS) logger.debug("Ready: GuiBuildSettings") @@ -185,6 +188,21 @@ def buildID(self) -> str: """The build ID of the build of the dialog.""" return self._build.buildID + ## + # Events + ## + + def closeEvent(self, event: QEvent) -> None: + """Capture the user closing the window so we can save + settings. + """ + logger.debug("Closing: GuiBuildSettings") + self._askToSaveBuild() + self._saveSettings() + event.accept() + self.deleteLater() + return + ## # Private Slots ## @@ -207,7 +225,7 @@ def _stackPageSelected(self, pageId: int) -> None: @pyqtSlot("QAbstractButton*") def _dialogButtonClicked(self, button: QAbstractButton) -> None: """Handle button clicks from the dialog button box.""" - role = self.dlgButtons.buttonRole(button) + role = self.buttonBox.buttonRole(button) if role == QDialogButtonBox.ApplyRole: self._emitBuildData() elif role == QDialogButtonBox.AcceptRole: @@ -217,21 +235,6 @@ def _dialogButtonClicked(self, button: QAbstractButton) -> None: self.close() return - ## - # Events - ## - - def closeEvent(self, event: QEvent) -> None: - """Capture the user closing the window so we can save - settings. - """ - logger.debug("Closing: GuiBuildSettings") - self._askToSaveBuild() - self._saveSettings() - event.accept() - self.deleteLater() - return - ## # Internal Functions ## @@ -279,7 +282,7 @@ def _emitBuildData(self) -> None: # END Class GuiBuildSettings -class _FilterTab(QWidget): +class _FilterTab(NFixedPage): C_DATA = 0 C_NAME = 0 @@ -395,11 +398,7 @@ def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None: CONFIG.pxInt(pOptions.getInt("GuiBuildSettings", "filterWidth", 300)) ]) - self.outerBox = QHBoxLayout() - self.outerBox.addWidget(self.mainSplit) - self.outerBox.setContentsMargins(0, 0, 0, 0) - - self.setLayout(self.outerBox) + self.setCentralWidget(self.mainSplit) return @@ -580,7 +579,7 @@ def _scanChildren(self, item: QTreeWidgetItem | None, items: list) -> list[QTree # END Class _FilterTab -class _HeadingsTab(QWidget): +class _HeadingsTab(NScrollablePage): EDIT_TITLE = 1 EDIT_CHAPTER = 2 @@ -758,7 +757,7 @@ def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None: self.outerBox.addLayout(self.editFormBox) self.outerBox.addStretch(1) - self.setLayout(self.outerBox) + self.setCentralLayout(self.outerBox) return @@ -825,6 +824,7 @@ def _editHeading(self, heading: int) -> None: # Private Slots ## + @pyqtSlot() def _saveFormat(self) -> None: """Save the format from the edit text box.""" heading = self._editing @@ -881,7 +881,7 @@ def highlightBlock(self, text: str) -> None: # END Class _HeadingSyntaxHighlighter -class _ContentTab(QWidget): +class _ContentTab(NScrollableForm): def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None: super().__init__(parent=buildMain) @@ -890,42 +890,26 @@ def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None: iPx = SHARED.theme.baseIconSize - # Left Form - # ========= - - self.formLeft = NSimpleLayout() - self.formLeft.addGroupLabel(self._build.getLabel("text.grpContent")) - + # Text Content self.incSynopsis = NSwitch(self, width=2*iPx, height=iPx) self.incComments = NSwitch(self, width=2*iPx, height=iPx) self.incKeywords = NSwitch(self, width=2*iPx, height=iPx) self.incBodyText = NSwitch(self, width=2*iPx, height=iPx) - self.formLeft.addRow(self._build.getLabel("text.includeSynopsis"), self.incSynopsis) - self.formLeft.addRow(self._build.getLabel("text.includeComments"), self.incComments) - self.formLeft.addRow(self._build.getLabel("text.includeKeywords"), self.incKeywords) - self.formLeft.addRow(self._build.getLabel("text.includeBodyText"), self.incBodyText) - - # Right Form - # ========== - - self.formRight = NSimpleLayout() - self.formRight.addGroupLabel(self._build.getLabel("text.grpInsert")) + self.addGroupLabel(self._build.getLabel("text.grpContent")) + self.addRow(self._build.getLabel("text.includeSynopsis"), self.incSynopsis) + self.addRow(self._build.getLabel("text.includeComments"), self.incComments) + self.addRow(self._build.getLabel("text.includeKeywords"), self.incKeywords) + self.addRow(self._build.getLabel("text.includeBodyText"), self.incBodyText) + # Insert Content self.addNoteHead = NSwitch(self, width=2*iPx, height=iPx) - self.formRight.addRow(self._build.getLabel("text.addNoteHeadings"), self.addNoteHead) - - # Assemble GUI - # ============ + self.addGroupLabel(self._build.getLabel("text.grpInsert")) + self.addRow(self._build.getLabel("text.addNoteHeadings"), self.addNoteHead) - self.outerBox = QHBoxLayout() - self.outerBox.addLayout(self.formLeft, 1) - self.outerBox.addLayout(self.formRight, 1) - self.outerBox.setContentsMargins(0, 0, 0, 0) - self.outerBox.setSpacing(CONFIG.pxInt(16)) - - self.setLayout(self.outerBox) + # Finalise + self.finalise() return @@ -950,7 +934,7 @@ def saveContent(self) -> None: # END Class _ContentTab -class _FormatTab(QWidget): +class _FormatTab(NScrollableForm): def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None: super().__init__(parent=buildMain) @@ -964,20 +948,20 @@ def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None: spW = 6*SHARED.theme.textNWidth dbW = 8*SHARED.theme.textNWidth - # Text Format Form - # ================ + # Text Format + # =========== - self.formFormat = NConfigLayout() - self.formFormat.addGroupLabel(self._build.getLabel("format.grpFormat")) + self.addGroupLabel(self._build.getLabel("format.grpFormat")) # Font Family - self.textFont = QLineEdit() + self.textFont = QLineEdit(self) self.textFont.setReadOnly(True) self.btnTextFont = QPushButton("...") self.btnTextFont.setMaximumWidth(int(2.5*SHARED.theme.getTextWidth("..."))) self.btnTextFont.clicked.connect(self._selectFont) - self.formFormat.addRow( - self._build.getLabel("format.textFont"), self.textFont, button=self.btnTextFont + self.addRow( + self._build.getLabel("format.textFont"), self.textFont, + button=self.btnTextFont, stretch=(3, 2) ) # Font Size @@ -986,9 +970,7 @@ def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None: self.textSize.setMaximum(60) self.textSize.setSingleStep(1) self.textSize.setMinimumWidth(spW) - self.formFormat.addRow( - self._build.getLabel("format.textSize"), self.textSize, unit="pt" - ) + self.addRow(self._build.getLabel("format.textSize"), self.textSize, unit="pt") # Line Height self.lineHeight = QDoubleSpinBox(self) @@ -997,31 +979,25 @@ def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None: self.lineHeight.setMaximum(3.0) self.lineHeight.setSingleStep(0.05) self.lineHeight.setDecimals(2) - self.formFormat.addRow( - self._build.getLabel("format.lineHeight"), self.lineHeight, unit="em" - ) + self.addRow(self._build.getLabel("format.lineHeight"), self.lineHeight, unit="em") - # Text Options Form - # ================= + # Text Options + # ============ - self.formOptions = NSimpleLayout() - self.formOptions.addGroupLabel(self._build.getLabel("format.grpOptions")) - self.formOptions.setContentsMargins(0, 0, 0, 0) + self.addGroupLabel(self._build.getLabel("format.grpOptions")) self.justifyText = NSwitch(self, width=2*iPx, height=iPx) self.stripUnicode = NSwitch(self, width=2*iPx, height=iPx) self.replaceTabs = NSwitch(self, width=2*iPx, height=iPx) - self.formOptions.addRow(self._build.getLabel("format.justifyText"), self.justifyText) - self.formOptions.addRow(self._build.getLabel("format.stripUnicode"), self.stripUnicode) - self.formOptions.addRow(self._build.getLabel("format.replaceTabs"), self.replaceTabs) + self.addRow(self._build.getLabel("format.justifyText"), self.justifyText) + self.addRow(self._build.getLabel("format.stripUnicode"), self.stripUnicode) + self.addRow(self._build.getLabel("format.replaceTabs"), self.replaceTabs) - # Page Layout Form - # ================ + # Page Layout + # =========== - self.formLayout = NSimpleLayout() - self.formLayout.addGroupLabel(self._build.getLabel("format.grpPage")) - self.formLayout.setContentsMargins(0, 0, 0, 0) + self.addGroupLabel(self._build.getLabel("format.grpPage")) self.pageUnit = QComboBox(self) for key, name in nwLabels.UNIT_NAME.items(): @@ -1053,38 +1029,17 @@ def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None: self.rightMargin = QDoubleSpinBox(self) self.rightMargin.setFixedWidth(dbW) - self.formLayout.addRow(self._build.getLabel("format.pageUnit"), self.pageUnit) - self.formLayout.addRow(self._build.getLabel("format.pageSize"), self.pageSize) - self.formLayout.addRow(self._build.getLabel("format.pageWidth"), self.pageWidth) - self.formLayout.addRow(self._build.getLabel("format.pageHeight"), self.pageHeight) - self.formLayout.addRow(self._build.getLabel("format.topMargin"), self.topMargin) - self.formLayout.addRow(self._build.getLabel("format.bottomMargin"), self.bottomMargin) - self.formLayout.addRow(self._build.getLabel("format.leftMargin"), self.leftMargin) - self.formLayout.addRow(self._build.getLabel("format.rightMargin"), self.rightMargin) + self.addRow(self._build.getLabel("format.pageUnit"), self.pageUnit) + self.addRow(self._build.getLabel("format.pageSize"), self.pageSize) + self.addRow(self._build.getLabel("format.pageWidth"), self.pageWidth) + self.addRow(self._build.getLabel("format.pageHeight"), self.pageHeight) + self.addRow(self._build.getLabel("format.topMargin"), self.topMargin) + self.addRow(self._build.getLabel("format.bottomMargin"), self.bottomMargin) + self.addRow(self._build.getLabel("format.leftMargin"), self.leftMargin) + self.addRow(self._build.getLabel("format.rightMargin"), self.rightMargin) - # Assemble GUI - # ============ - - self.formLeft = QVBoxLayout() - self.formLeft.addLayout(self.formFormat) - self.formLeft.addLayout(self.formOptions) - self.formLeft.addStretch(1) - self.formLeft.setContentsMargins(0, 0, 0, 0) - self.formLeft.setSpacing(CONFIG.pxInt(8)) - - self.formRight = QVBoxLayout() - self.formRight.addLayout(self.formLayout) - self.formRight.addStretch(1) - self.formRight.setContentsMargins(0, 0, 0, 0) - self.formRight.setSpacing(CONFIG.pxInt(8)) - - self.outerBox = QHBoxLayout() - self.outerBox.addLayout(self.formLeft, 1) - self.outerBox.addLayout(self.formRight, 1) - self.outerBox.setContentsMargins(0, 0, 0, 0) - self.outerBox.setSpacing(CONFIG.pxInt(16)) - - self.setLayout(self.outerBox) + # Finalise + self.finalise() return @@ -1248,7 +1203,7 @@ def _pageSizeValueChanged(self): # END Class _FormatTab -class _OutputTab(QWidget): +class _OutputTab(NScrollableForm): def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None: super().__init__(parent=buildMain) @@ -1257,36 +1212,18 @@ def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None: iPx = SHARED.theme.baseIconSize - # Left Form - # ========= - - self.formLeft = NSimpleLayout() - self.formLeft.addGroupLabel(self._build.getLabel("odt")) - + # Open Document + self.addGroupLabel(self._build.getLabel("odt")) self.odtAddColours = NSwitch(self, width=2*iPx, height=iPx) + self.addRow(self._build.getLabel("odt.addColours"), self.odtAddColours) - self.formLeft.addRow(self._build.getLabel("odt.addColours"), self.odtAddColours) - - # Right Form - # ========== - - self.formRight = NSimpleLayout() - self.formRight.addGroupLabel(self._build.getLabel("html")) - + # HTML Document + self.addGroupLabel(self._build.getLabel("html")) self.htmlAddStyles = NSwitch(self, width=2*iPx, height=iPx) + self.addRow(self._build.getLabel("html.addStyles"), self.htmlAddStyles) - self.formRight.addRow(self._build.getLabel("html.addStyles"), self.htmlAddStyles) - - # Assemble GUI - # ============ - - self.outerBox = QHBoxLayout() - self.outerBox.addLayout(self.formLeft, 1) - self.outerBox.addLayout(self.formRight, 1) - self.outerBox.setContentsMargins(0, 0, 0, 0) - self.outerBox.setSpacing(CONFIG.pxInt(16)) - - self.setLayout(self.outerBox) + # Finalise + self.finalise() return diff --git a/tests/test_tools/test_tools_manuscript.py b/tests/test_tools/test_tools_manuscript.py index ed9eb756d..0978ee050 100644 --- a/tests/test_tools/test_tools_manuscript.py +++ b/tests/test_tools/test_tools_manuscript.py @@ -116,7 +116,7 @@ def _testNewSettingsReady(new: BuildSettings): with qtbot.waitSignal(bSettings.newSettingsReady, timeout=5000): bSettings.newSettingsReady.connect(_testNewSettingsReady) - bSettings.dlgButtons.button(QDialogButtonBox.Save).click() + bSettings.buttonBox.button(QDialogButtonBox.Save).click() assert isinstance(build, BuildSettings) assert build.name == "Test Build" @@ -133,7 +133,7 @@ def _testNewSettingsReady(new: BuildSettings): with qtbot.waitSignal(bSettings.newSettingsReady, timeout=5000): bSettings.newSettingsReady.connect(_testNewSettingsReady) - bSettings.dlgButtons.button(QDialogButtonBox.Apply).click() # Should leave the dialog open + bSettings.buttonBox.button(QDialogButtonBox.Apply).click() # Should leave the dialog open assert isinstance(build, BuildSettings) assert build.name == "Test Build" diff --git a/tests/test_tools/test_tools_manussettings.py b/tests/test_tools/test_tools_manussettings.py index de3a68a07..d347d8172 100644 --- a/tests/test_tools/test_tools_manussettings.py +++ b/tests/test_tools/test_tools_manussettings.py @@ -53,19 +53,19 @@ def testBuildSettings_Init(qtbot: QtBot, nwGUI: GuiMain, projPath: Path, mockRnd bSettings.loadContent() # Flip through pages - bSettings.optSideBar._group.button(bSettings.OPT_OUTPUT).click() + bSettings.sidebar._group.button(bSettings.OPT_OUTPUT).click() assert isinstance(bSettings.toolStack.currentWidget(), _OutputTab) - bSettings.optSideBar._group.button(bSettings.OPT_FORMAT).click() + bSettings.sidebar._group.button(bSettings.OPT_FORMAT).click() assert isinstance(bSettings.toolStack.currentWidget(), _FormatTab) - bSettings.optSideBar._group.button(bSettings.OPT_CONTENT).click() + bSettings.sidebar._group.button(bSettings.OPT_CONTENT).click() assert isinstance(bSettings.toolStack.currentWidget(), _ContentTab) - bSettings.optSideBar._group.button(bSettings.OPT_HEADINGS).click() + bSettings.sidebar._group.button(bSettings.OPT_HEADINGS).click() assert isinstance(bSettings.toolStack.currentWidget(), _HeadingsTab) - bSettings.optSideBar._group.button(bSettings.OPT_FILTERS).click() + bSettings.sidebar._group.button(bSettings.OPT_FILTERS).click() assert isinstance(bSettings.toolStack.currentWidget(), _FilterTab) # Check dialog buttons @@ -80,7 +80,7 @@ def _testNewSettingsReady(new: BuildSettings): # Capture Apply button with qtbot.waitSignal(bSettings.newSettingsReady, timeout=5000): bSettings.newSettingsReady.connect(_testNewSettingsReady) - bSettings._dialogButtonClicked(bSettings.dlgButtons.button(QDialogButtonBox.Apply)) + bSettings._dialogButtonClicked(bSettings.buttonBox.button(QDialogButtonBox.Apply)) assert triggered @@ -89,7 +89,7 @@ def _testNewSettingsReady(new: BuildSettings): with qtbot.waitSignal(bSettings.newSettingsReady, timeout=5000): bSettings.newSettingsReady.connect(_testNewSettingsReady) - bSettings._dialogButtonClicked(bSettings.dlgButtons.button(QDialogButtonBox.Save)) + bSettings._dialogButtonClicked(bSettings.buttonBox.button(QDialogButtonBox.Save)) assert triggered @@ -106,7 +106,7 @@ def _testNewSettingsReady(new: BuildSettings): assert triggered # Finish - bSettings._dialogButtonClicked(bSettings.dlgButtons.button(QDialogButtonBox.Close)) + bSettings._dialogButtonClicked(bSettings.buttonBox.button(QDialogButtonBox.Close)) # qtbot.stop() # END Test testBuildSettings_Init @@ -141,7 +141,7 @@ def testBuildSettings_Filter(qtbot: QtBot, nwGUI: GuiMain, projPath: Path, mockR bSettings.loadContent() filterTab = bSettings.optTabSelect - bSettings.optSideBar._group.button(bSettings.OPT_FILTERS).click() + bSettings.sidebar._group.button(bSettings.OPT_FILTERS).click() assert bSettings.toolStack.currentWidget() is filterTab # Check content @@ -312,7 +312,7 @@ def testBuildSettings_Filter(qtbot: QtBot, nwGUI: GuiMain, projPath: Path, mockR ] # Finish - bSettings._dialogButtonClicked(bSettings.dlgButtons.button(QDialogButtonBox.Close)) + bSettings._dialogButtonClicked(bSettings.buttonBox.button(QDialogButtonBox.Close)) # qtbot.stop() # END Test testBuildSettings_Filter @@ -343,7 +343,7 @@ def testBuildSettings_Headings(qtbot: QtBot, nwGUI: GuiMain): bSettings.loadContent() headTab = bSettings.optTabHeadings - bSettings.optSideBar._group.button(bSettings.OPT_HEADINGS).click() + bSettings.sidebar._group.button(bSettings.OPT_HEADINGS).click() assert bSettings.toolStack.currentWidget() is headTab # Check initial values @@ -468,7 +468,7 @@ def testBuildSettings_Headings(qtbot: QtBot, nwGUI: GuiMain): assert build.getBool("headings.hideSection") is True # Finish - bSettings._dialogButtonClicked(bSettings.dlgButtons.button(QDialogButtonBox.Close)) + bSettings._dialogButtonClicked(bSettings.buttonBox.button(QDialogButtonBox.Close)) # qtbot.stop() # END Test testBuildSettings_Headings @@ -492,7 +492,7 @@ def testBuildSettings_Content(qtbot: QtBot, nwGUI: GuiMain): bSettings.loadContent() contTab = bSettings.optTabContent - bSettings.optSideBar._group.button(bSettings.OPT_CONTENT).click() + bSettings.sidebar._group.button(bSettings.OPT_CONTENT).click() assert bSettings.toolStack.currentWidget() is contTab # Check initial values @@ -522,7 +522,7 @@ def testBuildSettings_Content(qtbot: QtBot, nwGUI: GuiMain): assert build.getBool("text.addNoteHeadings") is True # Finish - bSettings._dialogButtonClicked(bSettings.dlgButtons.button(QDialogButtonBox.Close)) + bSettings._dialogButtonClicked(bSettings.buttonBox.button(QDialogButtonBox.Close)) # qtbot.stop() # END Test testBuildSettings_Content @@ -559,7 +559,7 @@ def testBuildSettings_Format(monkeypatch, qtbot: QtBot, nwGUI: GuiMain): bSettings.loadContent() fmtTab = bSettings.optTabFormat - bSettings.optSideBar._group.button(bSettings.OPT_FORMAT).click() + bSettings.sidebar._group.button(bSettings.OPT_FORMAT).click() assert bSettings.toolStack.currentWidget() is fmtTab # Check initial values @@ -624,7 +624,7 @@ def testBuildSettings_Format(monkeypatch, qtbot: QtBot, nwGUI: GuiMain): assert fmtTab.textSize.value() == 10 # Finish - bSettings._dialogButtonClicked(bSettings.dlgButtons.button(QDialogButtonBox.Close)) + bSettings._dialogButtonClicked(bSettings.buttonBox.button(QDialogButtonBox.Close)) # qtbot.stop() # END Test testBuildSettings_Format @@ -644,7 +644,7 @@ def testBuildSettings_Output(qtbot: QtBot, nwGUI: GuiMain): bSettings.loadContent() outTab = bSettings.optTabOutput - bSettings.optSideBar._group.button(bSettings.OPT_OUTPUT).click() + bSettings.sidebar._group.button(bSettings.OPT_OUTPUT).click() assert bSettings.toolStack.currentWidget() is outTab # Check initial values @@ -662,7 +662,7 @@ def testBuildSettings_Output(qtbot: QtBot, nwGUI: GuiMain): assert build.getBool("html.addStyles") is True # Finish - bSettings._dialogButtonClicked(bSettings.dlgButtons.button(QDialogButtonBox.Close)) + bSettings._dialogButtonClicked(bSettings.buttonBox.button(QDialogButtonBox.Close)) # qtbot.stop() # END Test testBuildSettings_Output