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

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