Fix tray visibility and message reception issues
Some checks failed
build / build-win64 (push) Waiting to run
build / build-macos (push) Waiting to run
build / build-pip (push) Failing after 16s

- Disable sound initialization to prevent hanging
- Add missing import re in utils.py
- Fix settings loading for QSettings
- Update file paths to use PROJECT_ROOT
- Revert to working API paths and listener from commit efdc63e
This commit is contained in:
kdusek
2025-12-07 22:39:07 +01:00
parent 7b695d7b7f
commit 5138303016
4060 changed files with 579123 additions and 23 deletions

View File

@@ -0,0 +1,6 @@
# Automatically generated configuration for PyQt6.QtPrintSupport.
sip-version = "6.14.0"
sip-abi-version = "13.8"
module-tags = ["Qt_6_10_0", "Linux"]
module-disabled-features = ["PyQt_OpenGL_ES2"]

View File

@@ -0,0 +1,58 @@
// QtPrintSupportmod.sip generated by MetaSIP
//
// This file is part of the QtPrintSupport Python extension module.
//
// Copyright (c) 2025 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of PyQt6.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
%Module(name=PyQt6.QtPrintSupport, keyword_arguments="Optional", use_limited_api=True)
%Import QtCore/QtCoremod.sip
%Import QtGui/QtGuimod.sip
%Import QtWidgets/QtWidgetsmod.sip
%Copying
Copyright (c) 2025 Riverbank Computing Limited <info@riverbankcomputing.com>
This file is part of PyQt6.
This file may be used under the terms of the GNU General Public License
version 3.0 as published by the Free Software Foundation and appearing in
the file LICENSE included in the packaging of this file. Please review the
following information to ensure the GNU General Public License version 3.0
requirements will be met: http://www.gnu.org/copyleft/gpl.html.
If you do not wish to use this file under the terms of the GPL version 3.0
then you may purchase a commercial license. For more information contact
info@riverbankcomputing.com.
This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
%End
%DefaultSupertype PyQt6.sip.simplewrapper
%Include qabstractprintdialog.sip
%Include qpagesetupdialog.sip
%Include qprintdialog.sip
%Include qprintengine.sip
%Include qprinter.sip
%Include qprinterinfo.sip
%Include qprintpreviewdialog.sip
%Include qprintpreviewwidget.sip
%Include qpyprintsupport_qlist.sip

View File

@@ -0,0 +1,134 @@
// qabstractprintdialog.sip generated by MetaSIP
//
// This file is part of the QtPrintSupport Python extension module.
//
// Copyright (c) 2025 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of PyQt6.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
%If (PyQt_PrintDialog)
class QAbstractPrintDialog : public QDialog
{
%TypeHeaderCode
#include <qabstractprintdialog.h>
%End
%ConvertToSubClassCode
static struct class_graph {
const char *name;
sipTypeDef **type;
int yes, no;
} graph[] = {
#if defined(SIP_FEATURE_PyQt_PrintDialog)
{sipName_QPageSetupDialog, &sipType_QPageSetupDialog, -1, 1},
#else
{0, 0, -1, 1},
#endif
#if defined(SIP_FEATURE_PyQt_PrintPreviewWidget)
{sipName_QPrintPreviewWidget, &sipType_QPrintPreviewWidget, -1, 2},
#else
{0, 0, -1, 2},
#endif
#if defined(SIP_FEATURE_PyQt_PrintPreviewDialog)
{sipName_QPrintPreviewDialog, &sipType_QPrintPreviewDialog, -1, 3},
#else
{0, 0, -1, 3},
#endif
#if defined(SIP_FEATURE_PyQt_Printer)
{sipName_QAbstractPrintDialog, &sipType_QAbstractPrintDialog, 4, -1},
#else
{0, 0, 4, -1},
#endif
#if defined(SIP_FEATURE_PyQt_PrintDialog)
{sipName_QPrintDialog, &sipType_QPrintDialog, -1, -1},
#else
{0, 0, -1, -1},
#endif
};
int i = 0;
sipType = NULL;
do
{
struct class_graph *cg = &graph[i];
if (cg->name != NULL && sipCpp->inherits(cg->name))
{
sipType = *cg->type;
i = cg->yes;
}
else
i = cg->no;
}
while (i >= 0);
%End
public:
enum PrintRange
{
AllPages,
Selection,
PageRange,
CurrentPage,
};
enum PrintDialogOption /BaseType=Flag/
{
PrintToFile,
PrintSelection,
PrintPageRange,
PrintCollateCopies,
PrintShowPageSize,
PrintCurrentPage,
};
typedef QFlags<QAbstractPrintDialog::PrintDialogOption> PrintDialogOptions;
QAbstractPrintDialog(QPrinter *printer, QWidget *parent /TransferThis/ = 0);
virtual ~QAbstractPrintDialog();
void setPrintRange(QAbstractPrintDialog::PrintRange range);
QAbstractPrintDialog::PrintRange printRange() const;
void setMinMax(int min, int max);
int minPage() const;
int maxPage() const;
void setFromTo(int fromPage, int toPage);
int fromPage() const;
int toPage() const;
QPrinter *printer() const;
void setOptionTabs(const QList<QWidget *> &tabs);
};
%End
%ModuleHeaderCode
// Imports from QtCore.
typedef sipErrorState (*pyqt6_qtprintsupport_get_connection_parts_t)(PyObject *, QObject *, const char *, bool, QObject **, QByteArray &);
extern pyqt6_qtprintsupport_get_connection_parts_t pyqt6_qtprintsupport_get_connection_parts;
%End
%ModuleCode
// Imports from QtCore.
pyqt6_qtprintsupport_get_connection_parts_t pyqt6_qtprintsupport_get_connection_parts;
%End
%PostInitialisationCode
// Imports from QtCore.
pyqt6_qtprintsupport_get_connection_parts = (pyqt6_qtprintsupport_get_connection_parts_t)sipImportSymbol("pyqt6_get_connection_parts");
Q_ASSERT(pyqt6_qtprintsupport_get_connection_parts);
%End

