summaryrefslogtreecommitdiffstats
path: root/src/printsupport/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'src/printsupport/dialogs')
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog_unix.cpp31
-rw-r--r--src/printsupport/dialogs/qprintdialog_unix.cpp88
2 files changed, 14 insertions, 105 deletions
diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
index 90fb3ef542..a1e7d559db 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+++ b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
@@ -53,11 +53,8 @@
#include <private/qabstractpagesetupdialog_p.h>
#include <private/qprinter_p.h>
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
-# include <private/qcups_p.h>
-# include <cups/cups.h>
-# include <private/qprintengine_pdf_p.h>
-#endif
+#include <private/qcups_p.h>
+#include <private/qprintengine_pdf_p.h>
QT_BEGIN_NAMESPACE
@@ -224,16 +221,12 @@ public:
void init();
QPageSetupWidget *widget;
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
QCUPSSupport *cups;
-#endif
};
QPageSetupDialogPrivate::~QPageSetupDialogPrivate()
{
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
delete cups;
-#endif
}
void QPageSetupDialogPrivate::init()
@@ -242,14 +235,12 @@ void QPageSetupDialogPrivate::init()
widget = new QPageSetupWidget(q);
widget->setPrinter(printer);
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
if (printer->outputFormat() == QPrinter::NativeFormat && QCUPSSupport::isAvailable()) {
cups = new QCUPSSupport;
widget->selectPrinter(cups);
} else {
cups = 0;
}
-#endif
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel,
@@ -353,9 +344,7 @@ void QPageSetupWidget::setupPrinter() const
int ps = m_printer->pageSize();
if (val.type() == QVariant::Int) {
ps = val.toInt();
- }
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- else if (m_cups && QCUPSSupport::isAvailable() && m_cups->currentPPD()) {
+ } else if (m_cups && QCUPSSupport::isAvailable() && m_cups->currentPPD()) {
QByteArray cupsPageSize = val.toByteArray();
QPrintEngine *engine = m_printer->printEngine();
engine->setProperty(PPK_CupsStringPageSize, QString::fromLatin1(cupsPageSize));
@@ -373,7 +362,7 @@ void QPageSetupWidget::setupPrinter() const
break;
}
}
-#endif
+
if (ps == QPrinter::Custom)
m_printer->setPaperSize(sizeForOrientation(orientation, m_paperSize), QPrinter::Point);
else
@@ -390,7 +379,7 @@ void QPageSetupWidget::selectPrinter(QCUPSSupport *cups)
{
m_cups = cups;
widget.paperSize->clear();
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+
if (m_cups && QCUPSSupport::isAvailable()) {
const ppd_option_t* pageSizes = m_cups->pageSizes();
const int numChoices = pageSizes ? pageSizes->num_choices : 0;
@@ -426,7 +415,7 @@ void QPageSetupWidget::selectPrinter(QCUPSSupport *cups)
m_bottomMargin = paper.bottom() - content.bottom();
}
}
-#endif
+
if (widget.paperSize->count() == 0) {
populatePaperSizes(widget.paperSize);
widget.paperSize->setCurrentIndex(widget.paperSize->findData(
@@ -471,9 +460,7 @@ void QPageSetupWidget::_q_paperSizeChanged()
bool custom = size == QPrinter::Custom;
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
custom = custom ? !m_cups : custom;
-#endif
widget.paperWidth->setEnabled(custom);
widget.paperHeight->setEnabled(custom);
@@ -485,16 +472,14 @@ void QPageSetupWidget::_q_paperSizeChanged()
m_pagePreview->setPaperSize(m_paperSize);
} else {
Q_ASSERT(m_printer);
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
if (m_cups) { // combobox is filled with cups based data
QByteArray cupsPageSize = widget.paperSize->itemData(widget.paperSize->currentIndex()).toByteArray();
m_paperSize = m_cups->paperRect(cupsPageSize).size();
if (orientation == QPrinter::Landscape)
m_paperSize = QSizeF(m_paperSize.height(), m_paperSize.width()); // swap
- }
- else
-#endif
+ } else {
m_paperSize = qt_printerPaperSize(orientation, size, QPrinter::Point, 1);
+ }
m_pagePreview->setPaperSize(m_paperSize);
widget.paperWidth->setValue(m_paperSize.width() / m_currentMultiplier);
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index f7689c1620..4ba04be9ec 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -60,15 +60,8 @@
#include "ui_qprintsettingsoutput.h"
#include "ui_qprintwidget.h"
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
-# include <private/qcups_p.h>
-# include <cups/cups.h>
-# include <private/qprintengine_pdf_p.h>
-#else
-# include <QtCore/qlibrary.h>
-#endif
-
-#include <private/qprinterinfo_unix_p.h>
+#include <private/qcups_p.h>
+#include <private/qprintengine_pdf_p.h>
QT_BEGIN_NAMESPACE
@@ -82,10 +75,8 @@ public:
QPrintPropertiesDialog(QAbstractPrintDialog *parent = 0);
~QPrintPropertiesDialog();
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
void setCups(QCUPSSupport *cups) { m_cups = cups; }
void addItemToOptions(QOptionTreeItem *parent, QList<const ppd_option_t*>& options, QList<const char*>& markedOptions) const;
-#endif
void selectPrinter();
void selectPdfPsPrinter(const QPrinter *p);
@@ -100,10 +91,8 @@ protected:
private:
Ui::QPrintPropertiesWidget widget;
QDialogButtonBox *m_buttons;
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
QCUPSSupport *m_cups;
QPPDOptionsModel *m_cupsOptionsModel;
-#endif
};
class QPrintDialogPrivate : public QAbstractPrintDialogPrivate
@@ -118,9 +107,7 @@ public:
/// copy printer properties to the widget
void applyPrinterProperties(QPrinter *p);
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
void selectPrinter(QCUPSSupport *cups);
-#endif
void _q_chbPrintLastFirstToggled(bool);
#ifndef QT_NO_MESSAGEBOX
@@ -151,9 +138,7 @@ public:
bool checkFields();
void setupPrinter();
void setOptionsPane(QPrintDialogPrivate *pane);
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
void setCupsProperties();
-#endif
// slots
void _q_printerChanged(int index);
@@ -165,21 +150,17 @@ public:
Ui::QPrintWidget widget;
QAbstractPrintDialog * q;
QPrinter *printer;
- QList<QPrinterDescription> lprPrinters;
void updateWidget();
private:
QPrintDialogPrivate *optionsPane;
bool filePrintersAdded;
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
QCUPSSupport* cups;
int cupsPrinterCount;
const cups_dest_t* cupsPrinters;
const ppd_file_t* cupsPPD;
-#endif
};
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
class QOptionTreeItem
{
public:
@@ -249,15 +230,10 @@ private slots:
};
-#endif
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
QPrintPropertiesDialog::QPrintPropertiesDialog(QAbstractPrintDialog *parent)
- : QDialog(parent)
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- , m_cups(0), m_cupsOptionsModel(0)
-#endif
+ : QDialog(parent), m_cups(0), m_cupsOptionsModel(0)
{
QVBoxLayout *lay = new QVBoxLayout(this);
this->setLayout(lay);
@@ -273,11 +249,7 @@ QPrintPropertiesDialog::QPrintPropertiesDialog(QAbstractPrintDialog *parent)
QPrintPropertiesDialog::~QPrintPropertiesDialog()
{
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
delete m_cupsOptionsModel;
-#else
- delete widget.cupsPropertiesPage;
-#endif
}
void QPrintPropertiesDialog::applyPrinterProperties(QPrinter *p)
@@ -289,7 +261,6 @@ void QPrintPropertiesDialog::setupPrinter() const
{
widget.pageSetup->setupPrinter();
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
QPPDOptionsModel* model = static_cast<QPPDOptionsModel*>(widget.treeView->model());
if (model) {
QOptionTreeItem* rootItem = model->rootItem;
@@ -299,12 +270,10 @@ void QPrintPropertiesDialog::setupPrinter() const
addItemToOptions(rootItem, options, markedOptions);
model->cups->saveOptions(options, markedOptions);
}
-#endif
}
void QPrintPropertiesDialog::selectPrinter()
{
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
widget.pageSetup->selectPrinter(m_cups);
widget.treeView->setModel(0);
if (m_cups && QCUPSSupport::isAvailable()) {
@@ -329,9 +298,7 @@ void QPrintPropertiesDialog::selectPrinter()
widget.tabs->setTabEnabled(1, false);
}
- } else
-#endif
- {
+ } else {
widget.cupsPropertiesPage->setEnabled(false);
widget.pageSetup->selectPrinter(0);
}
@@ -350,7 +317,6 @@ void QPrintPropertiesDialog::showEvent(QShowEvent* event)
event->accept();
}
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
void QPrintPropertiesDialog::addItemToOptions(QOptionTreeItem *parent, QList<const ppd_option_t*>& options, QList<const char*>& markedOptions) const
{
for (int i = 0; i < parent->childItems.count(); ++i) {
@@ -366,7 +332,6 @@ void QPrintPropertiesDialog::addItemToOptions(QOptionTreeItem *parent, QList<con
}
}
}
-#endif
QPrintDialogPrivate::QPrintDialogPrivate()
: top(0), bottom(0), buttons(0), collapseButton(0)
@@ -573,12 +538,10 @@ void QPrintDialogPrivate::setTabs(const QList<QWidget*> &tabWidgets)
}
}
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
void QPrintDialogPrivate::selectPrinter(QCUPSSupport *cups)
{
options.duplex->setEnabled(cups && cups->ppdOption("Duplex"));
}
-#endif
////////////////////////////////////////////////////////////////////////////////
@@ -630,10 +593,8 @@ void QPrintDialog::accept()
/*! \internal
*/
QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p)
- : parent(p), propertiesDialog(0), printer(0), optionsPane(0), filePrintersAdded(false)
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- , cups(0), cupsPrinterCount(0), cupsPrinters(0), cupsPPD(0)
-#endif
+ : parent(p), propertiesDialog(0), printer(0), optionsPane(0), filePrintersAdded(false),
+ cups(0), cupsPrinterCount(0), cupsPrinters(0), cupsPPD(0)
{
q = 0;
if (parent)
@@ -642,7 +603,6 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p)
widget.setupUi(parent);
int currentPrinterIndex = 0;
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
cups = new QCUPSSupport;
if (QCUPSSupport::isAvailable()) {
cupsPPD = cups->currentPPD();
@@ -664,16 +624,7 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p)
widget.properties->setEnabled(true);
}
currentPrinterIndex = cups->currentPrinterIndex();
- } else {
-#endif
- currentPrinterIndex = qt_getLprPrinters(lprPrinters);
- // populating printer combo
- QList<QPrinterDescription>::const_iterator i = lprPrinters.constBegin();
- for(; i != lprPrinters.constEnd(); ++i)
- widget.printers->addItem((*i).name);
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
}
-#endif
#if !defined(QT_NO_FILESYSTEMMODEL) && !defined(QT_NO_COMPLETER)
QFileSystemModel *fsm = new QFileSystemModel(widget.filename);
@@ -725,9 +676,7 @@ void QUnixPrintWidgetPrivate::updateWidget()
QUnixPrintWidgetPrivate::~QUnixPrintWidgetPrivate()
{
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
delete cups;
-#endif
}
void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
@@ -751,16 +700,13 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
widget.lOutput->setEnabled(true);
if (propertiesDialog)
propertiesDialog->selectPdfPsPrinter(printer);
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
if (optionsPane)
optionsPane->selectPrinter(0);
-#endif
return;
}
}
widget.location->setText(QString());
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
if (QCUPSSupport::isAvailable()) {
cups->setCurrentPrinter(index);
@@ -780,21 +726,7 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
propertiesDialog->selectPrinter();
if (optionsPane)
optionsPane->selectPrinter(cups);
- } else {
- if (optionsPane)
- optionsPane->selectPrinter(0);
-#endif
- if (lprPrinters.count() > 0) {
- QString type = lprPrinters.at(index).name + QLatin1Char('@') + lprPrinters.at(index).host;
- if (!lprPrinters.at(index).comment.isEmpty())
- type += QLatin1String(", ") + lprPrinters.at(index).comment;
- widget.type->setText(type);
- if (propertiesDialog)
- propertiesDialog->selectPrinter();
- }
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
}
-#endif
}
void QUnixPrintWidgetPrivate::setOptionsPane(QPrintDialogPrivate *pane)
@@ -908,9 +840,7 @@ void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked()
}
if (propertiesDialog->result() == QDialog::Rejected) {
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
propertiesDialog->setCups(cups);
-#endif
propertiesDialog->applyPrinterProperties(q->printer());
if (q->isOptionEnabled(QPrintDialog::PrintToFile)
@@ -922,7 +852,6 @@ void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked()
propertiesDialog->exec();
}
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
void QUnixPrintWidgetPrivate::setCupsProperties()
{
if (cups && QCUPSSupport::isAvailable() && cups->pageSizes()) {
@@ -949,7 +878,6 @@ void QUnixPrintWidgetPrivate::setCupsProperties()
}
}
}
-#endif
void QUnixPrintWidgetPrivate::setupPrinter()
{
@@ -972,10 +900,8 @@ void QUnixPrintWidgetPrivate::setupPrinter()
if (propertiesDialog && propertiesDialog->result() == QDialog::Accepted)
propertiesDialog->setupPrinter();
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
if (!propertiesDialog)
setCupsProperties();
-#endif
}
@@ -1004,7 +930,6 @@ void QUnixPrintWidget::updatePrinter()
}
////////////////////////////////////////////////////////////////////////////////
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
QPPDOptionsModel::QPPDOptionsModel(QCUPSSupport *c, QObject *parent)
: QAbstractItemModel(parent), rootItem(0), cups(c), ppd(c->currentPPD())
@@ -1244,7 +1169,6 @@ void QPPDOptionsEditor::cbChanged(int)
*/
}
-#endif // !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
#endif // defined (Q_OS_UNIX)
QT_END_NAMESPACE