| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||
| 5 | ** | - | ||||||||||||||||||
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||||||||
| 7 | ** | - | ||||||||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||||||||
| 16 | ** | - | ||||||||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||
| 25 | ** | - | ||||||||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||
| 29 | ** | - | ||||||||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
| 31 | ** | - | ||||||||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||||||||
| 33 | - | |||||||||||||||||||
| 34 | #include "qplatformdefs.h" | - | ||||||||||||||||||
| 35 | - | |||||||||||||||||||
| 36 | #ifndef QT_NO_PRINTDIALOG | - | ||||||||||||||||||
| 37 | - | |||||||||||||||||||
| 38 | #include "private/qabstractprintdialog_p.h" | - | ||||||||||||||||||
| 39 | #include <QtWidgets/qmessagebox.h> | - | ||||||||||||||||||
| 40 | #include "qprintdialog.h" | - | ||||||||||||||||||
| 41 | #include "qfiledialog.h" | - | ||||||||||||||||||
| 42 | #include <QtCore/qdir.h> | - | ||||||||||||||||||
| 43 | #include <QtGui/qevent.h> | - | ||||||||||||||||||
| 44 | #include <QtWidgets/qfilesystemmodel.h> | - | ||||||||||||||||||
| 45 | #include <QtWidgets/qstyleditemdelegate.h> | - | ||||||||||||||||||
| 46 | #include <QtPrintSupport/qprinter.h> | - | ||||||||||||||||||
| 47 | - | |||||||||||||||||||
| 48 | #include <qpa/qplatformprintplugin.h> | - | ||||||||||||||||||
| 49 | #include <qpa/qplatformprintersupport.h> | - | ||||||||||||||||||
| 50 | - | |||||||||||||||||||
| 51 | #include <private/qprintdevice_p.h> | - | ||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | #include <QtWidgets/qdialogbuttonbox.h> | - | ||||||||||||||||||
| 54 | - | |||||||||||||||||||
| 55 | #include "private/qfscompleter_p.h" | - | ||||||||||||||||||
| 56 | #include "ui_qprintpropertieswidget.h" | - | ||||||||||||||||||
| 57 | #include "ui_qprintsettingsoutput.h" | - | ||||||||||||||||||
| 58 | #include "ui_qprintwidget.h" | - | ||||||||||||||||||
| 59 | - | |||||||||||||||||||
| 60 | #ifndef QT_NO_CUPS | - | ||||||||||||||||||
| 61 | #include <private/qcups_p.h> | - | ||||||||||||||||||
| 62 | #include "qcupsjobwidget_p.h" | - | ||||||||||||||||||
| 63 | #endif | - | ||||||||||||||||||
| 64 | - | |||||||||||||||||||
| 65 | /* | - | ||||||||||||||||||
| 66 | - | |||||||||||||||||||
| 67 | Print dialog class declarations | - | ||||||||||||||||||
| 68 | - | |||||||||||||||||||
| 69 | QPrintDialog: The main Print Dialog, nothing really held here. | - | ||||||||||||||||||
| 70 | - | |||||||||||||||||||
| 71 | QUnixPrintWidget: | - | ||||||||||||||||||
| 72 | QUnixPrintWidgetPrivate: The real Unix Print Dialog implementation. | - | ||||||||||||||||||
| 73 | - | |||||||||||||||||||
| 74 | Directly includes the upper half of the Print Dialog | - | ||||||||||||||||||
| 75 | containing the Printer Selection widgets and | - | ||||||||||||||||||
| 76 | Properties button. | - | ||||||||||||||||||
| 77 | - | |||||||||||||||||||
| 78 | Embeds the Properties pop-up dialog from | - | ||||||||||||||||||
| 79 | QPrintPropertiesDialog | - | ||||||||||||||||||
| 80 | - | |||||||||||||||||||
| 81 | Embeds the lower half from separate widget class | - | ||||||||||||||||||
| 82 | QPrintDialogPrivate | - | ||||||||||||||||||
| 83 | - | |||||||||||||||||||
| 84 | Layout in qprintwidget.ui | - | ||||||||||||||||||
| 85 | - | |||||||||||||||||||
| 86 | QPrintDialogPrivate: The lower half of the Print Dialog containing the | - | ||||||||||||||||||
| 87 | Copies and Options tabs that expands when the | - | ||||||||||||||||||
| 88 | Options button is selected. | - | ||||||||||||||||||
| 89 | - | |||||||||||||||||||
| 90 | Layout in qprintsettingsoutput.ui | - | ||||||||||||||||||
| 91 | - | |||||||||||||||||||
| 92 | QPrintPropertiesDialog: Dialog displayed when clicking on Properties button to | - | ||||||||||||||||||
| 93 | allow editing of Page and Advanced tabs. | - | ||||||||||||||||||
| 94 | - | |||||||||||||||||||
| 95 | Layout in qprintpropertieswidget.ui | - | ||||||||||||||||||
| 96 | */ | - | ||||||||||||||||||
| 97 | - | |||||||||||||||||||
| 98 | static void initResources() | - | ||||||||||||||||||
| 99 | { | - | ||||||||||||||||||
| 100 | Q_INIT_RESOURCE(qprintdialog); | - | ||||||||||||||||||
| 101 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||
| 102 | - | |||||||||||||||||||
| 103 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 104 | - | |||||||||||||||||||
| 105 | class QOptionTreeItem; | - | ||||||||||||||||||
| 106 | class QPPDOptionsModel; | - | ||||||||||||||||||
| 107 | - | |||||||||||||||||||
| 108 | class QPrintPropertiesDialog : public QDialog | - | ||||||||||||||||||
| 109 | { | - | ||||||||||||||||||
| 110 | Q_OBJECT | - | ||||||||||||||||||
| 111 | public: | - | ||||||||||||||||||
| 112 | QPrintPropertiesDialog(QAbstractPrintDialog *parent = 0); | - | ||||||||||||||||||
| 113 | ~QPrintPropertiesDialog(); | - | ||||||||||||||||||
| 114 | - | |||||||||||||||||||
| 115 | void selectPrinter(QPrinter::OutputFormat outputFormat, const QString &printerName); | - | ||||||||||||||||||
| 116 | - | |||||||||||||||||||
| 117 | /// copy printer properties to the widget | - | ||||||||||||||||||
| 118 | void applyPrinterProperties(QPrinter *p); | - | ||||||||||||||||||
| 119 | void setupPrinter() const; | - | ||||||||||||||||||
| 120 | - | |||||||||||||||||||
| 121 | private: | - | ||||||||||||||||||
| 122 | friend class QUnixPrintWidgetPrivate; | - | ||||||||||||||||||
| 123 | Ui::QPrintPropertiesWidget widget; | - | ||||||||||||||||||
| 124 | QDialogButtonBox *m_buttons; | - | ||||||||||||||||||
| 125 | #ifndef QT_NO_CUPS | - | ||||||||||||||||||
| 126 | QCupsJobWidget *m_jobOptions; | - | ||||||||||||||||||
| 127 | #endif | - | ||||||||||||||||||
| 128 | }; | - | ||||||||||||||||||
| 129 | - | |||||||||||||||||||
| 130 | class QUnixPrintWidgetPrivate; | - | ||||||||||||||||||
| 131 | - | |||||||||||||||||||
| 132 | class QUnixPrintWidget : public QWidget | - | ||||||||||||||||||
| 133 | { | - | ||||||||||||||||||
| 134 | Q_OBJECT | - | ||||||||||||||||||
| 135 | - | |||||||||||||||||||
| 136 | public: | - | ||||||||||||||||||
| 137 | explicit QUnixPrintWidget(QPrinter *printer, QWidget *parent = 0); | - | ||||||||||||||||||
| 138 | ~QUnixPrintWidget(); | - | ||||||||||||||||||
| 139 | void updatePrinter(); | - | ||||||||||||||||||
| 140 | - | |||||||||||||||||||
| 141 | private: | - | ||||||||||||||||||
| 142 | friend class QPrintDialogPrivate; | - | ||||||||||||||||||
| 143 | friend class QUnixPrintWidgetPrivate; | - | ||||||||||||||||||
| 144 | QUnixPrintWidgetPrivate *d; | - | ||||||||||||||||||
| 145 | Q_PRIVATE_SLOT(d, void _q_printerChanged(int)) | - | ||||||||||||||||||
| 146 | Q_PRIVATE_SLOT(d, void _q_btnBrowseClicked()) | - | ||||||||||||||||||
| 147 | Q_PRIVATE_SLOT(d, void _q_btnPropertiesClicked()) | - | ||||||||||||||||||
| 148 | }; | - | ||||||||||||||||||
| 149 | - | |||||||||||||||||||
| 150 | class QUnixPrintWidgetPrivate | - | ||||||||||||||||||
| 151 | { | - | ||||||||||||||||||
| 152 | public: | - | ||||||||||||||||||
| 153 | QUnixPrintWidgetPrivate(QUnixPrintWidget *q, QPrinter *prn); | - | ||||||||||||||||||
| 154 | ~QUnixPrintWidgetPrivate(); | - | ||||||||||||||||||
| 155 | - | |||||||||||||||||||
| 156 | /// copy printer properties to the widget | - | ||||||||||||||||||
| 157 | void applyPrinterProperties(); | - | ||||||||||||||||||
| 158 | bool checkFields(); | - | ||||||||||||||||||
| 159 | void setupPrinter(); | - | ||||||||||||||||||
| 160 | void setOptionsPane(QPrintDialogPrivate *pane); | - | ||||||||||||||||||
| 161 | void setupPrinterProperties(); | - | ||||||||||||||||||
| 162 | // slots | - | ||||||||||||||||||
| 163 | void _q_printerChanged(int index); | - | ||||||||||||||||||
| 164 | void _q_btnPropertiesClicked(); | - | ||||||||||||||||||
| 165 | void _q_btnBrowseClicked(); | - | ||||||||||||||||||
| 166 | - | |||||||||||||||||||
| 167 | QUnixPrintWidget * const parent; | - | ||||||||||||||||||
| 168 | QPrintPropertiesDialog *propertiesDialog; | - | ||||||||||||||||||
| 169 | Ui::QPrintWidget widget; | - | ||||||||||||||||||
| 170 | QAbstractPrintDialog * q; | - | ||||||||||||||||||
| 171 | QPrinter *printer; | - | ||||||||||||||||||
| 172 | QPrintDevice m_currentPrintDevice; | - | ||||||||||||||||||
| 173 | - | |||||||||||||||||||
| 174 | void updateWidget(); | - | ||||||||||||||||||
| 175 | - | |||||||||||||||||||
| 176 | private: | - | ||||||||||||||||||
| 177 | QPrintDialogPrivate *optionsPane; | - | ||||||||||||||||||
| 178 | bool filePrintersAdded; | - | ||||||||||||||||||
| 179 | bool propertiesDialogShown; | - | ||||||||||||||||||
| 180 | }; | - | ||||||||||||||||||
| 181 | - | |||||||||||||||||||
| 182 | class QPrintDialogPrivate : public QAbstractPrintDialogPrivate | - | ||||||||||||||||||
| 183 | { | - | ||||||||||||||||||
| 184 | Q_DECLARE_PUBLIC(QPrintDialog) | - | ||||||||||||||||||
| 185 | Q_DECLARE_TR_FUNCTIONS(QPrintDialog) | - | ||||||||||||||||||
| 186 | public: | - | ||||||||||||||||||
| 187 | QPrintDialogPrivate(); | - | ||||||||||||||||||
| 188 | ~QPrintDialogPrivate(); | - | ||||||||||||||||||
| 189 | - | |||||||||||||||||||
| 190 | void init(); | - | ||||||||||||||||||
| 191 | /// copy printer properties to the widget | - | ||||||||||||||||||
| 192 | void applyPrinterProperties(); | - | ||||||||||||||||||
| 193 | - | |||||||||||||||||||
| 194 | void selectPrinter(const QPrinter::OutputFormat outputFormat); | - | ||||||||||||||||||
| 195 | - | |||||||||||||||||||
| 196 | void _q_togglePageSetCombo(bool); | - | ||||||||||||||||||
| 197 | #ifndef QT_NO_MESSAGEBOX | - | ||||||||||||||||||
| 198 | void _q_checkFields(); | - | ||||||||||||||||||
| 199 | #endif | - | ||||||||||||||||||
| 200 | void _q_collapseOrExpandDialog(); | - | ||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | void setupPrinter(); | - | ||||||||||||||||||
| 203 | void updateWidgets(); | - | ||||||||||||||||||
| 204 | - | |||||||||||||||||||
| 205 | virtual void setTabs(const QList<QWidget*> &tabs) Q_DECL_OVERRIDE; | - | ||||||||||||||||||
| 206 | - | |||||||||||||||||||
| 207 | Ui::QPrintSettingsOutput options; | - | ||||||||||||||||||
| 208 | QUnixPrintWidget *top; | - | ||||||||||||||||||
| 209 | QWidget *bottom; | - | ||||||||||||||||||
| 210 | QDialogButtonBox *buttons; | - | ||||||||||||||||||
| 211 | QPushButton *collapseButton; | - | ||||||||||||||||||
| 212 | QPrinter::OutputFormat printerOutputFormat; | - | ||||||||||||||||||
| 213 | }; | - | ||||||||||||||||||
| 214 | - | |||||||||||||||||||
| 215 | - | |||||||||||||||||||
| 216 | //////////////////////////////////////////////////////////////////////////////// | - | ||||||||||||||||||
| 217 | //////////////////////////////////////////////////////////////////////////////// | - | ||||||||||||||||||
| 218 | - | |||||||||||||||||||
| 219 | /* | - | ||||||||||||||||||
| 220 | - | |||||||||||||||||||
| 221 | QPrintPropertiesDialog | - | ||||||||||||||||||
| 222 | - | |||||||||||||||||||
| 223 | Dialog displayed when clicking on Properties button to allow editing of Page | - | ||||||||||||||||||
| 224 | and Advanced tabs. | - | ||||||||||||||||||
| 225 | - | |||||||||||||||||||
| 226 | */ | - | ||||||||||||||||||
| 227 | - | |||||||||||||||||||
| 228 | QPrintPropertiesDialog::QPrintPropertiesDialog(QAbstractPrintDialog *parent) | - | ||||||||||||||||||
| 229 | : QDialog(parent) | - | ||||||||||||||||||
| 230 | { | - | ||||||||||||||||||
| 231 | setWindowTitle(tr("Printer Properties")); | - | ||||||||||||||||||
| 232 | QVBoxLayout *lay = new QVBoxLayout(this); | - | ||||||||||||||||||
| 233 | this->setLayout(lay); | - | ||||||||||||||||||
| 234 | QWidget *content = new QWidget(this); | - | ||||||||||||||||||
| 235 | widget.setupUi(content); | - | ||||||||||||||||||
| 236 | m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); | - | ||||||||||||||||||
| 237 | lay->addWidget(content); | - | ||||||||||||||||||
| 238 | lay->addWidget(m_buttons); | - | ||||||||||||||||||
| 239 | - | |||||||||||||||||||
| 240 | connect(m_buttons->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept())); | - | ||||||||||||||||||
| 241 | connect(m_buttons->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject())); | - | ||||||||||||||||||
| 242 | - | |||||||||||||||||||
| 243 | #ifndef QT_NO_CUPS | - | ||||||||||||||||||
| 244 | m_jobOptions = new QCupsJobWidget(); | - | ||||||||||||||||||
| 245 | widget.tabs->addTab(m_jobOptions, tr("Job Options")); | - | ||||||||||||||||||
| 246 | #endif | - | ||||||||||||||||||
| 247 | } never executed: end of block | 0 | ||||||||||||||||||
| 248 | - | |||||||||||||||||||
| 249 | QPrintPropertiesDialog::~QPrintPropertiesDialog() | - | ||||||||||||||||||
| 250 | { | - | ||||||||||||||||||
| 251 | } | - | ||||||||||||||||||
| 252 | - | |||||||||||||||||||
| 253 | void QPrintPropertiesDialog::applyPrinterProperties(QPrinter *p) | - | ||||||||||||||||||
| 254 | { | - | ||||||||||||||||||
| 255 | widget.pageSetup->setPrinter(p); | - | ||||||||||||||||||
| 256 | #ifndef QT_NO_CUPS | - | ||||||||||||||||||
| 257 | m_jobOptions->setPrinter(p); | - | ||||||||||||||||||
| 258 | #endif | - | ||||||||||||||||||
| 259 | } never executed: end of block | 0 | ||||||||||||||||||
| 260 | - | |||||||||||||||||||
| 261 | void QPrintPropertiesDialog::setupPrinter() const | - | ||||||||||||||||||
| 262 | { | - | ||||||||||||||||||
| 263 | widget.pageSetup->setupPrinter(); | - | ||||||||||||||||||
| 264 | #ifndef QT_NO_CUPS | - | ||||||||||||||||||
| 265 | m_jobOptions->setupPrinter(); | - | ||||||||||||||||||
| 266 | #endif | - | ||||||||||||||||||
| 267 | } never executed: end of block | 0 | ||||||||||||||||||
| 268 | - | |||||||||||||||||||
| 269 | void QPrintPropertiesDialog::selectPrinter(QPrinter::OutputFormat outputFormat, const QString &printerName) | - | ||||||||||||||||||
| 270 | { | - | ||||||||||||||||||
| 271 | widget.pageSetup->selectPrinter(outputFormat, printerName); | - | ||||||||||||||||||
| 272 | } never executed: end of block | 0 | ||||||||||||||||||
| 273 | - | |||||||||||||||||||
| 274 | //////////////////////////////////////////////////////////////////////////////// | - | ||||||||||||||||||
| 275 | //////////////////////////////////////////////////////////////////////////////// | - | ||||||||||||||||||
| 276 | - | |||||||||||||||||||
| 277 | /* | - | ||||||||||||||||||
| 278 | - | |||||||||||||||||||
| 279 | QPrintDialogPrivate | - | ||||||||||||||||||
| 280 | - | |||||||||||||||||||
| 281 | The lower half of the Print Dialog containing the Copies and Options | - | ||||||||||||||||||
| 282 | tabs that expands when the Options button is selected. | - | ||||||||||||||||||
| 283 | - | |||||||||||||||||||
| 284 | */ | - | ||||||||||||||||||
| 285 | QPrintDialogPrivate::QPrintDialogPrivate() | - | ||||||||||||||||||
| 286 | : top(0), bottom(0), buttons(0), collapseButton(0) | - | ||||||||||||||||||
| 287 | { | - | ||||||||||||||||||
| 288 | initResources(); | - | ||||||||||||||||||
| 289 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||
| 290 | - | |||||||||||||||||||
| 291 | QPrintDialogPrivate::~QPrintDialogPrivate() | - | ||||||||||||||||||
| 292 | { | - | ||||||||||||||||||
| 293 | } | - | ||||||||||||||||||
| 294 | - | |||||||||||||||||||
| 295 | void QPrintDialogPrivate::init() | - | ||||||||||||||||||
| 296 | { | - | ||||||||||||||||||
| 297 | Q_Q(QPrintDialog); | - | ||||||||||||||||||
| 298 | - | |||||||||||||||||||
| 299 | top = new QUnixPrintWidget(q->printer(), q); | - | ||||||||||||||||||
| 300 | bottom = new QWidget(q); | - | ||||||||||||||||||
| 301 | options.setupUi(bottom); | - | ||||||||||||||||||
| 302 | options.color->setIconSize(QSize(32, 32)); | - | ||||||||||||||||||
| 303 | options.color->setIcon(QIcon(QLatin1String(":/qt-project.org/dialogs/qprintdialog/images/status-color.png"))); | - | ||||||||||||||||||
| 304 | options.grayscale->setIconSize(QSize(32, 32)); | - | ||||||||||||||||||
| 305 | options.grayscale->setIcon(QIcon(QLatin1String(":/qt-project.org/dialogs/qprintdialog/images/status-gray-scale.png"))); | - | ||||||||||||||||||
| 306 | - | |||||||||||||||||||
| 307 | #ifndef QT_NO_CUPS | - | ||||||||||||||||||
| 308 | // Add Page Set widget if CUPS is available | - | ||||||||||||||||||
| 309 | options.pageSetCombo->addItem(tr("All Pages"), QVariant::fromValue(QCUPSSupport::AllPages)); | - | ||||||||||||||||||
| 310 | options.pageSetCombo->addItem(tr("Odd Pages"), QVariant::fromValue(QCUPSSupport::OddPages)); | - | ||||||||||||||||||
| 311 | options.pageSetCombo->addItem(tr("Even Pages"), QVariant::fromValue(QCUPSSupport::EvenPages)); | - | ||||||||||||||||||
| 312 | #endif | - | ||||||||||||||||||
| 313 | - | |||||||||||||||||||
| 314 | top->d->setOptionsPane(this); | - | ||||||||||||||||||
| 315 | - | |||||||||||||||||||
| 316 | buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, q); | - | ||||||||||||||||||
| 317 | collapseButton = new QPushButton(QPrintDialog::tr("&Options >>"), buttons); | - | ||||||||||||||||||
| 318 | buttons->addButton(collapseButton, QDialogButtonBox::ResetRole); | - | ||||||||||||||||||
| 319 | bottom->setVisible(false); | - | ||||||||||||||||||
| 320 | - | |||||||||||||||||||
| 321 | QPushButton *printButton = buttons->button(QDialogButtonBox::Ok); | - | ||||||||||||||||||
| 322 | printButton->setText(QPrintDialog::tr("&Print")); | - | ||||||||||||||||||
| 323 | printButton->setDefault(true); | - | ||||||||||||||||||
| 324 | - | |||||||||||||||||||
| 325 | QVBoxLayout *lay = new QVBoxLayout(q); | - | ||||||||||||||||||
| 326 | q->setLayout(lay); | - | ||||||||||||||||||
| 327 | lay->addWidget(top); | - | ||||||||||||||||||
| 328 | lay->addWidget(bottom); | - | ||||||||||||||||||
| 329 | lay->addWidget(buttons); | - | ||||||||||||||||||
| 330 | - | |||||||||||||||||||
| 331 | #ifdef QT_NO_MESSAGEBOX | - | ||||||||||||||||||
| 332 | QObject::connect(buttons, SIGNAL(accepted()), q, SLOT(accept())); | - | ||||||||||||||||||
| 333 | #else | - | ||||||||||||||||||
| 334 | QObject::connect(buttons, SIGNAL(accepted()), q, SLOT(_q_checkFields())); | - | ||||||||||||||||||
| 335 | #endif | - | ||||||||||||||||||
| 336 | QObject::connect(buttons, SIGNAL(rejected()), q, SLOT(reject())); | - | ||||||||||||||||||
| 337 | - | |||||||||||||||||||
| 338 | QObject::connect(options.printSelection, SIGNAL(toggled(bool)), | - | ||||||||||||||||||
| 339 | q, SLOT(_q_togglePageSetCombo(bool))); | - | ||||||||||||||||||
| 340 | - | |||||||||||||||||||
| 341 | QObject::connect(options.printCurrentPage, SIGNAL(toggled(bool)), | - | ||||||||||||||||||
| 342 | q, SLOT(_q_togglePageSetCombo(bool))); | - | ||||||||||||||||||
| 343 | - | |||||||||||||||||||
| 344 | QObject::connect(collapseButton, SIGNAL(released()), q, SLOT(_q_collapseOrExpandDialog())); | - | ||||||||||||||||||
| 345 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||
| 346 | - | |||||||||||||||||||
| 347 | // initialize printer options | - | ||||||||||||||||||
| 348 | void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputFormat) | - | ||||||||||||||||||
| 349 | { | - | ||||||||||||||||||
| 350 | Q_Q(QPrintDialog); | - | ||||||||||||||||||
| 351 | QPrinter *p = q->printer(); | - | ||||||||||||||||||
| 352 | printerOutputFormat = outputFormat; | - | ||||||||||||||||||
| 353 | - | |||||||||||||||||||
| 354 | if (p->colorMode() == QPrinter::Color)
| 0-4 | ||||||||||||||||||
| 355 | options.color->setChecked(true); executed 4 times by 1 test: options.color->setChecked(true);Executed by:
| 4 | ||||||||||||||||||
| 356 | else | - | ||||||||||||||||||
| 357 | options.grayscale->setChecked(true); never executed: options.grayscale->setChecked(true); | 0 | ||||||||||||||||||
| 358 | - | |||||||||||||||||||
| 359 | switch (p->duplex()) { | - | ||||||||||||||||||
| 360 | case QPrinter::DuplexNone: executed 4 times by 1 test: case QPrinter::DuplexNone:Executed by:
| 4 | ||||||||||||||||||
| 361 | options.noDuplex->setChecked(true); break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||
| 362 | case QPrinter::DuplexLongSide: never executed: case QPrinter::DuplexLongSide: | 0 | ||||||||||||||||||
| 363 | case QPrinter::DuplexAuto: never executed: case QPrinter::DuplexAuto: | 0 | ||||||||||||||||||
| 364 | options.duplexLong->setChecked(true); break; never executed: break; | 0 | ||||||||||||||||||
| 365 | case QPrinter::DuplexShortSide: never executed: case QPrinter::DuplexShortSide: | 0 | ||||||||||||||||||
| 366 | options.duplexShort->setChecked(true); break; never executed: break; | 0 | ||||||||||||||||||
| 367 | } | - | ||||||||||||||||||
| 368 | options.copies->setValue(p->copyCount()); | - | ||||||||||||||||||
| 369 | options.collate->setChecked(p->collateCopies()); | - | ||||||||||||||||||
| 370 | options.reverse->setChecked(p->pageOrder() == QPrinter::LastPageFirst); | - | ||||||||||||||||||
| 371 | - | |||||||||||||||||||
| 372 | if (outputFormat == QPrinter::PdfFormat || options.printSelection->isChecked()
| 0-4 | ||||||||||||||||||
| 373 | || options.printCurrentPage->isChecked())
| 0-4 | ||||||||||||||||||
| 374 | - | |||||||||||||||||||
| 375 | options.pageSetCombo->setEnabled(false); never executed: options.pageSetCombo->setEnabled(false); | 0 | ||||||||||||||||||
| 376 | else | - | ||||||||||||||||||
| 377 | options.pageSetCombo->setEnabled(true); executed 4 times by 1 test: options.pageSetCombo->setEnabled(true);Executed by:
| 4 | ||||||||||||||||||
| 378 | } | - | ||||||||||||||||||
| 379 | - | |||||||||||||||||||
| 380 | void QPrintDialogPrivate::applyPrinterProperties() | - | ||||||||||||||||||
| 381 | { | - | ||||||||||||||||||
| 382 | // apply printer options to property dialog | - | ||||||||||||||||||
| 383 | top->d->applyPrinterProperties(); | - | ||||||||||||||||||
| 384 | } never executed: end of block | 0 | ||||||||||||||||||
| 385 | - | |||||||||||||||||||
| 386 | void QPrintDialogPrivate::setupPrinter() | - | ||||||||||||||||||
| 387 | { | - | ||||||||||||||||||
| 388 | // First setup the requested OutputFormat, Printer and Page Size first | - | ||||||||||||||||||
| 389 | top->d->setupPrinter(); | - | ||||||||||||||||||
| 390 | - | |||||||||||||||||||
| 391 | // Then setup Print Job options | - | ||||||||||||||||||
| 392 | Q_Q(QPrintDialog); | - | ||||||||||||||||||
| 393 | QPrinter* p = q->printer(); | - | ||||||||||||||||||
| 394 | - | |||||||||||||||||||
| 395 | if (options.duplex->isEnabled()) {
| 0 | ||||||||||||||||||
| 396 | if (options.noDuplex->isChecked())
| 0 | ||||||||||||||||||
| 397 | p->setDuplex(QPrinter::DuplexNone); never executed: p->setDuplex(QPrinter::DuplexNone); | 0 | ||||||||||||||||||
| 398 | else if (options.duplexLong->isChecked())
| 0 | ||||||||||||||||||
| 399 | p->setDuplex(QPrinter::DuplexLongSide); never executed: p->setDuplex(QPrinter::DuplexLongSide); | 0 | ||||||||||||||||||
| 400 | else | - | ||||||||||||||||||
| 401 | p->setDuplex(QPrinter::DuplexShortSide); never executed: p->setDuplex(QPrinter::DuplexShortSide); | 0 | ||||||||||||||||||
| 402 | } | - | ||||||||||||||||||
| 403 | - | |||||||||||||||||||
| 404 | p->setColorMode(options.color->isChecked() ? QPrinter::Color : QPrinter::GrayScale); | - | ||||||||||||||||||
| 405 | p->setPageOrder(options.reverse->isChecked() ? QPrinter::LastPageFirst : QPrinter::FirstPageFirst); | - | ||||||||||||||||||
| 406 | - | |||||||||||||||||||
| 407 | // print range | - | ||||||||||||||||||
| 408 | if (options.printAll->isChecked()) {
| 0 | ||||||||||||||||||
| 409 | p->setPrintRange(QPrinter::AllPages); | - | ||||||||||||||||||
| 410 | p->setFromTo(0,0); | - | ||||||||||||||||||
| 411 | } else if (options.printSelection->isChecked()) { never executed: end of block
| 0 | ||||||||||||||||||
| 412 | p->setPrintRange(QPrinter::Selection); | - | ||||||||||||||||||
| 413 | p->setFromTo(0,0); | - | ||||||||||||||||||
| 414 | } else if (options.printCurrentPage->isChecked()) { never executed: end of block
| 0 | ||||||||||||||||||
| 415 | p->setPrintRange(QPrinter::CurrentPage); | - | ||||||||||||||||||
| 416 | p->setFromTo(0,0); | - | ||||||||||||||||||
| 417 | } else if (options.printRange->isChecked()) { never executed: end of block
| 0 | ||||||||||||||||||
| 418 | if (q->isOptionEnabled(QPrintDialog::PrintPageRange)) {
| 0 | ||||||||||||||||||
| 419 | p->setPrintRange(QPrinter::PageRange); | - | ||||||||||||||||||
| 420 | p->setFromTo(options.from->value(), qMax(options.from->value(), options.to->value())); | - | ||||||||||||||||||
| 421 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 422 | // This case happens when CUPS server-side page range is enabled | - | ||||||||||||||||||
| 423 | // Setting the range to the printer occurs below | - | ||||||||||||||||||
| 424 | p->setPrintRange(QPrinter::AllPages); | - | ||||||||||||||||||
| 425 | p->setFromTo(0,0); | - | ||||||||||||||||||
| 426 | } never executed: end of block | 0 | ||||||||||||||||||
| 427 | } | - | ||||||||||||||||||
| 428 | - | |||||||||||||||||||
| 429 | #ifndef QT_NO_CUPS | - | ||||||||||||||||||
| 430 | // page set | - | ||||||||||||||||||
| 431 | if (p->printRange() == QPrinter::AllPages || p->printRange() == QPrinter::PageRange) {
| 0 | ||||||||||||||||||
| 432 | //If the application is selecting pages and the first page number is even then need to adjust the odd-even accordingly | - | ||||||||||||||||||
| 433 | QCUPSSupport::PageSet pageSet = options.pageSetCombo->itemData(options.pageSetCombo->currentIndex()).value<QCUPSSupport::PageSet>(); | - | ||||||||||||||||||
| 434 | if (q->isOptionEnabled(QPrintDialog::PrintPageRange)
| 0 | ||||||||||||||||||
| 435 | && p->printRange() == QPrinter::PageRange
| 0 | ||||||||||||||||||
| 436 | && (q->fromPage() % 2 == 0)) {
| 0 | ||||||||||||||||||
| 437 | - | |||||||||||||||||||
| 438 | switch (pageSet) { | - | ||||||||||||||||||
| 439 | case QCUPSSupport::AllPages: never executed: case QCUPSSupport::AllPages: | 0 | ||||||||||||||||||
| 440 | break; never executed: break; | 0 | ||||||||||||||||||
| 441 | case QCUPSSupport::OddPages: never executed: case QCUPSSupport::OddPages: | 0 | ||||||||||||||||||
| 442 | QCUPSSupport::setPageSet(p, QCUPSSupport::EvenPages); | - | ||||||||||||||||||
| 443 | break; never executed: break; | 0 | ||||||||||||||||||
| 444 | case QCUPSSupport::EvenPages: never executed: case QCUPSSupport::EvenPages: | 0 | ||||||||||||||||||
| 445 | QCUPSSupport::setPageSet(p, QCUPSSupport::OddPages); | - | ||||||||||||||||||
| 446 | break; never executed: break; | 0 | ||||||||||||||||||
| 447 | } | - | ||||||||||||||||||
| 448 | } else if (pageSet != QCUPSSupport::AllPages) { never executed: end of block
| 0 | ||||||||||||||||||
| 449 | QCUPSSupport::setPageSet(p, pageSet); | - | ||||||||||||||||||
| 450 | } never executed: end of block | 0 | ||||||||||||||||||
| 451 | - | |||||||||||||||||||
| 452 | // server-side page range, since we set the page range on the printer to 0-0/AllPages above, | - | ||||||||||||||||||
| 453 | // we need to take the values directly from the widget as q->fromPage() will return 0 | - | ||||||||||||||||||
| 454 | if (!q->isOptionEnabled(QPrintDialog::PrintPageRange) && options.printRange->isChecked())
| 0 | ||||||||||||||||||
| 455 | QCUPSSupport::setPageRange(p, options.from->value(), qMax(options.from->value(), options.to->value())); never executed: QCUPSSupport::setPageRange(p, options.from->value(), qMax(options.from->value(), options.to->value())); | 0 | ||||||||||||||||||
| 456 | } never executed: end of block | 0 | ||||||||||||||||||
| 457 | #endif | - | ||||||||||||||||||
| 458 | - | |||||||||||||||||||
| 459 | // copies | - | ||||||||||||||||||
| 460 | p->setCopyCount(options.copies->value()); | - | ||||||||||||||||||
| 461 | p->setCollateCopies(options.collate->isChecked()); | - | ||||||||||||||||||
| 462 | } never executed: end of block | 0 | ||||||||||||||||||
| 463 | - | |||||||||||||||||||
| 464 | void QPrintDialogPrivate::_q_togglePageSetCombo(bool checked) | - | ||||||||||||||||||
| 465 | { | - | ||||||||||||||||||
| 466 | if (printerOutputFormat == QPrinter::PdfFormat)
| 0 | ||||||||||||||||||
| 467 | return; never executed: return; | 0 | ||||||||||||||||||
| 468 | - | |||||||||||||||||||
| 469 | options.pageSetCombo->setDisabled(checked); | - | ||||||||||||||||||
| 470 | } never executed: end of block | 0 | ||||||||||||||||||
| 471 | - | |||||||||||||||||||
| 472 | void QPrintDialogPrivate::_q_collapseOrExpandDialog() | - | ||||||||||||||||||
| 473 | { | - | ||||||||||||||||||
| 474 | int collapseHeight = 0; | - | ||||||||||||||||||
| 475 | Q_Q(QPrintDialog); | - | ||||||||||||||||||
| 476 | QWidget *widgetToHide = bottom; | - | ||||||||||||||||||
| 477 | if (widgetToHide->isVisible()) {
| 0 | ||||||||||||||||||
| 478 | collapseButton->setText(QPrintDialog::tr("&Options >>")); | - | ||||||||||||||||||
| 479 | collapseHeight = widgetToHide->y() + widgetToHide->height() - (top->y() + top->height()); | - | ||||||||||||||||||
| 480 | } never executed: end of block | 0 | ||||||||||||||||||
| 481 | else | - | ||||||||||||||||||
| 482 | collapseButton->setText(QPrintDialog::tr("&Options <<")); never executed: collapseButton->setText(QPrintDialog::tr("&Options <<")); | 0 | ||||||||||||||||||
| 483 | widgetToHide->setVisible(! widgetToHide->isVisible()); | - | ||||||||||||||||||
| 484 | if (! widgetToHide->isVisible()) { // make it shrink
| 0 | ||||||||||||||||||
| 485 | q->layout()->activate(); | - | ||||||||||||||||||
| 486 | q->resize( QSize(q->width(), q->height() - collapseHeight) ); | - | ||||||||||||||||||
| 487 | } never executed: end of block | 0 | ||||||||||||||||||
| 488 | } never executed: end of block | 0 | ||||||||||||||||||
| 489 | - | |||||||||||||||||||
| 490 | #ifndef QT_NO_MESSAGEBOX | - | ||||||||||||||||||
| 491 | void QPrintDialogPrivate::_q_checkFields() | - | ||||||||||||||||||
| 492 | { | - | ||||||||||||||||||
| 493 | Q_Q(QPrintDialog); | - | ||||||||||||||||||
| 494 | if (top->d->checkFields())
| 0 | ||||||||||||||||||
| 495 | q->accept(); never executed: q->accept(); | 0 | ||||||||||||||||||
| 496 | } never executed: end of block | 0 | ||||||||||||||||||
| 497 | #endif // QT_NO_MESSAGEBOX | - | ||||||||||||||||||
| 498 | - | |||||||||||||||||||
| 499 | - | |||||||||||||||||||
| 500 | void QPrintDialogPrivate::updateWidgets() | - | ||||||||||||||||||
| 501 | { | - | ||||||||||||||||||
| 502 | Q_Q(QPrintDialog); | - | ||||||||||||||||||
| 503 | options.gbPrintRange->setVisible(q->isOptionEnabled(QPrintDialog::PrintPageRange) || | - | ||||||||||||||||||
| 504 | q->isOptionEnabled(QPrintDialog::PrintSelection) || | - | ||||||||||||||||||
| 505 | q->isOptionEnabled(QPrintDialog::PrintCurrentPage)); | - | ||||||||||||||||||
| 506 | - | |||||||||||||||||||
| 507 | options.printRange->setEnabled(q->isOptionEnabled(QPrintDialog::PrintPageRange)); | - | ||||||||||||||||||
| 508 | options.printSelection->setVisible(q->isOptionEnabled(QPrintDialog::PrintSelection)); | - | ||||||||||||||||||
| 509 | options.printCurrentPage->setVisible(q->isOptionEnabled(QPrintDialog::PrintCurrentPage)); | - | ||||||||||||||||||
| 510 | options.collate->setVisible(q->isOptionEnabled(QPrintDialog::PrintCollateCopies)); | - | ||||||||||||||||||
| 511 | - | |||||||||||||||||||
| 512 | #ifndef QT_NO_CUPS | - | ||||||||||||||||||
| 513 | // Don't display Page Set if only Selection or Current Page are enabled | - | ||||||||||||||||||
| 514 | if (!q->isOptionEnabled(QPrintDialog::PrintPageRange)
| 0-1 | ||||||||||||||||||
| 515 | && (q->isOptionEnabled(QPrintDialog::PrintSelection) || q->isOptionEnabled(QPrintDialog::PrintCurrentPage))) {
| 0-1 | ||||||||||||||||||
| 516 | options.pageSetCombo->setVisible(false); | - | ||||||||||||||||||
| 517 | options.pageSetLabel->setVisible(false); | - | ||||||||||||||||||
| 518 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 519 | options.pageSetCombo->setVisible(true); | - | ||||||||||||||||||
| 520 | options.pageSetLabel->setVisible(true); | - | ||||||||||||||||||
| 521 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||
| 522 | - | |||||||||||||||||||
| 523 | if (!q->isOptionEnabled(QPrintDialog::PrintPageRange)) {
| 0-1 | ||||||||||||||||||
| 524 | // If we can do CUPS server side pages selection, | - | ||||||||||||||||||
| 525 | // display the page range widgets | - | ||||||||||||||||||
| 526 | options.gbPrintRange->setVisible(true); | - | ||||||||||||||||||
| 527 | options.printRange->setEnabled(true); | - | ||||||||||||||||||
| 528 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||
| 529 | #endif | - | ||||||||||||||||||
| 530 | - | |||||||||||||||||||
| 531 | switch (q->printRange()) { | - | ||||||||||||||||||
| 532 | case QPrintDialog::AllPages: executed 1 time by 1 test: case QPrintDialog::AllPages:Executed by:
| 1 | ||||||||||||||||||
| 533 | options.printAll->setChecked(true); | - | ||||||||||||||||||
| 534 | options.pageSetCombo->setEnabled(true); | - | ||||||||||||||||||
| 535 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||
| 536 | case QPrintDialog::Selection: never executed: case QPrintDialog::Selection: | 0 | ||||||||||||||||||
| 537 | options.printSelection->setChecked(true); | - | ||||||||||||||||||
| 538 | options.pageSetCombo->setEnabled(false); | - | ||||||||||||||||||
| 539 | break; never executed: break; | 0 | ||||||||||||||||||
| 540 | case QPrintDialog::PageRange: never executed: case QPrintDialog::PageRange: | 0 | ||||||||||||||||||
| 541 | options.printRange->setChecked(true); | - | ||||||||||||||||||
| 542 | options.pageSetCombo->setEnabled(true); | - | ||||||||||||||||||
| 543 | break; never executed: break; | 0 | ||||||||||||||||||
| 544 | case QPrintDialog::CurrentPage: never executed: case QPrintDialog::CurrentPage: | 0 | ||||||||||||||||||
| 545 | if (q->isOptionEnabled(QPrintDialog::PrintCurrentPage)) {
| 0 | ||||||||||||||||||
| 546 | options.printCurrentPage->setChecked(true); | - | ||||||||||||||||||
| 547 | options.pageSetCombo->setEnabled(false); | - | ||||||||||||||||||
| 548 | } never executed: end of block | 0 | ||||||||||||||||||
| 549 | break; never executed: break; | 0 | ||||||||||||||||||
| 550 | default: never executed: default: | 0 | ||||||||||||||||||
| 551 | break; never executed: break; | 0 | ||||||||||||||||||
| 552 | } | - | ||||||||||||||||||
| 553 | const int minPage = qMax(1, qMin(q->minPage() , q->maxPage())); | - | ||||||||||||||||||
| 554 | const int maxPage = qMax(1, q->maxPage() == INT_MAX ? 9999 : q->maxPage()); | - | ||||||||||||||||||
| 555 | - | |||||||||||||||||||
| 556 | options.from->setMinimum(minPage); | - | ||||||||||||||||||
| 557 | options.to->setMinimum(minPage); | - | ||||||||||||||||||
| 558 | options.from->setMaximum(maxPage); | - | ||||||||||||||||||
| 559 | options.to->setMaximum(maxPage); | - | ||||||||||||||||||
| 560 | - | |||||||||||||||||||
| 561 | options.from->setValue(q->fromPage()); | - | ||||||||||||||||||
| 562 | options.to->setValue(q->toPage()); | - | ||||||||||||||||||
| 563 | top->d->updateWidget(); | - | ||||||||||||||||||
| 564 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||
| 565 | - | |||||||||||||||||||
| 566 | void QPrintDialogPrivate::setTabs(const QList<QWidget*> &tabWidgets) | - | ||||||||||||||||||
| 567 | { | - | ||||||||||||||||||
| 568 | QList<QWidget*>::ConstIterator iter = tabWidgets.begin(); | - | ||||||||||||||||||
| 569 | while(iter != tabWidgets.constEnd()) {
| 0 | ||||||||||||||||||
| 570 | QWidget *tab = *iter; | - | ||||||||||||||||||
| 571 | options.tabs->addTab(tab, tab->windowTitle()); | - | ||||||||||||||||||
| 572 | ++iter; | - | ||||||||||||||||||
| 573 | } never executed: end of block | 0 | ||||||||||||||||||
| 574 | } never executed: end of block | 0 | ||||||||||||||||||
| 575 | - | |||||||||||||||||||
| 576 | //////////////////////////////////////////////////////////////////////////////// | - | ||||||||||||||||||
| 577 | //////////////////////////////////////////////////////////////////////////////// | - | ||||||||||||||||||
| 578 | - | |||||||||||||||||||
| 579 | /* | - | ||||||||||||||||||
| 580 | - | |||||||||||||||||||
| 581 | QPrintDialog | - | ||||||||||||||||||
| 582 | - | |||||||||||||||||||
| 583 | The main Print Dialog. | - | ||||||||||||||||||
| 584 | - | |||||||||||||||||||
| 585 | */ | - | ||||||||||||||||||
| 586 | - | |||||||||||||||||||
| 587 | QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent) | - | ||||||||||||||||||
| 588 | : QAbstractPrintDialog(*(new QPrintDialogPrivate), printer, parent) | - | ||||||||||||||||||
| 589 | { | - | ||||||||||||||||||
| 590 | Q_D(QPrintDialog); | - | ||||||||||||||||||
| 591 | d->init(); | - | ||||||||||||||||||
| 592 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 593 | - | |||||||||||||||||||
| 594 | /*! | - | ||||||||||||||||||
| 595 | Constructs a print dialog with the given \a parent. | - | ||||||||||||||||||
| 596 | */ | - | ||||||||||||||||||
| 597 | QPrintDialog::QPrintDialog(QWidget *parent) | - | ||||||||||||||||||
| 598 | : QAbstractPrintDialog(*(new QPrintDialogPrivate), 0, parent) | - | ||||||||||||||||||
| 599 | { | - | ||||||||||||||||||
| 600 | Q_D(QPrintDialog); | - | ||||||||||||||||||
| 601 | d->init(); | - | ||||||||||||||||||
| 602 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||
| 603 | - | |||||||||||||||||||
| 604 | QPrintDialog::~QPrintDialog() | - | ||||||||||||||||||
| 605 | { | - | ||||||||||||||||||
| 606 | } | - | ||||||||||||||||||
| 607 | - | |||||||||||||||||||
| 608 | void QPrintDialog::setVisible(bool visible) | - | ||||||||||||||||||
| 609 | { | - | ||||||||||||||||||
| 610 | Q_D(QPrintDialog); | - | ||||||||||||||||||
| 611 | - | |||||||||||||||||||
| 612 | if (visible)
| 0-1 | ||||||||||||||||||
| 613 | d->updateWidgets(); executed 1 time by 1 test: d->updateWidgets();Executed by:
| 1 | ||||||||||||||||||
| 614 | - | |||||||||||||||||||
| 615 | QAbstractPrintDialog::setVisible(visible); | - | ||||||||||||||||||
| 616 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||
| 617 | - | |||||||||||||||||||
| 618 | int QPrintDialog::exec() | - | ||||||||||||||||||
| 619 | { | - | ||||||||||||||||||
| 620 | return QDialog::exec(); never executed: return QDialog::exec(); | 0 | ||||||||||||||||||
| 621 | } | - | ||||||||||||||||||
| 622 | - | |||||||||||||||||||
| 623 | void QPrintDialog::accept() | - | ||||||||||||||||||
| 624 | { | - | ||||||||||||||||||
| 625 | Q_D(QPrintDialog); | - | ||||||||||||||||||
| 626 | d->setupPrinter(); | - | ||||||||||||||||||
| 627 | QDialog::accept(); | - | ||||||||||||||||||
| 628 | } never executed: end of block | 0 | ||||||||||||||||||
| 629 | - | |||||||||||||||||||
| 630 | //////////////////////////////////////////////////////////////////////////////// | - | ||||||||||||||||||
| 631 | //////////////////////////////////////////////////////////////////////////////// | - | ||||||||||||||||||
| 632 | - | |||||||||||||||||||
| 633 | /* | - | ||||||||||||||||||
| 634 | - | |||||||||||||||||||
| 635 | QUnixPrintWidget && QUnixPrintWidgetPrivate | - | ||||||||||||||||||
| 636 | - | |||||||||||||||||||
| 637 | The upper half of the Print Dialog containing the Printer Selection widgets | - | ||||||||||||||||||
| 638 | - | |||||||||||||||||||
| 639 | */ | - | ||||||||||||||||||
| 640 | - | |||||||||||||||||||
| 641 | #if defined (Q_OS_UNIX) | - | ||||||||||||||||||
| 642 | - | |||||||||||||||||||
| 643 | /*! \internal | - | ||||||||||||||||||
| 644 | */ | - | ||||||||||||||||||
| 645 | QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p, QPrinter *prn) | - | ||||||||||||||||||
| 646 | : parent(p), propertiesDialog(0), printer(prn), optionsPane(0), | - | ||||||||||||||||||
| 647 | filePrintersAdded(false), propertiesDialogShown(false) | - | ||||||||||||||||||
| 648 | { | - | ||||||||||||||||||
| 649 | q = 0; | - | ||||||||||||||||||
| 650 | if (parent)
| 0-3 | ||||||||||||||||||
| 651 | q = qobject_cast<QAbstractPrintDialog*> (parent->parent()); executed 3 times by 1 test: q = qobject_cast<QAbstractPrintDialog*> (parent->parent());Executed by:
| 3 | ||||||||||||||||||
| 652 | - | |||||||||||||||||||
| 653 | widget.setupUi(parent); | - | ||||||||||||||||||
| 654 | - | |||||||||||||||||||
| 655 | int currentPrinterIndex = 0; | - | ||||||||||||||||||
| 656 | QStringList printers; | - | ||||||||||||||||||
| 657 | QString defaultPrinter; | - | ||||||||||||||||||
| 658 | QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get(); | - | ||||||||||||||||||
| 659 | if (ps) {
| 0-3 | ||||||||||||||||||
| 660 | printers = ps->availablePrintDeviceIds(); | - | ||||||||||||||||||
| 661 | defaultPrinter = ps->defaultPrintDeviceId(); | - | ||||||||||||||||||
| 662 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||
| 663 | - | |||||||||||||||||||
| 664 | for (int i = 0; i < printers.size(); ++i) {
| 0-3 | ||||||||||||||||||
| 665 | widget.printers->addItem(printers.at(i)); | - | ||||||||||||||||||
| 666 | if (printers.at(i) == defaultPrinter)
| 0 | ||||||||||||||||||
| 667 | currentPrinterIndex = i; never executed: currentPrinterIndex = i; | 0 | ||||||||||||||||||
| 668 | } never executed: end of block | 0 | ||||||||||||||||||
| 669 | widget.properties->setEnabled(true); | - | ||||||||||||||||||
| 670 | - | |||||||||||||||||||
| 671 | #if !defined(QT_NO_FILESYSTEMMODEL) && !defined(QT_NO_COMPLETER) | - | ||||||||||||||||||
| 672 | QFileSystemModel *fsm = new QFileSystemModel(widget.filename); | - | ||||||||||||||||||
| 673 | fsm->setRootPath(QDir::homePath()); | - | ||||||||||||||||||
| 674 | widget.filename->setCompleter(new QCompleter(fsm, widget.filename)); | - | ||||||||||||||||||
| 675 | #endif | - | ||||||||||||||||||
| 676 | _q_printerChanged(currentPrinterIndex); | - | ||||||||||||||||||
| 677 | - | |||||||||||||||||||
| 678 | QObject::connect(widget.printers, SIGNAL(currentIndexChanged(int)), | - | ||||||||||||||||||
| 679 | parent, SLOT(_q_printerChanged(int))); | - | ||||||||||||||||||
| 680 | QObject::connect(widget.fileBrowser, SIGNAL(clicked()), parent, SLOT(_q_btnBrowseClicked())); | - | ||||||||||||||||||
| 681 | QObject::connect(widget.properties, SIGNAL(clicked()), parent, SLOT(_q_btnPropertiesClicked())); | - | ||||||||||||||||||
| 682 | - | |||||||||||||||||||
| 683 | // disable features that QPrinter does not yet support. | - | ||||||||||||||||||
| 684 | widget.preview->setVisible(false); | - | ||||||||||||||||||
| 685 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||
| 686 | - | |||||||||||||||||||
| 687 | void QUnixPrintWidgetPrivate::updateWidget() | - | ||||||||||||||||||
| 688 | { | - | ||||||||||||||||||
| 689 | const bool printToFile = q == 0 || q->isOptionEnabled(QPrintDialog::PrintToFile);
| 0-1 | ||||||||||||||||||
| 690 | if (printToFile && !filePrintersAdded) {
| 0-1 | ||||||||||||||||||
| 691 | if (widget.printers->count())
| 0-1 | ||||||||||||||||||
| 692 | widget.printers->insertSeparator(widget.printers->count()); never executed: widget.printers->insertSeparator(widget.printers->count()); | 0 | ||||||||||||||||||
| 693 | widget.printers->addItem(QPrintDialog::tr("Print to File (PDF)")); | - | ||||||||||||||||||
| 694 | filePrintersAdded = true; | - | ||||||||||||||||||
| 695 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||
| 696 | if (!printToFile && filePrintersAdded) {
| 0-1 | ||||||||||||||||||
| 697 | widget.printers->removeItem(widget.printers->count()-1); | - | ||||||||||||||||||
| 698 | widget.printers->removeItem(widget.printers->count()-1); | - | ||||||||||||||||||
| 699 | if (widget.printers->count())
| 0 | ||||||||||||||||||
| 700 | widget.printers->removeItem(widget.printers->count()-1); // remove separator never executed: widget.printers->removeItem(widget.printers->count()-1); | 0 | ||||||||||||||||||
| 701 | filePrintersAdded = false; | - | ||||||||||||||||||
| 702 | } never executed: end of block | 0 | ||||||||||||||||||
| 703 | if (printer && filePrintersAdded && (printer->outputFormat() != QPrinter::NativeFormat
| 0-1 | ||||||||||||||||||
| 704 | || printer->printerName().isEmpty()))
| 0 | ||||||||||||||||||
| 705 | { | - | ||||||||||||||||||
| 706 | if (printer->outputFormat() == QPrinter::PdfFormat)
| 0-1 | ||||||||||||||||||
| 707 | widget.printers->setCurrentIndex(widget.printers->count() - 1); executed 1 time by 1 test: widget.printers->setCurrentIndex(widget.printers->count() - 1);Executed by:
| 1 | ||||||||||||||||||
| 708 | widget.filename->setEnabled(true); | - | ||||||||||||||||||
| 709 | widget.lOutput->setEnabled(true); | - | ||||||||||||||||||
| 710 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||
| 711 | - | |||||||||||||||||||
| 712 | widget.filename->setVisible(printToFile); | - | ||||||||||||||||||
| 713 | widget.lOutput->setVisible(printToFile); | - | ||||||||||||||||||
| 714 | widget.fileBrowser->setVisible(printToFile); | - | ||||||||||||||||||
| 715 | - | |||||||||||||||||||
| 716 | widget.properties->setVisible(q->isOptionEnabled(QAbstractPrintDialog::PrintShowPageSize)); | - | ||||||||||||||||||
| 717 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||
| 718 | - | |||||||||||||||||||
| 719 | QUnixPrintWidgetPrivate::~QUnixPrintWidgetPrivate() | - | ||||||||||||||||||
| 720 | { | - | ||||||||||||||||||
| 721 | } | - | ||||||||||||||||||
| 722 | - | |||||||||||||||||||
| 723 | void QUnixPrintWidgetPrivate::_q_printerChanged(int index) | - | ||||||||||||||||||
| 724 | { | - | ||||||||||||||||||
| 725 | if (index < 0)
| 0-4 | ||||||||||||||||||
| 726 | return; never executed: return; | 0 | ||||||||||||||||||
| 727 | const int printerCount = widget.printers->count(); | - | ||||||||||||||||||
| 728 | widget.filename->setEnabled(false); | - | ||||||||||||||||||
| 729 | widget.lOutput->setEnabled(false); | - | ||||||||||||||||||
| 730 | - | |||||||||||||||||||
| 731 | // Reset properties dialog when printer is changed | - | ||||||||||||||||||
| 732 | if (propertiesDialog){
| 0-4 | ||||||||||||||||||
| 733 | delete propertiesDialog; | - | ||||||||||||||||||
| 734 | propertiesDialog = 0; | - | ||||||||||||||||||
| 735 | propertiesDialogShown = false; | - | ||||||||||||||||||
| 736 | } never executed: end of block | 0 | ||||||||||||||||||
| 737 | - | |||||||||||||||||||
| 738 | if (filePrintersAdded) {
| 0-4 | ||||||||||||||||||
| 739 | Q_ASSERT(index != printerCount - 2); // separator | - | ||||||||||||||||||
| 740 | if (index == printerCount - 1) { // PDF
| 0 | ||||||||||||||||||
| 741 | widget.location->setText(QPrintDialog::tr("Local file")); | - | ||||||||||||||||||
| 742 | widget.type->setText(QPrintDialog::tr("Write PDF file")); | - | ||||||||||||||||||
| 743 | widget.properties->setEnabled(true); | - | ||||||||||||||||||
| 744 | widget.filename->setEnabled(true); | - | ||||||||||||||||||
| 745 | QString filename = widget.filename->text(); | - | ||||||||||||||||||
| 746 | widget.filename->setText(filename); | - | ||||||||||||||||||
| 747 | widget.lOutput->setEnabled(true); | - | ||||||||||||||||||
| 748 | if (optionsPane)
| 0 | ||||||||||||||||||
| 749 | optionsPane->selectPrinter(QPrinter::PdfFormat); never executed: optionsPane->selectPrinter(QPrinter::PdfFormat); | 0 | ||||||||||||||||||
| 750 | return; never executed: return; | 0 | ||||||||||||||||||
| 751 | } | - | ||||||||||||||||||
| 752 | } never executed: end of block | 0 | ||||||||||||||||||
| 753 | - | |||||||||||||||||||
| 754 | if (printer) {
| 0-4 | ||||||||||||||||||
| 755 | QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get(); | - | ||||||||||||||||||
| 756 | if (ps)
| 0-4 | ||||||||||||||||||
| 757 | m_currentPrintDevice = ps->createPrintDevice(widget.printers->itemText(index)); executed 4 times by 1 test: m_currentPrintDevice = ps->createPrintDevice(widget.printers->itemText(index));Executed by:
| 4 | ||||||||||||||||||
| 758 | - | |||||||||||||||||||
| 759 | printer->setPrinterName(m_currentPrintDevice.id()); | - | ||||||||||||||||||
| 760 | - | |||||||||||||||||||
| 761 | widget.location->setText(m_currentPrintDevice.location()); | - | ||||||||||||||||||
| 762 | widget.type->setText(m_currentPrintDevice.makeAndModel()); | - | ||||||||||||||||||
| 763 | if (optionsPane)
| 1-3 | ||||||||||||||||||
| 764 | optionsPane->selectPrinter(QPrinter::NativeFormat); executed 1 time by 1 test: optionsPane->selectPrinter(QPrinter::NativeFormat);Executed by:
| 1 | ||||||||||||||||||
| 765 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||
| 766 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||
| 767 | - | |||||||||||||||||||
| 768 | void QUnixPrintWidgetPrivate::setOptionsPane(QPrintDialogPrivate *pane) | - | ||||||||||||||||||
| 769 | { | - | ||||||||||||||||||
| 770 | optionsPane = pane; | - | ||||||||||||||||||
| 771 | if (optionsPane)
| 0-3 | ||||||||||||||||||
| 772 | optionsPane->selectPrinter(QPrinter::NativeFormat); executed 3 times by 1 test: optionsPane->selectPrinter(QPrinter::NativeFormat);Executed by:
| 3 | ||||||||||||||||||
| 773 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||
| 774 | - | |||||||||||||||||||
| 775 | void QUnixPrintWidgetPrivate::_q_btnBrowseClicked() | - | ||||||||||||||||||
| 776 | { | - | ||||||||||||||||||
| 777 | QString filename = widget.filename->text(); | - | ||||||||||||||||||
| 778 | #ifndef QT_NO_FILEDIALOG | - | ||||||||||||||||||
| 779 | filename = QFileDialog::getSaveFileName(parent, QPrintDialog::tr("Print To File ..."), filename, | - | ||||||||||||||||||
| 780 | QString(), 0, QFileDialog::DontConfirmOverwrite); | - | ||||||||||||||||||
| 781 | #else | - | ||||||||||||||||||
| 782 | filename.clear(); | - | ||||||||||||||||||
| 783 | #endif | - | ||||||||||||||||||
| 784 | if (!filename.isEmpty()) {
| 0 | ||||||||||||||||||
| 785 | widget.filename->setText(filename); | - | ||||||||||||||||||
| 786 | widget.printers->setCurrentIndex(widget.printers->count() - 1); // the pdf one | - | ||||||||||||||||||
| 787 | } never executed: end of block | 0 | ||||||||||||||||||
| 788 | } never executed: end of block | 0 | ||||||||||||||||||
| 789 | - | |||||||||||||||||||
| 790 | void QUnixPrintWidgetPrivate::applyPrinterProperties() | - | ||||||||||||||||||
| 791 | { | - | ||||||||||||||||||
| 792 | if (printer == 0)
| 0-3 | ||||||||||||||||||
| 793 | return; never executed: return; | 0 | ||||||||||||||||||
| 794 | if (printer->outputFileName().isEmpty()) {
| 0-3 | ||||||||||||||||||
| 795 | QString home = QDir::homePath(); | - | ||||||||||||||||||
| 796 | QString cur = QDir::currentPath(); | - | ||||||||||||||||||
| 797 | if (home.at(home.length()-1) != QLatin1Char('/'))
| 0-3 | ||||||||||||||||||
| 798 | home += QLatin1Char('/'); executed 3 times by 1 test: home += QLatin1Char('/');Executed by:
| 3 | ||||||||||||||||||
| 799 | if (!cur.isEmpty() && cur.at(cur.length()-1) != QLatin1Char('/'))
| 0-3 | ||||||||||||||||||
| 800 | cur += QLatin1Char('/'); executed 3 times by 1 test: cur += QLatin1Char('/');Executed by:
| 3 | ||||||||||||||||||
| 801 | if (!cur.startsWith(home))
| 0-3 | ||||||||||||||||||
| 802 | cur = home; never executed: cur = home; | 0 | ||||||||||||||||||
| 803 | if (QGuiApplication::platformName() == QLatin1String("xcb")) {
| 0-3 | ||||||||||||||||||
| 804 | if (printer->docName().isEmpty()) {
| 0-3 | ||||||||||||||||||
| 805 | cur += QLatin1String("print.pdf"); | - | ||||||||||||||||||
| 806 | } else { executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||
| 807 | QRegExp re(QString::fromLatin1("(.*)\\.\\S+")); | - | ||||||||||||||||||
| 808 | if (re.exactMatch(printer->docName()))
| 0 | ||||||||||||||||||
| 809 | cur += re.cap(1); never executed: cur += re.cap(1); | 0 | ||||||||||||||||||
| 810 | else | - | ||||||||||||||||||
| 811 | cur += printer->docName(); never executed: cur += printer->docName(); | 0 | ||||||||||||||||||
| 812 | cur += QLatin1String(".pdf"); | - | ||||||||||||||||||
| 813 | } never executed: end of block | 0 | ||||||||||||||||||
| 814 | } // xcb | - | ||||||||||||||||||
| 815 | - | |||||||||||||||||||
| 816 | widget.filename->setText(cur); | - | ||||||||||||||||||
| 817 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||
| 818 | else | - | ||||||||||||||||||
| 819 | widget.filename->setText( printer->outputFileName() ); never executed: widget.filename->setText( printer->outputFileName() ); | 0 | ||||||||||||||||||
| 820 | QString printerName = printer->printerName(); | - | ||||||||||||||||||
| 821 | if (!printerName.isEmpty()) {
| 0-3 | ||||||||||||||||||
| 822 | for (int i = 0; i < widget.printers->count(); ++i) {
| 0 | ||||||||||||||||||
| 823 | if (widget.printers->itemText(i) == printerName) {
| 0 | ||||||||||||||||||
| 824 | widget.printers->setCurrentIndex(i); | - | ||||||||||||||||||
| 825 | break; never executed: break; | 0 | ||||||||||||||||||
| 826 | } | - | ||||||||||||||||||
| 827 | } never executed: end of block | 0 | ||||||||||||||||||
| 828 | } never executed: end of block | 0 | ||||||||||||||||||
| 829 | // PDF printer not added to the dialog yet, we'll handle those cases in QUnixPrintWidgetPrivate::updateWidget | - | ||||||||||||||||||
| 830 | - | |||||||||||||||||||
| 831 | if (propertiesDialog)
| 0-3 | ||||||||||||||||||
| 832 | propertiesDialog->applyPrinterProperties(printer); never executed: propertiesDialog->applyPrinterProperties(printer); | 0 | ||||||||||||||||||
| 833 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||
| 834 | - | |||||||||||||||||||
| 835 | #ifndef QT_NO_MESSAGEBOX | - | ||||||||||||||||||
| 836 | bool QUnixPrintWidgetPrivate::checkFields() | - | ||||||||||||||||||
| 837 | { | - | ||||||||||||||||||
| 838 | if (widget.filename->isEnabled()) {
| 0 | ||||||||||||||||||
| 839 | QString file = widget.filename->text(); | - | ||||||||||||||||||
| 840 | QFile f(file); | - | ||||||||||||||||||
| 841 | QFileInfo fi(f); | - | ||||||||||||||||||
| 842 | bool exists = fi.exists(); | - | ||||||||||||||||||
| 843 | bool opened = false; | - | ||||||||||||||||||
| 844 | if (exists && fi.isDir()) {
| 0 | ||||||||||||||||||
| 845 | QMessageBox::warning(q, q->windowTitle(), | - | ||||||||||||||||||
| 846 | QPrintDialog::tr("%1 is a directory.\nPlease choose a different file name.").arg(file)); | - | ||||||||||||||||||
| 847 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 848 | } else if ((exists && !fi.isWritable()) || !(opened = f.open(QFile::Append))) {
| 0 | ||||||||||||||||||
| 849 | QMessageBox::warning(q, q->windowTitle(), | - | ||||||||||||||||||
| 850 | QPrintDialog::tr("File %1 is not writable.\nPlease choose a different file name.").arg(file)); | - | ||||||||||||||||||
| 851 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 852 | } else if (exists) {
| 0 | ||||||||||||||||||
| 853 | int ret = QMessageBox::question(q, q->windowTitle(), | - | ||||||||||||||||||
| 854 | QPrintDialog::tr("%1 already exists.\nDo you want to overwrite it?").arg(file), | - | ||||||||||||||||||
| 855 | QMessageBox::Yes|QMessageBox::No, QMessageBox::No); | - | ||||||||||||||||||
| 856 | if (ret == QMessageBox::No)
| 0 | ||||||||||||||||||
| 857 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 858 | } never executed: end of block | 0 | ||||||||||||||||||
| 859 | if (opened) {
| 0 | ||||||||||||||||||
| 860 | f.close(); | - | ||||||||||||||||||
| 861 | if (!exists)
| 0 | ||||||||||||||||||
| 862 | f.remove(); never executed: f.remove(); | 0 | ||||||||||||||||||
| 863 | } never executed: end of block | 0 | ||||||||||||||||||
| 864 | } never executed: end of block | 0 | ||||||||||||||||||
| 865 | - | |||||||||||||||||||
| 866 | #ifndef QT_NO_CUPS | - | ||||||||||||||||||
| 867 | if (propertiesDialogShown) {
| 0 | ||||||||||||||||||
| 868 | QCUPSSupport::PagesPerSheet pagesPerSheet = propertiesDialog->widget.pageSetup->m_ui.pagesPerSheetCombo | - | ||||||||||||||||||
| 869 | ->currentData().value<QCUPSSupport::PagesPerSheet>(); | - | ||||||||||||||||||
| 870 | - | |||||||||||||||||||
| 871 | QCUPSSupport::PageSet pageSet = optionsPane->options.pageSetCombo->currentData().value<QCUPSSupport::PageSet>(); | - | ||||||||||||||||||
| 872 | - | |||||||||||||||||||
| 873 | - | |||||||||||||||||||
| 874 | if (pagesPerSheet != QCUPSSupport::OnePagePerSheet
| 0 | ||||||||||||||||||
| 875 | && pageSet != QCUPSSupport::AllPages) {
| 0 | ||||||||||||||||||
| 876 | QMessageBox::warning(q, q->windowTitle(), | - | ||||||||||||||||||
| 877 | QPrintDialog::tr("Options 'Pages Per Sheet' and 'Page Set' cannot be used together.\nPlease turn one of those options off.")); | - | ||||||||||||||||||
| 878 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 879 | } | - | ||||||||||||||||||
| 880 | } never executed: end of block | 0 | ||||||||||||||||||
| 881 | #endif | - | ||||||||||||||||||
| 882 | - | |||||||||||||||||||
| 883 | // Every test passed. Accept the dialog. | - | ||||||||||||||||||
| 884 | return true; never executed: return true; | 0 | ||||||||||||||||||
| 885 | } | - | ||||||||||||||||||
| 886 | #endif // QT_NO_MESSAGEBOX | - | ||||||||||||||||||
| 887 | - | |||||||||||||||||||
| 888 | void QUnixPrintWidgetPrivate::setupPrinterProperties() | - | ||||||||||||||||||
| 889 | { | - | ||||||||||||||||||
| 890 | if (propertiesDialog)
| 0 | ||||||||||||||||||
| 891 | delete propertiesDialog; never executed: delete propertiesDialog; | 0 | ||||||||||||||||||
| 892 | - | |||||||||||||||||||
| 893 | propertiesDialog = new QPrintPropertiesDialog(q); | - | ||||||||||||||||||
| 894 | propertiesDialog->setResult(QDialog::Rejected); | - | ||||||||||||||||||
| 895 | propertiesDialogShown = false; | - | ||||||||||||||||||
| 896 | - | |||||||||||||||||||
| 897 | propertiesDialog->applyPrinterProperties(q->printer()); | - | ||||||||||||||||||
| 898 | - | |||||||||||||||||||
| 899 | if (q->isOptionEnabled(QPrintDialog::PrintToFile)
| 0 | ||||||||||||||||||
| 900 | && (widget.printers->currentIndex() == widget.printers->count() - 1)) {// PDF
| 0 | ||||||||||||||||||
| 901 | propertiesDialog->selectPrinter(QPrinter::PdfFormat, QString()); | - | ||||||||||||||||||
| 902 | } never executed: end of block | 0 | ||||||||||||||||||
| 903 | else | - | ||||||||||||||||||
| 904 | propertiesDialog->selectPrinter(QPrinter::NativeFormat, widget.printers->currentText()); never executed: propertiesDialog->selectPrinter(QPrinter::NativeFormat, widget.printers->currentText()); | 0 | ||||||||||||||||||
| 905 | } | - | ||||||||||||||||||
| 906 | - | |||||||||||||||||||
| 907 | void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked() | - | ||||||||||||||||||
| 908 | { | - | ||||||||||||||||||
| 909 | if (!propertiesDialog)
| 0 | ||||||||||||||||||
| 910 | setupPrinterProperties(); never executed: setupPrinterProperties(); | 0 | ||||||||||||||||||
| 911 | propertiesDialog->exec(); | - | ||||||||||||||||||
| 912 | if (!propertiesDialogShown && propertiesDialog->result() == QDialog::Rejected) {
| 0 | ||||||||||||||||||
| 913 | // If properties dialog was rejected the dialog is deleted and | - | ||||||||||||||||||
| 914 | // the properties are set to defaults when printer is setup | - | ||||||||||||||||||
| 915 | delete propertiesDialog; | - | ||||||||||||||||||
| 916 | propertiesDialog = 0; | - | ||||||||||||||||||
| 917 | propertiesDialogShown = false; | - | ||||||||||||||||||
| 918 | } else never executed: end of block | 0 | ||||||||||||||||||
| 919 | // properties dialog was shown and accepted | - | ||||||||||||||||||
| 920 | propertiesDialogShown = true; never executed: propertiesDialogShown = true; | 0 | ||||||||||||||||||
| 921 | } | - | ||||||||||||||||||
| 922 | - | |||||||||||||||||||
| 923 | void QUnixPrintWidgetPrivate::setupPrinter() | - | ||||||||||||||||||
| 924 | { | - | ||||||||||||||||||
| 925 | const int printerCount = widget.printers->count(); | - | ||||||||||||||||||
| 926 | const int index = widget.printers->currentIndex(); | - | ||||||||||||||||||
| 927 | - | |||||||||||||||||||
| 928 | if (filePrintersAdded && index == printerCount - 1) { // PDF
| 0 | ||||||||||||||||||
| 929 | printer->setPrinterName(QString()); | - | ||||||||||||||||||
| 930 | Q_ASSERT(index != printerCount - 2); // separator | - | ||||||||||||||||||
| 931 | printer->setOutputFormat(QPrinter::PdfFormat); | - | ||||||||||||||||||
| 932 | QString path = widget.filename->text(); | - | ||||||||||||||||||
| 933 | if (QDir::isRelativePath(path))
| 0 | ||||||||||||||||||
| 934 | path = QDir::homePath() + QDir::separator() + path; never executed: path = QDir::homePath() + QDir::separator() + path; | 0 | ||||||||||||||||||
| 935 | printer->setOutputFileName(path); | - | ||||||||||||||||||
| 936 | } never executed: end of block | 0 | ||||||||||||||||||
| 937 | else { | - | ||||||||||||||||||
| 938 | printer->setPrinterName(widget.printers->currentText()); | - | ||||||||||||||||||
| 939 | printer->setOutputFileName(QString()); | - | ||||||||||||||||||
| 940 | } never executed: end of block | 0 | ||||||||||||||||||
| 941 | - | |||||||||||||||||||
| 942 | if (!propertiesDialog)
| 0 | ||||||||||||||||||
| 943 | setupPrinterProperties(); never executed: setupPrinterProperties(); | 0 | ||||||||||||||||||
| 944 | - | |||||||||||||||||||
| 945 | if (propertiesDialog->result() == QDialog::Accepted || !propertiesDialogShown)
| 0 | ||||||||||||||||||
| 946 | propertiesDialog->setupPrinter(); never executed: propertiesDialog->setupPrinter(); | 0 | ||||||||||||||||||
| 947 | } never executed: end of block | 0 | ||||||||||||||||||
| 948 | - | |||||||||||||||||||
| 949 | /*! \internal | - | ||||||||||||||||||
| 950 | */ | - | ||||||||||||||||||
| 951 | QUnixPrintWidget::QUnixPrintWidget(QPrinter *printer, QWidget *parent) | - | ||||||||||||||||||
| 952 | : QWidget(parent), d(new QUnixPrintWidgetPrivate(this, printer)) | - | ||||||||||||||||||
| 953 | { | - | ||||||||||||||||||
| 954 | d->applyPrinterProperties(); | - | ||||||||||||||||||
| 955 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||
| 956 | - | |||||||||||||||||||
| 957 | /*! \internal | - | ||||||||||||||||||
| 958 | */ | - | ||||||||||||||||||
| 959 | QUnixPrintWidget::~QUnixPrintWidget() | - | ||||||||||||||||||
| 960 | { | - | ||||||||||||||||||
| 961 | delete d; | - | ||||||||||||||||||
| 962 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||
| 963 | - | |||||||||||||||||||
| 964 | /*! \internal | - | ||||||||||||||||||
| 965 | - | |||||||||||||||||||
| 966 | Updates the printer with the states held in the QUnixPrintWidget. | - | ||||||||||||||||||
| 967 | */ | - | ||||||||||||||||||
| 968 | void QUnixPrintWidget::updatePrinter() | - | ||||||||||||||||||
| 969 | { | - | ||||||||||||||||||
| 970 | d->setupPrinter(); | - | ||||||||||||||||||
| 971 | } never executed: end of block | 0 | ||||||||||||||||||
| 972 | - | |||||||||||||||||||
| 973 | //////////////////////////////////////////////////////////////////////////////// | - | ||||||||||||||||||
| 974 | //////////////////////////////////////////////////////////////////////////////// | - | ||||||||||||||||||
| 975 | - | |||||||||||||||||||
| 976 | #endif // defined (Q_OS_UNIX) | - | ||||||||||||||||||
| 977 | - | |||||||||||||||||||
| 978 | QT_END_NAMESPACE | - | ||||||||||||||||||
| 979 | - | |||||||||||||||||||
| 980 | #include "moc_qprintdialog.cpp" | - | ||||||||||||||||||
| 981 | #include "qprintdialog_unix.moc" | - | ||||||||||||||||||
| 982 | - | |||||||||||||||||||
| 983 | #endif // QT_NO_PRINTDIALOG | - | ||||||||||||||||||
| 984 | - | |||||||||||||||||||
| Source code | Switch to Preprocessed file |