diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-09 14:40:03 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-09 14:40:03 (GMT) |
commit | d1cc1db7f8c050ab254263babb287fb37d5ef52f (patch) | |
tree | ad3b35d6e53364e9fb03f38fe68305500db47051 | |
parent | 6ccf78b9675f50691bd6abc878c2b0d5281c0a51 (diff) | |
parent | 1517456a6be97260286faa10fd8263440c7b62a4 (diff) | |
download | Qt-d1cc1db7f8c050ab254263babb287fb37d5ef52f.zip Qt-d1cc1db7f8c050ab254263babb287fb37d5ef52f.tar.gz Qt-d1cc1db7f8c050ab254263babb287fb37d5ef52f.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-1:
Get the printDialog to check for default paperSize via CUPS
-rw-r--r-- | src/gui/dialogs/qprintdialog_unix.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/gui/dialogs/qprintdialog_unix.cpp b/src/gui/dialogs/qprintdialog_unix.cpp index 23f5831..00dc3e6 100644 --- a/src/gui/dialogs/qprintdialog_unix.cpp +++ b/src/gui/dialogs/qprintdialog_unix.cpp @@ -154,6 +154,9 @@ public: bool checkFields(); void setupPrinter(); void setOptionsPane(QPrintDialogPrivate *pane); +#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) + void setCupsProperties(); +#endif // slots void _q_printerChanged(int index); @@ -942,7 +945,7 @@ bool QUnixPrintWidgetPrivate::checkFields() void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked() { - if (propertiesDialog == 0) { + if (!propertiesDialog) { propertiesDialog = new QPrintPropertiesDialog(q); propertiesDialog->setResult(QDialog::Rejected); } @@ -962,6 +965,35 @@ void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked() propertiesDialog->exec(); } +#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) +void QUnixPrintWidgetPrivate::setCupsProperties() +{ + if (cups && QCUPSSupport::isAvailable()) { + QPrintEngine *engine = printer->printEngine(); + const ppd_option_t* pageSizes = cups->pageSizes(); + QByteArray cupsPageSize; + for (int i = 0; i < pageSizes->num_choices; ++i) { + if (static_cast<int>(pageSizes->choices[i].marked) == 1) + cupsPageSize = pageSizes->choices[i].choice; + } + engine->setProperty(PPK_CupsStringPageSize, QString::fromLatin1(cupsPageSize)); + engine->setProperty(PPK_CupsOptions, cups->options()); + + QRect pageRect = cups->pageRect(cupsPageSize); + engine->setProperty(PPK_CupsPageRect, pageRect); + + QRect paperRect = cups->paperRect(cupsPageSize); + engine->setProperty(PPK_CupsPaperRect, paperRect); + + for (int ps = 0; ps < QPrinter::NPaperSize; ++ps) { + QPdf::PaperSize size = QPdf::paperSize(QPrinter::PaperSize(ps)); + if (size.width == paperRect.width() && size.height == paperRect.height()) + printer->setPaperSize(static_cast<QPrinter::PaperSize>(ps)); + } + } +} +#endif + void QUnixPrintWidgetPrivate::setupPrinter() { const int printerCount = widget.printers->count(); @@ -986,6 +1018,10 @@ void QUnixPrintWidgetPrivate::setupPrinter() if (propertiesDialog && propertiesDialog->result() == QDialog::Accepted) propertiesDialog->setupPrinter(); +#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) + if (!propertiesDialog) + setCupsProperties(); +#endif } |