Clean up flags in all GUI classes

This commit is contained in:
Veronica Berglyd Olsen
2024-04-03 21:09:49 +02:00
parent 20c5993e2d
commit 8fff376076
32 changed files with 236 additions and 229 deletions
+8 -4
View File
@@ -61,8 +61,12 @@ class Config:
self.appHandle = "novelwriter" self.appHandle = "novelwriter"
# Set Paths # Set Paths
confRoot = Path(QStandardPaths.writableLocation(QStandardPaths.ConfigLocation)) confRoot = Path(QStandardPaths.writableLocation(
dataRoot = Path(QStandardPaths.writableLocation(QStandardPaths.AppDataLocation)) QStandardPaths.StandardLocation.ConfigLocation)
)
dataRoot = Path(QStandardPaths.writableLocation(
QStandardPaths.StandardLocation.AppDataLocation)
)
self._confPath = confRoot.absolute() / self.appHandle # The user config location self._confPath = confRoot.absolute() / self.appHandle # The user config location
self._dataPath = dataRoot.absolute() / self.appHandle # The user data location self._dataPath = dataRoot.absolute() / self.appHandle # The user data location
@@ -83,7 +87,7 @@ class Config:
# Localisation # Localisation
# Note that these paths must be strings # Note that these paths must be strings
self._nwLangPath = self._appPath / "assets" / "i18n" self._nwLangPath = self._appPath / "assets" / "i18n"
self._qtLangPath = QLibraryInfo.location(QLibraryInfo.TranslationsPath) self._qtLangPath = QLibraryInfo.location(QLibraryInfo.LibraryLocation.TranslationsPath)
hasLocale = (self._nwLangPath / f"nw_{QLocale.system().name()}.qm").exists() hasLocale = (self._nwLangPath / f"nw_{QLocale.system().name()}.qm").exists()
self._qLocale = QLocale.system() if hasLocale else QLocale("en_GB") self._qLocale = QLocale.system() if hasLocale else QLocale("en_GB")
@@ -369,7 +373,7 @@ class Config:
elif self.osDarwin and "Helvetica" in fontFam: elif self.osDarwin and "Helvetica" in fontFam:
self.textFont = "Helvetica" self.textFont = "Helvetica"
else: else:
self.textFont = fontDB.systemFont(QFontDatabase.GeneralFont).family() self.textFont = fontDB.systemFont(QFontDatabase.SystemFont.GeneralFont).family()
else: else:
self.textFont = family self.textFont = family
return return
+6 -6
View File
@@ -32,7 +32,7 @@ from PyQt5.QtWidgets import (
) )
from novelwriter import CONFIG, SHARED from novelwriter import CONFIG, SHARED
from novelwriter.common import readTextFile from novelwriter.common import cssCol, readTextFile
from novelwriter.extensions.configlayout import NColourLabel from novelwriter.extensions.configlayout import NColourLabel
from novelwriter.extensions.versioninfo import VersionInfoWidget from novelwriter.extensions.versioninfo import VersionInfoWidget
from novelwriter.types import QtAlignRightTop, QtDialogClose from novelwriter.types import QtAlignRightTop, QtDialogClose
@@ -70,7 +70,7 @@ class GuiAbout(QDialog):
self.nwLicence = QLabel(self.tr("This application is licenced under {0}").format( self.nwLicence = QLabel(self.tr("This application is licenced under {0}").format(
"<a href='https://www.gnu.org/licenses/gpl-3.0.html'>GPL v3.0</a>" "<a href='https://www.gnu.org/licenses/gpl-3.0.html'>GPL v3.0</a>"
)) ), self)
self.nwLicence.setOpenExternalLinks(True) self.nwLicence.setOpenExternalLinks(True)
# Credits # Credits
@@ -147,10 +147,10 @@ class GuiAbout(QDialog):
def _setStyleSheet(self) -> None: def _setStyleSheet(self) -> None:
"""Set stylesheet for all browser tabs.""" """Set stylesheet for all browser tabs."""
baseCol = self.palette().window().color() baseCol = cssCol(self.palette().window().color())
self.txtCredits.setStyleSheet(( self.txtCredits.setStyleSheet(
"QTextBrowser {{border: none; background: rgb({r},{g},{b});}} " f"QTextBrowser {{border: none; background: {baseCol};}} "
).format(r=baseCol.red(), g=baseCol.green(), b=baseCol.blue())) )
return return
# END Class GuiAbout # END Class GuiAbout
+7 -6
View File
@@ -54,7 +54,8 @@ class GuiDocMerge(QDialog):
self._data = {} self._data = {}
self.headLabel = QLabel("<b>{0}</b>".format(self.tr("Documents to Merge"))) self.headLabel = QLabel(self.tr("Documents to Merge"), self)
self.headLabel.setFont(SHARED.theme.guiFontB)
self.helpLabel = NColourLabel( self.helpLabel = NColourLabel(
self.tr("Drag and drop items to change the order, or uncheck to exclude."), self.tr("Drag and drop items to change the order, or uncheck to exclude."),
SHARED.theme.helpText, parent=self, wrap=True SHARED.theme.helpText, parent=self, wrap=True
@@ -70,12 +71,12 @@ class GuiDocMerge(QDialog):
self.listBox.setIconSize(iSz) self.listBox.setIconSize(iSz)
self.listBox.setMinimumWidth(CONFIG.pxInt(400)) self.listBox.setMinimumWidth(CONFIG.pxInt(400))
self.listBox.setMinimumHeight(CONFIG.pxInt(180)) self.listBox.setMinimumHeight(CONFIG.pxInt(180))
self.listBox.setSelectionBehavior(QAbstractItemView.SelectRows) self.listBox.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
self.listBox.setSelectionMode(QAbstractItemView.SingleSelection) self.listBox.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection)
self.listBox.setDragDropMode(QAbstractItemView.InternalMove) self.listBox.setDragDropMode(QAbstractItemView.DragDropMode.InternalMove)
# Merge Options # Merge Options
self.trashLabel = QLabel(self.tr("Move merged items to Trash")) self.trashLabel = QLabel(self.tr("Move merged items to Trash"), self)
self.trashSwitch = NSwitch(self, height=iPx) self.trashSwitch = NSwitch(self, height=iPx)
self.optBox = QGridLayout() self.optBox = QGridLayout()
@@ -85,7 +86,7 @@ class GuiDocMerge(QDialog):
self.optBox.setColumnStretch(2, 1) self.optBox.setColumnStretch(2, 1)
# Buttons # Buttons
self.buttonBox = QDialogButtonBox(QtDialogOk | QtDialogCancel) self.buttonBox = QDialogButtonBox(QtDialogOk | QtDialogCancel, self)
self.buttonBox.accepted.connect(self.accept) self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject) self.buttonBox.rejected.connect(self.reject)
+8 -7
View File
@@ -58,7 +58,8 @@ class GuiDocSplit(QDialog):
self.setWindowTitle(self.tr("Split Document")) self.setWindowTitle(self.tr("Split Document"))
self.headLabel = QLabel("<b>{0}</b>".format(self.tr("Document Headings"))) self.headLabel = QLabel(self.tr("Document Headings"), self)
self.headLabel.setFont(SHARED.theme.guiFontB)
self.helpLabel = NColourLabel( self.helpLabel = NColourLabel(
self.tr("Select the maximum level to split into files."), self.tr("Select the maximum level to split into files."),
SHARED.theme.helpText, parent=self, wrap=True SHARED.theme.helpText, parent=self, wrap=True
@@ -76,8 +77,8 @@ class GuiDocSplit(QDialog):
docHierarchy = pOptions.getBool("GuiDocSplit", "docHierarchy", True) docHierarchy = pOptions.getBool("GuiDocSplit", "docHierarchy", True)
# Heading Selection # Heading Selection
self.listBox = QListWidget() self.listBox = QListWidget(self)
self.listBox.setDragDropMode(QAbstractItemView.NoDragDrop) self.listBox.setDragDropMode(QAbstractItemView.DragDropMode.NoDragDrop)
self.listBox.setMinimumWidth(CONFIG.pxInt(400)) self.listBox.setMinimumWidth(CONFIG.pxInt(400))
self.listBox.setMinimumHeight(CONFIG.pxInt(180)) self.listBox.setMinimumHeight(CONFIG.pxInt(180))
@@ -92,15 +93,15 @@ class GuiDocSplit(QDialog):
self.splitLevel.currentIndexChanged.connect(self._reloadList) self.splitLevel.currentIndexChanged.connect(self._reloadList)
# Split Options # Split Options
self.folderLabel = QLabel(self.tr("Split into a new folder")) self.folderLabel = QLabel(self.tr("Split into a new folder"), self)
self.folderSwitch = NSwitch(self, height=iPx) self.folderSwitch = NSwitch(self, height=iPx)
self.folderSwitch.setChecked(intoFolder) self.folderSwitch.setChecked(intoFolder)
self.hierarchyLabel = QLabel(self.tr("Create document hierarchy")) self.hierarchyLabel = QLabel(self.tr("Create document hierarchy"), self)
self.hierarchySwitch = NSwitch(self, height=iPx) self.hierarchySwitch = NSwitch(self, height=iPx)
self.hierarchySwitch.setChecked(docHierarchy) self.hierarchySwitch.setChecked(docHierarchy)
self.trashLabel = QLabel(self.tr("Move split document to Trash")) self.trashLabel = QLabel(self.tr("Move split document to Trash"), self)
self.trashSwitch = NSwitch(self, height=iPx) self.trashSwitch = NSwitch(self, height=iPx)
self.optBox = QGridLayout() self.optBox = QGridLayout()
@@ -115,7 +116,7 @@ class GuiDocSplit(QDialog):
self.optBox.setColumnStretch(3, 1) self.optBox.setColumnStretch(3, 1)
# Buttons # Buttons
self.buttonBox = QDialogButtonBox(QtDialogOk | QtDialogCancel) self.buttonBox = QDialogButtonBox(QtDialogOk | QtDialogCancel, self)
self.buttonBox.accepted.connect(self.accept) self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject) self.buttonBox.rejected.connect(self.reject)
+2 -2
View File
@@ -56,13 +56,13 @@ class GuiEditLabel(QDialog):
self.labelValue.selectAll() self.labelValue.selectAll()
# Buttons # Buttons
self.buttonBox = QDialogButtonBox(QtDialogOk | QtDialogCancel) self.buttonBox = QDialogButtonBox(QtDialogOk | QtDialogCancel, self)
self.buttonBox.accepted.connect(self.accept) self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject) self.buttonBox.rejected.connect(self.reject)
# Assemble # Assemble
self.innerBox = QHBoxLayout() self.innerBox = QHBoxLayout()
self.innerBox.addWidget(QLabel(self.tr("Label")), 0) self.innerBox.addWidget(QLabel(self.tr("Label"), self), 0)
self.innerBox.addWidget(self.labelValue, 1) self.innerBox.addWidget(self.labelValue, 1)
self.innerBox.setSpacing(mSp) self.innerBox.setSpacing(mSp)
+2 -2
View File
@@ -87,7 +87,7 @@ class GuiPreferences(QDialog):
self.mainForm.setHelpTextStyle(SHARED.theme.helpText) self.mainForm.setHelpTextStyle(SHARED.theme.helpText)
# Buttons # Buttons
self.buttonBox = QDialogButtonBox(QtDialogApply | QtDialogSave | QtDialogClose) self.buttonBox = QDialogButtonBox(QtDialogApply | QtDialogSave | QtDialogClose, self)
self.buttonBox.clicked.connect(self._dialogButtonClicked) self.buttonBox.clicked.connect(self._dialogButtonClicked)
# Assemble # Assemble
@@ -811,7 +811,7 @@ class GuiPreferences(QDialog):
"""Open a dialog to select the backup folder.""" """Open a dialog to select the backup folder."""
if path := QFileDialog.getExistingDirectory( if path := QFileDialog.getExistingDirectory(
self, self.tr("Backup Directory"), str(self.backupPath) or "", self, self.tr("Backup Directory"), str(self.backupPath) or "",
options=QFileDialog.ShowDirsOnly options=QFileDialog.Option.ShowDirsOnly
): ):
self.backupPath = path self.backupPath = path
self.mainForm.setHelpText("backupPath", self.tr("Path: {0}").format(path)) self.mainForm.setHelpText("backupPath", self.tr("Path: {0}").format(path))
+2 -2
View File
@@ -84,7 +84,7 @@ class GuiProjectSettings(QDialog):
self.sidebar.buttonClicked.connect(self._sidebarClicked) self.sidebar.buttonClicked.connect(self._sidebarClicked)
# Buttons # Buttons
self.buttonBox = QDialogButtonBox(QtDialogSave | QtDialogCancel) self.buttonBox = QDialogButtonBox(QtDialogSave | QtDialogCancel, self)
self.buttonBox.accepted.connect(self._doSave) self.buttonBox.accepted.connect(self._doSave)
self.buttonBox.rejected.connect(self.close) self.buttonBox.rejected.connect(self.close)
@@ -603,7 +603,7 @@ class _ReplacePage(NFixedPage):
) )
# List Box # List Box
self.listBox = QTreeWidget() self.listBox = QTreeWidget(self)
self.listBox.setHeaderLabels([self.tr("Keyword"), self.tr("Replace With")]) self.listBox.setHeaderLabels([self.tr("Keyword"), self.tr("Replace With")])
self.listBox.setColumnWidth(self.COL_KEY, wCol0) self.listBox.setColumnWidth(self.COL_KEY, wCol0)
self.listBox.setIndentation(0) self.listBox.setIndentation(0)
+4 -4
View File
@@ -66,14 +66,14 @@ class GuiQuoteSelect(QDialog):
lblFont.setPointSizeF(4*lblFont.pointSizeF()) lblFont.setPointSizeF(4*lblFont.pointSizeF())
# Preview Label # Preview Label
self.previewLabel = QLabel(current) self.previewLabel = QLabel(current, self)
self.previewLabel.setFont(lblFont) self.previewLabel.setFont(lblFont)
self.previewLabel.setFixedSize(QSize(pxW, pxH)) self.previewLabel.setFixedSize(QSize(pxW, pxH))
self.previewLabel.setAlignment(QtAlignCenter) self.previewLabel.setAlignment(QtAlignCenter)
self.previewLabel.setFrameStyle(QFrame.Box | QFrame.Plain) self.previewLabel.setFrameStyle(QFrame.Shape.Box | QFrame.Shadow.Plain)
# Quote Symbols # Quote Symbols
self.listBox = QListWidget() self.listBox = QListWidget(self)
self.listBox.itemSelectionChanged.connect(self._selectedSymbol) self.listBox.itemSelectionChanged.connect(self._selectedSymbol)
minSize = 100 minSize = 100
@@ -90,7 +90,7 @@ class GuiQuoteSelect(QDialog):
self.listBox.setMinimumHeight(CONFIG.pxInt(150)) self.listBox.setMinimumHeight(CONFIG.pxInt(150))
# Buttons # Buttons
self.buttonBox = QDialogButtonBox(QtDialogOk | QtDialogCancel) self.buttonBox = QDialogButtonBox(QtDialogOk | QtDialogCancel, self)
self.buttonBox.accepted.connect(self.accept) self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject) self.buttonBox.rejected.connect(self.reject)
+2 -2
View File
@@ -92,7 +92,7 @@ class GuiWordList(QDialog):
# List Box # List Box
self.listBox = QListWidget(self) self.listBox = QListWidget(self)
self.listBox.setDragDropMode(QAbstractItemView.NoDragDrop) self.listBox.setDragDropMode(QAbstractItemView.DragDropMode.NoDragDrop)
self.listBox.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) self.listBox.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
self.listBox.setSortingEnabled(True) self.listBox.setSortingEnabled(True)
@@ -111,7 +111,7 @@ class GuiWordList(QDialog):
self.editBox.addWidget(self.delButton, 0) self.editBox.addWidget(self.delButton, 0)
# Buttons # Buttons
self.buttonBox = QDialogButtonBox(QtDialogSave | QtDialogClose) self.buttonBox = QDialogButtonBox(QtDialogSave | QtDialogClose, self)
self.buttonBox.accepted.connect(self._doSave) self.buttonBox.accepted.connect(self._doSave)
self.buttonBox.rejected.connect(self.close) self.buttonBox.rejected.connect(self.close)
+1 -1
View File
@@ -59,7 +59,7 @@ class NProgressCircle(QProgressBar):
bar=self.palette().highlight().color(), bar=self.palette().highlight().color(),
text=self.palette().text().color() text=self.palette().text().color()
) )
self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
self.setFixedWidth(size) self.setFixedWidth(size)
self.setFixedHeight(size) self.setFixedHeight(size)
return return
+3 -3
View File
@@ -59,7 +59,7 @@ class NPagedSideBar(QToolBar):
self.setOrientation(Qt.Orientation.Vertical) self.setOrientation(Qt.Orientation.Vertical)
stretch = QWidget(self) stretch = QWidget(self)
stretch.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) stretch.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
self._stretchAction = self.addWidget(stretch) self._stretchAction = self.addWidget(stretch)
return return
@@ -119,7 +119,7 @@ class _NPagedToolButton(QToolButton):
def __init__(self, parent: QWidget) -> None: def __init__(self, parent: QWidget) -> None:
super().__init__(parent=parent) super().__init__(parent=parent)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
self.setCheckable(True) self.setCheckable(True)
fH = self.fontMetrics().height() fH = self.fontMetrics().height()
@@ -197,7 +197,7 @@ class _NPagedToolLabel(QLabel):
def __init__(self, parent: QWidget, textColor: QColor | None = None) -> None: def __init__(self, parent: QWidget, textColor: QColor | None = None) -> None:
super().__init__(parent=parent) super().__init__(parent=parent)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
fH = self.fontMetrics().height() fH = self.fontMetrics().height()
self._bH = round(fH * 1.7) self._bH = round(fH * 1.7)
+1 -1
View File
@@ -46,7 +46,7 @@ class NSwitch(QAbstractButton):
self._rR = self._xR - self._rB self._rR = self._xR - self._rB
self.setCheckable(True) self.setCheckable(True)
self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
self.setFixedWidth(self._xW) self.setFixedWidth(self._xW)
self.setFixedHeight(self._xH) self.setFixedHeight(self._xH)
self._offset = self._xR self._offset = self._xR
+6 -6
View File
@@ -58,8 +58,8 @@ class NSwitchBox(QScrollArea):
self._content = QGridLayout() self._content = QGridLayout()
self._content.setColumnStretch(1, 1) self._content.setColumnStretch(1, 1)
self._widget = QWidget() self._widget = QWidget(self)
self._widget.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) self._widget.setSizePolicy(QSizePolicy.Policy.MinimumExpanding, QSizePolicy.Policy.Minimum)
self._widget.setLayout(self._content) self._widget.setLayout(self._content)
self.setWidgetResizable(True) self.setWidgetResizable(True)
@@ -69,7 +69,7 @@ class NSwitchBox(QScrollArea):
def addLabel(self, text: str) -> None: def addLabel(self, text: str) -> None:
"""Add a header label to the content box.""" """Add a header label to the content box."""
label = QLabel(text) label = QLabel(text, self)
font = label.font() font = label.font()
font.setBold(True) font.setBold(True)
label.setFont(font) label.setFont(font)
@@ -80,12 +80,12 @@ class NSwitchBox(QScrollArea):
def addItem(self, qIcon: QIcon, text: str, identifier: str, default: bool = False) -> None: def addItem(self, qIcon: QIcon, text: str, identifier: str, default: bool = False) -> None:
"""Add an item to the content box.""" """Add an item to the content box."""
icon = QLabel("") icon = QLabel("", self)
icon.setAlignment(QtAlignRightMiddle) icon.setAlignment(QtAlignRightMiddle)
icon.setPixmap(qIcon.pixmap(self._sIcon, self._sIcon)) icon.setPixmap(qIcon.pixmap(self._sIcon, self._sIcon))
self._content.addWidget(icon, self._index, 0, QtAlignLeft) self._content.addWidget(icon, self._index, 0, QtAlignLeft)
label = QLabel(text) label = QLabel(text, self)
self._content.addWidget(label, self._index, 1, QtAlignLeft) self._content.addWidget(label, self._index, 1, QtAlignLeft)
switch = NSwitch(self, height=self._hSwitch) switch = NSwitch(self, height=self._hSwitch)
@@ -100,7 +100,7 @@ class NSwitchBox(QScrollArea):
def addSeparator(self) -> None: def addSeparator(self) -> None:
"""Add a blank entry in the content box.""" """Add a blank entry in the content box."""
spacer = QWidget() spacer = QWidget(self)
spacer.setFixedHeight(int(0.5*self._sIcon)) spacer.setFixedHeight(int(0.5*self._sIcon))
self._content.addWidget(spacer, self._index, 0, 1, 3, QtAlignLeft) self._content.addWidget(spacer, self._index, 0, 1, 3, QtAlignLeft)
self._widgets.append(spacer) self._widgets.append(spacer)
+27 -38
View File
@@ -65,7 +65,8 @@ from novelwriter.text.counting import standardCounter
from novelwriter.tools.lipsum import GuiLipsum from novelwriter.tools.lipsum import GuiLipsum
from novelwriter.types import ( from novelwriter.types import (
QtAlignCenterTop, QtAlignJustify, QtAlignLeft, QtAlignLeftTop, QtAlignCenterTop, QtAlignJustify, QtAlignLeft, QtAlignLeftTop,
QtAlignRight, QtModCtrl, QtMouseLeft, QtModeNone, QtModShift QtAlignRight, QtKeepAnchor, QtModCtrl, QtMouseLeft, QtModeNone, QtModShift,
QtMoveAnchor, QtMoveLeft, QtMoveRight
) )
if TYPE_CHECKING: # pragma: no cover if TYPE_CHECKING: # pragma: no cover
@@ -656,8 +657,8 @@ class GuiDocEditor(QPlainTextEdit):
"""Make a text selection.""" """Make a text selection."""
if start >= 0 and length > 0: if start >= 0 and length > 0:
cursor = self.textCursor() cursor = self.textCursor()
cursor.setPosition(start, QTextCursor.MoveMode.MoveAnchor) cursor.setPosition(start, QtMoveAnchor)
cursor.setPosition(start + length, QTextCursor.MoveMode.KeepAnchor) cursor.setPosition(start + length, QtKeepAnchor)
self.setTextCursor(cursor) self.setTextCursor(cursor)
return return
@@ -1092,8 +1093,8 @@ class GuiDocEditor(QPlainTextEdit):
block = cursor.block() block = cursor.block()
if block.isValid(): if block.isValid():
pos += block.position() pos += block.position()
cursor.setPosition(pos, QTextCursor.MoveMode.MoveAnchor) cursor.setPosition(pos, QtMoveAnchor)
cursor.setPosition(pos + length, QTextCursor.MoveMode.KeepAnchor) cursor.setPosition(pos + length, QtKeepAnchor)
cursor.insertText(text) cursor.insertText(text)
self._completer.hide() self._completer.hide()
return return
@@ -1153,9 +1154,7 @@ class GuiDocEditor(QPlainTextEdit):
block = pCursor.block() block = pCursor.block()
sCursor = self.textCursor() sCursor = self.textCursor()
sCursor.setPosition(block.position() + cPos) sCursor.setPosition(block.position() + cPos)
sCursor.movePosition( sCursor.movePosition(QtMoveRight, QtKeepAnchor, cLen)
QTextCursor.MoveOperation.Right, QTextCursor.MoveMode.KeepAnchor, cLen
)
if suggest: if suggest:
ctxMenu.addSeparator() ctxMenu.addSeparator()
ctxMenu.addAction(self.tr("Spelling Suggestion(s)")) ctxMenu.addAction(self.tr("Spelling Suggestion(s)"))
@@ -1351,8 +1350,8 @@ class GuiDocEditor(QPlainTextEdit):
else: else:
resIdx = 0 if doLoop else maxIdx resIdx = 0 if doLoop else maxIdx
cursor.setPosition(resS[resIdx], QTextCursor.MoveMode.MoveAnchor) cursor.setPosition(resS[resIdx], QtMoveAnchor)
cursor.setPosition(resE[resIdx], QTextCursor.MoveMode.KeepAnchor) cursor.setPosition(resE[resIdx], QtKeepAnchor)
self.setTextCursor(cursor) self.setTextCursor(cursor)
self.docSearch.setResultCount(resIdx + 1, len(resS)) self.docSearch.setResultCount(resIdx + 1, len(resS))
@@ -1398,8 +1397,8 @@ class GuiDocEditor(QPlainTextEdit):
break break
if hasSelection: if hasSelection:
cursor.setPosition(origA, QTextCursor.MoveMode.MoveAnchor) cursor.setPosition(origA, QtMoveAnchor)
cursor.setPosition(origB, QTextCursor.MoveMode.KeepAnchor) cursor.setPosition(origB, QtKeepAnchor)
else: else:
cursor.setPosition(origA) cursor.setPosition(origA)
@@ -1502,8 +1501,8 @@ class GuiDocEditor(QPlainTextEdit):
if blockS != blockE: if blockS != blockE:
posE = blockS.position() + blockS.length() - 1 posE = blockS.position() + blockS.length() - 1
cursor.clearSelection() cursor.clearSelection()
cursor.setPosition(posS, QTextCursor.MoveMode.MoveAnchor) cursor.setPosition(posS, QtMoveAnchor)
cursor.setPosition(posE, QTextCursor.MoveMode.KeepAnchor) cursor.setPosition(posE, QtKeepAnchor)
self.setTextCursor(cursor) self.setTextCursor(cursor)
numB = 0 numB = 0
@@ -1580,8 +1579,8 @@ class GuiDocEditor(QPlainTextEdit):
if select == _SelectAction.MOVE_AFTER: if select == _SelectAction.MOVE_AFTER:
cursor.setPosition(posE + len(before + after)) cursor.setPosition(posE + len(before + after))
elif select == _SelectAction.KEEP_SELECTION: elif select == _SelectAction.KEEP_SELECTION:
cursor.setPosition(posE + len(before), QTextCursor.MoveMode.MoveAnchor) cursor.setPosition(posE + len(before), QtMoveAnchor)
cursor.setPosition(posS + len(before), QTextCursor.MoveMode.KeepAnchor) cursor.setPosition(posS + len(before), QtKeepAnchor)
elif select == _SelectAction.KEEP_POSITION: elif select == _SelectAction.KEEP_POSITION:
cursor.setPosition(posO + len(before)) cursor.setPosition(posO + len(before))
@@ -1603,9 +1602,7 @@ class GuiDocEditor(QPlainTextEdit):
self._allowAutoReplace(False) self._allowAutoReplace(False)
for posC in range(posS, posE+1): for posC in range(posS, posE+1):
cursor.setPosition(posC) cursor.setPosition(posC)
cursor.movePosition( cursor.movePosition(QtMoveLeft, QtKeepAnchor, 2)
QTextCursor.MoveOperation.Left, QTextCursor.MoveMode.KeepAnchor, 2
)
selText = cursor.selectedText() selText = cursor.selectedText()
nS = len(selText) nS = len(selText)
@@ -1625,16 +1622,12 @@ class GuiDocEditor(QPlainTextEdit):
cursor.setPosition(posC) cursor.setPosition(posC)
if pC in closeCheck: if pC in closeCheck:
cursor.beginEditBlock() cursor.beginEditBlock()
cursor.movePosition( cursor.movePosition(QtMoveLeft, QtKeepAnchor, 1)
QTextCursor.MoveOperation.Left, QTextCursor.MoveMode.KeepAnchor, 1
)
cursor.insertText(oQuote) cursor.insertText(oQuote)
cursor.endEditBlock() cursor.endEditBlock()
else: else:
cursor.beginEditBlock() cursor.beginEditBlock()
cursor.movePosition( cursor.movePosition(QtMoveLeft, QtKeepAnchor, 1)
QTextCursor.MoveOperation.Left, QTextCursor.MoveMode.KeepAnchor, 1
)
cursor.insertText(cQuote) cursor.insertText(cQuote)
cursor.endEditBlock() cursor.endEditBlock()
@@ -1850,9 +1843,7 @@ class GuiDocEditor(QPlainTextEdit):
cursor.beginEditBlock() cursor.beginEditBlock()
cursor.clearSelection() cursor.clearSelection()
cursor.setPosition(rS) cursor.setPosition(rS)
cursor.movePosition( cursor.movePosition(QtMoveRight, QtKeepAnchor, rE-rS)
QTextCursor.MoveOperation.Right, QTextCursor.MoveMode.KeepAnchor, rE-rS
)
cursor.insertText(cleanText.rstrip() + "\n") cursor.insertText(cleanText.rstrip() + "\n")
cursor.endEditBlock() cursor.endEditBlock()
@@ -2018,9 +2009,7 @@ class GuiDocEditor(QPlainTextEdit):
tInsert = tInsert + self._typPadChar tInsert = tInsert + self._typPadChar
if nDelete > 0: if nDelete > 0:
cursor.movePosition( cursor.movePosition(QtMoveLeft, QtKeepAnchor, nDelete)
QTextCursor.MoveOperation.Left, QTextCursor.MoveMode.KeepAnchor, nDelete
)
cursor.insertText(tInsert) cursor.insertText(tInsert)
return return
@@ -2076,8 +2065,8 @@ class GuiDocEditor(QPlainTextEdit):
return cursor return cursor
cursor.clearSelection() cursor.clearSelection()
cursor.setPosition(sPos, QTextCursor.MoveMode.MoveAnchor) cursor.setPosition(sPos, QtMoveAnchor)
cursor.setPosition(ePos, QTextCursor.MoveMode.KeepAnchor) cursor.setPosition(ePos, QtKeepAnchor)
self.setTextCursor(cursor) self.setTextCursor(cursor)
@@ -2101,8 +2090,8 @@ class GuiDocEditor(QPlainTextEdit):
posE = cursor.selectionEnd() posE = cursor.selectionEnd()
selTxt = cursor.selectedText() selTxt = cursor.selectedText()
if selTxt.startswith(nwUnicode.U_PSEP): if selTxt.startswith(nwUnicode.U_PSEP):
cursor.setPosition(posS+1, QTextCursor.MoveMode.MoveAnchor) cursor.setPosition(posS+1, QtMoveAnchor)
cursor.setPosition(posE, QTextCursor.MoveMode.KeepAnchor) cursor.setPosition(posE, QtKeepAnchor)
self.setTextCursor(cursor) self.setTextCursor(cursor)
@@ -2441,11 +2430,11 @@ class GuiDocEditSearch(QFrame):
self.searchOpt.setIconSize(iSz) self.searchOpt.setIconSize(iSz)
self.searchOpt.setContentsMargins(0, 0, 0, 0) self.searchOpt.setContentsMargins(0, 0, 0, 0)
self.searchLabel = QLabel(self.tr("Search")) self.searchLabel = QLabel(self.tr("Search"), self)
self.searchLabel.setFont(self.boxFont) self.searchLabel.setFont(self.boxFont)
self.searchLabel.setIndent(CONFIG.pxInt(6)) self.searchLabel.setIndent(CONFIG.pxInt(6))
self.resultLabel = QLabel("?/?") self.resultLabel = QLabel("?/?", self)
self.resultLabel.setFont(self.boxFont) self.resultLabel.setFont(self.boxFont)
self.resultLabel.setMinimumWidth(SHARED.theme.getTextWidth("?/?", self.boxFont)) self.resultLabel.setMinimumWidth(SHARED.theme.getTextWidth("?/?", self.boxFont))
@@ -3047,7 +3036,7 @@ class GuiDocEditFooter(QWidget):
self.statusIcon.setFixedHeight(iPx) self.statusIcon.setFixedHeight(iPx)
self.statusIcon.setAlignment(QtAlignLeftTop) self.statusIcon.setAlignment(QtAlignLeftTop)
self.statusText = QLabel(self.tr("Status")) self.statusText = QLabel(self.tr("Status"), self)
self.statusText.setIndent(0) self.statusText.setIndent(0)
self.statusText.setMargin(0) self.statusText.setMargin(0)
self.statusText.setContentsMargins(0, 0, 0, 0) self.statusText.setContentsMargins(0, 0, 0, 0)
+1 -1
View File
@@ -116,7 +116,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
# Cache Spell Error Format # Cache Spell Error Format
self._spellErr = QTextCharFormat() self._spellErr = QTextCharFormat()
self._spellErr.setUnderlineColor(SHARED.theme.colSpell) self._spellErr.setUnderlineColor(SHARED.theme.colSpell)
self._spellErr.setUnderlineStyle(QTextCharFormat.SpellCheckUnderline) self._spellErr.setUnderlineStyle(QTextCharFormat.UnderlineStyle.SpellCheckUnderline)
# Multiple or Trailing Spaces # Multiple or Trailing Spaces
if CONFIG.showMultiSpaces: if CONFIG.showMultiSpaces:
+6 -4
View File
@@ -49,7 +49,9 @@ from novelwriter.error import logException
from novelwriter.extensions.eventfilters import WheelEventFilter from novelwriter.extensions.eventfilters import WheelEventFilter
from novelwriter.extensions.modified import NIconToolButton from novelwriter.extensions.modified import NIconToolButton
from novelwriter.gui.theme import STYLES_MIN_TOOLBUTTON from novelwriter.gui.theme import STYLES_MIN_TOOLBUTTON
from novelwriter.types import QtAlignCenterTop, QtAlignJustify, QtMouseLeft from novelwriter.types import (
QtAlignCenterTop, QtAlignJustify, QtKeepAnchor, QtMouseLeft, QtMoveAnchor
)
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -452,8 +454,8 @@ class GuiDocViewer(QTextBrowser):
posE = cursor.selectionEnd() posE = cursor.selectionEnd()
selTxt = cursor.selectedText() selTxt = cursor.selectedText()
if selTxt.startswith(nwUnicode.U_PSEP): if selTxt.startswith(nwUnicode.U_PSEP):
cursor.setPosition(posS+1, QTextCursor.MoveMode.MoveAnchor) cursor.setPosition(posS+1, QtMoveAnchor)
cursor.setPosition(posE, QTextCursor.MoveMode.KeepAnchor) cursor.setPosition(posE, QtKeepAnchor)
self.setTextCursor(cursor) self.setTextCursor(cursor)
@@ -635,7 +637,7 @@ class GuiDocViewHeader(QWidget):
self.setAutoFillBackground(True) self.setAutoFillBackground(True)
# Title Label # Title Label
self.itemTitle = QLabel() self.itemTitle = QLabel(self)
self.itemTitle.setText("") self.itemTitle.setText("")
self.itemTitle.setIndent(0) self.itemTitle.setIndent(0)
self.itemTitle.setMargin(0) self.itemTitle.setMargin(0)
+5 -5
View File
@@ -115,25 +115,25 @@ class GuiItemDetails(QWidget):
self.cCountName.setFont(fntLabel) self.cCountName.setFont(fntLabel)
self.cCountName.setAlignment(QtAlignRight) self.cCountName.setAlignment(QtAlignRight)
self.cCountData = QLabel("") self.cCountData = QLabel("", self)
self.cCountData.setFont(fntValue) self.cCountData.setFont(fntValue)
self.cCountData.setAlignment(QtAlignRight) self.cCountData.setAlignment(QtAlignRight)
# Word Count # Word Count
self.wCountName = QLabel(" "+self.tr("Words")) self.wCountName = QLabel(" "+self.tr("Words"), self)
self.wCountName.setFont(fntLabel) self.wCountName.setFont(fntLabel)
self.wCountName.setAlignment(QtAlignRight) self.wCountName.setAlignment(QtAlignRight)
self.wCountData = QLabel("") self.wCountData = QLabel("", self)
self.wCountData.setFont(fntValue) self.wCountData.setFont(fntValue)
self.wCountData.setAlignment(QtAlignRight) self.wCountData.setAlignment(QtAlignRight)
# Paragraph Count # Paragraph Count
self.pCountName = QLabel(" "+self.tr("Paragraphs")) self.pCountName = QLabel(" "+self.tr("Paragraphs"), self)
self.pCountName.setFont(fntLabel) self.pCountName.setFont(fntLabel)
self.pCountName.setAlignment(QtAlignRight) self.pCountName.setAlignment(QtAlignRight)
self.pCountData = QLabel("") self.pCountData = QLabel("", self)
self.pCountData.setFont(fntValue) self.pCountData.setFont(fntValue)
self.pCountData.setAlignment(QtAlignRight) self.pCountData.setAlignment(QtAlignRight)
+35 -35
View File
@@ -70,7 +70,7 @@ class GuiOutlineView(QWidget):
self.outlineBar = GuiOutlineToolBar(self) self.outlineBar = GuiOutlineToolBar(self)
self.outlineBar.setEnabled(False) self.outlineBar.setEnabled(False)
self.splitOutline = QSplitter(Qt.Orientation.Vertical) self.splitOutline = QSplitter(Qt.Orientation.Vertical, self)
self.splitOutline.addWidget(self.outlineTree) self.splitOutline.addWidget(self.outlineTree)
self.splitOutline.addWidget(self.outlineData) self.splitOutline.addWidget(self.outlineData)
self.splitOutline.setOpaqueResize(False) self.splitOutline.setOpaqueResize(False)
@@ -220,7 +220,7 @@ class GuiOutlineToolBar(QToolBar):
stretch.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) stretch.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
# Novel Selector # Novel Selector
self.novelLabel = QLabel(self.tr("Outline of")) self.novelLabel = QLabel(self.tr("Outline of"), self)
self.novelLabel.setContentsMargins(0, 0, mPx, 0) self.novelLabel.setContentsMargins(0, 0, mPx, 0)
self.novelValue = NovelSelector(self) self.novelValue = NovelSelector(self)
@@ -803,12 +803,12 @@ class GuiOutlineDetails(QScrollArea):
bFont = SHARED.theme.guiFontB bFont = SHARED.theme.guiFontB
# Details Area # Details Area
self.titleLabel = QLabel(self.tr("Title")) self.titleLabel = QLabel(self.tr("Title"), self)
self.fileLabel = QLabel(self.tr("Document")) self.fileLabel = QLabel(self.tr("Document"), self)
self.itemLabel = QLabel(self.tr("Status")) self.itemLabel = QLabel(self.tr("Status"), self)
self.titleValue = QLabel("") self.titleValue = QLabel("", self)
self.fileValue = QLabel("") self.fileValue = QLabel("", self)
self.itemValue = QLabel("") self.itemValue = QLabel("", self)
self.titleLabel.setFont(bFont) self.titleLabel.setFont(bFont)
self.fileLabel.setFont(bFont) self.fileLabel.setFont(bFont)
@@ -822,12 +822,12 @@ class GuiOutlineDetails(QScrollArea):
self.itemValue.setMaximumWidth(maxTitle) self.itemValue.setMaximumWidth(maxTitle)
# Stats Area # Stats Area
self.cCLabel = QLabel(self.tr("Characters")) self.cCLabel = QLabel(self.tr("Characters"), self)
self.wCLabel = QLabel(self.tr("Words")) self.wCLabel = QLabel(self.tr("Words"), self)
self.pCLabel = QLabel(self.tr("Paragraphs")) self.pCLabel = QLabel(self.tr("Paragraphs"), self)
self.cCValue = QLabel("") self.cCValue = QLabel("", self)
self.wCValue = QLabel("") self.wCValue = QLabel("", self)
self.pCValue = QLabel("") self.pCValue = QLabel("", self)
self.cCLabel.setFont(bFont) self.cCLabel.setFont(bFont)
self.wCLabel.setFont(bFont) self.wCLabel.setFont(bFont)
@@ -841,10 +841,10 @@ class GuiOutlineDetails(QScrollArea):
self.pCValue.setAlignment(QtAlignRight) self.pCValue.setAlignment(QtAlignRight)
# Synopsis # Synopsis
self.synopLabel = QLabel(self.tr("Synopsis")) self.synopLabel = QLabel(self.tr("Synopsis"), self)
self.synopLabel.setFont(bFont) self.synopLabel.setFont(bFont)
self.synopValue = QLabel("") self.synopValue = QLabel("", self)
self.synopValue.setWordWrap(True) self.synopValue.setWordWrap(True)
self.synopValue.setAlignment(QtAlignLeftTop) self.synopValue.setAlignment(QtAlignLeftTop)
@@ -852,15 +852,15 @@ class GuiOutlineDetails(QScrollArea):
self.synopLWrap.addWidget(self.synopValue, 1) self.synopLWrap.addWidget(self.synopValue, 1)
# Tags # Tags
self.povKeyLabel = QLabel(trConst(nwLabels.KEY_NAME[nwKeyWords.POV_KEY])) self.povKeyLabel = QLabel(trConst(nwLabels.KEY_NAME[nwKeyWords.POV_KEY]), self)
self.focKeyLabel = QLabel(trConst(nwLabels.KEY_NAME[nwKeyWords.FOCUS_KEY])) self.focKeyLabel = QLabel(trConst(nwLabels.KEY_NAME[nwKeyWords.FOCUS_KEY]), self)
self.chrKeyLabel = QLabel(trConst(nwLabels.KEY_NAME[nwKeyWords.CHAR_KEY])) self.chrKeyLabel = QLabel(trConst(nwLabels.KEY_NAME[nwKeyWords.CHAR_KEY]), self)
self.pltKeyLabel = QLabel(trConst(nwLabels.KEY_NAME[nwKeyWords.PLOT_KEY])) self.pltKeyLabel = QLabel(trConst(nwLabels.KEY_NAME[nwKeyWords.PLOT_KEY]), self)
self.timKeyLabel = QLabel(trConst(nwLabels.KEY_NAME[nwKeyWords.TIME_KEY])) self.timKeyLabel = QLabel(trConst(nwLabels.KEY_NAME[nwKeyWords.TIME_KEY]), self)
self.wldKeyLabel = QLabel(trConst(nwLabels.KEY_NAME[nwKeyWords.WORLD_KEY])) self.wldKeyLabel = QLabel(trConst(nwLabels.KEY_NAME[nwKeyWords.WORLD_KEY]), self)
self.objKeyLabel = QLabel(trConst(nwLabels.KEY_NAME[nwKeyWords.OBJECT_KEY])) self.objKeyLabel = QLabel(trConst(nwLabels.KEY_NAME[nwKeyWords.OBJECT_KEY]), self)
self.entKeyLabel = QLabel(trConst(nwLabels.KEY_NAME[nwKeyWords.ENTITY_KEY])) self.entKeyLabel = QLabel(trConst(nwLabels.KEY_NAME[nwKeyWords.ENTITY_KEY]), self)
self.cstKeyLabel = QLabel(trConst(nwLabels.KEY_NAME[nwKeyWords.CUSTOM_KEY])) self.cstKeyLabel = QLabel(trConst(nwLabels.KEY_NAME[nwKeyWords.CUSTOM_KEY]), self)
self.povKeyLabel.setFont(bFont) self.povKeyLabel.setFont(bFont)
self.focKeyLabel.setFont(bFont) self.focKeyLabel.setFont(bFont)
@@ -882,15 +882,15 @@ class GuiOutlineDetails(QScrollArea):
self.entKeyLWrap = QHBoxLayout() self.entKeyLWrap = QHBoxLayout()
self.cstKeyLWrap = QHBoxLayout() self.cstKeyLWrap = QHBoxLayout()
self.povKeyValue = QLabel("") self.povKeyValue = QLabel("", self)
self.focKeyValue = QLabel("") self.focKeyValue = QLabel("", self)
self.chrKeyValue = QLabel("") self.chrKeyValue = QLabel("", self)
self.pltKeyValue = QLabel("") self.pltKeyValue = QLabel("", self)
self.timKeyValue = QLabel("") self.timKeyValue = QLabel("", self)
self.wldKeyValue = QLabel("") self.wldKeyValue = QLabel("", self)
self.objKeyValue = QLabel("") self.objKeyValue = QLabel("", self)
self.entKeyValue = QLabel("") self.entKeyValue = QLabel("", self)
self.cstKeyValue = QLabel("") self.cstKeyValue = QLabel("", self)
self.povKeyValue.setWordWrap(True) self.povKeyValue.setWordWrap(True)
self.focKeyValue.setWordWrap(True) self.focKeyValue.setWordWrap(True)
@@ -977,7 +977,7 @@ class GuiOutlineDetails(QScrollArea):
self.tagsForm.setVerticalSpacing(vSpace) self.tagsForm.setVerticalSpacing(vSpace)
# Assemble # Assemble
self.outerWidget = QWidget() self.outerWidget = QWidget(self)
self.outerBox = QHBoxLayout() self.outerBox = QHBoxLayout()
self.outerBox.addWidget(self.mainGroup, 0) self.outerBox.addWidget(self.mainGroup, 0)
self.outerBox.addWidget(self.tagsGroup, 1) self.outerBox.addWidget(self.tagsGroup, 1)
+1 -1
View File
@@ -271,7 +271,7 @@ class GuiProjectToolBar(QWidget):
self.setAutoFillBackground(True) self.setAutoFillBackground(True)
# Widget Label # Widget Label
self.viewLabel = QLabel(self.tr("Project Content")) self.viewLabel = QLabel(self.tr("Project Content"), self)
self.viewLabel.setFont(SHARED.theme.guiFontB) self.viewLabel.setFont(SHARED.theme.guiFontB)
self.viewLabel.setContentsMargins(0, 0, 0, 0) self.viewLabel.setContentsMargins(0, 0, 0, 0)
self.viewLabel.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) self.viewLabel.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
+1 -1
View File
@@ -71,7 +71,7 @@ class GuiProjectSearch(QWidget):
self._map: dict[str, tuple[int, float]] = {} self._map: dict[str, tuple[int, float]] = {}
# Header # Header
self.viewLabel = QLabel(self.tr("Project Search")) self.viewLabel = QLabel(self.tr("Project Search"), self)
self.viewLabel.setFont(SHARED.theme.guiFontB) self.viewLabel.setFont(SHARED.theme.guiFontB)
self.viewLabel.setContentsMargins(mPx, tPx, 0, mPx) self.viewLabel.setContentsMargins(mPx, tPx, 0, mPx)
+8 -8
View File
@@ -66,8 +66,8 @@ class GuiMainStatus(QStatusBar):
xM = CONFIG.pxInt(8) xM = CONFIG.pxInt(8)
# The Spell Checker Language # The Spell Checker Language
self.langIcon = QLabel("") self.langIcon = QLabel("", self)
self.langText = QLabel(self.tr("None")) self.langText = QLabel(self.tr("None"), self)
self.langIcon.setContentsMargins(0, 0, 0, 0) self.langIcon.setContentsMargins(0, 0, 0, 0)
self.langText.setContentsMargins(0, 0, xM, 0) self.langText.setContentsMargins(0, 0, xM, 0)
self.addPermanentWidget(self.langIcon) self.addPermanentWidget(self.langIcon)
@@ -75,7 +75,7 @@ class GuiMainStatus(QStatusBar):
# The Editor Status # The Editor Status
self.docIcon = StatusLED(colNone, colSaved, colUnsaved, iPx, iPx, self) self.docIcon = StatusLED(colNone, colSaved, colUnsaved, iPx, iPx, self)
self.docText = QLabel(self.tr("Editor")) self.docText = QLabel(self.tr("Editor"), self)
self.docIcon.setContentsMargins(0, 0, 0, 0) self.docIcon.setContentsMargins(0, 0, 0, 0)
self.docText.setContentsMargins(0, 0, xM, 0) self.docText.setContentsMargins(0, 0, xM, 0)
self.addPermanentWidget(self.docIcon) self.addPermanentWidget(self.docIcon)
@@ -83,15 +83,15 @@ class GuiMainStatus(QStatusBar):
# The Project Status # The Project Status
self.projIcon = StatusLED(colNone, colSaved, colUnsaved, iPx, iPx, self) self.projIcon = StatusLED(colNone, colSaved, colUnsaved, iPx, iPx, self)
self.projText = QLabel(self.tr("Project")) self.projText = QLabel(self.tr("Project"), self)
self.projIcon.setContentsMargins(0, 0, 0, 0) self.projIcon.setContentsMargins(0, 0, 0, 0)
self.projText.setContentsMargins(0, 0, xM, 0) self.projText.setContentsMargins(0, 0, xM, 0)
self.addPermanentWidget(self.projIcon) self.addPermanentWidget(self.projIcon)
self.addPermanentWidget(self.projText) self.addPermanentWidget(self.projText)
# The Project and Session Stats # The Project and Session Stats
self.statsIcon = QLabel() self.statsIcon = QLabel(self)
self.statsText = QLabel("") self.statsText = QLabel("", self)
self.statsIcon.setContentsMargins(0, 0, 0, 0) self.statsIcon.setContentsMargins(0, 0, 0, 0)
self.statsText.setContentsMargins(0, 0, xM, 0) self.statsText.setContentsMargins(0, 0, xM, 0)
self.addPermanentWidget(self.statsIcon) self.addPermanentWidget(self.statsIcon)
@@ -99,8 +99,8 @@ class GuiMainStatus(QStatusBar):
# The Session Clock # The Session Clock
# Set the minimum width so the label doesn't rescale every second # Set the minimum width so the label doesn't rescale every second
self.timeIcon = QLabel() self.timeIcon = QLabel(self)
self.timeText = QLabel("") self.timeText = QLabel("", self)
self.timeText.setToolTip(self.tr("Session Time")) self.timeText.setToolTip(self.tr("Session Time"))
self.timeText.setMinimumWidth(SHARED.theme.getTextWidth("00:00:00:")) self.timeText.setMinimumWidth(SHARED.theme.getTextWidth("00:00:00:"))
self.timeIcon.setContentsMargins(0, 0, 0, 0) self.timeIcon.setContentsMargins(0, 0, 0, 0)
+4 -2
View File
@@ -171,7 +171,9 @@ class GuiTheme:
# Monospace Font # Monospace Font
self.guiFontFixed = QFont() self.guiFontFixed = QFont()
self.guiFontFixed.setPointSizeF(0.95*self.fontPointSize) self.guiFontFixed.setPointSizeF(0.95*self.fontPointSize)
self.guiFontFixed.setFamily(QFontDatabase.systemFont(QFontDatabase.FixedFont).family()) self.guiFontFixed.setFamily(
QFontDatabase.systemFont(QFontDatabase.SystemFont.FixedFont).family()
)
logger.debug("GUI Font Family: %s", self.guiFont.family()) logger.debug("GUI Font Family: %s", self.guiFont.family())
logger.debug("GUI Font Point Size: %.2f", self.fontPointSize) logger.debug("GUI Font Point Size: %.2f", self.fontPointSize)
@@ -401,7 +403,7 @@ class GuiTheme:
font.setFamily("Arial") font.setFamily("Arial")
font.setPointSize(10) font.setPointSize(10)
else: else:
font = fontDB.systemFont(QFontDatabase.GeneralFont) font = fontDB.systemFont(QFontDatabase.SystemFont.GeneralFont)
CONFIG.guiFont = font.family() CONFIG.guiFont = font.family()
CONFIG.guiFontSize = font.pointSize() CONFIG.guiFontSize = font.pointSize()
else: else:
+3 -3
View File
@@ -71,7 +71,7 @@ class GuiDictionaries(QDialog):
self.tr("Download a dictionary from one of the links, and add it below."), self.tr("Download a dictionary from one of the links, and add it below."),
f"&nbsp;\u203a <a href='{foUrl}'>{foUrl}</a>", f"&nbsp;\u203a <a href='{foUrl}'>{foUrl}</a>",
f"&nbsp;\u203a <a href='{loUrl}'>{loUrl}</a>", f"&nbsp;\u203a <a href='{loUrl}'>{loUrl}</a>",
])) ]), self)
self.huInfo.setOpenExternalLinks(True) self.huInfo.setOpenExternalLinks(True)
self.huInfo.setWordWrap(True) self.huInfo.setWordWrap(True)
self.huInput = QLineEdit(self) self.huInput = QLineEdit(self)
@@ -90,7 +90,7 @@ class GuiDictionaries(QDialog):
self.huAddBox.addWidget(self.huImport) self.huAddBox.addWidget(self.huImport)
# Install Path # Install Path
self.inInfo = QLabel(self.tr("Dictionary install location")) self.inInfo = QLabel(self.tr("Dictionary install location"), self)
self.inPath = QLineEdit(self) self.inPath = QLineEdit(self)
self.inPath.setReadOnly(True) self.inPath.setReadOnly(True)
self.inBrowse = NIconToolButton(self, iSz, "browse") self.inBrowse = NIconToolButton(self, iSz, "browse")
@@ -108,7 +108,7 @@ class GuiDictionaries(QDialog):
self.infoBox.setFrameStyle(QFrame.Shape.NoFrame) self.infoBox.setFrameStyle(QFrame.Shape.NoFrame)
# Buttons # Buttons
self.buttonBox = QDialogButtonBox(QtDialogClose) self.buttonBox = QDialogButtonBox(QtDialogClose, self)
self.buttonBox.rejected.connect(self._doClose) self.buttonBox.rejected.connect(self._doClose)
# Assemble # Assemble
+7 -6
View File
@@ -61,7 +61,7 @@ class GuiLipsum(QDialog):
self.innerBox.setSpacing(CONFIG.pxInt(16)) self.innerBox.setSpacing(CONFIG.pxInt(16))
# Icon # Icon
self.docIcon = QLabel() self.docIcon = QLabel(self)
self.docIcon.setPixmap(SHARED.theme.getPixmap("proj_document", (nPx, nPx))) self.docIcon.setPixmap(SHARED.theme.getPixmap("proj_document", (nPx, nPx)))
self.leftBox = QVBoxLayout() self.leftBox = QVBoxLayout()
@@ -71,15 +71,16 @@ class GuiLipsum(QDialog):
self.innerBox.addLayout(self.leftBox) self.innerBox.addLayout(self.leftBox)
# Form # Form
self.headLabel = QLabel("<b>{0}</b>".format(self.tr("Insert Lorem Ipsum Text"))) self.headLabel = QLabel(self.tr("Insert Lorem Ipsum Text"))
self.headLabel.setFont(SHARED.theme.guiFontB)
self.paraLabel = QLabel(self.tr("Number of paragraphs")) self.paraLabel = QLabel(self.tr("Number of paragraphs"), self)
self.paraCount = QSpinBox() self.paraCount = QSpinBox(self)
self.paraCount.setMinimum(1) self.paraCount.setMinimum(1)
self.paraCount.setMaximum(100) self.paraCount.setMaximum(100)
self.paraCount.setValue(5) self.paraCount.setValue(5)
self.randLabel = QLabel(self.tr("Randomise order")) self.randLabel = QLabel(self.tr("Randomise order"), self)
self.randSwitch = NSwitch(self) self.randSwitch = NSwitch(self)
self.formBox = QGridLayout() self.formBox = QGridLayout()
@@ -93,7 +94,7 @@ class GuiLipsum(QDialog):
self.innerBox.addLayout(self.formBox) self.innerBox.addLayout(self.formBox)
# Buttons # Buttons
self.buttonBox = QDialogButtonBox() self.buttonBox = QDialogButtonBox(self)
self.buttonBox.rejected.connect(self.close) self.buttonBox.rejected.connect(self.close)
self.btnClose = self.buttonBox.addButton(QtDialogClose) self.btnClose = self.buttonBox.addButton(QtDialogClose)
+12 -12
View File
@@ -90,8 +90,8 @@ class GuiManuscriptBuild(QDialog):
# Output Format # Output Format
# ============= # =============
self.lblFormat = QLabel(self.tr("Output Format")) self.lblFormat = QLabel(self.tr("Output Format"), self)
self.listFormats = QListWidget() self.listFormats = QListWidget(self)
self.listFormats.setIconSize(iSz) self.listFormats.setIconSize(iSz)
current = None current = None
for key in nwBuildFmt: for key in nwBuildFmt:
@@ -109,14 +109,14 @@ class GuiManuscriptBuild(QDialog):
self.formatBox.addWidget(self.listFormats, 1) self.formatBox.addWidget(self.listFormats, 1)
self.formatBox.setContentsMargins(0, 0, 0, 0) self.formatBox.setContentsMargins(0, 0, 0, 0)
self.formatWidget = QWidget() self.formatWidget = QWidget(self)
self.formatWidget.setLayout(self.formatBox) self.formatWidget.setLayout(self.formatBox)
self.formatWidget.setContentsMargins(0, 0, 0, 0) self.formatWidget.setContentsMargins(0, 0, 0, 0)
# Table of Contents # Table of Contents
# ================= # =================
self.lblContent = QLabel(self.tr("Table of Contents")) self.lblContent = QLabel(self.tr("Table of Contents"), self)
self.listContent = QListWidget(self) self.listContent = QListWidget(self)
self.listContent.setIconSize(iSz) self.listContent.setIconSize(iSz)
@@ -127,7 +127,7 @@ class GuiManuscriptBuild(QDialog):
self.contentBox.addWidget(self.listContent, 0) self.contentBox.addWidget(self.listContent, 0)
self.contentBox.setContentsMargins(0, 0, 0, 0) self.contentBox.setContentsMargins(0, 0, 0, 0)
self.contentWidget = QWidget() self.contentWidget = QWidget(self)
self.contentWidget.setLayout(self.contentBox) self.contentWidget.setLayout(self.contentBox)
self.contentWidget.setContentsMargins(0, 0, 0, 0) self.contentWidget.setContentsMargins(0, 0, 0, 0)
@@ -139,12 +139,12 @@ class GuiManuscriptBuild(QDialog):
font.setUnderline(True) font.setUnderline(True)
font.setPointSizeF(1.5*font.pointSizeF()) font.setPointSizeF(1.5*font.pointSizeF())
self.lblMain = QLabel(self._build.name) self.lblMain = QLabel(self._build.name, self)
self.lblMain.setWordWrap(True) self.lblMain.setWordWrap(True)
self.lblMain.setFont(font) self.lblMain.setFont(font)
# Build Path # Build Path
self.lblPath = QLabel(self.tr("Path")) self.lblPath = QLabel(self.tr("Path"), self)
self.buildPath = QLineEdit(self) self.buildPath = QLineEdit(self)
self.btnBrowse = NIconToolButton(self, iSz, "browse") self.btnBrowse = NIconToolButton(self, iSz, "browse")
@@ -154,7 +154,7 @@ class GuiManuscriptBuild(QDialog):
self.pathBox.setSpacing(sp8) self.pathBox.setSpacing(sp8)
# Build Name # Build Name
self.lblName = QLabel(self.tr("File Name")) self.lblName = QLabel(self.tr("File Name"), self)
self.buildName = QLineEdit(self) self.buildName = QLineEdit(self)
self.btnReset = NIconToolButton(self, iSz, "revert") self.btnReset = NIconToolButton(self, iSz, "revert")
self.btnReset.setToolTip(self.tr("Reset file name to default")) self.btnReset.setToolTip(self.tr("Reset file name to default"))
@@ -181,19 +181,19 @@ class GuiManuscriptBuild(QDialog):
self.buildBox.setVerticalSpacing(sp4) self.buildBox.setVerticalSpacing(sp4)
# Dialog Buttons # Dialog Buttons
self.btnOpen = QPushButton(SHARED.theme.getIcon("browse"), self.tr("Open Folder")) self.btnOpen = QPushButton(SHARED.theme.getIcon("browse"), self.tr("Open Folder"), self)
self.btnOpen.setIconSize(bSz) self.btnOpen.setIconSize(bSz)
self.btnBuild = QPushButton(SHARED.theme.getIcon("export"), self.tr("&Build")) self.btnBuild = QPushButton(SHARED.theme.getIcon("export"), self.tr("&Build"), self)
self.btnBuild.setIconSize(bSz) self.btnBuild.setIconSize(bSz)
self.dlgButtons = QDialogButtonBox(QtDialogClose) self.dlgButtons = QDialogButtonBox(QtDialogClose, self)
self.dlgButtons.addButton(self.btnOpen, QtRoleAction) self.dlgButtons.addButton(self.btnOpen, QtRoleAction)
self.dlgButtons.addButton(self.btnBuild, QtRoleAction) self.dlgButtons.addButton(self.btnBuild, QtRoleAction)
# Assemble GUI # Assemble GUI
# ============ # ============
self.mainSplit = QSplitter() self.mainSplit = QSplitter(self)
self.mainSplit.addWidget(self.formatWidget) self.mainSplit.addWidget(self.formatWidget)
self.mainSplit.addWidget(self.contentWidget) self.mainSplit.addWidget(self.contentWidget)
self.mainSplit.setHandleWidth(sp16) self.mainSplit.setHandleWidth(sp16)
+11 -11
View File
@@ -124,7 +124,7 @@ class GuiManuscript(QDialog):
self.tbEdit.setStyleSheet(buttonStyle) self.tbEdit.setStyleSheet(buttonStyle)
self.tbEdit.clicked.connect(self._editSelectedBuild) self.tbEdit.clicked.connect(self._editSelectedBuild)
self.lblBuilds = QLabel("<b>{0}</b>".format(self.tr("Builds"))) self.lblBuilds = QLabel("<b>{0}</b>".format(self.tr("Builds")), self)
self.listToolBox = QHBoxLayout() self.listToolBox = QHBoxLayout()
self.listToolBox.addWidget(self.lblBuilds) self.listToolBox.addWidget(self.lblBuilds)
@@ -141,8 +141,8 @@ class GuiManuscript(QDialog):
self.buildList.setIconSize(iSz) self.buildList.setIconSize(iSz)
self.buildList.doubleClicked.connect(self._editSelectedBuild) self.buildList.doubleClicked.connect(self._editSelectedBuild)
self.buildList.currentItemChanged.connect(self._updateBuildDetails) self.buildList.currentItemChanged.connect(self._updateBuildDetails)
self.buildList.setSelectionMode(QAbstractItemView.SingleSelection) self.buildList.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection)
self.buildList.setDragDropMode(QAbstractItemView.InternalMove) self.buildList.setDragDropMode(QAbstractItemView.DragDropMode.InternalMove)
# Details Tabs # Details Tabs
# ============ # ============
@@ -170,16 +170,16 @@ class GuiManuscript(QDialog):
# Process Controls # Process Controls
# ================ # ================
self.btnPreview = QPushButton(self.tr("Preview")) self.btnPreview = QPushButton(self.tr("Preview"), self)
self.btnPreview.clicked.connect(self._generatePreview) self.btnPreview.clicked.connect(self._generatePreview)
self.btnPrint = QPushButton(self.tr("Print")) self.btnPrint = QPushButton(self.tr("Print"), self)
self.btnPrint.clicked.connect(self._printDocument) self.btnPrint.clicked.connect(self._printDocument)
self.btnBuild = QPushButton(self.tr("Build")) self.btnBuild = QPushButton(self.tr("Build"), self)
self.btnBuild.clicked.connect(self._buildManuscript) self.btnBuild.clicked.connect(self._buildManuscript)
self.btnClose = QPushButton(self.tr("Close")) self.btnClose = QPushButton(self.tr("Close"), self)
self.btnClose.clicked.connect(self.close) self.btnClose.clicked.connect(self.close)
self.processBox = QGridLayout() self.processBox = QGridLayout()
@@ -211,7 +211,7 @@ class GuiManuscript(QDialog):
self.optsWidget = QWidget(self) self.optsWidget = QWidget(self)
self.optsWidget.setLayout(self.controlBox) self.optsWidget.setLayout(self.controlBox)
self.mainSplit = QSplitter() self.mainSplit = QSplitter(self)
self.mainSplit.addWidget(self.optsWidget) self.mainSplit.addWidget(self.optsWidget)
self.mainSplit.addWidget(self.docWdiget) self.mainSplit.addWidget(self.docWdiget)
self.mainSplit.setCollapsible(0, False) self.mainSplit.setCollapsible(0, False)
@@ -906,7 +906,7 @@ class _PreviewWidget(QTextBrowser):
def printPreview(self, printer: QPrinter) -> None: def printPreview(self, printer: QPrinter) -> None:
"""Connect the print preview painter to the document viewer.""" """Connect the print preview painter to the document viewer."""
QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor)) QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
printer.setOrientation(QPrinter.Portrait) printer.setOrientation(QPrinter.Orientation.Portrait)
self.document().print(printer) self.document().print(printer)
QApplication.restoreOverrideCursor() QApplication.restoreOverrideCursor()
return return
@@ -1054,10 +1054,10 @@ class _StatsWidget(QWidget):
"""Build the minimal stats page.""" """Build the minimal stats page."""
mPx = CONFIG.pxInt(8) mPx = CONFIG.pxInt(8)
self.lblWordCount = QLabel(self.tr("Words")) self.lblWordCount = QLabel(self.tr("Words"), self)
self.minWordCount = QLabel(self) self.minWordCount = QLabel(self)
self.lblCharCount = QLabel(self.tr("Characters")) self.lblCharCount = QLabel(self.tr("Characters"), self)
self.minCharCount = QLabel(self) self.minCharCount = QLabel(self)
# Assemble # Assemble
+22 -22
View File
@@ -102,7 +102,7 @@ class GuiBuildSettings(QDialog):
) )
# Settings Name # Settings Name
self.lblBuildName = QLabel(self.tr("Name")) self.lblBuildName = QLabel(self.tr("Name"), self)
self.editBuildName = QLineEdit(self) self.editBuildName = QLineEdit(self)
# SideBar # SideBar
@@ -134,7 +134,7 @@ class GuiBuildSettings(QDialog):
self.toolStack.addWidget(self.optTabOutput) self.toolStack.addWidget(self.optTabOutput)
# Buttons # Buttons
self.buttonBox = QDialogButtonBox(QtDialogApply | QtDialogSave | QtDialogClose) self.buttonBox = QDialogButtonBox(QtDialogApply | QtDialogSave | QtDialogClose, self)
self.buttonBox.clicked.connect(self._dialogButtonClicked) self.buttonBox.clicked.connect(self._dialogButtonClicked)
# Assemble # Assemble
@@ -331,15 +331,15 @@ class _FilterTab(NFixedPage):
treeHeader = self.optTree.header() treeHeader = self.optTree.header()
treeHeader.setStretchLastSection(False) treeHeader.setStretchLastSection(False)
treeHeader.setMinimumSectionSize(iPx + cMg) # See Issue #1551 treeHeader.setMinimumSectionSize(iPx + cMg) # See Issue #1551
treeHeader.setSectionResizeMode(self.C_NAME, QHeaderView.Stretch) treeHeader.setSectionResizeMode(self.C_NAME, QHeaderView.ResizeMode.Stretch)
treeHeader.setSectionResizeMode(self.C_ACTIVE, QHeaderView.Fixed) treeHeader.setSectionResizeMode(self.C_ACTIVE, QHeaderView.ResizeMode.Fixed)
treeHeader.setSectionResizeMode(self.C_STATUS, QHeaderView.Fixed) treeHeader.setSectionResizeMode(self.C_STATUS, QHeaderView.ResizeMode.Fixed)
treeHeader.resizeSection(self.C_ACTIVE, iPx + cMg) treeHeader.resizeSection(self.C_ACTIVE, iPx + cMg)
treeHeader.resizeSection(self.C_STATUS, iPx + cMg) treeHeader.resizeSection(self.C_STATUS, iPx + cMg)
self.optTree.setDragDropMode(QAbstractItemView.NoDragDrop) self.optTree.setDragDropMode(QAbstractItemView.DragDropMode.NoDragDrop)
self.optTree.setSelectionMode(QAbstractItemView.ExtendedSelection) self.optTree.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
self.optTree.setSelectionBehavior(QAbstractItemView.SelectRows) self.optTree.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
# Filters # Filters
# ======= # =======
@@ -359,7 +359,7 @@ class _FilterTab(NFixedPage):
self.resetButton.clicked.connect(lambda: self._setSelectedMode(self.F_FILTERED)) self.resetButton.clicked.connect(lambda: self._setSelectedMode(self.F_FILTERED))
self.modeBox = QHBoxLayout() self.modeBox = QHBoxLayout()
self.modeBox.addWidget(QLabel(self.tr("Mark selection as"))) self.modeBox.addWidget(QLabel(self.tr("Mark selection as"), self))
self.modeBox.addStretch(1) self.modeBox.addStretch(1)
self.modeBox.addWidget(self.includedButton) self.modeBox.addWidget(self.includedButton)
self.modeBox.addWidget(self.excludedButton) self.modeBox.addWidget(self.excludedButton)
@@ -369,7 +369,7 @@ class _FilterTab(NFixedPage):
# Filer Options # Filer Options
self.filterOpt = NSwitchBox(self, iPx) self.filterOpt = NSwitchBox(self, iPx)
self.filterOpt.switchToggled.connect(self._applyFilterSwitch) self.filterOpt.switchToggled.connect(self._applyFilterSwitch)
self.filterOpt.setFrameStyle(QFrame.NoFrame) self.filterOpt.setFrameStyle(QFrame.Shape.NoFrame)
# Assemble GUI # Assemble GUI
# ============ # ============
@@ -381,10 +381,10 @@ class _FilterTab(NFixedPage):
self.selectionBox.addLayout(self.modeBox) self.selectionBox.addLayout(self.modeBox)
self.selectionBox.setContentsMargins(0, 0, 0, 0) self.selectionBox.setContentsMargins(0, 0, 0, 0)
self.selectionWidget = QWidget() self.selectionWidget = QWidget(self)
self.selectionWidget.setLayout(self.selectionBox) self.selectionWidget.setLayout(self.selectionBox)
self.mainSplit = QSplitter() self.mainSplit = QSplitter(self)
self.mainSplit.addWidget(self.selectionWidget) self.mainSplit.addWidget(self.selectionWidget)
self.mainSplit.addWidget(self.filterOpt) self.mainSplit.addWidget(self.filterOpt)
self.mainSplit.setCollapsible(0, False) self.mainSplit.setCollapsible(0, False)
@@ -703,7 +703,7 @@ class _HeadingsTab(NScrollablePage):
# Edit Form # Edit Form
# ========= # =========
self.lblEditForm = QLabel(self.tr("Editing: {0}").format(self.tr("None"))) self.lblEditForm = QLabel(self.tr("Editing: {0}").format(self.tr("None")), self)
self.editTextBox = QPlainTextEdit(self) self.editTextBox = QPlainTextEdit(self)
self.editTextBox.setFixedHeight(5*iPx) self.editTextBox.setFixedHeight(5*iPx)
@@ -759,12 +759,12 @@ class _HeadingsTab(NScrollablePage):
self.layoutMatrix.addWidget(self.layoutHeading, 0, 0, 1, 5) self.layoutMatrix.addWidget(self.layoutHeading, 0, 0, 1, 5)
# Title Layout # Title Layout
self.mtxTitle = QLabel(self._build.getLabel("headings.fmtTitle")) self.mtxTitle = QLabel(self._build.getLabel("headings.fmtTitle"), self)
self.centerTitle = NSwitch(self, height=iPx) self.centerTitle = NSwitch(self, height=iPx)
self.breakTitle = NSwitch(self, height=iPx) self.breakTitle = NSwitch(self, height=iPx)
lblCenterT = QLabel(self.tr("Centre")) lblCenterT = QLabel(self.tr("Centre"), self)
lblCenterT.setIndent(sSp) lblCenterT.setIndent(sSp)
lblBreakT = QLabel(self.tr("Page Break")) lblBreakT = QLabel(self.tr("Page Break"), self)
lblBreakT.setIndent(sSp) lblBreakT.setIndent(sSp)
self.layoutMatrix.addWidget(self.mtxTitle, 1, 0) self.layoutMatrix.addWidget(self.mtxTitle, 1, 0)
@@ -774,12 +774,12 @@ class _HeadingsTab(NScrollablePage):
self.layoutMatrix.addWidget(self.breakTitle, 1, 4) self.layoutMatrix.addWidget(self.breakTitle, 1, 4)
# Chapter Layout # Chapter Layout
self.mtxChapter = QLabel(self._build.getLabel("headings.fmtChapter")) self.mtxChapter = QLabel(self._build.getLabel("headings.fmtChapter"), self)
self.centerChapter = NSwitch(self, height=iPx) self.centerChapter = NSwitch(self, height=iPx)
self.breakChapter = NSwitch(self, height=iPx) self.breakChapter = NSwitch(self, height=iPx)
lblCenterC = QLabel(self.tr("Centre")) lblCenterC = QLabel(self.tr("Centre"), self)
lblCenterC.setIndent(sSp) lblCenterC.setIndent(sSp)
lblBreakC = QLabel(self.tr("Page Break")) lblBreakC = QLabel(self.tr("Page Break"), self)
lblBreakC.setIndent(sSp) lblBreakC.setIndent(sSp)
self.layoutMatrix.addWidget(self.mtxChapter, 2, 0) self.layoutMatrix.addWidget(self.mtxChapter, 2, 0)
@@ -789,12 +789,12 @@ class _HeadingsTab(NScrollablePage):
self.layoutMatrix.addWidget(self.breakChapter, 2, 4) self.layoutMatrix.addWidget(self.breakChapter, 2, 4)
# Scene Layout # Scene Layout
self.mtxScene = QLabel(self._build.getLabel("headings.fmtScene")) self.mtxScene = QLabel(self._build.getLabel("headings.fmtScene"), self)
self.centerScene = NSwitch(self, height=iPx) self.centerScene = NSwitch(self, height=iPx)
self.breakScene = NSwitch(self, height=iPx) self.breakScene = NSwitch(self, height=iPx)
lblCenterS = QLabel(self.tr("Centre")) lblCenterS = QLabel(self.tr("Centre"), self)
lblCenterS.setIndent(sSp) lblCenterS.setIndent(sSp)
lblBreakS = QLabel(self.tr("Page Break")) lblBreakS = QLabel(self.tr("Page Break"), self)
lblBreakS.setIndent(sSp) lblBreakS.setIndent(sSp)
self.layoutMatrix.addWidget(self.mtxScene, 3, 0) self.layoutMatrix.addWidget(self.mtxScene, 3, 0)
+4 -4
View File
@@ -95,7 +95,7 @@ class GuiNovelDetails(QDialog):
self.mainStack.addWidget(self.contentsPage) self.mainStack.addWidget(self.contentsPage)
# Buttons # Buttons
self.buttonBox = QDialogButtonBox(QtDialogClose) self.buttonBox = QDialogButtonBox(QtDialogClose, self)
self.buttonBox.rejected.connect(self.close) self.buttonBox.rejected.connect(self.close)
# Assemble # Assemble
@@ -366,7 +366,7 @@ class _ContentsPage(NFixedPage):
countFrom = options.getInt("GuiNovelDetails", "countFrom", 1) countFrom = options.getInt("GuiNovelDetails", "countFrom", 1)
clearDouble = options.getBool("GuiNovelDetails", "clearDouble", True) clearDouble = options.getBool("GuiNovelDetails", "clearDouble", True)
self.wpLabel = QLabel(self.tr("Words per page")) self.wpLabel = QLabel(self.tr("Words per page"), self)
self.wpValue = QSpinBox(self) self.wpValue = QSpinBox(self)
self.wpValue.setMinimum(10) self.wpValue.setMinimum(10)
@@ -375,7 +375,7 @@ class _ContentsPage(NFixedPage):
self.wpValue.setValue(wordsPerPage) self.wpValue.setValue(wordsPerPage)
self.wpValue.valueChanged.connect(self._populateTree) self.wpValue.valueChanged.connect(self._populateTree)
self.poLabel = QLabel(self.tr("First page offset")) self.poLabel = QLabel(self.tr("First page offset"), self)
self.poValue = QSpinBox(self) self.poValue = QSpinBox(self)
self.poValue.setMinimum(1) self.poValue.setMinimum(1)
@@ -384,7 +384,7 @@ class _ContentsPage(NFixedPage):
self.poValue.setValue(countFrom) self.poValue.setValue(countFrom)
self.poValue.valueChanged.connect(self._populateTree) self.poValue.valueChanged.connect(self._populateTree)
self.dblLabel = QLabel(self.tr("Chapters on odd pages")) self.dblLabel = QLabel(self.tr("Chapters on odd pages"), self)
self.dblValue = NSwitch(self, height=iPx) self.dblValue = NSwitch(self, height=iPx)
self.dblValue.setChecked(clearDouble) self.dblValue.setChecked(clearDouble)
+4 -4
View File
@@ -682,10 +682,10 @@ class _NewProjectForm(QWidget):
# ======== # ========
self.extraBox = QVBoxLayout() self.extraBox = QVBoxLayout()
self.extraBox.addWidget(QLabel("<b>{0}</b>".format(self.tr("Chapters and Scenes")))) self.extraBox.addWidget(QLabel("<b>{0}</b>".format(self.tr("Chapters and Scenes")), self))
self.extraBox.addLayout(self.novelForm) self.extraBox.addLayout(self.novelForm)
self.extraBox.addSpacing(sPx) self.extraBox.addSpacing(sPx)
self.extraBox.addWidget(QLabel("<b>{0}</b>".format(self.tr("Project Notes")))) self.extraBox.addWidget(QLabel("<b>{0}</b>".format(self.tr("Project Notes")), self))
self.extraBox.addLayout(self.notesForm) self.extraBox.addLayout(self.notesForm)
self.extraBox.setContentsMargins(0, 0, 0, 0) self.extraBox.setContentsMargins(0, 0, 0, 0)
@@ -694,7 +694,7 @@ class _NewProjectForm(QWidget):
self.extraWidget.setContentsMargins(0, 0, 0, 0) self.extraWidget.setContentsMargins(0, 0, 0, 0)
self.formBox = QVBoxLayout() self.formBox = QVBoxLayout()
self.formBox.addWidget(QLabel("<b>{0}</b>".format(self.tr("Create New Project")))) self.formBox.addWidget(QLabel("<b>{0}</b>".format(self.tr("Create New Project")), self))
self.formBox.addLayout(self.projectForm) self.formBox.addLayout(self.projectForm)
self.formBox.addSpacing(sPx) self.formBox.addSpacing(sPx)
self.formBox.addWidget(self.extraWidget) self.formBox.addWidget(self.extraWidget)
@@ -738,7 +738,7 @@ class _NewProjectForm(QWidget):
"""Select a project folder.""" """Select a project folder."""
if projDir := QFileDialog.getExistingDirectory( if projDir := QFileDialog.getExistingDirectory(
self, self.tr("Select Project Folder"), self, self.tr("Select Project Folder"),
str(self._basePath), options=QFileDialog.ShowDirsOnly str(self._basePath), options=QFileDialog.Option.ShowDirsOnly
): ):
self._basePath = Path(projDir) self._basePath = Path(projDir)
self._updateProjPath() self._updateProjPath()
+20 -20
View File
@@ -105,7 +105,7 @@ class GuiWritingStats(QDialog):
pOptions.getInt("GuiWritingStats", "widthCol3", 80) pOptions.getInt("GuiWritingStats", "widthCol3", 80)
) )
self.listBox = QTreeWidget() self.listBox = QTreeWidget(self)
self.listBox.setHeaderLabels([ self.listBox.setHeaderLabels([
self.tr("Session Start"), self.tr("Session Start"),
self.tr("Length"), self.tr("Length"),
@@ -145,36 +145,36 @@ class GuiWritingStats(QDialog):
self.infoForm = QGridLayout(self) self.infoForm = QGridLayout(self)
self.infoBox.setLayout(self.infoForm) self.infoBox.setLayout(self.infoForm)
self.labelTotal = QLabel(formatTime(0)) self.labelTotal = QLabel(formatTime(0), self)
self.labelTotal.setFont(SHARED.theme.guiFontFixed) self.labelTotal.setFont(SHARED.theme.guiFontFixed)
self.labelTotal.setAlignment(QtAlignRightMiddle) self.labelTotal.setAlignment(QtAlignRightMiddle)
self.labelIdleT = QLabel(formatTime(0)) self.labelIdleT = QLabel(formatTime(0), self)
self.labelIdleT.setFont(SHARED.theme.guiFontFixed) self.labelIdleT.setFont(SHARED.theme.guiFontFixed)
self.labelIdleT.setAlignment(QtAlignRightMiddle) self.labelIdleT.setAlignment(QtAlignRightMiddle)
self.labelFilter = QLabel(formatTime(0)) self.labelFilter = QLabel(formatTime(0), self)
self.labelFilter.setFont(SHARED.theme.guiFontFixed) self.labelFilter.setFont(SHARED.theme.guiFontFixed)
self.labelFilter.setAlignment(QtAlignRightMiddle) self.labelFilter.setAlignment(QtAlignRightMiddle)
self.novelWords = QLabel("0") self.novelWords = QLabel("0", self)
self.novelWords.setFont(SHARED.theme.guiFontFixed) self.novelWords.setFont(SHARED.theme.guiFontFixed)
self.novelWords.setAlignment(QtAlignRightMiddle) self.novelWords.setAlignment(QtAlignRightMiddle)
self.notesWords = QLabel("0") self.notesWords = QLabel("0", self)
self.notesWords.setFont(SHARED.theme.guiFontFixed) self.notesWords.setFont(SHARED.theme.guiFontFixed)
self.notesWords.setAlignment(QtAlignRightMiddle) self.notesWords.setAlignment(QtAlignRightMiddle)
self.totalWords = QLabel("0") self.totalWords = QLabel("0", self)
self.totalWords.setFont(SHARED.theme.guiFontFixed) self.totalWords.setFont(SHARED.theme.guiFontFixed)
self.totalWords.setAlignment(QtAlignRightMiddle) self.totalWords.setAlignment(QtAlignRightMiddle)
lblTTime = QLabel(self.tr("Total Time:")) lblTTime = QLabel(self.tr("Total Time:"), self)
lblITime = QLabel(self.tr("Idle Time:")) lblITime = QLabel(self.tr("Idle Time:"), self)
lblFTime = QLabel(self.tr("Filtered Time:")) lblFTime = QLabel(self.tr("Filtered Time:"), self)
lblNvCount = QLabel(self.tr("Novel Word Count:")) lblNvCount = QLabel(self.tr("Novel Word Count:"), self)
lblNtCount = QLabel(self.tr("Notes Word Count:")) lblNtCount = QLabel(self.tr("Notes Word Count:"), self)
lblTtCount = QLabel(self.tr("Total Word Count:")) lblTtCount = QLabel(self.tr("Total Word Count:"), self)
self.infoForm.addWidget(lblTTime, 0, 0) self.infoForm.addWidget(lblTTime, 0, 0)
self.infoForm.addWidget(lblITime, 1, 0) self.infoForm.addWidget(lblITime, 1, 0)
@@ -235,12 +235,12 @@ class GuiWritingStats(QDialog):
) )
self.showIdleTime.clicked.connect(self._updateListBox) self.showIdleTime.clicked.connect(self._updateListBox)
self.filterForm.addWidget(QLabel(self.tr("Count novel files")), 0, 0) self.filterForm.addWidget(QLabel(self.tr("Count novel files"), self), 0, 0)
self.filterForm.addWidget(QLabel(self.tr("Count note files")), 1, 0) self.filterForm.addWidget(QLabel(self.tr("Count note files"), self), 1, 0)
self.filterForm.addWidget(QLabel(self.tr("Hide zero word count")), 2, 0) self.filterForm.addWidget(QLabel(self.tr("Hide zero word count"), self), 2, 0)
self.filterForm.addWidget(QLabel(self.tr("Hide negative word count")), 3, 0) self.filterForm.addWidget(QLabel(self.tr("Hide negative word count"), self), 3, 0)
self.filterForm.addWidget(QLabel(self.tr("Group entries by day")), 4, 0) self.filterForm.addWidget(QLabel(self.tr("Group entries by day"), self), 4, 0)
self.filterForm.addWidget(QLabel(self.tr("Show idle time")), 5, 0) self.filterForm.addWidget(QLabel(self.tr("Show idle time"), self), 5, 0)
self.filterForm.addWidget(self.incNovel, 0, 1) self.filterForm.addWidget(self.incNovel, 0, 1)
self.filterForm.addWidget(self.incNotes, 1, 1) self.filterForm.addWidget(self.incNotes, 1, 1)
self.filterForm.addWidget(self.hideZeros, 2, 1) self.filterForm.addWidget(self.hideZeros, 2, 1)
@@ -261,7 +261,7 @@ class GuiWritingStats(QDialog):
self.optsBox = QHBoxLayout() self.optsBox = QHBoxLayout()
self.optsBox.addStretch(1) self.optsBox.addStretch(1)
self.optsBox.addWidget(QLabel(self.tr("Word count cap for the histogram")), 0) self.optsBox.addWidget(QLabel(self.tr("Word count cap for the histogram"), self), 0)
self.optsBox.addWidget(self.histMax, 0) self.optsBox.addWidget(self.histMax, 0)
# Buttons # Buttons
+8 -1
View File
@@ -24,7 +24,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
from __future__ import annotations from __future__ import annotations
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt5.QtGui import QColor, QPainter from PyQt5.QtGui import QColor, QPainter, QTextCursor
from PyQt5.QtWidgets import QDialogButtonBox, QStyle from PyQt5.QtWidgets import QDialogButtonBox, QStyle
# Qt Alignment Flags # Qt Alignment Flags
@@ -81,3 +81,10 @@ QtRoleAccept = QDialogButtonBox.ButtonRole.AcceptRole
QtRoleAction = QDialogButtonBox.ButtonRole.ActionRole QtRoleAction = QDialogButtonBox.ButtonRole.ActionRole
QtRoleApply = QDialogButtonBox.ButtonRole.ApplyRole QtRoleApply = QDialogButtonBox.ButtonRole.ApplyRole
QtRoleReject = QDialogButtonBox.ButtonRole.RejectRole QtRoleReject = QDialogButtonBox.ButtonRole.RejectRole
# Cursor Types
QtKeepAnchor = QTextCursor.MoveMode.KeepAnchor
QtMoveAnchor = QTextCursor.MoveMode.MoveAnchor
QtMoveLeft = QTextCursor.MoveOperation.Left
QtMoveRight = QTextCursor.MoveOperation.Right
+5 -5
View File
@@ -37,7 +37,7 @@ from novelwriter.enum import (
) )
from novelwriter.gui.doceditor import GuiDocEditor, GuiDocToolBar from novelwriter.gui.doceditor import GuiDocEditor, GuiDocToolBar
from novelwriter.text.counting import standardCounter from novelwriter.text.counting import standardCounter
from novelwriter.types import QtAlignJustify, QtAlignLeft, QtMouseLeft from novelwriter.types import QtAlignJustify, QtAlignLeft, QtKeepAnchor, QtMouseLeft, QtMoveRight
KEY_DELAY = 1 KEY_DELAY = 1
@@ -1413,7 +1413,7 @@ def testGuiEditor_MultiBlockFormatting(qtbot, nwGUI, projPath, ipsumText, mockRn
# Toggle Comment # Toggle Comment
cursor = nwGUI.docEditor.textCursor() cursor = nwGUI.docEditor.textCursor()
cursor.setPosition(50) cursor.setPosition(50)
cursor.movePosition(QTextCursor.MoveOperation.Right, QTextCursor.MoveMode.KeepAnchor, 2000) cursor.movePosition(QtMoveRight, QtKeepAnchor, 2000)
nwGUI.docEditor.setTextCursor(cursor) nwGUI.docEditor.setTextCursor(cursor)
nwGUI.docEditor._iterFormatBlocks(nwDocAction.BLOCK_COM) nwGUI.docEditor._iterFormatBlocks(nwDocAction.BLOCK_COM)
@@ -1434,7 +1434,7 @@ def testGuiEditor_MultiBlockFormatting(qtbot, nwGUI, projPath, ipsumText, mockRn
# Un-toggle all # Un-toggle all
cursor = nwGUI.docEditor.textCursor() cursor = nwGUI.docEditor.textCursor()
cursor.setPosition(50) cursor.setPosition(50)
cursor.movePosition(QTextCursor.MoveOperation.Right, QTextCursor.MoveMode.KeepAnchor, 3000) cursor.movePosition(QtMoveRight, QtKeepAnchor, 3000)
nwGUI.docEditor.setTextCursor(cursor) nwGUI.docEditor.setTextCursor(cursor)
nwGUI.docEditor._iterFormatBlocks(nwDocAction.BLOCK_COM) nwGUI.docEditor._iterFormatBlocks(nwDocAction.BLOCK_COM)
@@ -1445,7 +1445,7 @@ def testGuiEditor_MultiBlockFormatting(qtbot, nwGUI, projPath, ipsumText, mockRn
# Toggle Ignore Text # Toggle Ignore Text
cursor = nwGUI.docEditor.textCursor() cursor = nwGUI.docEditor.textCursor()
cursor.setPosition(50) cursor.setPosition(50)
cursor.movePosition(QTextCursor.MoveOperation.Right, QTextCursor.MoveMode.KeepAnchor, 2000) cursor.movePosition(QtMoveRight, QtKeepAnchor, 2000)
nwGUI.docEditor.setTextCursor(cursor) nwGUI.docEditor.setTextCursor(cursor)
nwGUI.docEditor._iterFormatBlocks(nwDocAction.BLOCK_IGN) nwGUI.docEditor._iterFormatBlocks(nwDocAction.BLOCK_IGN)
@@ -1456,7 +1456,7 @@ def testGuiEditor_MultiBlockFormatting(qtbot, nwGUI, projPath, ipsumText, mockRn
# Clear all paragraphs # Clear all paragraphs
cursor = nwGUI.docEditor.textCursor() cursor = nwGUI.docEditor.textCursor()
cursor.setPosition(50) cursor.setPosition(50)
cursor.movePosition(QTextCursor.MoveOperation.Right, QTextCursor.MoveMode.KeepAnchor, 3000) cursor.movePosition(QtMoveRight, QtKeepAnchor, 3000)
nwGUI.docEditor.setTextCursor(cursor) nwGUI.docEditor.setTextCursor(cursor)
nwGUI.docEditor._iterFormatBlocks(nwDocAction.BLOCK_TXT) nwGUI.docEditor._iterFormatBlocks(nwDocAction.BLOCK_TXT)