Clean up warnings and deprecations in extensions and formats
This commit is contained in:
@@ -33,7 +33,6 @@ from PyQt6.QtWidgets import (
|
|||||||
QVBoxLayout, QWidget
|
QVBoxLayout, QWidget
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
|
||||||
from novelwriter.types import QtScrollAsNeeded
|
from novelwriter.types import QtScrollAsNeeded
|
||||||
|
|
||||||
DEFAULT_SCALE = 0.9
|
DEFAULT_SCALE = 0.9
|
||||||
@@ -99,14 +98,14 @@ class NScrollableForm(QScrollArea):
|
|||||||
self._helpCol = QColor(0, 0, 0)
|
self._helpCol = QColor(0, 0, 0)
|
||||||
self._fontScale = DEFAULT_SCALE
|
self._fontScale = DEFAULT_SCALE
|
||||||
self._first = True
|
self._first = True
|
||||||
self._indent = CONFIG.pxInt(12)
|
self._indent = 12
|
||||||
|
|
||||||
self._sections: dict[int, QLabel] = {}
|
self._sections: dict[int, QLabel] = {}
|
||||||
self._editable: dict[str, NColourLabel] = {}
|
self._editable: dict[str, NColourLabel] = {}
|
||||||
self._index: dict[str, QWidget] = {}
|
self._index: dict[str, QWidget] = {}
|
||||||
|
|
||||||
self._layout = QVBoxLayout()
|
self._layout = QVBoxLayout()
|
||||||
self._layout.setSpacing(CONFIG.pxInt(12))
|
self._layout.setSpacing(12)
|
||||||
|
|
||||||
self._widget = QWidget(self)
|
self._widget = QWidget(self)
|
||||||
self._widget.setLayout(self._layout)
|
self._widget.setLayout(self._layout)
|
||||||
@@ -156,24 +155,25 @@ class NScrollableForm(QScrollArea):
|
|||||||
def scrollToSection(self, identifier: int) -> None:
|
def scrollToSection(self, identifier: int) -> None:
|
||||||
"""Scroll to the requested section identifier."""
|
"""Scroll to the requested section identifier."""
|
||||||
if identifier in self._sections:
|
if identifier in self._sections:
|
||||||
yPos = self._sections[identifier].pos().y() - CONFIG.pxInt(8)
|
yPos = self._sections[identifier].pos().y() - 8
|
||||||
self.verticalScrollBar().setValue(yPos)
|
if vBar := self.verticalScrollBar():
|
||||||
|
vBar.setValue(yPos)
|
||||||
return
|
return
|
||||||
|
|
||||||
def scrollToLabel(self, label: str) -> None:
|
def scrollToLabel(self, label: str) -> None:
|
||||||
"""Scroll to the requested label."""
|
"""Scroll to the requested label."""
|
||||||
if label in self._index:
|
if label in self._index:
|
||||||
yPos = self._index[label].pos().y() - CONFIG.pxInt(8)
|
yPos = self._index[label].pos().y() - 8
|
||||||
self.verticalScrollBar().setValue(yPos)
|
if vBar := self.verticalScrollBar():
|
||||||
|
vBar.setValue(yPos)
|
||||||
return
|
return
|
||||||
|
|
||||||
def addGroupLabel(self, label: str, identifier: int | None = None) -> None:
|
def addGroupLabel(self, label: str, identifier: int | None = None) -> None:
|
||||||
"""Add a text label to separate groups of settings."""
|
"""Add a text label to separate groups of settings."""
|
||||||
hM = CONFIG.pxInt(4)
|
|
||||||
qLabel = QLabel(f"<b>{label}</b>", self)
|
qLabel = QLabel(f"<b>{label}</b>", self)
|
||||||
qLabel.setContentsMargins(0, hM, 0, hM)
|
qLabel.setContentsMargins(0, 4, 0, 4)
|
||||||
if not self._first:
|
if not self._first:
|
||||||
self._layout.addSpacing(5*hM)
|
self._layout.addSpacing(20)
|
||||||
self._layout.addWidget(qLabel)
|
self._layout.addWidget(qLabel)
|
||||||
self._first = False
|
self._first = False
|
||||||
if identifier is not None:
|
if identifier is not None:
|
||||||
@@ -192,7 +192,7 @@ class NScrollableForm(QScrollArea):
|
|||||||
) -> None:
|
) -> 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(12)
|
||||||
|
|
||||||
if isinstance(widget, list):
|
if isinstance(widget, list):
|
||||||
wBox = QHBoxLayout()
|
wBox = QHBoxLayout()
|
||||||
@@ -205,7 +205,7 @@ class NScrollableForm(QScrollArea):
|
|||||||
icon.setPixmap(item)
|
icon.setPixmap(item)
|
||||||
wBox.addWidget(icon)
|
wBox.addWidget(icon)
|
||||||
elif isinstance(item, int):
|
elif isinstance(item, int):
|
||||||
wBox.addSpacing(CONFIG.pxInt(item))
|
wBox.addSpacing(item)
|
||||||
qWidget = QWidget(self)
|
qWidget = QWidget(self)
|
||||||
qWidget.setLayout(wBox)
|
qWidget.setLayout(wBox)
|
||||||
else:
|
else:
|
||||||
@@ -252,7 +252,7 @@ class NScrollableForm(QScrollArea):
|
|||||||
|
|
||||||
def finalise(self) -> None:
|
def finalise(self) -> None:
|
||||||
"""Finalise the layout when the form is built."""
|
"""Finalise the layout when the form is built."""
|
||||||
self._layout.addSpacing(CONFIG.pxInt(20))
|
self._layout.addSpacing(20)
|
||||||
self._layout.addStretch(1)
|
self._layout.addStretch(1)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from PyQt6.QtCore import QPoint, QRectF, QSize, Qt, pyqtSignal, pyqtSlot
|
from PyQt6.QtCore import QPoint, QRectF, QSize, Qt, pyqtSignal, pyqtSlot
|
||||||
from PyQt6.QtGui import QAction, QColor, QPainter, QPaintEvent, QPolygon
|
from PyQt6.QtGui import QColor, QPainter, QPaintEvent, QPolygon
|
||||||
from PyQt6.QtWidgets import (
|
from PyQt6.QtWidgets import (
|
||||||
QAbstractButton, QButtonGroup, QLabel, QStyle, QStyleOptionToolButton,
|
QAbstractButton, QButtonGroup, QLabel, QStyleOptionToolButton, QToolBar,
|
||||||
QToolBar, QToolButton, QWidget
|
QToolButton, QWidget
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter.types import (
|
from novelwriter.types import (
|
||||||
@@ -83,21 +83,19 @@ class NPagedSideBar(QToolBar):
|
|||||||
self.insertWidget(self._stretchAction, label)
|
self.insertWidget(self._stretchAction, label)
|
||||||
return
|
return
|
||||||
|
|
||||||
def addButton(self, text: str, buttonId: int = -1) -> QAction:
|
def addButton(self, text: str, buttonId: int = -1) -> None:
|
||||||
"""Add a new button to the toolbar."""
|
"""Add a new button to the toolbar."""
|
||||||
button = _PagedToolButton(self)
|
button = _PagedToolButton(self)
|
||||||
button.setText(text)
|
button.setText(text)
|
||||||
|
self.insertWidget(self._stretchAction, button)
|
||||||
action = self.insertWidget(self._stretchAction, button)
|
|
||||||
self._group.addButton(button, id=buttonId)
|
self._group.addButton(button, id=buttonId)
|
||||||
|
|
||||||
self._buttons[buttonId] = button
|
self._buttons[buttonId] = button
|
||||||
|
return
|
||||||
return action
|
|
||||||
|
|
||||||
def setSelected(self, buttonId: int) -> None:
|
def setSelected(self, buttonId: int) -> None:
|
||||||
"""Set the selected button."""
|
"""Set the selected button."""
|
||||||
self._group.button(buttonId).setChecked(True)
|
if button := self._group.button(buttonId):
|
||||||
|
button.setChecked(True)
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
@@ -115,7 +113,7 @@ class NPagedSideBar(QToolBar):
|
|||||||
|
|
||||||
class _PagedToolButton(QToolButton):
|
class _PagedToolButton(QToolButton):
|
||||||
|
|
||||||
__slots__ = ("_bH", "_tM", "_lM", "_cR", "_aH")
|
__slots__ = ("_bH", "_tM", "_aH")
|
||||||
|
|
||||||
def __init__(self, parent: QWidget) -> None:
|
def __init__(self, parent: QWidget) -> None:
|
||||||
super().__init__(parent=parent)
|
super().__init__(parent=parent)
|
||||||
@@ -126,8 +124,6 @@ class _PagedToolButton(QToolButton):
|
|||||||
fH = self.fontMetrics().height()
|
fH = self.fontMetrics().height()
|
||||||
self._bH = round(fH * 1.7)
|
self._bH = round(fH * 1.7)
|
||||||
self._tM = (self._bH - fH)//2
|
self._tM = (self._bH - fH)//2
|
||||||
self._lM = 3*self.style().pixelMetric(QStyle.PixelMetric.PM_ButtonMargin)//2
|
|
||||||
self._cR = self._lM//2
|
|
||||||
self._aH = 2*fH//7
|
self._aH = 2*fH//7
|
||||||
self.setFixedHeight(self._bH)
|
self.setFixedHeight(self._bH)
|
||||||
|
|
||||||
@@ -145,53 +141,51 @@ class _PagedToolButton(QToolButton):
|
|||||||
opt = QStyleOptionToolButton()
|
opt = QStyleOptionToolButton()
|
||||||
opt.initFrom(self)
|
opt.initFrom(self)
|
||||||
|
|
||||||
paint = QPainter(self)
|
painter = QPainter(self)
|
||||||
paint.setRenderHint(QtPaintAntiAlias, True)
|
painter.setRenderHint(QtPaintAntiAlias, True)
|
||||||
paint.setPen(QtNoPen)
|
painter.setPen(QtNoPen)
|
||||||
paint.setBrush(QtNoBrush)
|
painter.setBrush(QtNoBrush)
|
||||||
|
|
||||||
width = self.width()
|
width = self.width()
|
||||||
height = self.height()
|
height = self.height()
|
||||||
palette = self.palette()
|
palette = self.palette()
|
||||||
|
|
||||||
if opt.state & QtMouseOver == QtMouseOver: # pragma: no cover
|
if opt.state & QtMouseOver == QtMouseOver: # pragma: no cover
|
||||||
backCol = palette.base()
|
painter.setBrush(palette.light())
|
||||||
paint.setBrush(backCol)
|
painter.drawRoundedRect(0, 0, width, height, 4, 4)
|
||||||
paint.setOpacity(0.75)
|
|
||||||
paint.drawRoundedRect(0, 0, width, height, self._cR, self._cR)
|
|
||||||
|
|
||||||
if self.isChecked():
|
if self.isChecked():
|
||||||
backCol = palette.highlight()
|
painter.setBrush(palette.highlight())
|
||||||
paint.setBrush(backCol)
|
painter.setOpacity(0.35)
|
||||||
paint.setOpacity(0.35)
|
painter.drawRoundedRect(0, 0, width, height, 4, 4)
|
||||||
paint.drawRoundedRect(0, 0, width, height, self._cR, self._cR)
|
|
||||||
textCol = palette.highlightedText().color()
|
textCol = palette.highlightedText().color()
|
||||||
else:
|
else:
|
||||||
textCol = palette.text().color()
|
textCol = palette.text().color()
|
||||||
|
|
||||||
tW = width - 2*self._lM
|
tW = width - 24
|
||||||
tH = height - 2*self._tM
|
tH = height - 2*self._tM
|
||||||
|
|
||||||
paint.setPen(textCol)
|
painter.setPen(textCol)
|
||||||
paint.setOpacity(1.0)
|
painter.setOpacity(1.0)
|
||||||
paint.drawText(QRectF(self._lM, self._tM, tW, tH), QtAlignLeft, self.text())
|
painter.drawText(QRectF(12, self._tM, tW, tH), QtAlignLeft, self.text())
|
||||||
|
|
||||||
tC = self.height()//2
|
tC = self.height()//2
|
||||||
tW = self.width() - self._aH - self._lM
|
tW = self.width() - self._aH - 12
|
||||||
if self.isChecked():
|
if self.isChecked():
|
||||||
paint.setBrush(textCol)
|
painter.setBrush(textCol)
|
||||||
paint.drawPolygon(QPolygon([
|
painter.drawPolygon(QPolygon([
|
||||||
QPoint(tW, tC - self._aH),
|
QPoint(tW, tC - self._aH),
|
||||||
QPoint(tW + self._aH, tC),
|
QPoint(tW + self._aH, tC),
|
||||||
QPoint(tW, tC + self._aH),
|
QPoint(tW, tC + self._aH),
|
||||||
]))
|
]))
|
||||||
|
painter.end()
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
class _NPagedToolLabel(QLabel):
|
class _NPagedToolLabel(QLabel):
|
||||||
|
|
||||||
__slots__ = ("_bH", "_tM", "_lM", "_textCol")
|
__slots__ = ("_bH", "_tM", "_textCol")
|
||||||
|
|
||||||
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)
|
||||||
@@ -201,7 +195,6 @@ class _NPagedToolLabel(QLabel):
|
|||||||
fH = self.fontMetrics().height()
|
fH = self.fontMetrics().height()
|
||||||
self._bH = round(fH * 1.7)
|
self._bH = round(fH * 1.7)
|
||||||
self._tM = (self._bH - fH)//2
|
self._tM = (self._bH - fH)//2
|
||||||
self._lM = self.style().pixelMetric(QStyle.PixelMetric.PM_ButtonMargin)//2
|
|
||||||
self.setFixedHeight(self._bH)
|
self.setFixedHeight(self._bH)
|
||||||
|
|
||||||
self._textCol = textColor or self.palette().text().color()
|
self._textCol = textColor or self.palette().text().color()
|
||||||
@@ -212,18 +205,15 @@ class _NPagedToolLabel(QLabel):
|
|||||||
"""Overload the paint event to draw a simple, left aligned text
|
"""Overload the paint event to draw a simple, left aligned text
|
||||||
label that matches the button style.
|
label that matches the button style.
|
||||||
"""
|
"""
|
||||||
paint = QPainter(self)
|
tW = self.width() - 8
|
||||||
paint.setRenderHint(QtPaintAntiAlias, True)
|
tH = self.height() - 2*self._tM
|
||||||
paint.setPen(QtNoPen)
|
|
||||||
|
|
||||||
width = self.width()
|
painter = QPainter(self)
|
||||||
height = self.height()
|
painter.setRenderHint(QtPaintAntiAlias, True)
|
||||||
|
painter.setPen(QtNoPen)
|
||||||
tW = width - 2*self._lM
|
painter.setPen(self._textCol)
|
||||||
tH = height - 2*self._tM
|
painter.setOpacity(1.0)
|
||||||
|
painter.drawText(QRectF(4, self._tM, tW, tH), QtAlignLeft, self.text())
|
||||||
paint.setPen(self._textCol)
|
painter.end()
|
||||||
paint.setOpacity(1.0)
|
|
||||||
paint.drawText(QRectF(self._lM, self._tM, tW, tH), QtAlignLeft, self.text())
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import logging
|
|||||||
from PyQt6.QtGui import QColor, QPainter, QPaintEvent
|
from PyQt6.QtGui import QColor, QPainter, QPaintEvent
|
||||||
from PyQt6.QtWidgets import QAbstractButton, QWidget
|
from PyQt6.QtWidgets import QAbstractButton, QWidget
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
|
||||||
from novelwriter.enum import nwTrinary
|
from novelwriter.enum import nwTrinary
|
||||||
from novelwriter.types import QtBlack, QtPaintAntiAlias
|
from novelwriter.types import QtBlack, QtPaintAntiAlias
|
||||||
|
|
||||||
@@ -37,9 +36,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class StatusLED(QAbstractButton):
|
class StatusLED(QAbstractButton):
|
||||||
|
|
||||||
__slots__ = (
|
__slots__ = ("_neutral", "_postitve", "_negative", "_color", "_state")
|
||||||
"_neutral", "_postitve", "_negative", "_color", "_state", "_bPx"
|
|
||||||
)
|
|
||||||
|
|
||||||
def __init__(self, sW: int, sH: int, parent: QWidget | None = None) -> None:
|
def __init__(self, sW: int, sH: int, parent: QWidget | None = None) -> None:
|
||||||
super().__init__(parent=parent)
|
super().__init__(parent=parent)
|
||||||
@@ -48,7 +45,6 @@ class StatusLED(QAbstractButton):
|
|||||||
self._negative = QtBlack
|
self._negative = QtBlack
|
||||||
self._color = QtBlack
|
self._color = QtBlack
|
||||||
self._state = nwTrinary.NEUTRAL
|
self._state = nwTrinary.NEUTRAL
|
||||||
self._bPx = CONFIG.pxInt(1)
|
|
||||||
self.setFixedWidth(sW)
|
self.setFixedWidth(sW)
|
||||||
self.setFixedHeight(sH)
|
self.setFixedHeight(sH)
|
||||||
return
|
return
|
||||||
@@ -82,12 +78,9 @@ class StatusLED(QAbstractButton):
|
|||||||
"""Draw the LED."""
|
"""Draw the LED."""
|
||||||
painter = QPainter(self)
|
painter = QPainter(self)
|
||||||
painter.setRenderHint(QtPaintAntiAlias, True)
|
painter.setRenderHint(QtPaintAntiAlias, True)
|
||||||
painter.setPen(self.palette().windowText().color())
|
painter.setPen(self.palette().text().color())
|
||||||
painter.setBrush(self._color)
|
painter.setBrush(self._color)
|
||||||
painter.setOpacity(1.0)
|
painter.setOpacity(1.0)
|
||||||
painter.drawEllipse(
|
painter.drawEllipse(1, 1, self.width() - 2, self.height() - 2)
|
||||||
self._bPx, self._bPx,
|
painter.end()
|
||||||
self.width() - 2*self._bPx,
|
|
||||||
self.height() - 2*self._bPx
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -27,13 +27,13 @@ from PyQt6.QtCore import QPropertyAnimation, Qt, pyqtProperty
|
|||||||
from PyQt6.QtGui import QEnterEvent, QMouseEvent, QPainter, QPaintEvent, QResizeEvent
|
from PyQt6.QtGui import QEnterEvent, QMouseEvent, QPainter, QPaintEvent, QResizeEvent
|
||||||
from PyQt6.QtWidgets import QAbstractButton, QWidget
|
from PyQt6.QtWidgets import QAbstractButton, QWidget
|
||||||
|
|
||||||
from novelwriter import CONFIG, SHARED
|
from novelwriter import SHARED
|
||||||
from novelwriter.types import QtMouseLeft, QtNoPen, QtPaintAntiAlias, QtSizeFixed
|
from novelwriter.types import QtMouseLeft, QtNoPen, QtPaintAntiAlias, QtSizeFixed
|
||||||
|
|
||||||
|
|
||||||
class NSwitch(QAbstractButton):
|
class NSwitch(QAbstractButton):
|
||||||
|
|
||||||
__slots__ = ("_xW", "_xH", "_xR", "_rB", "_rH", "_rR", "_offset")
|
__slots__ = ("_xW", "_xH", "_xR", "_rH", "_rR", "_offset")
|
||||||
|
|
||||||
def __init__(self, parent: QWidget, height: int = 0) -> None:
|
def __init__(self, parent: QWidget, height: int = 0) -> None:
|
||||||
super().__init__(parent=parent)
|
super().__init__(parent=parent)
|
||||||
@@ -41,9 +41,8 @@ class NSwitch(QAbstractButton):
|
|||||||
self._xH = height or SHARED.theme.baseButtonHeight
|
self._xH = height or SHARED.theme.baseButtonHeight
|
||||||
self._xW = 2*self._xH
|
self._xW = 2*self._xH
|
||||||
self._xR = int(self._xH*0.5)
|
self._xR = int(self._xH*0.5)
|
||||||
self._rB = CONFIG.pxInt(2)
|
self._rH = self._xH - 4
|
||||||
self._rH = self._xH - 2*self._rB
|
self._rR = self._xR - 2
|
||||||
self._rR = self._xR - self._rB
|
|
||||||
|
|
||||||
self.setCheckable(True)
|
self.setCheckable(True)
|
||||||
self.setSizePolicy(QtSizeFixed, QtSizeFixed)
|
self.setSizePolicy(QtSizeFixed, QtSizeFixed)
|
||||||
@@ -98,14 +97,14 @@ class NSwitch(QAbstractButton):
|
|||||||
trackBrush = palette.highlight()
|
trackBrush = palette.highlight()
|
||||||
thumbBrush = palette.highlightedText()
|
thumbBrush = palette.highlightedText()
|
||||||
else:
|
else:
|
||||||
trackBrush = palette.mid()
|
trackBrush = palette.midlight()
|
||||||
thumbBrush = palette.light()
|
thumbBrush = palette.light()
|
||||||
|
|
||||||
if self.isEnabled():
|
if self.isEnabled():
|
||||||
trackOpacity = 1.0
|
trackOpacity = 1.0
|
||||||
else:
|
else:
|
||||||
trackOpacity = 0.6
|
trackOpacity = 0.6
|
||||||
trackBrush = palette.dark()
|
trackBrush = palette.mid()
|
||||||
thumbBrush = palette.mid()
|
thumbBrush = palette.mid()
|
||||||
|
|
||||||
painter.setBrush(trackBrush)
|
painter.setBrush(trackBrush)
|
||||||
@@ -113,7 +112,7 @@ class NSwitch(QAbstractButton):
|
|||||||
painter.drawRoundedRect(0, 0, self._xW, self._xH, self._xR, self._xR)
|
painter.drawRoundedRect(0, 0, self._xW, self._xH, self._xR, self._xR)
|
||||||
|
|
||||||
painter.setBrush(thumbBrush)
|
painter.setBrush(thumbBrush)
|
||||||
painter.drawEllipse(self._offset - self._rR, self._rB, self._rH, self._rH)
|
painter.drawEllipse(self._offset - self._rR, 2, self._rH, self._rH)
|
||||||
painter.end()
|
painter.end()
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class VersionInfoWidget(QWidget):
|
|||||||
self._layout = QVBoxLayout()
|
self._layout = QVBoxLayout()
|
||||||
self._layout.addWidget(self._lblInfo)
|
self._layout.addWidget(self._lblInfo)
|
||||||
self._layout.addWidget(self._lblRelease)
|
self._layout.addWidget(self._lblRelease)
|
||||||
self._layout.setSpacing(CONFIG.pxInt(2))
|
self._layout.setSpacing(2)
|
||||||
self._layout.setContentsMargins(0, 0, 0, 0)
|
self._layout.setContentsMargins(0, 0, 0, 0)
|
||||||
|
|
||||||
self.setLayout(self._layout)
|
self.setLayout(self._layout)
|
||||||
|
|||||||
@@ -278,8 +278,10 @@ class ToQTextDocument(Tokenizer):
|
|||||||
printer.setPageMargins(self._pageMargins, QPageLayout.Unit.Millimeter)
|
printer.setPageMargins(self._pageMargins, QPageLayout.Unit.Millimeter)
|
||||||
printer.setOutputFileName(str(path))
|
printer.setOutputFileName(str(path))
|
||||||
|
|
||||||
self._document.documentLayout().setPaintDevice(printer)
|
if layout := self._document.documentLayout():
|
||||||
self._document.setPageSize(printer.pageRect(QPrinter.Unit.Millimeter).size())
|
layout.setPaintDevice(printer)
|
||||||
|
|
||||||
|
self._document.setPageSize(printer.pageRect(QPrinter.Unit.DevicePixel).size())
|
||||||
self._document.print(printer)
|
self._document.print(printer)
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -458,7 +460,8 @@ class ToQTextDocument(Tokenizer):
|
|||||||
cursor.insertFrame(fFmt)
|
cursor.insertFrame(fFmt)
|
||||||
cursor.setBlockFormat(bFmt)
|
cursor.setBlockFormat(bFmt)
|
||||||
cursor.insertText(self._project.localLookup("New Page"), cFmt)
|
cursor.insertText(self._project.localLookup("New Page"), cFmt)
|
||||||
cursor.swap(self._document.rootFrame().lastCursorPosition())
|
if root := self._document.rootFrame():
|
||||||
|
cursor.swap(root.lastCursorPosition())
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user