| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). | 
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com) | 
|---|
| 5 | ** | 
|---|
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | 
|---|
| 7 | ** | 
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
|---|
| 9 | ** Commercial Usage | 
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in | 
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the | 
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 13 | ** a written agreement between you and Nokia. | 
|---|
| 14 | ** | 
|---|
| 15 | ** GNU Lesser General Public License Usage | 
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software | 
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
|---|
| 19 | ** packaging of this file.  Please review the following information to | 
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | 
|---|
| 22 | ** | 
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain | 
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL | 
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this | 
|---|
| 26 | ** package. | 
|---|
| 27 | ** | 
|---|
| 28 | ** GNU General Public License Usage | 
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU | 
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software | 
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 32 | ** packaging of this file.  Please review the following information to | 
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be | 
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html. | 
|---|
| 35 | ** | 
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please | 
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com. | 
|---|
| 38 | ** $QT_END_LICENSE$ | 
|---|
| 39 | ** | 
|---|
| 40 | ****************************************************************************/ | 
|---|
| 41 |  | 
|---|
| 42 | #include "qabstractprintdialog_p.h" | 
|---|
| 43 | #include "qcoreapplication.h" | 
|---|
| 44 | #include "qprintdialog.h" | 
|---|
| 45 | #include "qprinter.h" | 
|---|
| 46 | #include "private/qprinter_p.h" | 
|---|
| 47 |  | 
|---|
| 48 | #ifndef QT_NO_PRINTDIALOG | 
|---|
| 49 |  | 
|---|
| 50 | QT_BEGIN_NAMESPACE | 
|---|
| 51 |  | 
|---|
| 52 | // hack | 
|---|
| 53 | class QPrintDialogPrivate : public QAbstractPrintDialogPrivate | 
|---|
| 54 | { | 
|---|
| 55 | }; | 
|---|
| 56 |  | 
|---|
| 57 | /*! | 
|---|
| 58 | \class QAbstractPrintDialog | 
|---|
| 59 | \brief The QAbstractPrintDialog class provides a base implementation for | 
|---|
| 60 | print dialogs used to configure printers. | 
|---|
| 61 |  | 
|---|
| 62 | This class implements getter and setter functions that are used to | 
|---|
| 63 | customize settings shown in print dialogs, but it is not used directly. | 
|---|
| 64 | Use QPrintDialog to display a print dialog in your application. | 
|---|
| 65 |  | 
|---|
| 66 | \sa QPrintDialog, QPrinter, {Printing with Qt} | 
|---|
| 67 | */ | 
|---|
| 68 |  | 
|---|
| 69 | /*! | 
|---|
| 70 | \enum QAbstractPrintDialog::PrintRange | 
|---|
| 71 |  | 
|---|
| 72 | Used to specify the print range selection option. | 
|---|
| 73 |  | 
|---|
| 74 | \value AllPages All pages should be printed. | 
|---|
| 75 | \value Selection Only the selection should be printed. | 
|---|
| 76 | \value PageRange The specified page range should be printed. | 
|---|
| 77 |  | 
|---|
| 78 | \sa QPrinter::PrintRange | 
|---|
| 79 | */ | 
|---|
| 80 |  | 
|---|
| 81 | /*! | 
|---|
| 82 | \enum QAbstractPrintDialog::PrintDialogOption | 
|---|
| 83 |  | 
|---|
| 84 | Used to specify which parts of the print dialog should be visible. | 
|---|
| 85 |  | 
|---|
| 86 | \value None None of the options are enabled. | 
|---|
| 87 | \value PrintToFile The print to file option is enabled. | 
|---|
| 88 | \value PrintSelection The print selection option is enabled. | 
|---|
| 89 | \value PrintPageRange The page range selection option is enabled. | 
|---|
| 90 | \value PrintCollateCopies | 
|---|
| 91 |  | 
|---|
| 92 | This value is obsolete and does nothing since Qt 4.5: | 
|---|
| 93 |  | 
|---|
| 94 | \value DontUseSheet In previous versions of Qt, exec() the print dialog | 
|---|
| 95 | would create a sheet by default the dialog was given a parent. | 
|---|
| 96 | This is no longer supported in Qt 4.5.  If you want to use sheets, use | 
|---|
| 97 | QPrintDialog::open() instead. | 
|---|
| 98 |  | 
|---|
| 99 | \value PrintShowPageSize  Show the page size + margins page only if this is enabled. | 
|---|
| 100 | */ | 
|---|
| 101 |  | 
|---|
| 102 | /*! | 
|---|
| 103 | Constructs an abstract print dialog for \a printer with \a parent | 
|---|
| 104 | as parent widget. | 
|---|
| 105 | */ | 
|---|
| 106 | QAbstractPrintDialog::QAbstractPrintDialog(QPrinter *printer, QWidget *parent) | 
|---|
| 107 | : QDialog(*(new QAbstractPrintDialogPrivate), parent) | 
|---|
| 108 | { | 
|---|
| 109 | Q_D(QAbstractPrintDialog); | 
|---|
| 110 | setWindowTitle(QCoreApplication::translate("QPrintDialog", "Print")); | 
|---|
| 111 | d->setPrinter(printer); | 
|---|
| 112 | } | 
|---|
| 113 |  | 
|---|
| 114 | /*! | 
|---|
| 115 | \internal | 
|---|
| 116 | */ | 
|---|
| 117 | QAbstractPrintDialog::QAbstractPrintDialog(QAbstractPrintDialogPrivate &ptr, | 
|---|
| 118 | QPrinter *printer, | 
|---|
| 119 | QWidget *parent) | 
|---|
| 120 | : QDialog(ptr, parent) | 
|---|
| 121 | { | 
|---|
| 122 | Q_D(QAbstractPrintDialog); | 
|---|
| 123 | setWindowTitle(QCoreApplication::translate("QPrintDialog", "Print")); | 
|---|
| 124 | d->setPrinter(printer); | 
|---|
| 125 | } | 
|---|
| 126 |  | 
|---|
| 127 | /*! | 
|---|
| 128 | \internal | 
|---|
| 129 | */ | 
|---|
| 130 | QAbstractPrintDialog::~QAbstractPrintDialog() | 
|---|
| 131 | { | 
|---|
| 132 | Q_D(QAbstractPrintDialog); | 
|---|
| 133 | if (d->ownsPrinter) | 
|---|
| 134 | delete d->printer; | 
|---|
| 135 | } | 
|---|
| 136 |  | 
|---|
| 137 | /*! | 
|---|
| 138 | Sets the given \a option to be enabled if \a on is true; | 
|---|
| 139 | otherwise, clears the given \a option. | 
|---|
| 140 |  | 
|---|
| 141 | \sa options, testOption() | 
|---|
| 142 | */ | 
|---|
| 143 | void QPrintDialog::setOption(PrintDialogOption option, bool on) | 
|---|
| 144 | { | 
|---|
| 145 | Q_D(QPrintDialog); | 
|---|
| 146 | if (!(d->pd->options & option) != !on) | 
|---|
| 147 | setOptions(d->pd->options ^ option); | 
|---|
| 148 | } | 
|---|
| 149 |  | 
|---|
| 150 | /*! | 
|---|
| 151 | Returns true if the given \a option is enabled; otherwise, returns | 
|---|
| 152 | false. | 
|---|
| 153 |  | 
|---|
| 154 | \sa options, setOption() | 
|---|
| 155 | */ | 
|---|
| 156 | bool QPrintDialog::testOption(PrintDialogOption option) const | 
|---|
| 157 | { | 
|---|
| 158 | Q_D(const QPrintDialog); | 
|---|
| 159 | return (d->pd->options & option) != 0; | 
|---|
| 160 | } | 
|---|
| 161 |  | 
|---|
| 162 | /*! | 
|---|
| 163 | \property QPrintDialog::options | 
|---|
| 164 | \brief the various options that affect the look and feel of the dialog | 
|---|
| 165 | \since 4.5 | 
|---|
| 166 |  | 
|---|
| 167 | By default, all options are disabled. | 
|---|
| 168 |  | 
|---|
| 169 | Options should be set before showing the dialog. Setting them while the | 
|---|
| 170 | dialog is visible is not guaranteed to have an immediate effect on the | 
|---|
| 171 | dialog (depending on the option and on the platform). | 
|---|
| 172 |  | 
|---|
| 173 | \sa setOption(), testOption() | 
|---|
| 174 | */ | 
|---|
| 175 | void QPrintDialog::setOptions(PrintDialogOptions options) | 
|---|
| 176 | { | 
|---|
| 177 | Q_D(QPrintDialog); | 
|---|
| 178 |  | 
|---|
| 179 | PrintDialogOptions changed = (options ^ d->pd->options); | 
|---|
| 180 | if (!changed) | 
|---|
| 181 | return; | 
|---|
| 182 |  | 
|---|
| 183 | d->pd->options = options; | 
|---|
| 184 | } | 
|---|
| 185 |  | 
|---|
| 186 | QPrintDialog::PrintDialogOptions QPrintDialog::options() const | 
|---|
| 187 | { | 
|---|
| 188 | Q_D(const QPrintDialog); | 
|---|
| 189 | return d->pd->options; | 
|---|
| 190 | } | 
|---|
| 191 |  | 
|---|
| 192 | /*! | 
|---|
| 193 | \obsolete | 
|---|
| 194 |  | 
|---|
| 195 | Use QPrintDialog::setOptions() instead. | 
|---|
| 196 | */ | 
|---|
| 197 | void QAbstractPrintDialog::setEnabledOptions(PrintDialogOptions options) | 
|---|
| 198 | { | 
|---|
| 199 | Q_D(QAbstractPrintDialog); | 
|---|
| 200 | d->pd->options = options; | 
|---|
| 201 | } | 
|---|
| 202 |  | 
|---|
| 203 | /*! | 
|---|
| 204 | \obsolete | 
|---|
| 205 |  | 
|---|
| 206 | Use QPrintDialog::setOption(\a option, true) instead. | 
|---|
| 207 | */ | 
|---|
| 208 | void QAbstractPrintDialog::addEnabledOption(PrintDialogOption option) | 
|---|
| 209 | { | 
|---|
| 210 | Q_D(QAbstractPrintDialog); | 
|---|
| 211 | d->pd->options |= option; | 
|---|
| 212 | } | 
|---|
| 213 |  | 
|---|
| 214 | /*! | 
|---|
| 215 | \obsolete | 
|---|
| 216 |  | 
|---|
| 217 | Use QPrintDialog::options() instead. | 
|---|
| 218 | */ | 
|---|
| 219 | QAbstractPrintDialog::PrintDialogOptions QAbstractPrintDialog::enabledOptions() const | 
|---|
| 220 | { | 
|---|
| 221 | Q_D(const QAbstractPrintDialog); | 
|---|
| 222 | return d->pd->options; | 
|---|
| 223 | } | 
|---|
| 224 |  | 
|---|
| 225 | /*! | 
|---|
| 226 | \obsolete | 
|---|
| 227 |  | 
|---|
| 228 | Use QPrintDialog::testOption(\a option) instead. | 
|---|
| 229 | */ | 
|---|
| 230 | bool QAbstractPrintDialog::isOptionEnabled(PrintDialogOption option) const | 
|---|
| 231 | { | 
|---|
| 232 | Q_D(const QAbstractPrintDialog); | 
|---|
| 233 | return d->pd->options & option; | 
|---|
| 234 | } | 
|---|
| 235 |  | 
|---|
| 236 | /*! | 
|---|
| 237 | Sets the print range option in to be \a range. | 
|---|
| 238 | */ | 
|---|
| 239 | void QAbstractPrintDialog::setPrintRange(PrintRange range) | 
|---|
| 240 | { | 
|---|
| 241 | Q_D(QAbstractPrintDialog); | 
|---|
| 242 | d->pd->printRange = range; | 
|---|
| 243 | } | 
|---|
| 244 |  | 
|---|
| 245 | /*! | 
|---|
| 246 | Returns the print range. | 
|---|
| 247 | */ | 
|---|
| 248 | QAbstractPrintDialog::PrintRange QAbstractPrintDialog::printRange() const | 
|---|
| 249 | { | 
|---|
| 250 | Q_D(const QAbstractPrintDialog); | 
|---|
| 251 | return d->pd->printRange; | 
|---|
| 252 | } | 
|---|
| 253 |  | 
|---|
| 254 | /*! | 
|---|
| 255 | Sets the page range in this dialog to be from \a min to \a max. This also | 
|---|
| 256 | enables the PrintPageRange option. | 
|---|
| 257 | */ | 
|---|
| 258 | void QAbstractPrintDialog::setMinMax(int min, int max) | 
|---|
| 259 | { | 
|---|
| 260 | Q_D(QAbstractPrintDialog); | 
|---|
| 261 | Q_ASSERT_X(min <= max, "QAbstractPrintDialog::setMinMax", | 
|---|
| 262 | "'min' must be less than or equal to 'max'"); | 
|---|
| 263 | d->pd->minPage = min; | 
|---|
| 264 | d->pd->maxPage = max; | 
|---|
| 265 | d->pd->options |= PrintPageRange; | 
|---|
| 266 | } | 
|---|
| 267 |  | 
|---|
| 268 | /*! | 
|---|
| 269 | Returns the minimum page in the page range. | 
|---|
| 270 | By default, this value is set to 1. | 
|---|
| 271 | */ | 
|---|
| 272 | int QAbstractPrintDialog::minPage() const | 
|---|
| 273 | { | 
|---|
| 274 | Q_D(const QAbstractPrintDialog); | 
|---|
| 275 | return d->pd->minPage; | 
|---|
| 276 | } | 
|---|
| 277 |  | 
|---|
| 278 | /*! | 
|---|
| 279 | Returns the maximum page in the page range. As of Qt 4.4, this | 
|---|
| 280 | function returns INT_MAX by default. Previous versions returned 1 | 
|---|
| 281 | by default. | 
|---|
| 282 | */ | 
|---|
| 283 | int QAbstractPrintDialog::maxPage() const | 
|---|
| 284 | { | 
|---|
| 285 | Q_D(const QAbstractPrintDialog); | 
|---|
| 286 | return d->pd->maxPage; | 
|---|
| 287 | } | 
|---|
| 288 |  | 
|---|
| 289 | /*! | 
|---|
| 290 | Sets the range in the print dialog to be from \a from to \a to. | 
|---|
| 291 | */ | 
|---|
| 292 | void QAbstractPrintDialog::setFromTo(int from, int to) | 
|---|
| 293 | { | 
|---|
| 294 | Q_D(QAbstractPrintDialog); | 
|---|
| 295 | Q_ASSERT_X(from <= to, "QAbstractPrintDialog::setFromTo", | 
|---|
| 296 | "'from' must be less than or equal to 'to'"); | 
|---|
| 297 | d->pd->fromPage = from; | 
|---|
| 298 | d->pd->toPage = to; | 
|---|
| 299 |  | 
|---|
| 300 | if (d->pd->minPage == 0 && d->pd->maxPage == 0) | 
|---|
| 301 | setMinMax(1, to); | 
|---|
| 302 | } | 
|---|
| 303 |  | 
|---|
| 304 | /*! | 
|---|
| 305 | Returns the first page to be printed | 
|---|
| 306 | By default, this value is set to 0. | 
|---|
| 307 | */ | 
|---|
| 308 | int QAbstractPrintDialog::fromPage() const | 
|---|
| 309 | { | 
|---|
| 310 | Q_D(const QAbstractPrintDialog); | 
|---|
| 311 | return d->pd->fromPage; | 
|---|
| 312 | } | 
|---|
| 313 |  | 
|---|
| 314 | /*! | 
|---|
| 315 | Returns the last page to be printed. | 
|---|
| 316 | By default, this value is set to 0. | 
|---|
| 317 | */ | 
|---|
| 318 | int QAbstractPrintDialog::toPage() const | 
|---|
| 319 | { | 
|---|
| 320 | Q_D(const QAbstractPrintDialog); | 
|---|
| 321 | return d->pd->toPage; | 
|---|
| 322 | } | 
|---|
| 323 |  | 
|---|
| 324 |  | 
|---|
| 325 | /*! | 
|---|
| 326 | Returns the printer that this printer dialog operates | 
|---|
| 327 | on. | 
|---|
| 328 | */ | 
|---|
| 329 | QPrinter *QAbstractPrintDialog::printer() const | 
|---|
| 330 | { | 
|---|
| 331 | Q_D(const QAbstractPrintDialog); | 
|---|
| 332 | return d->printer; | 
|---|
| 333 | } | 
|---|
| 334 |  | 
|---|
| 335 | void QAbstractPrintDialogPrivate::setPrinter(QPrinter *newPrinter) | 
|---|
| 336 | { | 
|---|
| 337 | if (newPrinter) { | 
|---|
| 338 | printer = newPrinter; | 
|---|
| 339 | ownsPrinter = false; | 
|---|
| 340 | } else { | 
|---|
| 341 | printer = new QPrinter; | 
|---|
| 342 | ownsPrinter = true; | 
|---|
| 343 | } | 
|---|
| 344 | pd = printer->d_func(); | 
|---|
| 345 | } | 
|---|
| 346 |  | 
|---|
| 347 | /*! | 
|---|
| 348 | \fn int QAbstractPrintDialog::exec() | 
|---|
| 349 |  | 
|---|
| 350 | This virtual function is called to pop up the dialog. It must be | 
|---|
| 351 | reimplemented in subclasses. | 
|---|
| 352 | */ | 
|---|
| 353 |  | 
|---|
| 354 | /*! | 
|---|
| 355 | \class QPrintDialog | 
|---|
| 356 |  | 
|---|
| 357 | \brief The QPrintDialog class provides a dialog for specifying | 
|---|
| 358 | the printer's configuration. | 
|---|
| 359 |  | 
|---|
| 360 | \ingroup dialogs | 
|---|
| 361 |  | 
|---|
| 362 | The dialog allows users to change document-related settings, such | 
|---|
| 363 | as the paper size and orientation, type of print (color or | 
|---|
| 364 | grayscale), range of pages, and number of copies to print. | 
|---|
| 365 |  | 
|---|
| 366 | Controls are also provided to enable users to choose from the | 
|---|
| 367 | printers available, including any configured network printers. | 
|---|
| 368 |  | 
|---|
| 369 | Typically, QPrintDialog objects are constructed with a QPrinter | 
|---|
| 370 | object, and executed using the exec() function. | 
|---|
| 371 |  | 
|---|
| 372 | \snippet doc/src/snippets/code/src_gui_dialogs_qabstractprintdialog.cpp 0 | 
|---|
| 373 |  | 
|---|
| 374 | If the dialog is accepted by the user, the QPrinter object is | 
|---|
| 375 | correctly configured for printing. | 
|---|
| 376 |  | 
|---|
| 377 | \raw HTML | 
|---|
| 378 | <table align="center"> | 
|---|
| 379 | <tr><td> | 
|---|
| 380 | \endraw | 
|---|
| 381 | \inlineimage plastique-printdialog.png | 
|---|
| 382 | \raw HTML | 
|---|
| 383 | </td><td> | 
|---|
| 384 | \endraw | 
|---|
| 385 | \inlineimage plastique-printdialog-properties.png | 
|---|
| 386 | \raw HTML | 
|---|
| 387 | </td></tr> | 
|---|
| 388 | </table> | 
|---|
| 389 | \endraw | 
|---|
| 390 |  | 
|---|
| 391 | The printer dialog (shown above in Plastique style) enables access to common | 
|---|
| 392 | printing properties. On X11 platforms that use the CUPS printing system, the | 
|---|
| 393 | settings for each available printer can be modified via the dialog's | 
|---|
| 394 | \gui{Properties} push button. | 
|---|
| 395 |  | 
|---|
| 396 | On Windows and Mac OS X, the native print dialog is used, which means that | 
|---|
| 397 | some QWidget and QDialog properties set on the dialog won't be respected. | 
|---|
| 398 | The native print dialog on | 
|---|
| 399 | Mac OS X does not support setting printer options, i.e. | 
|---|
| 400 | QAbstractPrintDialog::setEnabledOptions() and | 
|---|
| 401 | QAbstractPrintDialog::addEnabledOption() have no effect. | 
|---|
| 402 |  | 
|---|
| 403 | In Qt 4.4, it was possible to use the satic functions to show a sheet on | 
|---|
| 404 | Mac OS X. This is no longer supported in Qt 4.5. If you want this | 
|---|
| 405 | functionality, use QPrintDialog::open(). | 
|---|
| 406 |  | 
|---|
| 407 | \sa QPageSetupDialog, QPrinter, {Pixelator Example}, {Order Form Example}, | 
|---|
| 408 | {Image Viewer Example}, {Scribble Example} | 
|---|
| 409 | */ | 
|---|
| 410 |  | 
|---|
| 411 | /*! | 
|---|
| 412 | \fn QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent) | 
|---|
| 413 |  | 
|---|
| 414 | Constructs a new modal printer dialog for the given \a printer | 
|---|
| 415 | with the given \a parent. | 
|---|
| 416 | */ | 
|---|
| 417 |  | 
|---|
| 418 | /*! | 
|---|
| 419 | \fn QPrintDialog::~QPrintDialog() | 
|---|
| 420 |  | 
|---|
| 421 | Destroys the print dialog. | 
|---|
| 422 | */ | 
|---|
| 423 |  | 
|---|
| 424 | /*! | 
|---|
| 425 | \fn int QPrintDialog::exec() | 
|---|
| 426 | \reimp | 
|---|
| 427 | */ | 
|---|
| 428 |  | 
|---|
| 429 | /*! | 
|---|
| 430 | \since 4.4 | 
|---|
| 431 |  | 
|---|
| 432 | Set a list of widgets as \a tabs to be shown on the print dialog, if supported. | 
|---|
| 433 |  | 
|---|
| 434 | Currently this option is only supported on X11. | 
|---|
| 435 |  | 
|---|
| 436 | Setting the option tabs will transfer their ownership to the print dialog. | 
|---|
| 437 | */ | 
|---|
| 438 | void QAbstractPrintDialog::setOptionTabs(const QList<QWidget*> &tabs) | 
|---|
| 439 | { | 
|---|
| 440 | Q_D(QAbstractPrintDialog); | 
|---|
| 441 | d->setTabs(tabs); | 
|---|
| 442 | } | 
|---|
| 443 |  | 
|---|
| 444 | /*! | 
|---|
| 445 |  | 
|---|
| 446 | \fn void QPrintDialog::accepted(QPrinter *printer) | 
|---|
| 447 |  | 
|---|
| 448 | This signal is emitted when the user accepts the values set in the print dialog. | 
|---|
| 449 | The \a printer parameter includes the printer that the settings were applied to. | 
|---|
| 450 | */ | 
|---|
| 451 |  | 
|---|
| 452 | /*! | 
|---|
| 453 | \fn QPrinter *QPrintDialog::printer() | 
|---|
| 454 |  | 
|---|
| 455 | Returns the printer that this printer dialog operates | 
|---|
| 456 | on. This can be useful when using the QPrintDialog::open() method. | 
|---|
| 457 | */ | 
|---|
| 458 |  | 
|---|
| 459 | /*! | 
|---|
| 460 | Closes the dialog and sets its result code to \a result. If this dialog | 
|---|
| 461 | is shown with exec(), done() causes the local event loop to finish, | 
|---|
| 462 | and exec() to return \a result. | 
|---|
| 463 |  | 
|---|
| 464 | \sa QDialog::done() | 
|---|
| 465 | */ | 
|---|
| 466 | void QPrintDialog::done(int result) | 
|---|
| 467 | { | 
|---|
| 468 | Q_D(QPrintDialog); | 
|---|
| 469 | QDialog::done(result); | 
|---|
| 470 | if (result == Accepted) | 
|---|
| 471 | emit accepted(printer()); | 
|---|
| 472 | if (d->receiverToDisconnectOnClose) { | 
|---|
| 473 | disconnect(this, SIGNAL(accepted(QPrinter*)), | 
|---|
| 474 | d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); | 
|---|
| 475 | d->receiverToDisconnectOnClose = 0; | 
|---|
| 476 | } | 
|---|
| 477 | d->memberToDisconnectOnClose.clear(); | 
|---|
| 478 | } | 
|---|
| 479 |  | 
|---|
| 480 | /*! | 
|---|
| 481 | \since 4.5 | 
|---|
| 482 | \overload | 
|---|
| 483 |  | 
|---|
| 484 | Opens the dialog and connects its accepted() signal to the slot specified | 
|---|
| 485 | by \a receiver and \a member. | 
|---|
| 486 |  | 
|---|
| 487 | The signal will be disconnected from the slot when the dialog is closed. | 
|---|
| 488 | */ | 
|---|
| 489 | void QPrintDialog::open(QObject *receiver, const char *member) | 
|---|
| 490 | { | 
|---|
| 491 | Q_D(QPrintDialog); | 
|---|
| 492 | connect(this, SIGNAL(accepted(QPrinter*)), receiver, member); | 
|---|
| 493 | d->receiverToDisconnectOnClose = receiver; | 
|---|
| 494 | d->memberToDisconnectOnClose = member; | 
|---|
| 495 | QDialog::open(); | 
|---|
| 496 | } | 
|---|
| 497 |  | 
|---|
| 498 | QT_END_NAMESPACE | 
|---|
| 499 |  | 
|---|
| 500 | #endif // QT_NO_PRINTDIALOG | 
|---|