8#include <private/qpagesetupdialog_p.h>
9#include <private/qprintdevice_p.h>
11#include <private/qcups_p.h>
18#include <ui_qpagesetupwidget.h>
20#include <QtPrintSupport/qprinter.h>
22#include <qpa/qplatformprintplugin.h>
23#include <qpa/qplatformprintersupport.h>
34#ifdef PSD_ENABLE_PAPERSOURCE
35static const char *paperSourceNames[] = {
52struct PaperSourceNames
55 : paperSource(ps),
name(nam) {}
83 m_pagePreviewColumns = columns;
84 m_pagePreviewRows = rows;
107 for (
int i=1;
i<6; ++
i) {
114 p.fillRect(pageRect,
palette().light());
118 p.drawRect(marginRect);
120 marginRect.
adjust(2, 2, -1, -1);
121 p.setClipRect(marginRect);
126 QString text(
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi."_L1);
127 for (
int i=0;
i<3; ++
i)
131 const int textWidth = (marginRect.
width() - (
spacing * (m_pagePreviewColumns-1))) / m_pagePreviewColumns;
132 const int textHeight = (marginRect.
height() - (
spacing * (m_pagePreviewRows-1))) / m_pagePreviewRows;
134 for (
int x = 0 ;
x < m_pagePreviewColumns; ++
x) {
135 for (
int y = 0 ;
y < m_pagePreviewRows; ++
y) {
138 textWidth, textHeight);
149 int m_pagePreviewColumns, m_pagePreviewRows;
208 m_outputFormat(
QPrinter::PdfFormat),
211 m_savedPagesPerSheet(-1),
212 m_savedPagesPerSheetLayout(-1),
213 m_blockSignals(
false),
214 m_realCustomPageSizeIndex(-1)
226#ifdef PSD_ENABLE_PAPERSOURCE
227 for (
int i=0; paperSourceNames[
i]; ++
i)
228 m_ui.paperSource->insertItem(paperSourceNames[
i]);
230 m_ui.paperSourceLabel->setVisible(
false);
231 m_ui.paperSource->setVisible(
false);
234 m_ui.reverseLandscape->setVisible(
false);
235 m_ui.reversePortrait->setVisible(
false);
258void QPageSetupWidget::initUnits()
272void QPageSetupWidget::initPagesPerSheet()
275 m_ui.pagesPerSheetLayoutCombo->addItem(QPrintDialog::tr(
"Left to Right, Top to Bottom"),
277 m_ui.pagesPerSheetLayoutCombo->addItem(QPrintDialog::tr(
"Left to Right, Bottom to Top"),
279 m_ui.pagesPerSheetLayoutCombo->addItem(QPrintDialog::tr(
"Right to Left, Bottom to Top"),
281 m_ui.pagesPerSheetLayoutCombo->addItem(QPrintDialog::tr(
"Right to Left, Top to Bottom"),
283 m_ui.pagesPerSheetLayoutCombo->addItem(QPrintDialog::tr(
"Bottom to Top, Left to Right"),
285 m_ui.pagesPerSheetLayoutCombo->addItem(QPrintDialog::tr(
"Bottom to Top, Right to Left"),
287 m_ui.pagesPerSheetLayoutCombo->addItem(QPrintDialog::tr(
"Top to Bottom, Left to Right"),
289 m_ui.pagesPerSheetLayoutCombo->addItem(QPrintDialog::tr(
"Top to Bottom, Right to Left"),
292 m_ui.pagesPerSheetCombo->addItem(QPrintDialog::tr(
"1 (1x1)"),
294 m_ui.pagesPerSheetCombo->addItem(QPrintDialog::tr(
"2 (2x1)"),
296 m_ui.pagesPerSheetCombo->addItem(QPrintDialog::tr(
"4 (2x2)"),
298 m_ui.pagesPerSheetCombo->addItem(QPrintDialog::tr(
"6 (2x3)"),
300 m_ui.pagesPerSheetCombo->addItem(QPrintDialog::tr(
"9 (3x3)"),
302 m_ui.pagesPerSheetCombo->addItem(QPrintDialog::tr(
"16 (4x4)"),
306 m_ui.pagesPerSheetCombo->setCurrentIndex(0);
308 m_ui.pagesPerSheetLayoutCombo->setCurrentIndex(0);
311 m_ui.pagesPerSheetButtonGroup->hide();
315void QPageSetupWidget::initPageSizes()
317 m_blockSignals =
true;
319 m_ui.pageSizeCombo->clear();
321 m_realCustomPageSizeIndex = -1;
329 for (
const QPageSize &pageSize : pageSizes)
331 if (m_ui.pageSizeCombo->count() > 0) {
333 m_ui.pageSizeCombo->addItem(
tr(
"Custom"));
334 m_realCustomPageSizeIndex = m_ui.pageSizeCombo->count() - 1;
336 m_blockSignals =
false;
340 m_ui.pageSizeCombo->setCurrentIndex(-1);
341 m_ui.pageSizeCombo->setCurrentIndex(m_ui.pageSizeCombo->findData(
QVariant::fromValue(defaultSize)));
350 m_ui.pageSizeCombo->addItem(
tr(
"Custom"));
351 m_realCustomPageSizeIndex = m_ui.pageSizeCombo->count() - 1;
358 m_blockSignals =
false;
367 m_printDevice = printDevice;
384 m_units = m_pageLayout.
units();
387 m_outputFormat = outputFormat;
388 m_printerName = printerName;
393 if (m_ui.pageSizeCombo->currentIndex() == -1) {
396 m_ui.pageSizeCombo->setCurrentIndex(0);
402void QPageSetupWidget::updateWidget()
404 m_blockSignals =
true;
436 const bool isCustom = m_ui.pageSizeCombo->currentIndex() == m_realCustomPageSizeIndex && m_realCustomPageSizeIndex != -1;
445 max =
QMarginsF(9999.9999, 9999.9999, 9999.9999, 9999.9999);
451 m_ui.leftMargin->setSuffix(suffix);
452 m_ui.leftMargin->setMinimum(
min.left());
453 m_ui.leftMargin->setMaximum(max.
left());
454 m_ui.leftMargin->setValue(m_pageLayout.
margins().
left());
456 m_ui.rightMargin->setSuffix(suffix);
457 m_ui.rightMargin->setMinimum(
min.right());
458 m_ui.rightMargin->setMaximum(max.
right());
459 m_ui.rightMargin->setValue(m_pageLayout.
margins().
right());
461 m_ui.topMargin->setSuffix(suffix);
462 m_ui.topMargin->setMinimum(
min.top());
463 m_ui.topMargin->setMaximum(max.
top());
464 m_ui.topMargin->setValue(m_pageLayout.
margins().
top());
466 m_ui.bottomMargin->setSuffix(suffix);
467 m_ui.bottomMargin->setMinimum(
min.bottom());
468 m_ui.bottomMargin->setMaximum(max.
bottom());
469 m_ui.bottomMargin->setValue(m_pageLayout.
margins().
bottom());
471 m_ui.pageWidth->setSuffix(suffix);
472 m_ui.pageWidth->setValue(m_pageLayout.
fullRect(m_units).
width());
473 m_ui.pageWidth->setEnabled(isCustom);
474 m_ui.widthLabel->setEnabled(isCustom);
476 m_ui.pageHeight->setSuffix(suffix);
477 m_ui.pageHeight->setValue(m_pageLayout.
fullRect(m_units).
height());
478 m_ui.pageHeight->setEnabled(isCustom);
479 m_ui.heightLabel->setEnabled(isCustom);
486#ifdef PSD_ENABLE_PAPERSOURCE
487 m_ui.paperSource->setCurrentItem(printer->paperSource());
490 m_blockSignals =
false;
506#ifdef PSD_ENABLE_PAPERSOURCE
513 m_savedUnits = m_units;
514 m_savedPageLayout = m_pageLayout;
515 m_savedPagesPerSheet = m_ui.pagesPerSheetCombo->currentIndex();
516 m_savedPagesPerSheetLayout = m_ui.pagesPerSheetLayoutCombo->currentIndex();
521 m_units = m_savedUnits;
522 m_pageLayout = m_savedPageLayout;
527 m_ui.pagesPerSheetCombo->setCurrentIndex(m_savedPagesPerSheet);
528 m_ui.pagesPerSheetLayoutCombo->setCurrentIndex(m_savedPagesPerSheetLayout);
532bool QPageSetupWidget::hasPpdConflict()
const
534 if (m_pageSizePpdOption) {
535 if (m_pageSizePpdOption->conflicted) {
537 const int pixmap_size = m_ui.pageSizeCombo->sizeHint().height() * .75;
538 m_ui.pageSizeWarningLabel->setPixmap(warning.
pixmap(pixmap_size, pixmap_size));
540 m_ui.pageSizeWarningLabel->setPixmap(
QPixmap());
542 return m_pageSizePpdOption->conflicted;
550void QPageSetupWidget::pageSizeChanged()
553 if (m_ui.pageSizeCombo->currentIndex() != m_realCustomPageSizeIndex) {
554 pageSize = qvariant_cast<QPageSize>(m_ui.pageSizeCombo->currentData());
557 if (m_pageSizePpdOption) {
561 qWarning() <<
"QPrinSupport: Cups uses unsupported encoding" << ppd->lang_encoding;
564 for (
int i = 0;
i < m_pageSizePpdOption->num_choices; ++
i) {
565 const ppd_choice_t *choice = &m_pageSizePpdOption->choices[
i];
566 if (
toUtf16(choice->text) == m_ui.pageSizeCombo->currentText()) {
570 emit ppdOptionChanged();
580 customSize =
QSizeF(m_ui.pageHeight->value(), m_ui.pageWidth->value());
582 customSize =
QSizeF(m_ui.pageWidth->value(), m_ui.pageHeight->value());
586 if (m_pageSizePpdOption) {
590 emit ppdOptionChanged();
608void QPageSetupWidget::pageOrientationChanged()
617void QPageSetupWidget::pagesPerSheetChanged()
620 switch (m_ui.pagesPerSheetCombo->currentData().toInt()) {
643void QPageSetupWidget::unitChanged()
647 m_units = qvariant_cast<QPageLayout::Unit>(m_ui.unitCombo->currentData());
652void QPageSetupWidget::topMarginChanged(
double newValue)
660void QPageSetupWidget::bottomMarginChanged(
double newValue)
668void QPageSetupWidget::leftMarginChanged(
double newValue)
676void QPageSetupWidget::rightMarginChanged(
double newValue)
719#include "moc_qpagesetupdialog_unix_p.cpp"
721#include "moc_qpagesetupdialog.cpp"
static QStyle * style()
Returns the application's style object.
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment.
static ppd_option_t * findPpdOption(const char *optionName, QPrintDevice *printDevice)
static void setPagesPerSheetLayout(QPrinter *printer, const PagesPerSheet pagesPerSheet, const PagesPerSheetLayout pagesPerSheetLayout)
The QColor class provides colors based on RGB, HSV or CMYK values.
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
void activated(int index)
This signal is sent when the user chooses an item in the combobox.
void currentIndexChanged(int index)
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
The QDialog class is the base class of dialog windows.
virtual int exec()
Shows the dialog as a \l{QDialog::Modal Dialogs}{modal dialog}, blocking until the user closes it.
void valueChanged(double)
This signal is emitted whenever the spin box's value is changed.
qreal pointSizeF() const
Returns the point size of the font.
void setPointSizeF(qreal)
Sets the point size to pointSize.
The QIcon class provides scalable icons in different modes and states.
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
constexpr qreal right() const noexcept
Returns the right margin.
constexpr qreal left() const noexcept
Returns the left margin.
constexpr qreal top() const noexcept
Returns the top margin.
constexpr qreal bottom() const noexcept
Returns the bottom margin.
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
bool setLeftMargin(qreal leftMargin)
Sets the left page margin of the page layout to leftMargin.
QMarginsF minimumMargins() const
Returns the minimum margins of the page layout.
void setOrientation(Orientation orientation)
Sets the page orientation of the page layout to orientation.
QRect fullRectPoints() const
Returns the full page rectangle in Postscript Points (1/72 of an inch).
bool setBottomMargin(qreal bottomMargin)
Sets the bottom page margin of the page layout to bottomMargin.
Mode mode() const
Returns the page layout mode.
QRectF fullRect() const
Returns the full page rectangle in the current layout units.
void setUnits(Unit units)
Sets the units used to define the page layout.
Unit units() const
Returns the units the page layout is currently defined in.
bool setRightMargin(qreal rightMargin)
Sets the right page margin of the page layout to rightMargin.
Unit
This enum type is used to specify the measurement unit for page layout and margins.
bool setTopMargin(qreal topMargin)
Sets the top page margin of the page layout to topMargin.
QMarginsF margins() const
Returns the margins of the page layout using the currently set units.
Orientation orientation() const
Returns the page orientation of the page layout.
QMarginsF maximumMargins() const
Returns the maximum margins that would be applied if the page layout was in StandardMode.
void setPageSize(const QPageSize &pageSize, const QMarginsF &minMargins=QMarginsF(0, 0, 0, 0))
Sets the page size of the page layout to pageSize.
QPageSize pageSize() const
Returns the page size of the page layout.
void setPageLayout(const QPageLayout &layout)
void setPagePreviewLayout(int columns, int rows)
QPagePreview(QWidget *parent)
void paintEvent(QPaintEvent *) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
The QPageSetupDialog class provides a configuration dialog for the page-related options on a printer.
QPageSetupDialog(QPrinter *printer, QWidget *parent=nullptr)
Constructs a page setup dialog that configures printer with parent as the parent widget.
int exec() override
This virtual function is called to pop up the dialog.
void revertToSavedValues()
void setPrinter(QPrinter *printer, QPrintDevice *printDevice, QPrinter::OutputFormat outputFormat, const QString &printerName)
void setupPrinter() const
QPageSetupWidget(QWidget *parent=nullptr)
Unit
This enum type is used to specify the measurement unit for page sizes.
QString name() const
Returns a localized human-readable name for the page size.
PageSizeId
This enum type lists the available page sizes as defined in the Postscript PPD standard.
virtual bool setPageOrientation(QPageLayout::Orientation orientation)
QPageLayout pageLayout() const
virtual bool setPageLayout(const QPageLayout &pageLayout)
The QPaintEvent class contains event parameters for paint events.
The QPainter class performs low-level painting on widgets and other paint devices.
\inmodule QtCore\reentrant
QPageSize defaultPageSize() const
QVariant property(PrintDevicePropertyKey key) const
QList< QPageSize > supportedPageSizes() const
bool setProperty(PrintDevicePropertyKey key, const QVariant &value)
QMarginsF printableMargins(const QPageSize &pageSize, QPageLayout::Orientation orientation, int resolution) const
bool supportsCustomPageSizes() const
PaperSource
This enum type specifies what paper source QPrinter is to use.
void setPaperSource(PaperSource)
Sets the paper source setting to source.
OutputFormat
The OutputFormat enum is used to describe the format QPrinter should use for printing.
int resolution() const
Returns the current assumed resolution of the printer, as set by setResolution() or by the printer dr...
QString printerName() const
Returns the printer name.
OutputFormat outputFormat() const
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
\inmodule QtCore\reentrant
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
constexpr void moveCenter(const QPoint &p) noexcept
Moves the rectangle, leaving the center point at the given position.
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
constexpr QRect adjusted(int x1, int y1, int x2, int y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr QSize size() const noexcept
Returns the size of the rectangle.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr QSize toSize() const noexcept
Returns an integer based copy of this size.
constexpr qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
QSize scaled(int w, int h, Qt::AspectRatioMode mode) const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
virtual QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
QPageSetupWidget * widget
QUnixPageSetupDialogPrivate(QPrinter *printer)
~QUnixPageSetupDialogPrivate()
The QVBoxLayout class lines up widgets vertically.
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Combined button and popup list for selecting options.
constexpr const T & min(const T &a, const T &b)
int qRound(qfloat16 d) noexcept
GLenum GLsizei GLsizei GLint * values
[15]
GLint GLint GLint GLint GLint x
[0]
GLdouble GLdouble GLdouble GLdouble top
GLenum GLuint GLintptr offset
GLdouble GLdouble GLdouble GLdouble q
Q_GUI_EXPORT QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits)
QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits)
#define QStringLiteral(str)
#define QT_CONFIG(feature)
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
if(qFloatDistance(a, b)<(1<< 7))
[0]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent