44 #ifndef QT_NO_PRINTDIALOG 50 #include <ui_qpagesetupwidget.h> 52 #include <QtGui/qprinter.h> 53 #include <private/qabstractpagesetupdialog_p.h> 54 #include <private/qprinter_p.h> 56 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) 57 # include <private/qcups_p.h> 58 # include <cups/cups.h> 59 # include <private/qpdf_p.h> 111 #ifdef PSD_ENABLE_PAPERSOURCE 112 static const char *paperSourceNames[] = {
129 struct PaperSourceNames
132 : paperSource(ps),
name(nam) {}
145 setMinimumSize(50, 50);
167 QSizeF adjustedSize(m_size);
172 qreal width_factor = pageRect.
width() / m_size.width();
173 qreal height_factor = pageRect.
height() / m_size.height();
174 int leftSize =
qRound(m_left*width_factor);
175 int topSize =
qRound(m_top*height_factor);
176 int rightSize =
qRound(m_right*width_factor);
177 int bottomSize =
qRound(m_bottom * height_factor);
178 QRect marginRect(pageRect.
x()+leftSize,
179 pageRect.
y()+topSize,
180 pageRect.
width() - (leftSize+rightSize+1),
181 pageRect.
height() - (topSize+bottomSize+1));
184 QColor shadow(palette().mid().color());
185 for (
int i=1; i<6; ++i) {
189 p.
drawLine(offset.left(), offset.bottom(), offset.right(), offset.bottom());
190 p.
drawLine(offset.right(), offset.top(), offset.right(), offset.bottom()-1);
192 p.
fillRect(pageRect, palette().light());
198 marginRect.
adjust(2, 2, -1, -1);
204 QString text(
QLatin1String(
"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."));
205 for (
int i=0; i<3; ++i)
227 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) 234 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) 244 widget->setPrinter(printer);
245 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) 248 widget->selectPrinter(cups);
268 m_blockSignals(false),
276 widget.topMargin->setSuffix(suffix);
277 widget.bottomMargin->setSuffix(suffix);
278 widget.leftMargin->setSuffix(suffix);
279 widget.rightMargin->setSuffix(suffix);
280 widget.paperWidth->setSuffix(suffix);
281 widget.paperHeight->setSuffix(suffix);
284 widget.preview->setLayout(lay);
290 #ifdef PSD_ENABLE_PAPERSOURCE 291 for (
int i=0; paperSourceNames[i]; ++i)
292 widget.paperSource->insertItem(paperSourceNames[i]);
294 widget.paperSourceLabel->setVisible(
false);
295 widget.paperSource->setVisible(
false);
298 widget.reverseLandscape->setVisible(
false);
299 widget.reversePortrait->setVisible(
false);
304 units <<
tr(
"Centimeters (cm)") <<
tr(
"Millimeters (mm)") <<
tr(
"Inches (in)") <<
tr(
"Points (pt)");
305 widget.unit->addItems(units);
336 #ifdef PSD_ENABLE_PAPERSOURCE 357 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) 382 #ifdef PSD_ENABLE_PAPERSOURCE 392 widget.paperSize->clear();
393 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) 396 const int numChoices = pageSizes ? pageSizes->num_choices : 0;
398 int cupsDefaultSize = 0;
400 bool preferredSizeMatched =
false;
401 for (
int i = 0; i < numChoices; ++i) {
403 if (static_cast<int>(pageSizes->choices[i].marked) == 1)
405 if (
m_printer->d_func()->hasUserSetPageSize) {
409 widget.paperSize->setCurrentIndex(i);
410 preferredSizeMatched =
true;
414 if (!preferredSizeMatched)
415 widget.paperSize->setCurrentIndex(cupsDefaultSize);
416 if (
m_printer->d_func()->hasCustomPageMargins) {
419 QByteArray cupsPaperSizeChoice =
widget.paperSize->itemData(
widget.paperSize->currentIndex()).toByteArray();
430 if (
widget.paperSize->count() == 0) {
432 widget.paperSize->setCurrentIndex(
widget.paperSize->findData(
443 widget.paperSize->clear();
474 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) 475 custom = custom ? !
m_cups : custom;
478 widget.paperWidth->setEnabled(custom);
479 widget.paperHeight->setEnabled(custom);
480 widget.widthLabel->setEnabled(custom);
481 widget.heightLabel->setEnabled(custom);
488 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) 509 double tmp =
widget.paperWidth->value();
510 widget.paperWidth->setValue(
widget.paperHeight->value());
511 widget.paperHeight->setValue(tmp);
542 widget.topMargin->setSuffix(suffix);
543 widget.leftMargin->setSuffix(suffix);
544 widget.rightMargin->setSuffix(suffix);
545 widget.bottomMargin->setSuffix(suffix);
546 widget.paperWidth->setSuffix(suffix);
547 widget.paperHeight->setSuffix(suffix);
611 d->widget->setupPrinter();
618 #include "moc_qpagesetupdialog.cpp" 620 #endif // QT_NO_PRINTDIALOG The QVariant class acts like a union for the most common Qt data types.
void setBottomMargin(double newValue)
The QPainter class performs low-level painting on widgets and other paint devices.
The QColor class provides colors based on RGB, HSV or CMYK values.
const ppd_file_t * currentPPD() const
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
void _q_paperSizeChanged()
PaperSize paperSize(QPrinter::PaperSize paperSize)
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
void setTopMargin(double newValue)
Ui::QPageSetupWidget widget
void setMargins(qreal left, qreal top, qreal right, qreal bottom)
QSize toSize() const
Returns an integer based copy of this size.
int exec()
Shows the dialog as a modal dialog, blocking until the user closes it.
qreal width() const
Returns the width.
The QByteArray class provides an array of bytes.
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation...
qreal height() const
Returns the height.
void setPageMargins(qreal left, qreal top, qreal right, qreal bottom, Unit unit)
This function sets the left, top, right and bottom page margins for this printer. ...
static Qt::MouseButtons buttons
Orientation
This enum type (not to be confused with Orientation) is used to specify each page's orientation...
void unitChanged(int item)
int width() const
Returns the width of the rectangle.
void paintEvent(QPaintEvent *)
This event handler can be reimplemented in a subclass to receive paint events passed in event...
void scale(qreal w, qreal h, Qt::AspectRatioMode mode)
Scales the size to a rectangle with the given width and height, according to the specified mode...
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void setLeftMargin(double newValue)
double qt_multiplierForUnit(QPrinter::Unit unit, int resolution)
return the multiplier of converting from the unit value to postscript-points.
The QAbstractPageSetupDialog class provides a base for implementations of page setup dialogs...
void drawLine(const QLineF &line)
Draws a line defined by line.
void setPaperSize(PaperSize)
Sets the printer paper size to newPaperSize if that size is supported.
int height() const
Returns the height of the rectangle.
int bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
The QString class provides a Unicode character string.
QRect pageRect(const char *choice) const
void setWidth(qreal w)
Sets the width to the given width.
Q_DECL_CONSTEXPR T qAbs(const T &t)
static bool isAvailable()
void addItem(const QString &text, const QVariant &userData=QVariant())
Adds an item to the combobox with the given text, and containing the specified userData (stored in th...
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=0)
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment...
The QPen class defines how a QPainter should draw lines and outlines of shapes.
The QSizeF class defines the size of a two-dimensional object using floating point precision...
void setPaperSource(PaperSource)
Sets the paper source setting to source.
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
PageSize pageSize() const
Returns the printer page size.
void setOrientation(Orientation)
Sets the print orientation to orientation.
static QLocale system()
Returns a QLocale object initialized to the system locale.
QPrintEngine * printEngine() const
Returns the print engine used by the printer.
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
QPageSetupDialog(QPrinter *printer, QWidget *parent=0)
Constructs a page setup dialog that configures printer with parent as the parent widget.
Unit
This enum type is used to specify the measurement unit for page and paper sizes.
int width() const
Returns the width.
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
void setPrinter(QPrinter *printer)
~QPageSetupDialogPrivate()
The QPageSetupDialog class provides a configuration dialog for the page-related options on a printer...
#define QT_BEGIN_NAMESPACE
This macro expands to.
qreal pointSizeF() const
Returns the point size of the font.
PaperSize paperSize() const
Returns the printer paper size.
Orientation orientation() const
Returns the orientation setting.
const ppd_option_t * pageSizes() const
The QPrintEngine class defines an interface for how QPrinter interacts with a given printing subsyste...
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
QRect paperRect(const char *choice) const
QStringList options() const
The QPrinter class is a paint device that paints on a printer.
QSize size() const
Returns the size of the rectangle.
void _q_pageOrientationChanged()
The QStringList class provides a list of strings.
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
The QComboBox widget is a combined button and popup list.
PaperSource paperSource() const
Returns the printer's paper source.
QSizeF qt_printerPaperSize(QPrinter::Orientation, QPrinter::PaperSize, QPrinter::Unit, int)
QPagePreview(QWidget *parent)
void setupPrinter() const
copy information from the widget and apply that to the printer.
void moveCenter(const QPoint &p)
Moves the rectangle, leaving the center point at the given position.
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
virtual void setProperty(PrintEnginePropertyKey key, const QVariant &value)=0
Sets the print engine's property specified by key to the given value.
#define Q_DECLARE_PUBLIC(Class)
#define PPK_CupsStringPageSize
int right() const
Returns the x-coordinate of the rectangle's right edge.
static void populatePaperSizes(QComboBox *cb)
The QFont class specifies a font used for drawing text.
int y() const
Returns the y-coordinate of the rectangle's top edge.
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Type type() const
Returns the storage type of the value stored in the variant.
PaperSize
This enum type specifies what paper size QPrinter should use.
int x() const
Returns the x-coordinate of the rectangle's left edge.
QObject * parent() const
Returns a pointer to the parent object.
The QPoint class defines a point in the plane using integer precision.
static QSizeF sizeForOrientation(QPrinter::Orientation orientation, const QSizeF &size)
void setPaperSize(const QSizeF &size)
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
void setPen(const QColor &color)
Sets the painter's pen to have style Qt::SolidLine, width 0 and the specified color.
int height() const
Returns the height.
The QRect class defines a rectangle in the plane using integer precision.
void selectPdfPsPrinter(const QPrinter *p)
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
void setPointSizeF(qreal)
Sets the point size to pointSize.
void setHeight(qreal h)
Sets the height to the given height.
#define PPK_CupsPaperRect
QPagePreview * m_pagePreview
The QSize class defines the size of a two-dimensional object using integer point precision.
void setFont(const QFont &f)
Sets the painter's font to the given font.
The QVBoxLayout class lines up widgets vertically.
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
The QPaintEvent class contains event parameters for paint events.
void selectPrinter(QCUPSSupport *m_cups)
qreal m_currentMultiplier
QPageSetupWidget * widget
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
MeasurementSystem measurementSystem() const
Returns the measurement system for the locale.
void setRightMargin(double newValue)
Q_DECL_CONSTEXPR int qRound(qreal d)
QPageSetupWidget(QWidget *parent=0)
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
void getPageMargins(qreal *left, qreal *top, qreal *right, qreal *bottom, Unit unit) const
Returns the page margins for this printer in left, top, right, bottom.
PaperSource
This enum type specifies what paper source QPrinter is to use.