View File

@@ -0,0 +1,71 @@
// qpagesetupdialog.sip generated by MetaSIP
//
// This file is part of the QtPrintSupport Python extension module.
//
// Copyright (c) 2025 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of PyQt6.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
%If (PyQt_PrintDialog)
class QPageSetupDialog : public QDialog
{
%TypeHeaderCode
#include <qpagesetupdialog.h>
%End
public:
QPageSetupDialog(QPrinter *printer, QWidget *parent /TransferThis/ = 0);
explicit QPageSetupDialog(QWidget *parent /TransferThis/ = 0);
virtual ~QPageSetupDialog();
virtual void setVisible(bool visible);
virtual int exec() /PostHook=__pyQtPostEventLoopHook__,PreHook=__pyQtPreEventLoopHook__,ReleaseGIL/;
%MethodCode
// Transfer ownership back to Python (a modal dialog will probably have the
// main window as it's parent). This means the Qt dialog will be deleted when
// the Python wrapper is garbage collected. Although this is a little
// inconsistent, it saves having to code it explicitly to avoid the memory
// leak.
sipTransferBack(sipSelf);
Py_BEGIN_ALLOW_THREADS
sipRes = sipSelfWasArg ? sipCpp->QPageSetupDialog::exec()
: sipCpp->exec();
Py_END_ALLOW_THREADS
%End
virtual void open();
void open(SIP_PYOBJECT slot /TypeHint="PYQT_SLOT"/);
%MethodCode
QObject *receiver;
QByteArray slot_signature;
if ((sipError = pyqt6_qtprintsupport_get_connection_parts(a0, sipCpp, "()", false, &receiver, slot_signature)) == sipErrorNone)
{
sipCpp->open(receiver, slot_signature.constData());
}
else if (sipError == sipErrorContinue)
{
sipError = sipBadCallableArg(0, a0);
}
%End
virtual void done(int result);
QPrinter *printer();
};
%End

View File

