1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
8 ** |
8 ** |
152 /// copy printer properties to the widget |
152 /// copy printer properties to the widget |
153 void applyPrinterProperties(QPrinter *p); |
153 void applyPrinterProperties(QPrinter *p); |
154 bool checkFields(); |
154 bool checkFields(); |
155 void setupPrinter(); |
155 void setupPrinter(); |
156 void setOptionsPane(QPrintDialogPrivate *pane); |
156 void setOptionsPane(QPrintDialogPrivate *pane); |
|
157 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) |
|
158 void setCupsProperties(); |
|
159 #endif |
157 |
160 |
158 // slots |
161 // slots |
159 void _q_printerChanged(int index); |
162 void _q_printerChanged(int index); |
160 void _q_btnPropertiesClicked(); |
163 void _q_btnPropertiesClicked(); |
161 void _q_btnBrowseClicked(); |
164 void _q_btnBrowseClicked(); |
940 } |
943 } |
941 #endif // QT_NO_MESSAGEBOX |
944 #endif // QT_NO_MESSAGEBOX |
942 |
945 |
943 void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked() |
946 void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked() |
944 { |
947 { |
945 if (propertiesDialog == 0) { |
948 if (!propertiesDialog) { |
946 propertiesDialog = new QPrintPropertiesDialog(q); |
949 propertiesDialog = new QPrintPropertiesDialog(q); |
947 propertiesDialog->setResult(QDialog::Rejected); |
950 propertiesDialog->setResult(QDialog::Rejected); |
948 } |
951 } |
949 |
952 |
950 if (propertiesDialog->result() == QDialog::Rejected) { |
953 if (propertiesDialog->result() == QDialog::Rejected) { |
959 else |
962 else |
960 propertiesDialog->selectPrinter(); |
963 propertiesDialog->selectPrinter(); |
961 } |
964 } |
962 propertiesDialog->exec(); |
965 propertiesDialog->exec(); |
963 } |
966 } |
|
967 |
|
968 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) |
|
969 void QUnixPrintWidgetPrivate::setCupsProperties() |
|
970 { |
|
971 if (cups && QCUPSSupport::isAvailable()) { |
|
972 QPrintEngine *engine = printer->printEngine(); |
|
973 const ppd_option_t* pageSizes = cups->pageSizes(); |
|
974 QByteArray cupsPageSize; |
|
975 for (int i = 0; i < pageSizes->num_choices; ++i) { |
|
976 if (static_cast<int>(pageSizes->choices[i].marked) == 1) |
|
977 cupsPageSize = pageSizes->choices[i].choice; |
|
978 } |
|
979 engine->setProperty(PPK_CupsStringPageSize, QString::fromLatin1(cupsPageSize)); |
|
980 engine->setProperty(PPK_CupsOptions, cups->options()); |
|
981 |
|
982 QRect pageRect = cups->pageRect(cupsPageSize); |
|
983 engine->setProperty(PPK_CupsPageRect, pageRect); |
|
984 |
|
985 QRect paperRect = cups->paperRect(cupsPageSize); |
|
986 engine->setProperty(PPK_CupsPaperRect, paperRect); |
|
987 |
|
988 for (int ps = 0; ps < QPrinter::NPaperSize; ++ps) { |
|
989 QPdf::PaperSize size = QPdf::paperSize(QPrinter::PaperSize(ps)); |
|
990 if (size.width == paperRect.width() && size.height == paperRect.height()) |
|
991 printer->setPaperSize(static_cast<QPrinter::PaperSize>(ps)); |
|
992 } |
|
993 } |
|
994 } |
|
995 #endif |
964 |
996 |
965 void QUnixPrintWidgetPrivate::setupPrinter() |
997 void QUnixPrintWidgetPrivate::setupPrinter() |
966 { |
998 { |
967 const int printerCount = widget.printers->count(); |
999 const int printerCount = widget.printers->count(); |
968 const int index = widget.printers->currentIndex(); |
1000 const int index = widget.printers->currentIndex(); |