Qt 4.8
qpagesetupdialog_unix.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qpagesetupdialog.h"
43 
44 #ifndef QT_NO_PRINTDIALOG
46 
47 #include "qpainter.h"
48 #include "qprintdialog.h"
49 #include "qdialogbuttonbox.h"
50 #include <ui_qpagesetupwidget.h>
51 
52 #include <QtGui/qprinter.h>
53 #include <private/qabstractpagesetupdialog_p.h>
54 #include <private/qprinter_p.h>
55 
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>
60 #endif
61 
62 
64 
66 
67 // Disabled until we have support for papersources on unix
68 // #define PSD_ENABLE_PAPERSOURCE
69 
70 static void populatePaperSizes(QComboBox* cb)
71 {
95  cb->addItem(QPrintDialog::tr("Executive"), QPrinter::Executive);
100  cb->addItem(QPrintDialog::tr("Tabloid"), QPrinter::Tabloid);
101  cb->addItem(QPrintDialog::tr("US Common #10 Envelope"), QPrinter::Comm10E);
102  cb->addItem(QPrintDialog::tr("Custom"), QPrinter::Custom);
103 }
104 
105 
106 static QSizeF sizeForOrientation(QPrinter::Orientation orientation, const QSizeF &size)
107 {
108  return (orientation == QPrinter::Portrait) ? size : QSizeF(size.height(), size.width());
109 }
110 
111 #ifdef PSD_ENABLE_PAPERSOURCE
112 static const char *paperSourceNames[] = {
113  "Only One",
114  "Lower",
115  "Middle",
116  "Manual",
117  "Envelope",
118  "Envelope manual",
119  "Auto",
120  "Tractor",
121  "Small format",
122  "Large format",
123  "Large capacity",
124  "Cassette",
125  "Form source",
126  0
127 };
128 
129 struct PaperSourceNames
130 {
131  PaperSourceNames(const char *nam, QPrinter::PaperSource ps)
132  : paperSource(ps), name(nam) {}
133  QPrinter::PaperSource paperSource;
134  const char *name;
135 };
136 #endif
137 
138 
139 class QPagePreview : public QWidget
140 {
141 public:
142  QPagePreview(QWidget *parent) : QWidget(parent)
143  {
145  setMinimumSize(50, 50);
146  }
147 
148  void setPaperSize(const QSizeF& size)
149  {
150  m_size = size;
151  update();
152  }
153 
154  void setMargins(qreal left, qreal top, qreal right, qreal bottom)
155  {
156  m_left = left;
157  m_top = top;
158  m_right = right;
159  m_bottom = bottom;
160  update();
161  }
162 
163 protected:
165  {
166  QRect pageRect;
167  QSizeF adjustedSize(m_size);
168  adjustedSize.scale(width()-10, height()-10, Qt::KeepAspectRatio);
169  pageRect = QRect(QPoint(0,0), adjustedSize.toSize());
170  pageRect.moveCenter(rect().center());
171 
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));
182 
183  QPainter p(this);
184  QColor shadow(palette().mid().color());
185  for (int i=1; i<6; ++i) {
186  shadow.setAlpha(180-i*30);
187  QRect offset(pageRect.adjusted(i, i, i, i));
188  p.setPen(shadow);
189  p.drawLine(offset.left(), offset.bottom(), offset.right(), offset.bottom());
190  p.drawLine(offset.right(), offset.top(), offset.right(), offset.bottom()-1);
191  }
192  p.fillRect(pageRect, palette().light());
193 
194  if (marginRect.isValid()) {
195  p.setPen(QPen(palette().color(QPalette::Dark), 0, Qt::DotLine));
196  p.drawRect(marginRect);
197 
198  marginRect.adjust(2, 2, -1, -1);
199  p.setClipRect(marginRect);
200  QFont font;
201  font.setPointSizeF(font.pointSizeF()*0.25);
202  p.setFont(font);
203  p.setPen(palette().color(QPalette::Dark));
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)
206  text += text;
207  p.drawText(marginRect, Qt::TextWordWrap|Qt::AlignVCenter, text);
208  }
209  }
210 
211 private:
212  // all these are in points
213  qreal m_left, m_top, m_right, m_bottom;
215 };
216 
217 
219 {
221 
222 public:
224  void init();
225 
227 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
229 #endif
230 };
231 
233 {
234 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
235  delete cups;
236 #endif
237 }
238 
240 {
242 
243  widget = new QPageSetupWidget(q);
244  widget->setPrinter(printer);
245 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
246  if (printer->outputFormat() == QPrinter::NativeFormat && QCUPSSupport::isAvailable()) {
247  cups = new QCUPSSupport;
248  widget->selectPrinter(cups);
249  } else {
250  cups = 0;
251  }
252 #endif
253 
256  Qt::Horizontal, q);
257  QObject::connect(buttons, SIGNAL(accepted()), q, SLOT(accept()));
258  QObject::connect(buttons, SIGNAL(rejected()), q, SLOT(reject()));
259 
260  QVBoxLayout *lay = new QVBoxLayout(q);
261  lay->addWidget(widget);
262  lay->addWidget(buttons);
263 }
264 
266  : QWidget(parent),
267  m_printer(0),
268  m_blockSignals(false),
269  m_cups(0)
270 {
271  widget.setupUi(this);
272 
274  ? QString::fromLatin1(" in")
275  : QString::fromLatin1(" mm");
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);
282 
283  QVBoxLayout *lay = new QVBoxLayout(widget.preview);
284  widget.preview->setLayout(lay);
285  m_pagePreview = new QPagePreview(widget.preview);
286  lay->addWidget(m_pagePreview);
287 
289 
290 #ifdef PSD_ENABLE_PAPERSOURCE
291  for (int i=0; paperSourceNames[i]; ++i)
292  widget.paperSource->insertItem(paperSourceNames[i]);
293 #else
294  widget.paperSourceLabel->setVisible(false);
295  widget.paperSource->setVisible(false);
296 #endif
297 
298  widget.reverseLandscape->setVisible(false);
299  widget.reversePortrait->setVisible(false);
300 
301  populatePaperSizes(widget.paperSize);
302 
303  QStringList units;
304  units << tr("Centimeters (cm)") << tr("Millimeters (mm)") << tr("Inches (in)") << tr("Points (pt)");
305  widget.unit->addItems(units);
306  connect(widget.unit, SIGNAL(activated(int)), this, SLOT(unitChanged(int)));
307  widget.unit->setCurrentIndex((QLocale::system().measurementSystem() == QLocale::ImperialSystem) ? 2 : 1);
308 
309  connect(widget.paperSize, SIGNAL(currentIndexChanged(int)), this, SLOT(_q_paperSizeChanged()));
310  connect(widget.paperWidth, SIGNAL(valueChanged(double)), this, SLOT(_q_paperSizeChanged()));
311  connect(widget.paperHeight, SIGNAL(valueChanged(double)), this, SLOT(_q_paperSizeChanged()));
312 
313  connect(widget.leftMargin, SIGNAL(valueChanged(double)), this, SLOT(setLeftMargin(double)));
314  connect(widget.topMargin, SIGNAL(valueChanged(double)), this, SLOT(setTopMargin(double)));
315  connect(widget.rightMargin, SIGNAL(valueChanged(double)), this, SLOT(setRightMargin(double)));
316  connect(widget.bottomMargin, SIGNAL(valueChanged(double)), this, SLOT(setBottomMargin(double)));
317 
318  connect(widget.portrait, SIGNAL(clicked()), this, SLOT(_q_pageOrientationChanged()));
319  connect(widget.landscape, SIGNAL(clicked()), this, SLOT(_q_pageOrientationChanged()));
320 }
321 
323 {
324  m_printer = printer;
325  m_blockSignals = true;
326  selectPdfPsPrinter(printer);
328  unitChanged(widget.unit->currentIndex());
331  widget.paperWidth->setValue(m_paperSize.width() / m_currentMultiplier);
332  widget.paperHeight->setValue(m_paperSize.height() / m_currentMultiplier);
333 
334  widget.landscape->setChecked(printer->orientation() == QPrinter::Landscape);
335 
336 #ifdef PSD_ENABLE_PAPERSOURCE
337  widget.paperSource->setCurrentItem(printer->paperSource());
338 #endif
340  m_blockSignals = false;
342 }
343 
344 // set gui data on printer
346 {
347  QPrinter::Orientation orientation = widget.portrait->isChecked()
350  m_printer->setOrientation(orientation);
351  // paper format
352  QVariant val = widget.paperSize->itemData(widget.paperSize->currentIndex());
353  int ps = m_printer->pageSize();
354  if (val.type() == QVariant::Int) {
355  ps = val.toInt();
356  }
357 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
358  else if (m_cups && QCUPSSupport::isAvailable() && m_cups->currentPPD()) {
359  QByteArray cupsPageSize = val.toByteArray();
360  QPrintEngine *engine = m_printer->printEngine();
363 
364  QRect pageRect = m_cups->pageRect(cupsPageSize);
365  engine->setProperty(PPK_CupsPageRect, pageRect);
366 
367  QRect paperRect = m_cups->paperRect(cupsPageSize);
368  engine->setProperty(PPK_CupsPaperRect, paperRect);
369 
370  for(ps = 0; ps < QPrinter::NPaperSize; ++ps) {
372  if (size.width == paperRect.width() && size.height == paperRect.height())
373  break;
374  }
375  }
376 #endif
377  if (ps == QPrinter::Custom)
379  else
380  m_printer->setPaperSize(static_cast<QPrinter::PaperSize>(ps));
381 
382 #ifdef PSD_ENABLE_PAPERSOURCE
383  m_printer->setPaperSource((QPrinter::PaperSource)widget.paperSource->currentIndex());
384 #endif
386 
387 }
388 
390 {
391  m_cups = cups;
392  widget.paperSize->clear();
393 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
395  const ppd_option_t* pageSizes = m_cups->pageSizes();
396  const int numChoices = pageSizes ? pageSizes->num_choices : 0;
397 
398  int cupsDefaultSize = 0;
399  QSize qtPreferredSize = m_printer->paperSize(QPrinter::Point).toSize();
400  bool preferredSizeMatched = false;
401  for (int i = 0; i < numChoices; ++i) {
402  widget.paperSize->addItem(QString::fromLocal8Bit(pageSizes->choices[i].text), QByteArray(pageSizes->choices[i].choice));
403  if (static_cast<int>(pageSizes->choices[i].marked) == 1)
404  cupsDefaultSize = i;
405  if (m_printer->d_func()->hasUserSetPageSize) {
406  QRect cupsPaperSize = m_cups->paperRect(pageSizes->choices[i].choice);
407  QSize diff = cupsPaperSize.size() - qtPreferredSize;
408  if (qAbs(diff.width()) < 5 && qAbs(diff.height()) < 5) {
409  widget.paperSize->setCurrentIndex(i);
410  preferredSizeMatched = true;
411  }
412  }
413  }
414  if (!preferredSizeMatched)
415  widget.paperSize->setCurrentIndex(cupsDefaultSize);
416  if (m_printer->d_func()->hasCustomPageMargins) {
418  } else {
419  QByteArray cupsPaperSizeChoice = widget.paperSize->itemData(widget.paperSize->currentIndex()).toByteArray();
420  QRect paper = m_cups->paperRect(cupsPaperSizeChoice);
421  QRect content = m_cups->pageRect(cupsPaperSizeChoice);
422 
423  m_leftMargin = content.x() - paper.x();
424  m_topMargin = content.y() - paper.y();
425  m_rightMargin = paper.right() - content.right();
426  m_bottomMargin = paper.bottom() - content.bottom();
427  }
428  }
429 #endif
430  if (widget.paperSize->count() == 0) {
431  populatePaperSizes(widget.paperSize);
432  widget.paperSize->setCurrentIndex(widget.paperSize->findData(
434  }
435 
436  unitChanged(widget.unit->currentIndex());
438 }
439 
441 {
442  m_cups = 0;
443  widget.paperSize->clear();
444  populatePaperSizes(widget.paperSize);
445  widget.paperSize->setCurrentIndex(widget.paperSize->findData(p->paperSize()));
446 
447  m_leftMargin = 90;
448  m_topMargin = 72;
449  m_bottomMargin = 72;
450  m_rightMargin = 90;
451  unitChanged(widget.unit->currentIndex());
453 }
454 
455 // Updates size/preview after the combobox has been changed.
457 {
458  QVariant val = widget.paperSize->itemData(widget.paperSize->currentIndex());
459  int index = m_printer->pageSize();
460  if (val.type() == QVariant::Int) {
461  index = val.toInt();
462  }
463 
464  if (m_blockSignals) return;
465  m_blockSignals = true;
466 
468  QPrinter::Orientation orientation = widget.portrait->isChecked()
471 
472  bool custom = size == QPrinter::Custom;
473 
474 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
475  custom = custom ? !m_cups : custom;
476 #endif
477 
478  widget.paperWidth->setEnabled(custom);
479  widget.paperHeight->setEnabled(custom);
480  widget.widthLabel->setEnabled(custom);
481  widget.heightLabel->setEnabled(custom);
482  if (custom) {
483  m_paperSize.setWidth( widget.paperWidth->value() * m_currentMultiplier);
484  m_paperSize.setHeight( widget.paperHeight->value() * m_currentMultiplier);
486  } else {
488 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
489  if (m_cups) { // combobox is filled with cups based data
490  QByteArray cupsPageSize = widget.paperSize->itemData(widget.paperSize->currentIndex()).toByteArray();
491  m_paperSize = m_cups->paperRect(cupsPageSize).size();
492  if (orientation == QPrinter::Landscape)
494  }
495  else
496 #endif
497  m_paperSize = qt_printerPaperSize(orientation, size, QPrinter::Point, 1);
498 
499  m_pagePreview->setPaperSize(m_paperSize);
500  widget.paperWidth->setValue(m_paperSize.width() / m_currentMultiplier);
501  widget.paperHeight->setValue(m_paperSize.height() / m_currentMultiplier);
502  }
503  m_blockSignals = false;
504 }
505 
507 {
508  if (QPrinter::PaperSize(widget.paperSize->currentIndex()) == QPrinter::Custom) {
509  double tmp = widget.paperWidth->value();
510  widget.paperWidth->setValue(widget.paperHeight->value());
511  widget.paperHeight->setValue(tmp);
512  }
514 }
515 
516 extern double qt_multiplierForUnit(QPrinter::Unit unit, int resolution);
517 
519 {
520  QString suffix;
521  switch(item) {
522  case 0:
524  suffix = QString::fromLatin1(" cm");
525  break;
526  case 2:
528  suffix = QString::fromLatin1(" in");
529  break;
530  case 3:
532  suffix = QString::fromLatin1(" pt");
533  break;
534  case 1:
535  default:
537  suffix = QString::fromLatin1(" mm");
538  break;
539  }
540  const bool old = m_blockSignals;
541  m_blockSignals = true;
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);
548  widget.topMargin->setValue(m_topMargin / m_currentMultiplier);
549  widget.leftMargin->setValue(m_leftMargin / m_currentMultiplier);
550  widget.rightMargin->setValue(m_rightMargin / m_currentMultiplier);
551  widget.bottomMargin->setValue(m_bottomMargin / m_currentMultiplier);
552  widget.paperWidth->setValue(m_paperSize.width() / m_currentMultiplier);
553  widget.paperHeight->setValue(m_paperSize.height() / m_currentMultiplier);
554  m_blockSignals = old;
555 }
556 
557 void QPageSetupWidget::setTopMargin(double newValue)
558 {
559  if (m_blockSignals) return;
560  m_topMargin = newValue * m_currentMultiplier;
562 }
563 
565 {
566  if (m_blockSignals) return;
567  m_bottomMargin = newValue * m_currentMultiplier;
569 }
570 
571 void QPageSetupWidget::setLeftMargin(double newValue)
572 {
573  if (m_blockSignals) return;
574  m_leftMargin = newValue * m_currentMultiplier;
576 }
577 
578 void QPageSetupWidget::setRightMargin(double newValue)
579 {
580  if (m_blockSignals) return;
581  m_rightMargin = newValue * m_currentMultiplier;
583 }
584 
585 
586 
588  : QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), printer, parent)
589 {
591  d->init();
592 }
593 
594 
597 {
599  d->init();
600 }
601 
606 {
608 
609  int ret = QDialog::exec();
610  if (ret == Accepted)
611  d->widget->setupPrinter();
612  return ret;
613 }
614 
615 
617 
618 #include "moc_qpagesetupdialog.cpp"
619 
620 #endif // QT_NO_PRINTDIALOG
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
void setBottomMargin(double newValue)
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
const ppd_file_t * currentPPD() const
Definition: qcups.cpp:173
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 ...
Definition: qrect.h:431
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
PaperSize paperSize(QPrinter::PaperSize paperSize)
Definition: qpdf.cpp:905
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QSize size() const
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.
Definition: qsize.h:355
int exec()
Shows the dialog as a modal dialog, blocking until the user closes it.
Definition: qdialog.cpp:524
qreal width() const
Returns the width.
Definition: qsize.h:284
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
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...
Definition: qpainter.cpp:2801
#define SLOT(a)
Definition: qobjectdefs.h:226
qreal height() const
Returns the height.
Definition: qsize.h:287
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. ...
Definition: qprinter.cpp:1831
static Qt::MouseButtons buttons
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
Orientation
This enum type (not to be confused with Orientation) is used to specify each page&#39;s orientation...
Definition: qprinter.h:78
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
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...
Definition: qsize.h:296
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.
Definition: qprinter.cpp:123
The QAbstractPageSetupDialog class provides a base for implementations of page setup dialogs...
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
void setPaperSize(PaperSize)
Sets the printer paper size to newPaperSize if that size is supported.
Definition: qprinter.cpp:1163
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QString class provides a Unicode character string.
Definition: qstring.h:83
QRect pageRect(const char *choice) const
Definition: qcups.cpp:321
void setWidth(qreal w)
Sets the width to the given width.
Definition: qsize.h:290
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static bool isAvailable()
Definition: qcups.cpp:216
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...
Definition: qcombobox.h:323
#define Q_D(Class)
Definition: qglobal.h:2482
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.
Definition: qpen.h:64
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
void setPaperSource(PaperSource)
Sets the paper source setting to source.
Definition: qprinter.cpp:1593
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...
Definition: qvariant.cpp:2383
PageSize pageSize() const
Returns the printer page size.
Definition: qprinter.cpp:1187
void setOrientation(Orientation)
Sets the print orientation to orientation.
Definition: qprinter.cpp:1122
static QLocale system()
Returns a QLocale object initialized to the system locale.
Definition: qlocale.cpp:1917
QPrintEngine * printEngine() const
Returns the print engine used by the printer.
Definition: qprinter.cpp:1896
#define Q_Q(Class)
Definition: qglobal.h:2483
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
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.
Definition: qprinter.h:129
#define SIGNAL(a)
Definition: qobjectdefs.h:227
int width() const
Returns the width.
Definition: qsize.h:126
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
Definition: qpainter.cpp:6231
void setPrinter(QPrinter *printer)
The QPageSetupDialog class provides a configuration dialog for the page-related options on a printer...
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
qreal pointSizeF() const
Returns the point size of the font.
Definition: qfont.cpp:1142
PaperSize paperSize() const
Returns the printer paper size.
Definition: qprinter.cpp:1140
Orientation orientation() const
Returns the orientation setting.
Definition: qprinter.cpp:1098
const ppd_option_t * pageSizes() const
Definition: qcups.cpp:259
The QPrintEngine class defines an interface for how QPrinter interacts with a given printing subsyste...
Definition: qprintengine.h:56
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...
Definition: qobject.cpp:2580
QRect paperRect(const char *choice) const
Definition: qcups.cpp:310
static bool init
QStringList options() const
Definition: qcups.cpp:335
const char * name
The QPrinter class is a paint device that paints on a printer.
Definition: qprinter.h:66
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
The QComboBox widget is a combined button and popup list.
Definition: qcombobox.h:62
static Bigint * diff(Bigint *a, Bigint *b)
PaperSource paperSource() const
Returns the printer&#39;s paper source.
Definition: qprinter.cpp:1604
QSizeF qt_printerPaperSize(QPrinter::Orientation, QPrinter::PaperSize, QPrinter::Unit, int)
Definition: qprinter.cpp:145
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.
Definition: qrect.cpp:840
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
virtual void setProperty(PrintEnginePropertyKey key, const QVariant &value)=0
Sets the print engine&#39;s property specified by key to the given value.
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
#define PPK_CupsStringPageSize
Definition: qpdf_p.h:73
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
static void populatePaperSizes(QComboBox *cb)
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
PaperSize
This enum type specifies what paper size QPrinter should use.
Definition: qprinter.h:91
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QByteArray suffix
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.
Definition: qcolor.cpp:1094
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void selectPdfPsPrinter(const QPrinter *p)
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition: qpainter.h:650
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
quint16 index
void setPointSizeF(qreal)
Sets the point size to pointSize.
Definition: qfont.cpp:1121
void setHeight(qreal h)
Sets the height to the given height.
Definition: qsize.h:293
#define PPK_CupsPaperRect
Definition: qpdf_p.h:72
QPagePreview * m_pagePreview
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void setFont(const QFont &f)
Sets the painter&#39;s font to the given font.
Definition: qpainter.cpp:4288
#define PPK_CupsPageRect
Definition: qpdf_p.h:71
The QVBoxLayout class lines up widgets vertically.
Definition: qboxlayout.h:149
#define PPK_CupsOptions
Definition: qpdf_p.h:70
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
The QPaintEvent class contains event parameters for paint events.
Definition: qevent.h:298
void selectPrinter(QCUPSSupport *m_cups)
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
MeasurementSystem measurementSystem() const
Returns the measurement system for the locale.
Definition: qlocale.cpp:2265
void setRightMargin(double newValue)
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
QPageSetupWidget(QWidget *parent=0)
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
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.
Definition: qprinter.cpp:1853
#define text
Definition: qobjectdefs.h:80
PaperSource
This enum type specifies what paper source QPrinter is to use.
Definition: qprinter.h:103