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