@@ -0,0 +1,80 @@
// qprintdialog.sip generated by MetaSIP
//
// This file is part of the QtPrintSupport Python extension module.
//
// Copyright (c) 2025 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of PyQt6.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
%If (PyQt_PrintDialog)
class QPrintDialog : public QAbstractPrintDialog
{
%TypeHeaderCode
#include <qprintdialog.h>
%End
public:
QPrintDialog(QPrinter *printer, QWidget *parent /TransferThis/ = 0);
explicit QPrintDialog(QWidget *parent /TransferThis/ = 0);
virtual ~QPrintDialog();
virtual int exec() /PostHook=__pyQtPostEventLoopHook__,PreHook=__pyQtPreEventLoopHook__,ReleaseGIL/;
%MethodCode
// Transfer ownership back to Python (a modal dialog will probably have the
// main window as it's parent). This means the Qt dialog will be deleted when
// the Python wrapper is garbage collected. Although this is a little
// inconsistent, it saves having to code it explicitly to avoid the memory
// leak.
sipTransferBack(sipSelf);
Py_BEGIN_ALLOW_THREADS
sipRes = sipSelfWasArg ? sipCpp->QPrintDialog::exec()
: sipCpp->exec();
Py_END_ALLOW_THREADS
%End
%If (Android || Linux || WebAssembly)
virtual void accept();
%End
virtual void done(int result);
void setOption(QAbstractPrintDialog::PrintDialogOption option, bool on = true);
bool testOption(QAbstractPrintDialog::PrintDialogOption option) const;
void setOptions(QAbstractPrintDialog::PrintDialogOptions options);
QAbstractPrintDialog::PrintDialogOptions options() const;
virtual void setVisible(bool visible);
virtual void open();
void open(SIP_PYOBJECT slot /TypeHint="PYQT_SLOT"/);
%MethodCode
QObject *receiver;
QByteArray slot_signature;
if ((sipError = pyqt6_qtprintsupport_get_connection_parts(a0, sipCpp, "()", false, &receiver, slot_signature)) == sipErrorNone)
{
sipCpp->open(receiver, slot_signature.constData());
}
else if (sipError == sipErrorContinue)
{
sipError = sipBadCallableArg(0, a0);
}
%End
signals:
void accepted();
void accepted(QPrinter *printer);
};
%End

View File

@@ -0,0 +1,78 @@
// qprintengine.sip generated by MetaSIP
//
// This file is part of the QtPrintSupport Python extension module.
//
// Copyright (c) 2025 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of PyQt6.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
%If (PyQt_Printer)
class QPrintEngine
{
%TypeHeaderCode
#include <qprintengine.h>
%End
public:
virtual ~QPrintEngine();
enum PrintEnginePropertyKey
{
PPK_CollateCopies,
PPK_ColorMode,
PPK_Creator,
PPK_DocumentName,
PPK_FullPage,
PPK_NumberOfCopies,
PPK_Orientation,
PPK_OutputFileName,
PPK_PageOrder,
PPK_PageRect,
PPK_PageSize,
PPK_PaperRect,
PPK_PaperSource,
PPK_PrinterName,
PPK_PrinterProgram,
PPK_Resolution,
PPK_SelectionOption,
PPK_SupportedResolutions,
PPK_WindowsPageSize,
PPK_FontEmbedding,
PPK_Duplex,
PPK_PaperSources,
PPK_CustomPaperSize,
PPK_PageMargins,
PPK_PaperSize,
PPK_CopyCount,
PPK_SupportsMultipleCopies,
PPK_PaperName,
PPK_QPageSize,
PPK_QPageMargins,
PPK_QPageLayout,
PPK_CustomBase,
};
virtual void setProperty(QPrintEngine::PrintEnginePropertyKey key, const QVariant &value) = 0;
virtual QVariant property(QPrintEngine::PrintEnginePropertyKey key) const = 0;
virtual bool newPage() = 0;
virtual bool abort() = 0;
virtual int metric(QPaintDevice::PaintDeviceMetric) const = 0;
virtual QPrinter::PrinterState printerState() const = 0;
};
%End

View File

