Merge build settings page layout options
This commit is contained in:
@@ -147,12 +147,7 @@ SETTINGS_LABELS = {
|
|||||||
"format.grpPage": QT_TRANSLATE_NOOP("Builds", "Page Layout"),
|
"format.grpPage": QT_TRANSLATE_NOOP("Builds", "Page Layout"),
|
||||||
"format.pageUnit": QT_TRANSLATE_NOOP("Builds", "Unit"),
|
"format.pageUnit": QT_TRANSLATE_NOOP("Builds", "Unit"),
|
||||||
"format.pageSize": QT_TRANSLATE_NOOP("Builds", "Page Size"),
|
"format.pageSize": QT_TRANSLATE_NOOP("Builds", "Page Size"),
|
||||||
"format.pageWidth": QT_TRANSLATE_NOOP("Builds", "Page Width"),
|
"format.pageMargins": QT_TRANSLATE_NOOP("Builds", "Page Margins"),
|
||||||
"format.pageHeight": QT_TRANSLATE_NOOP("Builds", "Page Height"),
|
|
||||||
"format.topMargin": QT_TRANSLATE_NOOP("Builds", "Top Margin"),
|
|
||||||
"format.bottomMargin": QT_TRANSLATE_NOOP("Builds", "Bottom Margin"),
|
|
||||||
"format.leftMargin": QT_TRANSLATE_NOOP("Builds", "Left Margin"),
|
|
||||||
"format.rightMargin": QT_TRANSLATE_NOOP("Builds", "Right Margin"),
|
|
||||||
|
|
||||||
"odt": QT_TRANSLATE_NOOP("Builds", "Document Options"),
|
"odt": QT_TRANSLATE_NOOP("Builds", "Document Options"),
|
||||||
"odt.pageHeader": QT_TRANSLATE_NOOP("Builds", "Page Header"),
|
"odt.pageHeader": QT_TRANSLATE_NOOP("Builds", "Page Header"),
|
||||||
|
|||||||
@@ -180,9 +180,16 @@ class NScrollableForm(QScrollArea):
|
|||||||
self._sections[identifier] = qLabel
|
self._sections[identifier] = qLabel
|
||||||
return
|
return
|
||||||
|
|
||||||
def addRow(self, label: str, widget: QWidget | list[QWidget], helpText: str = "",
|
def addRow(
|
||||||
unit: str | None = None, button: QWidget | None = None, editable: str | None = None,
|
self,
|
||||||
stretch: tuple[int, int] = (1, 0)) -> None:
|
label: str | None,
|
||||||
|
widget: QWidget | list[QWidget | str | int],
|
||||||
|
helpText: str = "",
|
||||||
|
unit: str | None = None,
|
||||||
|
button: QWidget | None = None,
|
||||||
|
editable: str | None = None,
|
||||||
|
stretch: tuple[int, int] = (1, 0),
|
||||||
|
) -> None:
|
||||||
"""Add a label and a widget as a new row of the form."""
|
"""Add a label and a widget as a new row of the form."""
|
||||||
row = QHBoxLayout()
|
row = QHBoxLayout()
|
||||||
row.setSpacing(CONFIG.pxInt(12))
|
row.setSpacing(CONFIG.pxInt(12))
|
||||||
@@ -191,13 +198,18 @@ class NScrollableForm(QScrollArea):
|
|||||||
wBox = QHBoxLayout()
|
wBox = QHBoxLayout()
|
||||||
wBox.setContentsMargins(0, 0, 0, 0)
|
wBox.setContentsMargins(0, 0, 0, 0)
|
||||||
for item in widget:
|
for item in widget:
|
||||||
wBox.addWidget(item)
|
if isinstance(item, QWidget):
|
||||||
|
wBox.addWidget(item)
|
||||||
|
elif isinstance(item, str):
|
||||||
|
wBox.addWidget(QLabel(item, self))
|
||||||
|
elif isinstance(item, int):
|
||||||
|
wBox.addSpacing(CONFIG.pxInt(item))
|
||||||
qWidget = QWidget(self)
|
qWidget = QWidget(self)
|
||||||
qWidget.setLayout(wBox)
|
qWidget.setLayout(wBox)
|
||||||
else:
|
else:
|
||||||
qWidget = widget
|
qWidget = widget
|
||||||
|
|
||||||
qLabel = QLabel(label, self)
|
qLabel = QLabel(label or "", self)
|
||||||
qLabel.setIndent(self._indent)
|
qLabel.setIndent(self._indent)
|
||||||
qLabel.setBuddy(qWidget)
|
qLabel.setBuddy(qWidget)
|
||||||
|
|
||||||
@@ -230,7 +242,8 @@ class NScrollableForm(QScrollArea):
|
|||||||
row.addWidget(qWidget, stretch[1])
|
row.addWidget(qWidget, stretch[1])
|
||||||
|
|
||||||
self._layout.addLayout(row)
|
self._layout.addLayout(row)
|
||||||
self._index[label.strip()] = qWidget
|
if label:
|
||||||
|
self._index[label.strip()] = qWidget
|
||||||
self._first = False
|
self._first = False
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -136,9 +136,21 @@ class NSpinBox(QSpinBox):
|
|||||||
|
|
||||||
class NDoubleSpinBox(QDoubleSpinBox):
|
class NDoubleSpinBox(QDoubleSpinBox):
|
||||||
|
|
||||||
def __init__(self, parent: QWidget | None = None) -> None:
|
def __init__(
|
||||||
|
self,
|
||||||
|
parent: QWidget | None = None,
|
||||||
|
*,
|
||||||
|
min: float = 0.0,
|
||||||
|
max: float = 15.0,
|
||||||
|
step: float = 0.1,
|
||||||
|
prec: int = 2,
|
||||||
|
) -> None:
|
||||||
super().__init__(parent=parent)
|
super().__init__(parent=parent)
|
||||||
self.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
self.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
||||||
|
self.setMinimum(min)
|
||||||
|
self.setMaximum(max)
|
||||||
|
self.setSingleStep(step)
|
||||||
|
self.setDecimals(prec)
|
||||||
return
|
return
|
||||||
|
|
||||||
def wheelEvent(self, event: QWheelEvent) -> None:
|
def wheelEvent(self, event: QWheelEvent) -> None:
|
||||||
|
|||||||
@@ -964,6 +964,15 @@ class _FormattingTab(NScrollableForm):
|
|||||||
spW = 6*SHARED.theme.textNWidth
|
spW = 6*SHARED.theme.textNWidth
|
||||||
dbW = 8*SHARED.theme.textNWidth
|
dbW = 8*SHARED.theme.textNWidth
|
||||||
|
|
||||||
|
# Common Translations
|
||||||
|
|
||||||
|
trW = self.tr("W:") # Width
|
||||||
|
trH = self.tr("H:") # Height
|
||||||
|
trT = self.tr("T:") # Top
|
||||||
|
trB = self.tr("B:") # Bottom
|
||||||
|
trL = self.tr("L:") # Left
|
||||||
|
trR = self.tr("R:") # Right
|
||||||
|
|
||||||
# Text Content
|
# Text Content
|
||||||
# ============
|
# ============
|
||||||
|
|
||||||
@@ -1075,24 +1084,32 @@ class _FormattingTab(NScrollableForm):
|
|||||||
self._sidebar.addButton(title, section)
|
self._sidebar.addButton(title, section)
|
||||||
self.addGroupLabel(title, section)
|
self.addGroupLabel(title, section)
|
||||||
|
|
||||||
|
# Unit
|
||||||
self.pageUnit = NComboBox(self)
|
self.pageUnit = NComboBox(self)
|
||||||
for key, name in nwLabels.UNIT_NAME.items():
|
for key, name in nwLabels.UNIT_NAME.items():
|
||||||
self.pageUnit.addItem(trConst(name), key)
|
self.pageUnit.addItem(trConst(name), key)
|
||||||
|
|
||||||
|
self.addRow(self._build.getLabel("format.pageUnit"), self.pageUnit)
|
||||||
|
|
||||||
|
# Page Size
|
||||||
self.pageSize = NComboBox(self)
|
self.pageSize = NComboBox(self)
|
||||||
for key, name in nwLabels.PAPER_NAME.items():
|
for key, name in nwLabels.PAPER_NAME.items():
|
||||||
self.pageSize.addItem(trConst(name), key)
|
self.pageSize.addItem(trConst(name), key)
|
||||||
|
|
||||||
self.pageWidth = NDoubleSpinBox(self)
|
self.pageWidth = NDoubleSpinBox(self, max=500.0)
|
||||||
self.pageWidth.setFixedWidth(dbW)
|
self.pageWidth.setFixedWidth(dbW)
|
||||||
self.pageWidth.setMaximum(500.0)
|
|
||||||
self.pageWidth.valueChanged.connect(self._pageSizeValueChanged)
|
self.pageWidth.valueChanged.connect(self._pageSizeValueChanged)
|
||||||
|
|
||||||
self.pageHeight = NDoubleSpinBox(self)
|
self.pageHeight = NDoubleSpinBox(self, max=500.0)
|
||||||
self.pageHeight.setFixedWidth(dbW)
|
self.pageHeight.setFixedWidth(dbW)
|
||||||
self.pageHeight.setMaximum(500.0)
|
|
||||||
self.pageHeight.valueChanged.connect(self._pageSizeValueChanged)
|
self.pageHeight.valueChanged.connect(self._pageSizeValueChanged)
|
||||||
|
|
||||||
|
self.addRow(
|
||||||
|
self._build.getLabel("format.pageSize"),
|
||||||
|
[self.pageSize, 8, trW, self.pageWidth, trH, self.pageHeight],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Page Margins
|
||||||
self.topMargin = NDoubleSpinBox(self)
|
self.topMargin = NDoubleSpinBox(self)
|
||||||
self.topMargin.setFixedWidth(dbW)
|
self.topMargin.setFixedWidth(dbW)
|
||||||
|
|
||||||
@@ -1105,14 +1122,14 @@ class _FormattingTab(NScrollableForm):
|
|||||||
self.rightMargin = NDoubleSpinBox(self)
|
self.rightMargin = NDoubleSpinBox(self)
|
||||||
self.rightMargin.setFixedWidth(dbW)
|
self.rightMargin.setFixedWidth(dbW)
|
||||||
|
|
||||||
self.addRow(self._build.getLabel("format.pageUnit"), self.pageUnit)
|
self.addRow(
|
||||||
self.addRow(self._build.getLabel("format.pageSize"), self.pageSize)
|
self._build.getLabel("format.pageMargins"),
|
||||||
self.addRow(self._build.getLabel("format.pageWidth"), self.pageWidth)
|
[trT, self.topMargin, trB, self.bottomMargin],
|
||||||
self.addRow(self._build.getLabel("format.pageHeight"), self.pageHeight)
|
)
|
||||||
self.addRow(self._build.getLabel("format.topMargin"), self.topMargin)
|
self.addRow(
|
||||||
self.addRow(self._build.getLabel("format.bottomMargin"), self.bottomMargin)
|
"",
|
||||||
self.addRow(self._build.getLabel("format.leftMargin"), self.leftMargin)
|
[trL, self.leftMargin, trR, self.rightMargin],
|
||||||
self.addRow(self._build.getLabel("format.rightMargin"), self.rightMargin)
|
)
|
||||||
|
|
||||||
# Open Document
|
# Open Document
|
||||||
# =============
|
# =============
|
||||||
|
|||||||
Reference in New Issue
Block a user