Blame SOURCES/qt-everywhere-opensource-src-4.6.2-cups.patch

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