@@ -0,0 +1,178 @@
// qprinter.sip generated by MetaSIP
//
// This file is part of the QtPrintSupport Python extension module.
//
// Copyright (c) 2025 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of PyQt6.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
%If (PyQt_Printer)
class QPrinter : public QPagedPaintDevice
{
%TypeHeaderCode
#include <qprinter.h>
%End
public:
enum PrinterMode
{
ScreenResolution,
PrinterResolution,
HighResolution,
};
explicit QPrinter(QPrinter::PrinterMode mode = QPrinter::ScreenResolution);
QPrinter(const QPrinterInfo &printer, QPrinter::PrinterMode mode = QPrinter::ScreenResolution);
virtual ~QPrinter();
enum PageOrder
{
FirstPageFirst,
LastPageFirst,
};
enum ColorMode
{
GrayScale,
Color,
};
enum PaperSource
{
OnlyOne,
Lower,
Middle,
Manual,
Envelope,
EnvelopeManual,
Auto,
Tractor,
SmallFormat,
LargeFormat,
LargeCapacity,
Cassette,
FormSource,
MaxPageSource,
Upper,
CustomSource,
LastPaperSource,
};
enum PrinterState
{
Idle,
Active,
Aborted,
Error,
};
enum OutputFormat
{
NativeFormat,
PdfFormat,
};
enum PrintRange
{
AllPages,
Selection,
PageRange,
CurrentPage,
};
enum Unit
{
Millimeter,
Point,
Inch,
Pica,
Didot,
Cicero,
DevicePixel,
};
enum DuplexMode
{
DuplexNone,
DuplexAuto,
DuplexLongSide,
DuplexShortSide,
};
void setOutputFormat(QPrinter::OutputFormat format);
QPrinter::OutputFormat outputFormat() const;
void setPrinterName(const QString &);
QString printerName() const;
bool isValid() const;
void setOutputFileName(const QString &);
QString outputFileName() const;
void setPrintProgram(const QString &);
QString printProgram() const;
void setDocName(const QString &);
QString docName() const;
void setCreator(const QString &);
QString creator() const;
void setPageOrder(QPrinter::PageOrder);
QPrinter::PageOrder pageOrder() const;
void setResolution(int);
int resolution() const;
void setColorMode(QPrinter::ColorMode);
QPrinter::ColorMode colorMode() const;
void setCollateCopies(bool collate);
bool collateCopies() const;
void setFullPage(bool);
bool fullPage() const;
void setCopyCount(int);
int copyCount() const;
bool supportsMultipleCopies() const;
void setPaperSource(QPrinter::PaperSource);
QPrinter::PaperSource paperSource() const;
void setDuplex(QPrinter::DuplexMode duplex);
QPrinter::DuplexMode duplex() const;
QList<int> supportedResolutions() const;
void setFontEmbeddingEnabled(bool enable);
bool fontEmbeddingEnabled() const;
QRectF paperRect(QPrinter::Unit) const;
QRectF pageRect(QPrinter::Unit) const;
%If (Android || Linux || iOS || macOS || WebAssembly)
QString printerSelectionOption() const;
%End
%If (Android || Linux || iOS || macOS || WebAssembly)
void setPrinterSelectionOption(const QString &);
%End
virtual bool newPage();
bool abort();
QPrinter::PrinterState printerState() const;
virtual QPaintEngine *paintEngine() const;
QPrintEngine *printEngine() const;
void setFromTo(int fromPage, int toPage);
int fromPage() const;
int toPage() const;
void setPrintRange(QPrinter::PrintRange range);
QPrinter::PrintRange printRange() const;
protected:
virtual int metric(QPaintDevice::PaintDeviceMetric) const;
void setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine);
public:
void setPdfVersion(QPagedPaintDevice::PdfVersion version);
QPagedPaintDevice::PdfVersion pdfVersion() const;
};
%End

View File

@@ -0,0 +1,61 @@
// qprinterinfo.sip generated by MetaSIP
//
// This file is part of the QtPrintSupport Python extension module.
//
// Copyright (c) 2025 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of PyQt6.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
%If (PyQt_Printer)
class QPrinterInfo
{
%TypeHeaderCode
#include <qprinterinfo.h>
%End
public:
QPrinterInfo();
QPrinterInfo(const QPrinterInfo &src);
explicit QPrinterInfo(const QPrinter &printer);
~QPrinterInfo();
QString printerName() const;
bool isNull() const;
bool isDefault() const;
static QList<QPrinterInfo> availablePrinters();
static QPrinterInfo defaultPrinter();
QString description() const;
QString location() const;
QString makeAndModel() const;
static QPrinterInfo printerInfo(const QString &printerName);
bool isRemote() const;
QPrinter::PrinterState state() const;
QList<QPageSize> supportedPageSizes() const;
QPageSize defaultPageSize() const;
bool supportsCustomPageSizes() const;
QPageSize minimumPhysicalPageSize() const;
QPageSize maximumPhysicalPageSize() const;
QList<int> supportedResolutions() const;
static QStringList availablePrinterNames();
static QString defaultPrinterName();
QPrinter::DuplexMode defaultDuplexMode() const;
QList<QPrinter::DuplexMode> supportedDuplexModes() const;
QPrinter::ColorMode defaultColorMode() const;
QList<QPrinter::ColorMode> supportedColorModes() const;
};
%End

