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

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