summaryrefslogtreecommitdiffstats
path: root/src/gui/dialogs/qprintdialog_unix.cpp
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@nokia.com>2010-03-09 14:24:19 (GMT)
committerPierre Rossi <pierre.rossi@nokia.com>2010-03-09 14:33:13 (GMT)
commit1517456a6be97260286faa10fd8263440c7b62a4 (patch)
tree6676a2578aee5dfdcca57b565f9c0ceb6b9677ee /src/gui/dialogs/qprintdialog_unix.cpp
parentcfb517b4a3f62290968cf13a2b3fce9b04099c74 (diff)
downloadQt-1517456a6be97260286faa10fd8263440c7b62a4.zip
Qt-1517456a6be97260286faa10fd8263440c7b62a4.tar.gz
Qt-1517456a6be97260286faa10fd8263440c7b62a4.tar.bz2
Get the printDialog to check for default paperSize via CUPS
Task-number: QTBUG-6471 Reviewed-by: Trond
Diffstat (limited to 'src/gui/dialogs/qprintdialog_unix.cpp')
-rw-r--r--src/gui/dialogs/qprintdialog_unix.cpp38
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
}