View File

@@ -0,0 +1,59 @@
// qprintpreviewdialog.sip generated by MetaSIP
//
// This file is part of the QtPrintSupport Python extension module.
//
// Copyright (c) 2025 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of PyQt6.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
%If (PyQt_PrintPreviewDialog)
class QPrintPreviewDialog : public QDialog
{
%TypeHeaderCode
#include <qprintpreviewdialog.h>
%End
public:
QPrintPreviewDialog(QWidget *parent /TransferThis/ = 0, Qt::WindowFlags flags = Qt::WindowFlags());
QPrintPreviewDialog(QPrinter *printer, QWidget *parent /TransferThis/ = 0, Qt::WindowFlags flags = Qt::WindowFlags());
virtual ~QPrintPreviewDialog();
virtual void setVisible(bool visible);
virtual void open();
void open(SIP_PYOBJECT slot /TypeHint="PYQT_SLOT"/);
%MethodCode
QObject *receiver;
QByteArray slot_signature;
if ((sipError = pyqt6_qtprintsupport_get_connection_parts(a0, sipCpp, "()", false, &receiver, slot_signature)) == sipErrorNone)
{
sipCpp->open(receiver, slot_signature.constData());
}
else if (sipError == sipErrorContinue)
{
sipError = sipBadCallableArg(0, a0);
}
%End
QPrinter *printer();
virtual void done(int result);
signals:
void paintRequested(QPrinter *printer);
};
%End

View File

@@ -0,0 +1,82 @@
// qprintpreviewwidget.sip generated by MetaSIP
//
// This file is part of the QtPrintSupport Python extension module.
//
// Copyright (c) 2025 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of PyQt6.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
%If (PyQt_PrintPreviewWidget)
class QPrintPreviewWidget : public QWidget
{
%TypeHeaderCode
#include <qprintpreviewwidget.h>
%End
public:
enum ViewMode
{
SinglePageView,
FacingPagesView,
AllPagesView,
};
enum ZoomMode
{
CustomZoom,
FitToWidth,
FitInView,
};
QPrintPreviewWidget(QPrinter *printer, QWidget *parent /TransferThis/ = 0, Qt::WindowFlags flags = Qt::WindowFlags());
QPrintPreviewWidget(QWidget *parent /TransferThis/ = 0, Qt::WindowFlags flags = Qt::WindowFlags());
virtual ~QPrintPreviewWidget();
qreal zoomFactor() const;
QPageLayout::Orientation orientation() const;
QPrintPreviewWidget::ViewMode viewMode() const;
QPrintPreviewWidget::ZoomMode zoomMode() const;
int currentPage() const;
public slots:
virtual void setVisible(bool visible);
void print();
void zoomIn(qreal factor = 1.1);
void zoomOut(qreal factor = 1.1);
void setZoomFactor(qreal zoomFactor);
void setOrientation(QPageLayout::Orientation orientation);
void setViewMode(QPrintPreviewWidget::ViewMode viewMode);
void setZoomMode(QPrintPreviewWidget::ZoomMode zoomMode);
void setCurrentPage(int pageNumber);
void fitToWidth();
void fitInView();
void setLandscapeOrientation();
void setPortraitOrientation();
void setSinglePageViewMode();
void setFacingPagesViewMode();
void setAllPagesViewMode();
void updatePreview();
signals:
void paintRequested(QPrinter *printer);
void previewChanged();
public:
int pageCount() const;
};
%End

View File

