Collect all alignment flags into a new types module

This commit is contained in:
Veronica Berglyd Olsen
2024-04-01 18:27:18 +02:00
parent 468a0e7416
commit c3467d89c2
24 changed files with 195 additions and 171 deletions
+2 -4
View File
@@ -26,7 +26,6 @@ from __future__ import annotations
import logging
from PyQt5.QtGui import QCloseEvent, QColor
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (
QDialog, QDialogButtonBox, QHBoxLayout, QLabel, QTextBrowser, QVBoxLayout,
QWidget
@@ -36,6 +35,7 @@ from novelwriter import CONFIG, SHARED
from novelwriter.common import readTextFile
from novelwriter.extensions.configlayout import NColourLabel
from novelwriter.extensions.versioninfo import VersionInfoWidget
from novelwriter.types import QtAlignRightTop
logger = logging.getLogger(__name__)
@@ -100,10 +100,8 @@ class GuiAbout(QDialog):
self.innerBox.addSpacing(hB)
self.innerBox.addWidget(self.btnBox)
topRight = Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignRight
self.outerBox = QHBoxLayout()
self.outerBox.addWidget(self.nwLogo, 0, topRight)
self.outerBox.addWidget(self.nwLogo, 0, QtAlignRightTop)
self.outerBox.addLayout(self.innerBox, 1)
self.setLayout(self.outerBox)
+7 -6
View File
@@ -37,10 +37,11 @@ from PyQt5.QtWidgets import (
from novelwriter import CONFIG, SHARED
from novelwriter.constants import nwConst, nwUnicode
from novelwriter.dialogs.quotes import GuiQuoteSelect
from novelwriter.extensions.switch import NSwitch
from novelwriter.extensions.modified import NComboBox, NDoubleSpinBox, NSpinBox
from novelwriter.extensions.configlayout import NColourLabel, NScrollableForm
from novelwriter.extensions.modified import NComboBox, NDoubleSpinBox, NSpinBox
from novelwriter.extensions.pagedsidebar import NPagedSideBar
from novelwriter.extensions.switch import NSwitch
from novelwriter.types import QtAlignCenter
logger = logging.getLogger(__name__)
@@ -679,7 +680,7 @@ class GuiPreferences(QDialog):
self.quoteSym["SO"].setMaxLength(1)
self.quoteSym["SO"].setReadOnly(True)
self.quoteSym["SO"].setFixedWidth(qWidth)
self.quoteSym["SO"].setAlignment(Qt.AlignCenter)
self.quoteSym["SO"].setAlignment(QtAlignCenter)
self.quoteSym["SO"].setText(CONFIG.fmtSQuoteOpen)
self.btnSingleStyleO = QToolButton(self)
self.btnSingleStyleO.setIcon(mIcon)
@@ -695,7 +696,7 @@ class GuiPreferences(QDialog):
self.quoteSym["SC"].setMaxLength(1)
self.quoteSym["SC"].setReadOnly(True)
self.quoteSym["SC"].setFixedWidth(qWidth)
self.quoteSym["SC"].setAlignment(Qt.AlignCenter)
self.quoteSym["SC"].setAlignment(QtAlignCenter)
self.quoteSym["SC"].setText(CONFIG.fmtSQuoteClose)
self.btnSingleStyleC = QToolButton(self)
self.btnSingleStyleC.setIcon(mIcon)
@@ -712,7 +713,7 @@ class GuiPreferences(QDialog):
self.quoteSym["DO"].setMaxLength(1)
self.quoteSym["DO"].setReadOnly(True)
self.quoteSym["DO"].setFixedWidth(qWidth)
self.quoteSym["DO"].setAlignment(Qt.AlignCenter)
self.quoteSym["DO"].setAlignment(QtAlignCenter)
self.quoteSym["DO"].setText(CONFIG.fmtDQuoteOpen)
self.btnDoubleStyleO = QToolButton(self)
self.btnDoubleStyleO.setIcon(mIcon)
@@ -728,7 +729,7 @@ class GuiPreferences(QDialog):
self.quoteSym["DC"].setMaxLength(1)
self.quoteSym["DC"].setReadOnly(True)
self.quoteSym["DC"].setFixedWidth(qWidth)
self.quoteSym["DC"].setAlignment(Qt.AlignCenter)
self.quoteSym["DC"].setAlignment(QtAlignCenter)
self.quoteSym["DC"].setText(CONFIG.fmtDQuoteClose)
self.btnDoubleStyleC = QToolButton(self)
self.btnDoubleStyleC.setIcon(mIcon)
+3 -2
View File
@@ -34,6 +34,7 @@ from PyQt5.QtWidgets import (
from novelwriter import CONFIG
from novelwriter.constants import trConst, nwQuotes
from novelwriter.types import QtAlignCenter, QtAlignTop
logger = logging.getLogger(__name__)
@@ -68,7 +69,7 @@ class GuiQuoteSelect(QDialog):
self.previewLabel = QLabel(current)
self.previewLabel.setFont(lblFont)
self.previewLabel.setFixedSize(QSize(pxW, pxH))
self.previewLabel.setAlignment(Qt.AlignCenter)
self.previewLabel.setAlignment(QtAlignCenter)
self.previewLabel.setFrameStyle(QFrame.Box | QFrame.Plain)
# Quote Symbols
@@ -94,7 +95,7 @@ class GuiQuoteSelect(QDialog):
self.buttonBox.rejected.connect(self.reject)
# Assemble
self.labelBox.addWidget(self.previewLabel, 0, Qt.AlignTop)
self.labelBox.addWidget(self.previewLabel, 0, QtAlignTop)
self.labelBox.addStretch(1)
self.innerBox.addLayout(self.labelBox)
+2 -2
View File
@@ -93,8 +93,8 @@ class NWErrorMessage(QDialog):
# Assemble
self.mainBox = QGridLayout()
self.mainBox.addWidget(self.msgIcon, 0, 0, 2, 1, Qt.AlignTop)
self.mainBox.addWidget(self.msgHead, 0, 1, 1, 1, Qt.AlignTop)
self.mainBox.addWidget(self.msgIcon, 0, 0, 2, 1, Qt.AlignmentFlag.AlignTop)
self.mainBox.addWidget(self.msgHead, 0, 1, 1, 1, Qt.AlignmentFlag.AlignTop)
self.mainBox.addWidget(self.msgBody, 1, 1, 1, 1)
self.mainBox.addWidget(self.btnBox, 2, 0, 1, 2)
self.mainBox.setSpacing(16)
+3 -1
View File
@@ -29,6 +29,8 @@ from PyQt5.QtGui import QBrush, QColor, QPaintEvent, QPainter, QPen
from PyQt5.QtCore import QRect, Qt
from PyQt5.QtWidgets import QProgressBar, QSizePolicy, QWidget
from novelwriter.types import QtAlignCenter
class NProgressCircle(QProgressBar):
"""Extension: Circular Progress Widget
@@ -94,7 +96,7 @@ class NProgressCircle(QProgressBar):
painter.setPen(self._cPen)
painter.drawArc(self._cRect, 90*16, -angle)
painter.setPen(self._tColor)
painter.drawText(self._cRect, Qt.AlignCenter, self._text or f"{progress:.1f} %")
painter.drawText(self._cRect, QtAlignCenter, self._text or f"{progress:.1f} %")
return
# END Class NProgressCircle
-2
View File
@@ -37,8 +37,6 @@ from PyQt5.QtWidgets import (
from novelwriter import CONFIG
DEFAULT_SCALE = 0.9
RIGHT_TOP = Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignTop
LEFT_TOP = Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop
class NFixedPage(QFrame):
+4 -2
View File
@@ -32,6 +32,8 @@ from PyQt5.QtWidgets import (
QStyleOptionToolButton, QToolBar, QToolButton, QWidget
)
from novelwriter.types import QtAlignLeft
class NPagedSideBar(QToolBar):
"""Extensions: Paged Side Bar
@@ -171,7 +173,7 @@ class _NPagedToolButton(QToolButton):
paint.setPen(textCol)
paint.setOpacity(1.0)
paint.drawText(QRectF(self._lM, self._tM, tW, tH), Qt.AlignLeft, self.text())
paint.drawText(QRectF(self._lM, self._tM, tW, tH), QtAlignLeft, self.text())
tC = self.height()//2
tW = self.width() - self._aH - self._lM
@@ -223,7 +225,7 @@ class _NPagedToolLabel(QLabel):
paint.setPen(self._textCol)
paint.setOpacity(1.0)
paint.drawText(QRectF(self._lM, self._tM, tW, tH), Qt.AlignLeft, self.text())
paint.drawText(QRectF(self._lM, self._tM, tW, tH), QtAlignLeft, self.text())
return
+8 -7
View File
@@ -24,10 +24,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
from __future__ import annotations
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QGridLayout, QLabel, QScrollArea, QSizePolicy, QWidget
from novelwriter.extensions.switch import NSwitch
from novelwriter.types import QtAlignLeft, QtAlignRight, QtAlignRightMiddle
class NSwitchBox(QScrollArea):
@@ -72,7 +73,7 @@ class NSwitchBox(QScrollArea):
font = label.font()
font.setBold(True)
label.setFont(font)
self._content.addWidget(label, self._index, 0, 1, 3, Qt.AlignLeft)
self._content.addWidget(label, self._index, 0, 1, 3, QtAlignLeft)
self._widgets.append(label)
self._bumpIndex()
return
@@ -80,17 +81,17 @@ class NSwitchBox(QScrollArea):
def addItem(self, qIcon: QIcon, text: str, identifier: str, default: bool = False) -> None:
"""Add an item to the content box."""
icon = QLabel("")
icon.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
icon.setAlignment(QtAlignRightMiddle)
icon.setPixmap(qIcon.pixmap(self._sIcon, self._sIcon))
self._content.addWidget(icon, self._index, 0, Qt.AlignLeft)
self._content.addWidget(icon, self._index, 0, QtAlignLeft)
label = QLabel(text)
self._content.addWidget(label, self._index, 1, Qt.AlignLeft)
self._content.addWidget(label, self._index, 1, QtAlignLeft)
switch = NSwitch(self, height=self._hSwitch)
switch.setChecked(default)
switch.toggled.connect(lambda state: self._emitSwitchSignal(identifier, state))
self._content.addWidget(switch, self._index, 2, Qt.AlignRight)
self._content.addWidget(switch, self._index, 2, QtAlignRight)
self._widgets.append(switch)
self._bumpIndex()
@@ -101,7 +102,7 @@ class NSwitchBox(QScrollArea):
"""Add a blank entry in the content box."""
spacer = QWidget()
spacer.setFixedHeight(int(0.5*self._sIcon))
self._content.addWidget(spacer, self._index, 0, 1, 3, Qt.AlignLeft)
self._content.addWidget(spacer, self._index, 0, 1, 3, QtAlignLeft)
self._widgets.append(spacer)
self._bumpIndex()
return
+13 -12
View File
@@ -64,6 +64,9 @@ from novelwriter.gui.editordocument import GuiTextDocument
from novelwriter.gui.theme import STYLES_MIN_TOOLBUTTON
from novelwriter.text.counting import standardCounter
from novelwriter.tools.lipsum import GuiLipsum
from novelwriter.types import (
QtAlignCenterTop, QtAlignJustify, QtAlignLeft, QtAlignLeftTop, QtAlignRight
)
if TYPE_CHECKING: # pragma: no cover
from novelwriter.guimain import GuiMain
@@ -339,7 +342,7 @@ class GuiDocEditor(QPlainTextEdit):
options = QTextOption()
if CONFIG.doJustify:
options.setAlignment(Qt.AlignmentFlag.AlignJustify)
options.setAlignment(QtAlignJustify)
if CONFIG.showTabsNSpaces:
options.setFlags(options.flags() | QTextOption.Flag.ShowTabsAndSpaces)
if CONFIG.showLineEndings:
@@ -2514,8 +2517,8 @@ class GuiDocEditSearch(QFrame):
self.replaceButton.setToolTip(self.tr("Find and replace in current document"))
self.replaceButton.clicked.connect(self._doReplace)
self.mainBox.addWidget(self.searchLabel, 0, 0, 1, 2, Qt.AlignmentFlag.AlignLeft)
self.mainBox.addWidget(self.searchOpt, 0, 2, 1, 3, Qt.AlignmentFlag.AlignRight)
self.mainBox.addWidget(self.searchLabel, 0, 0, 1, 2, QtAlignLeft)
self.mainBox.addWidget(self.searchOpt, 0, 2, 1, 3, QtAlignRight)
self.mainBox.addWidget(self.showReplace, 1, 0, 1, 1)
self.mainBox.addWidget(self.searchBox, 1, 1, 1, 2)
self.mainBox.addWidget(self.searchButton, 1, 3, 1, 1)
@@ -2830,7 +2833,7 @@ class GuiDocEditHeader(QWidget):
self.itemTitle.setMargin(0)
self.itemTitle.setContentsMargins(0, 0, 0, 0)
self.itemTitle.setAutoFillBackground(True)
self.itemTitle.setAlignment(Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignTop)
self.itemTitle.setAlignment(QtAlignCenterTop)
self.itemTitle.setFixedHeight(iPx)
lblFont = self.itemTitle.font()
@@ -3053,13 +3056,11 @@ class GuiDocEditFooter(QWidget):
self.setContentsMargins(0, 0, 0, 0)
self.setAutoFillBackground(True)
alLeftTop = Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop
# Status
self.statusIcon = QLabel("", self)
self.statusIcon.setContentsMargins(0, 0, 0, 0)
self.statusIcon.setFixedHeight(iPx)
self.statusIcon.setAlignment(alLeftTop)
self.statusIcon.setAlignment(QtAlignLeftTop)
self.statusText = QLabel(self.tr("Status"))
self.statusText.setIndent(0)
@@ -3067,14 +3068,14 @@ class GuiDocEditFooter(QWidget):
self.statusText.setContentsMargins(0, 0, 0, 0)
self.statusText.setAutoFillBackground(True)
self.statusText.setFixedHeight(fPx)
self.statusText.setAlignment(alLeftTop)
self.statusText.setAlignment(QtAlignLeftTop)
self.statusText.setFont(lblFont)
# Lines
self.linesIcon = QLabel("", self)
self.linesIcon.setContentsMargins(0, 0, 0, 0)
self.linesIcon.setFixedHeight(iPx)
self.linesIcon.setAlignment(alLeftTop)
self.linesIcon.setAlignment(QtAlignLeftTop)
self.linesText = QLabel("", self)
self.linesText.setIndent(0)
@@ -3082,14 +3083,14 @@ class GuiDocEditFooter(QWidget):
self.linesText.setContentsMargins(0, 0, 0, 0)
self.linesText.setAutoFillBackground(True)
self.linesText.setFixedHeight(fPx)
self.linesText.setAlignment(alLeftTop)
self.linesText.setAlignment(QtAlignLeftTop)
self.linesText.setFont(lblFont)
# Words
self.wordsIcon = QLabel("", self)
self.wordsIcon.setContentsMargins(0, 0, 0, 0)
self.wordsIcon.setFixedHeight(iPx)
self.wordsIcon.setAlignment(alLeftTop)
self.wordsIcon.setAlignment(QtAlignLeftTop)
self.wordsText = QLabel("", self)
self.wordsText.setIndent(0)
@@ -3097,7 +3098,7 @@ class GuiDocEditFooter(QWidget):
self.wordsText.setContentsMargins(0, 0, 0, 0)
self.wordsText.setAutoFillBackground(True)
self.wordsText.setFixedHeight(fPx)
self.wordsText.setAlignment(alLeftTop)
self.wordsText.setAlignment(QtAlignLeftTop)
self.wordsText.setFont(lblFont)
# Assemble Layout
+3 -2
View File
@@ -49,6 +49,7 @@ from novelwriter.error import logException
from novelwriter.extensions.eventfilters import WheelEventFilter
from novelwriter.extensions.modified import NIconToolButton
from novelwriter.gui.theme import STYLES_MIN_TOOLBUTTON
from novelwriter.types import QtAlignCenterTop, QtAlignJustify
logger = logging.getLogger(__name__)
@@ -164,7 +165,7 @@ class GuiDocViewer(QTextBrowser):
self.document().setDocumentMargin(0)
options = QTextOption()
if CONFIG.doJustify:
options.setAlignment(Qt.AlignmentFlag.AlignJustify)
options.setAlignment(QtAlignJustify)
self.document().setDefaultTextOption(options)
# Scroll bars
@@ -639,7 +640,7 @@ class GuiDocViewHeader(QWidget):
self.itemTitle.setMargin(0)
self.itemTitle.setContentsMargins(0, 0, 0, 0)
self.itemTitle.setAutoFillBackground(True)
self.itemTitle.setAlignment(Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignTop)
self.itemTitle.setAlignment(QtAlignCenterTop)
self.itemTitle.setFixedHeight(iPx)
lblFont = self.itemTitle.font()
+2 -1
View File
@@ -47,6 +47,7 @@ from novelwriter.enum import nwDocMode, nwItemClass, nwOutline
from novelwriter.extensions.modified import NIconToolButton
from novelwriter.extensions.novelselector import NovelSelector
from novelwriter.gui.theme import STYLES_MIN_TOOLBUTTON
from novelwriter.types import QtAlignRight
if TYPE_CHECKING: # pragma: no cover
from novelwriter.guimain import GuiMain
@@ -676,7 +677,7 @@ class GuiNovelTree(QTreeWidget):
newItem.setData(self.C_DATA, self.D_HANDLE, tHandle)
newItem.setData(self.C_DATA, self.D_TITLE, sTitle)
newItem.setData(self.C_DATA, self.D_KEY, tKey)
newItem.setTextAlignment(self.C_WORDS, Qt.AlignmentFlag.AlignRight)
newItem.setTextAlignment(self.C_WORDS, QtAlignRight)
self._updateTreeItemValues(newItem, novIdx, tHandle, sTitle)
self._treeMap[tKey] = newItem
+43 -45
View File
@@ -48,6 +48,7 @@ from novelwriter.error import logException
from novelwriter.common import checkInt, formatFileFilter, makeFileNameSafe
from novelwriter.constants import nwHeaders, trConst, nwKeyWords, nwLabels
from novelwriter.extensions.novelselector import NovelSelector
from novelwriter.types import QtAlignLeftTop, QtAlignRight, QtAlignRightTop
logger = logging.getLogger(__name__)
@@ -675,11 +676,11 @@ class GuiOutlineTree(QTreeWidget):
headItem = self.headerItem()
if isinstance(headItem, QTreeWidgetItem):
headItem.setTextAlignment(
self._colIdx[nwOutline.CCOUNT], Qt.AlignmentFlag.AlignRight)
self._colIdx[nwOutline.CCOUNT], QtAlignRight)
headItem.setTextAlignment(
self._colIdx[nwOutline.WCOUNT], Qt.AlignmentFlag.AlignRight)
self._colIdx[nwOutline.WCOUNT], QtAlignRight)
headItem.setTextAlignment(
self._colIdx[nwOutline.PCOUNT], Qt.AlignmentFlag.AlignRight)
self._colIdx[nwOutline.PCOUNT], QtAlignRight)
novStruct = SHARED.project.index.novelStructure(rootHandle=rootHandle, activeOnly=True)
for _, tHandle, sTitle, novIdx in novStruct:
@@ -705,9 +706,9 @@ class GuiOutlineTree(QTreeWidget):
trItem.setText(self._colIdx[nwOutline.CCOUNT], f"{novIdx.charCount:n}")
trItem.setText(self._colIdx[nwOutline.WCOUNT], f"{novIdx.wordCount:n}")
trItem.setText(self._colIdx[nwOutline.PCOUNT], f"{novIdx.paraCount:n}")
trItem.setTextAlignment(self._colIdx[nwOutline.CCOUNT], Qt.AlignmentFlag.AlignRight)
trItem.setTextAlignment(self._colIdx[nwOutline.WCOUNT], Qt.AlignmentFlag.AlignRight)
trItem.setTextAlignment(self._colIdx[nwOutline.PCOUNT], Qt.AlignmentFlag.AlignRight)
trItem.setTextAlignment(self._colIdx[nwOutline.CCOUNT], QtAlignRight)
trItem.setTextAlignment(self._colIdx[nwOutline.WCOUNT], QtAlignRight)
trItem.setTextAlignment(self._colIdx[nwOutline.PCOUNT], QtAlignRight)
refs = SHARED.project.index.getReferences(tHandle, sTitle)
trItem.setText(self._colIdx[nwOutline.POV], ", ".join(refs[nwKeyWords.POV_KEY]))
@@ -834,9 +835,9 @@ class GuiOutlineDetails(QScrollArea):
self.cCValue.setMinimumWidth(wCount)
self.wCValue.setMinimumWidth(wCount)
self.pCValue.setMinimumWidth(wCount)
self.cCValue.setAlignment(Qt.AlignRight)
self.wCValue.setAlignment(Qt.AlignRight)
self.pCValue.setAlignment(Qt.AlignRight)
self.cCValue.setAlignment(QtAlignRight)
self.wCValue.setAlignment(QtAlignRight)
self.pCValue.setAlignment(QtAlignRight)
# Synopsis
self.synopLabel = QLabel(self.tr("Synopsis"))
@@ -844,7 +845,7 @@ class GuiOutlineDetails(QScrollArea):
self.synopValue = QLabel("")
self.synopValue.setWordWrap(True)
self.synopValue.setAlignment(Qt.AlignTop | Qt.AlignLeft)
self.synopValue.setAlignment(QtAlignLeftTop)
self.synopLWrap = QHBoxLayout()
self.synopLWrap.addWidget(self.synopValue, 1)
@@ -925,23 +926,20 @@ class GuiOutlineDetails(QScrollArea):
self.mainForm = QGridLayout()
self.mainGroup.setLayout(self.mainForm)
topLeft = Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignLeft
topRight = Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignRight
self.mainForm.addWidget(self.titleLabel, 0, 0, 1, 1, topLeft)
self.mainForm.addWidget(self.titleValue, 0, 1, 1, 1, topLeft)
self.mainForm.addWidget(self.cCLabel, 0, 2, 1, 1, topLeft)
self.mainForm.addWidget(self.cCValue, 0, 3, 1, 1, topRight)
self.mainForm.addWidget(self.fileLabel, 1, 0, 1, 1, topLeft)
self.mainForm.addWidget(self.fileValue, 1, 1, 1, 1, topLeft)
self.mainForm.addWidget(self.wCLabel, 1, 2, 1, 1, topLeft)
self.mainForm.addWidget(self.wCValue, 1, 3, 1, 1, topRight)
self.mainForm.addWidget(self.itemLabel, 2, 0, 1, 1, topLeft)
self.mainForm.addWidget(self.itemValue, 2, 1, 1, 1, topLeft)
self.mainForm.addWidget(self.pCLabel, 2, 2, 1, 1, topLeft)
self.mainForm.addWidget(self.pCValue, 2, 3, 1, 1, topRight)
self.mainForm.addWidget(self.synopLabel, 3, 0, 1, 4, topLeft)
self.mainForm.addLayout(self.synopLWrap, 4, 0, 1, 4, topLeft)
self.mainForm.addWidget(self.titleLabel, 0, 0, 1, 1, QtAlignLeftTop)
self.mainForm.addWidget(self.titleValue, 0, 1, 1, 1, QtAlignLeftTop)
self.mainForm.addWidget(self.cCLabel, 0, 2, 1, 1, QtAlignLeftTop)
self.mainForm.addWidget(self.cCValue, 0, 3, 1, 1, QtAlignRightTop)
self.mainForm.addWidget(self.fileLabel, 1, 0, 1, 1, QtAlignLeftTop)
self.mainForm.addWidget(self.fileValue, 1, 1, 1, 1, QtAlignLeftTop)
self.mainForm.addWidget(self.wCLabel, 1, 2, 1, 1, QtAlignLeftTop)
self.mainForm.addWidget(self.wCValue, 1, 3, 1, 1, QtAlignRightTop)
self.mainForm.addWidget(self.itemLabel, 2, 0, 1, 1, QtAlignLeftTop)
self.mainForm.addWidget(self.itemValue, 2, 1, 1, 1, QtAlignLeftTop)
self.mainForm.addWidget(self.pCLabel, 2, 2, 1, 1, QtAlignLeftTop)
self.mainForm.addWidget(self.pCValue, 2, 3, 1, 1, QtAlignRightTop)
self.mainForm.addWidget(self.synopLabel, 3, 0, 1, 4, QtAlignLeftTop)
self.mainForm.addLayout(self.synopLWrap, 4, 0, 1, 4, QtAlignLeftTop)
self.mainForm.setColumnStretch(1, 1)
self.mainForm.setRowStretch(4, 1)
@@ -953,24 +951,24 @@ class GuiOutlineDetails(QScrollArea):
self.tagsForm = QGridLayout()
self.tagsGroup.setLayout(self.tagsForm)
self.tagsForm.addWidget(self.povKeyLabel, 0, 0, 1, 1, topLeft)
self.tagsForm.addLayout(self.povKeyLWrap, 0, 1, 1, 1, topLeft)
self.tagsForm.addWidget(self.focKeyLabel, 1, 0, 1, 1, topLeft)
self.tagsForm.addLayout(self.focKeyLWrap, 1, 1, 1, 1, topLeft)
self.tagsForm.addWidget(self.chrKeyLabel, 2, 0, 1, 1, topLeft)
self.tagsForm.addLayout(self.chrKeyLWrap, 2, 1, 1, 1, topLeft)
self.tagsForm.addWidget(self.pltKeyLabel, 3, 0, 1, 1, topLeft)
self.tagsForm.addLayout(self.pltKeyLWrap, 3, 1, 1, 1, topLeft)
self.tagsForm.addWidget(self.timKeyLabel, 4, 0, 1, 1, topLeft)
self.tagsForm.addLayout(self.timKeyLWrap, 4, 1, 1, 1, topLeft)
self.tagsForm.addWidget(self.wldKeyLabel, 5, 0, 1, 1, topLeft)
self.tagsForm.addLayout(self.wldKeyLWrap, 5, 1, 1, 1, topLeft)
self.tagsForm.addWidget(self.objKeyLabel, 6, 0, 1, 1, topLeft)
self.tagsForm.addLayout(self.objKeyLWrap, 6, 1, 1, 1, topLeft)
self.tagsForm.addWidget(self.entKeyLabel, 7, 0, 1, 1, topLeft)
self.tagsForm.addLayout(self.entKeyLWrap, 7, 1, 1, 1, topLeft)
self.tagsForm.addWidget(self.cstKeyLabel, 8, 0, 1, 1, topLeft)
self.tagsForm.addLayout(self.cstKeyLWrap, 8, 1, 1, 1, topLeft)
self.tagsForm.addWidget(self.povKeyLabel, 0, 0, 1, 1, QtAlignLeftTop)
self.tagsForm.addLayout(self.povKeyLWrap, 0, 1, 1, 1, QtAlignLeftTop)
self.tagsForm.addWidget(self.focKeyLabel, 1, 0, 1, 1, QtAlignLeftTop)
self.tagsForm.addLayout(self.focKeyLWrap, 1, 1, 1, 1, QtAlignLeftTop)
self.tagsForm.addWidget(self.chrKeyLabel, 2, 0, 1, 1, QtAlignLeftTop)
self.tagsForm.addLayout(self.chrKeyLWrap, 2, 1, 1, 1, QtAlignLeftTop)
self.tagsForm.addWidget(self.pltKeyLabel, 3, 0, 1, 1, QtAlignLeftTop)
self.tagsForm.addLayout(self.pltKeyLWrap, 3, 1, 1, 1, QtAlignLeftTop)
self.tagsForm.addWidget(self.timKeyLabel, 4, 0, 1, 1, QtAlignLeftTop)
self.tagsForm.addLayout(self.timKeyLWrap, 4, 1, 1, 1, QtAlignLeftTop)
self.tagsForm.addWidget(self.wldKeyLabel, 5, 0, 1, 1, QtAlignLeftTop)
self.tagsForm.addLayout(self.wldKeyLWrap, 5, 1, 1, 1, QtAlignLeftTop)
self.tagsForm.addWidget(self.objKeyLabel, 6, 0, 1, 1, QtAlignLeftTop)
self.tagsForm.addLayout(self.objKeyLWrap, 6, 1, 1, 1, QtAlignLeftTop)
self.tagsForm.addWidget(self.entKeyLabel, 7, 0, 1, 1, QtAlignLeftTop)
self.tagsForm.addLayout(self.entKeyLWrap, 7, 1, 1, 1, QtAlignLeftTop)
self.tagsForm.addWidget(self.cstKeyLabel, 8, 0, 1, 1, QtAlignLeftTop)
self.tagsForm.addLayout(self.cstKeyLWrap, 8, 1, 1, 1, QtAlignLeftTop)
self.tagsForm.setColumnStretch(1, 1)
self.tagsForm.setRowStretch(8, 1)
+5 -4
View File
@@ -54,6 +54,7 @@ from novelwriter.dialogs.projectsettings import GuiProjectSettings
from novelwriter.enum import nwDocMode, nwItemType, nwItemClass, nwItemLayout
from novelwriter.extensions.modified import NIconToolButton
from novelwriter.gui.theme import STYLES_MIN_TOOLBUTTON
from novelwriter.types import QtAlignLeft, QtAlignRight
if TYPE_CHECKING: # pragma: no cover
from novelwriter.guimain import GuiMain
@@ -1585,10 +1586,10 @@ class GuiProjectTree(QTreeWidget):
newItem.setText(self.C_ACTIVE, "")
newItem.setText(self.C_STATUS, "")
newItem.setTextAlignment(self.C_NAME, Qt.AlignmentFlag.AlignLeft)
newItem.setTextAlignment(self.C_COUNT, Qt.AlignmentFlag.AlignRight)
newItem.setTextAlignment(self.C_ACTIVE, Qt.AlignmentFlag.AlignLeft)
newItem.setTextAlignment(self.C_STATUS, Qt.AlignmentFlag.AlignLeft)
newItem.setTextAlignment(self.C_NAME, QtAlignLeft)
newItem.setTextAlignment(self.C_COUNT, QtAlignRight)
newItem.setTextAlignment(self.C_ACTIVE, QtAlignLeft)
newItem.setTextAlignment(self.C_STATUS, QtAlignLeft)
newItem.setData(self.C_DATA, self.D_HANDLE, tHandle)
newItem.setData(self.C_DATA, self.D_WORDS, 0)
+3 -2
View File
@@ -38,6 +38,7 @@ from novelwriter import CONFIG, SHARED
from novelwriter.common import checkInt, cssCol
from novelwriter.core.coretools import DocSearch
from novelwriter.core.item import NWItem
from novelwriter.types import QtAlignMiddle, QtAlignRight
logger = logging.getLogger(__name__)
@@ -124,7 +125,7 @@ class GuiProjectSearch(QWidget):
# Assemble
self.headerBox = QHBoxLayout()
self.headerBox.addWidget(self.viewLabel, 1)
self.headerBox.addWidget(self.searchOpt, 0, Qt.AlignmentFlag.AlignVCenter)
self.headerBox.addWidget(self.searchOpt, 0, QtAlignMiddle)
self.headerBox.setContentsMargins(0, 0, 0, 0)
self.headerBox.setSpacing(0)
@@ -328,7 +329,7 @@ class GuiProjectSearch(QWidget):
tItem.setIcon(self.C_NAME, docIcon)
tItem.setData(self.C_NAME, self.D_HANDLE, tHandle)
tItem.setText(self.C_COUNT, f"({len(results):n}{ext})")
tItem.setTextAlignment(self.C_COUNT, Qt.AlignmentFlag.AlignRight)
tItem.setTextAlignment(self.C_COUNT, QtAlignRight)
tItem.setForeground(self.C_COUNT, self.palette().highlight())
index = self._map.get(tHandle, (self.searchResult.topLevelItemCount(), 0.0))[0]
+6 -5
View File
@@ -35,6 +35,7 @@ from PyQt5.QtWidgets import (
from novelwriter import CONFIG, SHARED
from novelwriter.common import readTextFile
from novelwriter.extensions.switch import NSwitch
from novelwriter.types import QtAlignLeft, QtAlignRight
logger = logging.getLogger(__name__)
@@ -82,11 +83,11 @@ class GuiLipsum(QDialog):
self.randSwitch = NSwitch(self)
self.formBox = QGridLayout()
self.formBox.addWidget(self.headLabel, 0, 0, 1, 2, Qt.AlignLeft)
self.formBox.addWidget(self.paraLabel, 1, 0, 1, 1, Qt.AlignLeft)
self.formBox.addWidget(self.paraCount, 1, 1, 1, 1, Qt.AlignRight)
self.formBox.addWidget(self.randLabel, 2, 0, 1, 1, Qt.AlignLeft)
self.formBox.addWidget(self.randSwitch, 2, 1, 1, 1, Qt.AlignRight)
self.formBox.addWidget(self.headLabel, 0, 0, 1, 2, QtAlignLeft)
self.formBox.addWidget(self.paraLabel, 1, 0, 1, 1, QtAlignLeft)
self.formBox.addWidget(self.paraCount, 1, 1, 1, 1, QtAlignRight)
self.formBox.addWidget(self.randLabel, 2, 0, 1, 1, QtAlignLeft)
self.formBox.addWidget(self.randSwitch, 2, 1, 1, 1, QtAlignRight)
self.formBox.setVerticalSpacing(vSp)
self.formBox.setRowStretch(3, 1)
self.innerBox.addLayout(self.formBox)
+5 -4
View File
@@ -36,13 +36,14 @@ from PyQt5.QtWidgets import (
)
from novelwriter import CONFIG, SHARED
from novelwriter.enum import nwBuildFmt
from novelwriter.common import makeFileNameSafe, openExternalPath
from novelwriter.constants import nwLabels
from novelwriter.core.item import NWItem
from novelwriter.core.docbuild import NWBuildDocument
from novelwriter.core.buildsettings import BuildSettings
from novelwriter.core.docbuild import NWBuildDocument
from novelwriter.core.item import NWItem
from novelwriter.enum import nwBuildFmt
from novelwriter.extensions.simpleprogress import NProgressSimple
from novelwriter.types import QtAlignCenter
logger = logging.getLogger(__name__)
@@ -199,7 +200,7 @@ class GuiManuscriptBuild(QDialog):
])
self.outerBox = QVBoxLayout()
self.outerBox.addWidget(self.lblMain, 0, Qt.AlignCenter)
self.outerBox.addWidget(self.lblMain, 0, QtAlignCenter)
self.outerBox.addSpacing(sp16)
self.outerBox.addWidget(self.mainSplit, 1)
self.outerBox.addSpacing(sp4)
+19 -18
View File
@@ -52,6 +52,9 @@ from novelwriter.extensions.modified import NIconToolButton
from novelwriter.gui.theme import STYLES_FLAT_TABS, STYLES_MIN_TOOLBUTTON
from novelwriter.tools.manusbuild import GuiManuscriptBuild
from novelwriter.tools.manussettings import GuiBuildSettings
from novelwriter.types import (
QtAlignAbsolute, QtAlignCenter, QtAlignJustify, QtAlignRight, QtAlignTop
)
if TYPE_CHECKING: # pragma: no cover
from novelwriter.guimain import GuiMain
@@ -777,7 +780,7 @@ class _PreviewWidget(QTextBrowser):
self.ageLabel.setFont(aFont)
self.ageLabel.setPalette(aPalette)
self.ageLabel.setAutoFillBackground(True)
self.ageLabel.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.ageLabel.setAlignment(QtAlignCenter)
self.ageLabel.setFixedHeight(int(2.1*SHARED.theme.fontPixelSize))
# Progress
@@ -816,9 +819,9 @@ class _PreviewWidget(QTextBrowser):
"""Enable/disable the justify text option."""
pOptions = self.document().defaultTextOption()
if state:
pOptions.setAlignment(Qt.AlignmentFlag.AlignJustify)
pOptions.setAlignment(QtAlignJustify)
else:
pOptions.setAlignment(Qt.AlignmentFlag.AlignAbsolute)
pOptions.setAlignment(QtAlignAbsolute)
self.document().setDefaultTextOption(pOptions)
return
@@ -993,8 +996,8 @@ class _StatsWidget(QWidget):
self.mainStack.addWidget(self.maxWidget)
self.outerBox = QHBoxLayout()
self.outerBox.addWidget(self.toggleButton, 0, Qt.AlignmentFlag.AlignTop)
self.outerBox.addWidget(self.mainStack, 1, Qt.AlignmentFlag.AlignTop)
self.outerBox.addWidget(self.toggleButton, 0, QtAlignTop)
self.outerBox.addWidget(self.mainStack, 1, QtAlignTop)
self.outerBox.setContentsMargins(0, 0, 0, 0)
self.setLayout(self.outerBox)
@@ -1083,8 +1086,6 @@ class _StatsWidget(QWidget):
hPx = CONFIG.pxInt(12)
vPx = CONFIG.pxInt(4)
alignRight = Qt.AlignmentFlag.AlignRight
# Left Column
self.maxTotalWords = QLabel(self)
self.maxHeaderWords = QLabel(self)
@@ -1092,11 +1093,11 @@ class _StatsWidget(QWidget):
self.maxTitleCount = QLabel(self)
self.maxParCount = QLabel(self)
self.maxTotalWords.setAlignment(alignRight)
self.maxHeaderWords.setAlignment(alignRight)
self.maxTextWords.setAlignment(alignRight)
self.maxTitleCount.setAlignment(alignRight)
self.maxParCount.setAlignment(alignRight)
self.maxTotalWords.setAlignment(QtAlignRight)
self.maxHeaderWords.setAlignment(QtAlignRight)
self.maxTextWords.setAlignment(QtAlignRight)
self.maxTitleCount.setAlignment(QtAlignRight)
self.maxParCount.setAlignment(QtAlignRight)
self.leftForm = QFormLayout()
self.leftForm.addRow(self.tr("Words"), self.maxTotalWords)
@@ -1117,13 +1118,13 @@ class _StatsWidget(QWidget):
self.maxHeaderWordChars = QLabel(self)
self.maxTextWordChars = QLabel(self)
self.maxTotalChars.setAlignment(alignRight)
self.maxHeaderChars.setAlignment(alignRight)
self.maxTextChars.setAlignment(alignRight)
self.maxTotalChars.setAlignment(QtAlignRight)
self.maxHeaderChars.setAlignment(QtAlignRight)
self.maxTextChars.setAlignment(QtAlignRight)
self.maxTotalWordChars.setAlignment(alignRight)
self.maxHeaderWordChars.setAlignment(alignRight)
self.maxTextWordChars.setAlignment(alignRight)
self.maxTotalWordChars.setAlignment(QtAlignRight)
self.maxHeaderWordChars.setAlignment(QtAlignRight)
self.maxTextWordChars.setAlignment(QtAlignRight)
self.rightForm = QFormLayout()
self.rightForm.addRow(self.tr("Characters"), self.maxTotalChars)
+5 -4
View File
@@ -39,13 +39,14 @@ from PyQt5.QtWidgets import (
from novelwriter import CONFIG, SHARED
from novelwriter.constants import nwHeadFmt, nwKeyWords, nwLabels, trConst
from novelwriter.core.buildsettings import BuildSettings, FilterMode
from novelwriter.extensions.switch import NSwitch
from novelwriter.extensions.modified import NComboBox, NDoubleSpinBox, NSpinBox
from novelwriter.extensions.switchbox import NSwitchBox
from novelwriter.extensions.configlayout import (
NColourLabel, NFixedPage, NScrollableForm, NScrollablePage
)
from novelwriter.extensions.modified import NComboBox, NDoubleSpinBox, NSpinBox
from novelwriter.extensions.pagedsidebar import NPagedSideBar
from novelwriter.extensions.switch import NSwitch
from novelwriter.extensions.switchbox import NSwitchBox
from novelwriter.types import QtAlignLeft
if TYPE_CHECKING: # pragma: no cover
from novelwriter.guimain import GuiMain
@@ -473,7 +474,7 @@ class _FilterTab(NFixedPage):
trItem.setData(self.C_DATA, self.D_FILE, isFile)
trItem.setIcon(self.C_ACTIVE, SHARED.theme.getIcon(iconName))
trItem.setTextAlignment(self.C_NAME, Qt.AlignLeft)
trItem.setTextAlignment(self.C_NAME, QtAlignLeft)
if pHandle is None and nwItem.isRootType():
self.optTree.addTopLevelItem(trItem)
+11 -10
View File
@@ -37,10 +37,11 @@ from PyQt5.QtWidgets import (
from novelwriter import CONFIG, SHARED
from novelwriter.common import formatTime, numberToRoman
from novelwriter.constants import nwUnicode
from novelwriter.extensions.switch import NSwitch
from novelwriter.extensions.configlayout import NColourLabel, NFixedPage, NScrollablePage
from novelwriter.extensions.pagedsidebar import NPagedSideBar
from novelwriter.extensions.novelselector import NovelSelector
from novelwriter.extensions.pagedsidebar import NPagedSideBar
from novelwriter.extensions.switch import NSwitch
from novelwriter.types import QtAlignRight
logger = logging.getLogger(__name__)
@@ -337,10 +338,10 @@ class _ContentsPage(NFixedPage):
treeHeadItem = self.tocTree.headerItem()
if treeHeadItem:
treeHeadItem.setTextAlignment(self.C_WORDS, Qt.AlignmentFlag.AlignRight)
treeHeadItem.setTextAlignment(self.C_PAGES, Qt.AlignmentFlag.AlignRight)
treeHeadItem.setTextAlignment(self.C_PAGE, Qt.AlignmentFlag.AlignRight)
treeHeadItem.setTextAlignment(self.C_PROG, Qt.AlignmentFlag.AlignRight)
treeHeadItem.setTextAlignment(self.C_WORDS, QtAlignRight)
treeHeadItem.setTextAlignment(self.C_PAGES, QtAlignRight)
treeHeadItem.setTextAlignment(self.C_PAGE, QtAlignRight)
treeHeadItem.setTextAlignment(self.C_PROG, QtAlignRight)
treeHeader = self.tocTree.header()
treeHeader.setStretchLastSection(True)
@@ -490,10 +491,10 @@ class _ContentsPage(NFixedPage):
newItem.setText(self.C_PAGE, progPage)
newItem.setText(self.C_PROG, progText)
newItem.setTextAlignment(self.C_WORDS, Qt.AlignRight)
newItem.setTextAlignment(self.C_PAGES, Qt.AlignRight)
newItem.setTextAlignment(self.C_PAGE, Qt.AlignRight)
newItem.setTextAlignment(self.C_PROG, Qt.AlignRight)
newItem.setTextAlignment(self.C_WORDS, QtAlignRight)
newItem.setTextAlignment(self.C_PAGES, QtAlignRight)
newItem.setTextAlignment(self.C_PAGE, QtAlignRight)
newItem.setTextAlignment(self.C_PROG, QtAlignRight)
# Make pages and titles/partitions stand out
if tLevel < 2:
+6 -7
View File
@@ -41,14 +41,15 @@ from PyQt5.QtWidgets import (
)
from novelwriter import CONFIG, SHARED
from novelwriter.enum import nwItemClass
from novelwriter.common import cssCol, formatInt, makeFileNameSafe
from novelwriter.constants import nwFiles
from novelwriter.core.coretools import ProjectBuilder
from novelwriter.enum import nwItemClass
from novelwriter.extensions.configlayout import NWrappedWidgetBox
from novelwriter.extensions.switch import NSwitch
from novelwriter.extensions.modified import NSpinBox
from novelwriter.extensions.switch import NSwitch
from novelwriter.extensions.versioninfo import VersionInfoWidget
from novelwriter.types import QtAlignLeft, QtAlignRightTop
logger = logging.getLogger(__name__)
@@ -153,10 +154,8 @@ class GuiWelcome(QDialog):
self.innerBox.addSpacing(hB)
self.innerBox.addLayout(self.btnBox)
topRight = Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignRight
self.outerBox = QHBoxLayout()
self.outerBox.addWidget(self.nwLogo, 3, topRight)
self.outerBox.addWidget(self.nwLogo, 3, QtAlignRightTop)
self.outerBox.addLayout(self.innerBox, 9)
self.outerBox.setContentsMargins(hF, hE, hC, hE)
@@ -621,7 +620,7 @@ class _NewProjectForm(QWidget):
# Project Form
self.projectForm = QFormLayout()
self.projectForm.setAlignment(Qt.AlignmentFlag.AlignLeft)
self.projectForm.setAlignment(QtAlignLeft)
self.projectForm.addRow(self.tr("Project Name"), self.projName)
self.projectForm.addRow(self.tr("Author"), self.projAuthor)
self.projectForm.addRow(self.tr("Project Path"), self.pathBox)
@@ -672,7 +671,7 @@ class _NewProjectForm(QWidget):
self.addNotes.setChecked(False)
self.notesForm = QFormLayout()
self.notesForm.setAlignment(Qt.AlignmentFlag.AlignLeft)
self.notesForm.setAlignment(QtAlignLeft)
self.notesForm.addRow(self.tr("Add a folder for plot notes"), self.addPlot)
self.notesForm.addRow(self.tr("Add a folder for character notes"), self.addChar)
self.notesForm.addRow(self.tr("Add a folder for location notes"), self.addWorld)
+15 -14
View File
@@ -37,10 +37,11 @@ from PyQt5.QtWidgets import (
)
from novelwriter import CONFIG, SHARED
from novelwriter.error import formatException
from novelwriter.common import formatTime, checkInt, checkIntTuple, minmax
from novelwriter.constants import nwConst
from novelwriter.error import formatException
from novelwriter.extensions.switch import NSwitch
from novelwriter.types import QtAlignLeftMiddle, QtAlignRight, QtAlignRightMiddle
if TYPE_CHECKING: # pragma: no cover
from novelwriter.guimain import GuiMain
@@ -116,9 +117,9 @@ class GuiWritingStats(QDialog):
hHeader = self.listBox.headerItem()
if hHeader is not None:
hHeader.setTextAlignment(self.C_LENGTH, Qt.AlignRight)
hHeader.setTextAlignment(self.C_IDLE, Qt.AlignRight)
hHeader.setTextAlignment(self.C_COUNT, Qt.AlignRight)
hHeader.setTextAlignment(self.C_LENGTH, QtAlignRight)
hHeader.setTextAlignment(self.C_IDLE, QtAlignRight)
hHeader.setTextAlignment(self.C_COUNT, QtAlignRight)
sortCol = minmax(pOptions.getInt("GuiWritingStats", "sortCol", 0), 0, 2)
sortOrder = checkIntTuple(
@@ -141,27 +142,27 @@ class GuiWritingStats(QDialog):
self.labelTotal = QLabel(formatTime(0))
self.labelTotal.setFont(SHARED.theme.guiFontFixed)
self.labelTotal.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
self.labelTotal.setAlignment(QtAlignRightMiddle)
self.labelIdleT = QLabel(formatTime(0))
self.labelIdleT.setFont(SHARED.theme.guiFontFixed)
self.labelIdleT.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
self.labelIdleT.setAlignment(QtAlignRightMiddle)
self.labelFilter = QLabel(formatTime(0))
self.labelFilter.setFont(SHARED.theme.guiFontFixed)
self.labelFilter.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
self.labelFilter.setAlignment(QtAlignRightMiddle)
self.novelWords = QLabel("0")
self.novelWords.setFont(SHARED.theme.guiFontFixed)
self.novelWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
self.novelWords.setAlignment(QtAlignRightMiddle)
self.notesWords = QLabel("0")
self.notesWords.setFont(SHARED.theme.guiFontFixed)
self.notesWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
self.notesWords.setAlignment(QtAlignRightMiddle)
self.totalWords = QLabel("0")
self.totalWords.setFont(SHARED.theme.guiFontFixed)
self.totalWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
self.totalWords.setAlignment(QtAlignRightMiddle)
lblTTime = QLabel(self.tr("Total Time:"))
lblITime = QLabel(self.tr("Idle Time:"))
@@ -593,10 +594,10 @@ class GuiWritingStats(QDialog):
)
newItem.setData(self.C_BAR, Qt.DecorationRole, wBar)
newItem.setTextAlignment(self.C_LENGTH, Qt.AlignRight)
newItem.setTextAlignment(self.C_IDLE, Qt.AlignRight)
newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight)
newItem.setTextAlignment(self.C_BAR, Qt.AlignLeft | Qt.AlignVCenter)
newItem.setTextAlignment(self.C_LENGTH, QtAlignRight)
newItem.setTextAlignment(self.C_IDLE, QtAlignRight)
newItem.setTextAlignment(self.C_COUNT, QtAlignRight)
newItem.setTextAlignment(self.C_BAR, QtAlignLeftMiddle)
newItem.setFont(self.C_TIME, SHARED.theme.guiFontFixed)
newItem.setFont(self.C_LENGTH, SHARED.theme.guiFontFixed)
+14 -3
View File
@@ -1,6 +1,6 @@
"""
novelWriter Typings
=====================
novelWriter Types and Flags
=============================
File History:
Created: 2024-04-01 [2.4rc1]
@@ -25,8 +25,19 @@ from __future__ import annotations
from PyQt5.QtCore import Qt
# Qt Alignment Flags
QtAlignAbsolute = Qt.AlignmentFlag.AlignAbsolute
QtAlignCenter = Qt.AlignmentFlag.AlignCenter
QtAlignCenterTop = Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignTop
QtAlignJustify = Qt.AlignmentFlag.AlignJustify
QtAlignLeft = Qt.AlignmentFlag.AlignLeft
QtAlignRight = Qt.AlignmentFlag.AlignRight
QtAlignLeftBase = Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignBaseline
QtAlignLeftMiddle = Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter
QtAlignLeftTop = Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop
QtAlignMiddle = Qt.AlignmentFlag.AlignVCenter
QtAlignRight = Qt.AlignmentFlag.AlignRight
QtAlignRightBase = Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignBaseline
QtAlignRightMiddle = Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter
QtAlignRightTop = Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignTop
QtAlignTop = Qt.AlignmentFlag.AlignTop
+5 -4
View File
@@ -30,13 +30,14 @@ from PyQt5.QtCore import QThreadPool, Qt
from PyQt5.QtWidgets import QAction, QMenu, qApp
from novelwriter import CONFIG, SHARED
from novelwriter.constants import nwKeyWords, nwUnicode
from novelwriter.dialogs.editlabel import GuiEditLabel
from novelwriter.enum import (
nwDocAction, nwDocInsert, nwItemClass, nwItemLayout, nwTrinary, nwWidget
)
from novelwriter.constants import nwKeyWords, nwUnicode
from novelwriter.gui.doceditor import GuiDocEditor, GuiDocToolBar
from novelwriter.text.counting import standardCounter
from novelwriter.dialogs.editlabel import GuiEditLabel
from novelwriter.types import QtAlignJustify, QtAlignLeft
KEY_DELAY = 1
@@ -53,7 +54,7 @@ def testGuiEditor_Init(qtbot, nwGUI, projPath, ipsumText, mockRnd):
# Check Defaults
qDoc = nwGUI.docEditor.document()
assert qDoc.defaultTextOption().alignment() == Qt.AlignLeft
assert qDoc.defaultTextOption().alignment() == QtAlignLeft
assert nwGUI.docEditor.verticalScrollBarPolicy() == Qt.ScrollBarAsNeeded
assert nwGUI.docEditor.horizontalScrollBarPolicy() == Qt.ScrollBarAsNeeded
assert nwGUI.docEditor._typPadChar == nwUnicode.U_NBSP
@@ -76,7 +77,7 @@ def testGuiEditor_Init(qtbot, nwGUI, projPath, ipsumText, mockRnd):
qDoc = nwGUI.docEditor.document()
assert CONFIG.textFont == qDoc.defaultFont().family()
assert qDoc.defaultTextOption().alignment() == Qt.AlignJustify
assert qDoc.defaultTextOption().alignment() == QtAlignJustify
assert qDoc.defaultTextOption().flags() & QTextOption.ShowTabsAndSpaces
assert qDoc.defaultTextOption().flags() & QTextOption.ShowLineAndParagraphSeparators
assert nwGUI.docEditor.verticalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
+11 -10
View File
@@ -20,26 +20,27 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
from __future__ import annotations
import sys
import pytest
import sys
from pathlib import Path
from pytestqt.qtbot import QtBot
from novelwriter.constants import nwHeadFmt
from tools import C, buildTestProject
from mocked import causeOSError
from tools import C, buildTestProject
from PyQt5.QtCore import Qt, pyqtSlot
from PyQt5.QtWidgets import QAction, QDialogButtonBox, QListWidgetItem
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtPrintSupport import QPrintPreviewDialog
from PyQt5.QtWidgets import QAction, QDialogButtonBox, QListWidgetItem
from novelwriter import CONFIG, SHARED
from novelwriter.guimain import GuiMain
from novelwriter.constants import nwHeadFmt
from novelwriter.core.buildsettings import BuildSettings
from novelwriter.tools.manuscript import GuiManuscript
from novelwriter.guimain import GuiMain
from novelwriter.tools.manusbuild import GuiManuscriptBuild
from novelwriter.tools.manuscript import GuiManuscript
from novelwriter.tools.manussettings import GuiBuildSettings
from novelwriter.types import QtAlignAbsolute, QtAlignJustify
@pytest.mark.gui
@@ -262,11 +263,11 @@ def testManuscript_Features(monkeypatch, qtbot, nwGUI, projPath, mockRnd):
assert manus.docStats.maxTotalChars.text() == "117"
# Toggle justify
assert manus.docPreview.document().defaultTextOption().alignment() == Qt.AlignAbsolute
assert manus.docPreview.document().defaultTextOption().alignment() == QtAlignAbsolute
manus.docPreview.setJustify(True)
assert manus.docPreview.document().defaultTextOption().alignment() == Qt.AlignJustify
assert manus.docPreview.document().defaultTextOption().alignment() == QtAlignJustify
manus.docPreview.setJustify(False)
assert manus.docPreview.document().defaultTextOption().alignment() == Qt.AlignAbsolute
assert manus.docPreview.document().defaultTextOption().alignment() == QtAlignAbsolute
# Tests are too fast to trigger this one, so we trigger it manually to ensure it isn't failing
manus.docPreview._hideProgress()