openbsd-ports/x11/qt4/patches/patch-src_gui_painting_qprinter_cpp
dcoppa 69ec48c907 $ file /usr/local/lib/qt4/bin/{findtr,syncqt}
/usr/local/lib/qt4/bin/findtr: a /usr/bin/perl -w script text executable
/usr/local/lib/qt4/bin/syncqt: a /usr/bin/perl -w script text executable

These are both perl scripts, so use INSTALL_SCRIPT instead of
INSTALL_PROGRAM.

While here: qt-project.org -> qt.io in some comments.
2016-11-07 09:46:29 +00:00

55 lines
1.7 KiB
Plaintext

$OpenBSD: patch-src_gui_painting_qprinter_cpp,v 1.2 2016/11/07 09:46:29 dcoppa Exp $
Improve CUPS support.
https://bugreports.qt.io/browse/QTBUG-6433
https://bugs.kde.org/show_bug.cgi?id=180051
--- src/gui/painting/qprinter.cpp.orig Fri Jun 7 07:16:59 2013
+++ src/gui/painting/qprinter.cpp Fri Sep 27 10:29:54 2013
@@ -609,6 +609,44 @@ QPrinter::QPrinter(PrinterMode mode)
&& d_ptr->paintEngine->type() != QPaintEngine::MacPrinter) {
setOutputFormat(QPrinter::PdfFormat);
}
+
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ // fill in defaults from ppd file
+ QCUPSSupport cups;
+
+ int printernum = -1;
+ for (int i = 0; i < cups.availablePrintersCount(); i++) {
+ if (printerName().toLocal8Bit() == cups.availablePrinters()[i].name)
+ printernum = i;
+ }
+ if (printernum >= 0) {
+ cups.setCurrentPrinter(printernum);
+
+ const ppd_option_t* duplex = cups.ppdOption("Duplex");
+ if (duplex) {
+ // copy default ppd duplex to qt dialog
+ if (qstrcmp(duplex->defchoice, "DuplexTumble") == 0)
+ setDuplex(DuplexShortSide);
+ else if (qstrcmp(duplex->defchoice, "DuplexNoTumble") == 0)
+ setDuplex(DuplexLongSide);
+ else
+ setDuplex(DuplexNone);
+ }
+
+ if (cups.currentPPD()) {
+ // set default color
+ if (cups.currentPPD()->color_device)
+ setColorMode(Color);
+ else
+ setColorMode(GrayScale);
+ }
+
+ // set collation
+ const ppd_option_t *collate = cups.ppdOption("Collate");
+ if (collate)
+ setCollateCopies(qstrcmp(collate->defchoice, "True")==0);
+ }
+#endif
}
/*!