@@ -0,0 +1,229 @@
// This is the SIP interface definition for the QList based mapped types
// specific to the QtPrintSupport module.
//
// Copyright (c) 2025 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of PyQt6.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
%If (PyQt_Printer)
%MappedType QList<QPrinter::DuplexMode>
/TypeHintIn="Iterable[QPrinter.DuplexMode]",
TypeHintOut="List[QPrinter.DuplexMode]", TypeHintValue="[]"/
{
%TypeHeaderCode
#include <qprinter.h>
%End
%ConvertFromTypeCode
PyObject *l = PyList_New(sipCpp->size());
if (!l)
return 0;
for (int i = 0; i < sipCpp->size(); ++i)
{
PyObject *eobj = sipConvertFromEnum(sipCpp->at(i),
sipType_QPrinter_DuplexMode);
if (!eobj)
{
Py_DECREF(l);
return 0;
}
PyList_SetItem(l, i, eobj);
}
return l;
%End
%ConvertToTypeCode
PyObject *iter = PyObject_GetIter(sipPy);
if (!sipIsErr)
{
PyErr_Clear();
Py_XDECREF(iter);
return (iter && !PyBytes_Check(sipPy) && !PyUnicode_Check(sipPy));
}
if (!iter)
{
*sipIsErr = 1;
return 0;
}
QList<QPrinter::DuplexMode> *ql = new QList<QPrinter::DuplexMode>;
for (Py_ssize_t i = 0; ; ++i)
{
PyErr_Clear();
PyObject *itm = PyIter_Next(iter);
if (!itm)
{
if (PyErr_Occurred())
{
delete ql;
Py_DECREF(iter);
*sipIsErr = 1;
return 0;
}
break;
}
int v = sipConvertToEnum(itm, sipType_QPrinter_DuplexMode);
if (PyErr_Occurred())
{
PyErr_Format(PyExc_TypeError,
"index %zd has type '%s' but 'QPrinter.DuplexMode' is expected",
i, sipPyTypeName(Py_TYPE(itm)));
Py_DECREF(itm);
delete ql;
Py_DECREF(iter);
*sipIsErr = 1;
return 0;
}
ql->append(static_cast<QPrinter::DuplexMode>(v));
Py_DECREF(itm);
}
Py_DECREF(iter);
*sipCppPtr = ql;
return sipGetState(sipTransferObj);
%End
};
%End
%If (PyQt_Printer)
%MappedType QList<QPrinter::ColorMode>
/TypeHintIn="Iterable[QPrinter.ColorMode]",
TypeHintOut="List[QPrinter.ColorMode]", TypeHintValue="[]"/
{
%TypeHeaderCode
#include <qprinter.h>
%End
%ConvertFromTypeCode
PyObject *l = PyList_New(sipCpp->size());
if (!l)
return 0;
for (int i = 0; i < sipCpp->size(); ++i)
{
PyObject *eobj = sipConvertFromEnum(sipCpp->at(i),
sipType_QPrinter_ColorMode);
if (!eobj)
{
Py_DECREF(l);
return 0;
}
PyList_SetItem(l, i, eobj);
}
return l;
%End
%ConvertToTypeCode
PyObject *iter = PyObject_GetIter(sipPy);
if (!sipIsErr)
{
PyErr_Clear();
Py_XDECREF(iter);
return (iter && !PyBytes_Check(sipPy) && !PyUnicode_Check(sipPy));
}
if (!iter)
{
*sipIsErr = 1;
return 0;
}
QList<QPrinter::ColorMode> *ql = new QList<QPrinter::ColorMode>;
for (Py_ssize_t i = 0; ; ++i)
{
PyErr_Clear();
PyObject *itm = PyIter_Next(iter);
if (!itm)
{
if (PyErr_Occurred())
{
delete ql;
Py_DECREF(iter);
*sipIsErr = 1;
return 0;
}
break;
}
int v = sipConvertToEnum(itm, sipType_QPrinter_ColorMode);
if (PyErr_Occurred())
{
PyErr_Format(PyExc_TypeError,
"index %zd has type '%s' but 'QPrinter.ColorMode' is expected",
i, sipPyTypeName(Py_TYPE(itm)));
Py_DECREF(itm);
delete ql;
Py_DECREF(iter);
*sipIsErr = 1;
return 0;
}
ql->append(static_cast<QPrinter::ColorMode>(v));
Py_DECREF(itm);
}
Py_DECREF(iter);
*sipCppPtr = ql;
return sipGetState(sipTransferObj);
%End
};
%End