summaryrefslogtreecommitdiffstats
path: root/src/gui/dialogs/qprintdialog_unix.cpp
diff options
context:
space:
mode:
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 0487f23..17283f5 100644
--- a/src/gui/dialogs/qprintdialog_unix.cpp
+++ b/src/gui/dialogs/qprintdialog_unix.cpp
@@ -152,6 +152,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);
@@ -949,7 +952,7 @@ bool QUnixPrintWidgetPrivate::checkFields()
void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked()
{
- if (propertiesDialog == 0) {
+ if (!propertiesDialog) {
propertiesDialog = new QPrintPropertiesDialog(q);
propertiesDialog->setResult(QDialog::Rejected);
}
@@ -969,6 +972,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();
@@ -993,6 +1025,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
}