12f7dd6
diff -ur qt-everywhere-opensource-src-4.6.2/src/gui/dialogs/qprintdialog_unix.cpp qt-everywhere-opensource-src-4.6.2-cups/src/gui/dialogs/qprintdialog_unix.cpp
12f7dd6
--- qt-everywhere-opensource-src-4.6.2/src/gui/dialogs/qprintdialog_unix.cpp	2010-02-11 16:55:22.000000000 +0100
12f7dd6
+++ qt-everywhere-opensource-src-4.6.2-cups/src/gui/dialogs/qprintdialog_unix.cpp	2010-02-28 04:34:16.000000000 +0100
12f7dd6
@@ -569,6 +569,32 @@
12f7dd6
 void QPrintDialogPrivate::selectPrinter(QCUPSSupport *cups)
12f7dd6
 {
12f7dd6
     options.duplex->setEnabled(cups && cups->ppdOption("Duplex"));
12f7dd6
+
12f7dd6
+    if (cups) {
12f7dd6
+        const ppd_option_t* duplex = cups->ppdOption("Duplex");
12f7dd6
+        if (duplex) {
12f7dd6
+            // copy default ppd duplex to qt dialog
12f7dd6
+            if (qstrcmp(duplex->defchoice, "DuplexTumble") == 0)
12f7dd6
+                options.duplexShort->setChecked(true);
12f7dd6
+            else if (qstrcmp(duplex->defchoice, "DuplexNoTumble") == 0)
12f7dd6
+                options.duplexLong->setChecked(true);
12f7dd6
+            else
12f7dd6
+                options.noDuplex->setChecked(true);
12f7dd6
+        }
12f7dd6
+
12f7dd6
+        if (cups->currentPPD()) {
12f7dd6
+            // set default color
12f7dd6
+            if (cups->currentPPD()->color_device)
12f7dd6
+                options.color->setChecked(true);
12f7dd6
+            else
12f7dd6
+                options.grayscale->setChecked(true);
12f7dd6
+        }
12f7dd6
+
12f7dd6
+        // set collation
12f7dd6
+        const ppd_option_t *collate = cups->ppdOption("Collate");
12f7dd6
+        if (collate)
12f7dd6
+            options.collate->setChecked(qstrcmp(collate->defchoice, "True")==0);
12f7dd6
+    }
12f7dd6
 }
12f7dd6
 #endif
12f7dd6
 
12f7dd6
diff -ur qt-everywhere-opensource-src-4.6.2/src/gui/painting/qprinter.cpp qt-everywhere-opensource-src-4.6.2-cups/src/gui/painting/qprinter.cpp
12f7dd6
--- qt-everywhere-opensource-src-4.6.2/src/gui/painting/qprinter.cpp	2010-02-11 16:55:22.000000000 +0100
12f7dd6
+++ qt-everywhere-opensource-src-4.6.2-cups/src/gui/painting/qprinter.cpp	2010-02-28 04:55:15.000000000 +0100
12f7dd6
@@ -627,6 +627,44 @@
12f7dd6
                && d_ptr->paintEngine->type() != QPaintEngine::MacPrinter) {
12f7dd6
         setOutputFormat(QPrinter::PdfFormat);
12f7dd6
     }
12f7dd6
+
12f7dd6
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
12f7dd6
+    // fill in defaults from ppd file
12f7dd6
+    QCUPSSupport cups;
12f7dd6
+
12f7dd6
+    int printernum = -1;
12f7dd6
+    for (int i = 0; i < cups.availablePrintersCount(); i++) {
12f7dd6
+        if (printerName().toLocal8Bit() == cups.availablePrinters()[i].name)
12f7dd6
+            printernum = i;
12f7dd6
+    }
12f7dd6
+    if (printernum >= 0) {
12f7dd6
+        cups.setCurrentPrinter(printernum);
12f7dd6
+
12f7dd6
+        const ppd_option_t* duplex = cups.ppdOption("Duplex");
12f7dd6
+        if (duplex) {
12f7dd6
+            // copy default ppd duplex to qt dialog
12f7dd6
+            if (qstrcmp(duplex->defchoice, "DuplexTumble") == 0)
12f7dd6
+                setDuplex(DuplexShortSide);
12f7dd6
+            else if (qstrcmp(duplex->defchoice, "DuplexNoTumble") == 0)
12f7dd6
+                setDuplex(DuplexLongSide);
12f7dd6
+            else
12f7dd6
+                setDuplex(DuplexNone);
12f7dd6
+        }
12f7dd6
+
12f7dd6
+        if (cups.currentPPD()) {
12f7dd6
+            // set default color
d3bc0d2
+            if (cups.currentPPD()->color_device)
12f7dd6
+                setColorMode(Color);
12f7dd6
+            else
12f7dd6
+                setColorMode(GrayScale);
12f7dd6
+        }
12f7dd6
+
12f7dd6
+        // set collation
12f7dd6
+        const ppd_option_t *collate = cups.ppdOption("Collate");
12f7dd6
+        if (collate)
12f7dd6
+            setCollateCopies(qstrcmp(collate->defchoice, "True")==0);
12f7dd6
+    }
12f7dd6
+#endif
12f7dd6
 }
12f7dd6
 
12f7dd6
 /*!