summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qcups.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/painting/qcups.cpp')
-rw-r--r--src/gui/painting/qcups.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/gui/painting/qcups.cpp b/src/gui/painting/qcups.cpp
index 3ec5f72395..76050d9d71 100644
--- a/src/gui/painting/qcups.cpp
+++ b/src/gui/painting/qcups.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include <qdebug.h>
#include "qcups_p.h"
+#include "qprinterinfo_unix_p.h"
#ifndef QT_NO_CUPS
@@ -396,6 +397,50 @@ int QCUPSSupport::printFile(const char * printerName, const char * filename, con
return _cupsPrintFile(printerName, filename, title, num_options, options);
}
+QCUPSSupport::Printer::Printer(const QString &n) : name(n), isDefault(false), cupsPrinterIndex(-1)
+{
+}
+
+QList<QCUPSSupport::Printer> QCUPSSupport::availableUnixPrinters()
+{
+ QList<Printer> printers;
+
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ if (QCUPSSupport::isAvailable()) {
+ QCUPSSupport cups;
+ int cupsPrinterCount = cups.availablePrintersCount();
+ const cups_dest_t* cupsPrinters = cups.availablePrinters();
+ for (int i = 0; i < cupsPrinterCount; ++i) {
+ QString printerName(QString::fromLocal8Bit(cupsPrinters[i].name));
+ if (cupsPrinters[i].instance)
+ printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance);
+
+ Printer p(printerName);
+ if (cupsPrinters[i].is_default)
+ p.isDefault = true;
+ p.cupsPrinterIndex = i;
+ printers.append(p);
+ }
+ } else
+#endif
+ {
+ QList<QPrinterDescription> lprPrinters;
+ int defprn = qt_getLprPrinters(lprPrinters);
+ // populating printer combo
+ foreach (const QPrinterDescription &description, lprPrinters)
+ printers.append(Printer(description.name));
+ if (defprn >= 0 && defprn < printers.size())
+ printers[defprn].isDefault = true;
+ }
+
+ return printers;
+}
+
+QList<QPrinter::PaperSize> QCUPSSupport::getCupsPrinterPaperSizes(int cupsPrinterIndex)
+{
+ return qt_getCupsPrinterPaperSizes(cupsPrinterIndex);
+}
+
QT_END_NAMESPACE
#endif // QT_NO_CUPS