Collect all alignment flags into a new types module
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user