| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 
|---|
| 4 | ** All rights reserved. | 
|---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com) | 
|---|
| 6 | ** | 
|---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit. | 
|---|
| 8 | ** | 
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$ | 
|---|
| 10 | ** Commercial Usage | 
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in | 
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the | 
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 14 | ** a written agreement between you and Nokia. | 
|---|
| 15 | ** | 
|---|
| 16 | ** GNU Lesser General Public License Usage | 
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software | 
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
|---|
| 20 | ** packaging of this file.  Please review the following information to | 
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | 
|---|
| 23 | ** | 
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional | 
|---|
| 25 | ** rights.  These rights are described in the Nokia Qt LGPL Exception | 
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this 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 have questions regarding the use of this file, please contact | 
|---|
| 37 | ** Nokia at qt-info@nokia.com. | 
|---|
| 38 | ** $QT_END_LICENSE$ | 
|---|
| 39 | ** | 
|---|
| 40 | ****************************************************************************/ | 
|---|
| 41 |  | 
|---|
| 42 | #include <private/qabstractpagesetupdialog_p.h> | 
|---|
| 43 |  | 
|---|
| 44 | #ifndef QT_NO_PRINTDIALOG | 
|---|
| 45 |  | 
|---|
| 46 | QT_BEGIN_NAMESPACE | 
|---|
| 47 |  | 
|---|
| 48 | /*! | 
|---|
| 49 | \class QPageSetupDialog | 
|---|
| 50 |  | 
|---|
| 51 | \brief The QPageSetupDialog class provides a configuration dialog | 
|---|
| 52 | for the page-related options on a printer. | 
|---|
| 53 |  | 
|---|
| 54 | \ingroup standard-dialogs | 
|---|
| 55 | \ingroup printing | 
|---|
| 56 |  | 
|---|
| 57 | On Windows and Mac OS X the page setup dialog is implemented using | 
|---|
| 58 | the native page setup dialogs. | 
|---|
| 59 |  | 
|---|
| 60 | Note that on Windows and Mac OS X custom paper sizes won't be | 
|---|
| 61 | reflected in the native page setup dialogs. Additionally, custom | 
|---|
| 62 | page margins set on a QPrinter won't show in the native Mac OS X | 
|---|
| 63 | page setup dialog. | 
|---|
| 64 |  | 
|---|
| 65 | \sa QPrinter, QPrintDialog | 
|---|
| 66 | */ | 
|---|
| 67 |  | 
|---|
| 68 |  | 
|---|
| 69 | /*! | 
|---|
| 70 | \fn QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent) | 
|---|
| 71 |  | 
|---|
| 72 | Constructs a page setup dialog that configures \a printer with \a | 
|---|
| 73 | parent as the parent widget. | 
|---|
| 74 | */ | 
|---|
| 75 |  | 
|---|
| 76 | /*! | 
|---|
| 77 | \since 4.5 | 
|---|
| 78 |  | 
|---|
| 79 | \fn QPageSetupDialog::QPageSetupDialog(QWidget *parent) | 
|---|
| 80 |  | 
|---|
| 81 | Constructs a page setup dialog that configures a default-constructed | 
|---|
| 82 | QPrinter with \a parent as the parent widget. | 
|---|
| 83 |  | 
|---|
| 84 | \sa printer() | 
|---|
| 85 | */ | 
|---|
| 86 |  | 
|---|
| 87 | /*! | 
|---|
| 88 | \fn QPrinter *QPageSetupDialog::printer() | 
|---|
| 89 |  | 
|---|
| 90 | Returns the printer that was passed to the QPageSetupDialog | 
|---|
| 91 | constructor. | 
|---|
| 92 | */ | 
|---|
| 93 |  | 
|---|
| 94 | // hack | 
|---|
| 95 | class QPageSetupDialogPrivate : public QAbstractPageSetupDialogPrivate | 
|---|
| 96 | { | 
|---|
| 97 | }; | 
|---|
| 98 |  | 
|---|
| 99 | /*! | 
|---|
| 100 | \enum QPageSetupDialog::PageSetupDialogOption | 
|---|
| 101 | \since 4.4 | 
|---|
| 102 |  | 
|---|
| 103 | Used to specify options to the page setup dialog | 
|---|
| 104 |  | 
|---|
| 105 | This value is obsolete and does nothing since Qt 4.5: | 
|---|
| 106 |  | 
|---|
| 107 | \value DontUseSheet In previous versions of Qt, exec() the page setup dialog | 
|---|
| 108 | would create a sheet by default if the dialog was given a parent. | 
|---|
| 109 | This is no longer supported in Qt 4.5.  If you want to use sheets, use | 
|---|
| 110 | QPageSetupDialog::open() instead. | 
|---|
| 111 |  | 
|---|
| 112 | \omitvalue None | 
|---|
| 113 | \omitvalue OwnsPrinter | 
|---|
| 114 | */ | 
|---|
| 115 |  | 
|---|
| 116 | /*! | 
|---|
| 117 | Sets the given \a option to be enabled if \a on is true; | 
|---|
| 118 | otherwise, clears the given \a option. | 
|---|
| 119 |  | 
|---|
| 120 | \sa options, testOption() | 
|---|
| 121 | */ | 
|---|
| 122 | void QPageSetupDialog::setOption(PageSetupDialogOption option, bool on) | 
|---|
| 123 | { | 
|---|
| 124 | Q_D(QPageSetupDialog); | 
|---|
| 125 | if (!(d->opts & option) != !on) | 
|---|
| 126 | setOptions(d->opts ^ option); | 
|---|
| 127 | } | 
|---|
| 128 |  | 
|---|
| 129 | /*! | 
|---|
| 130 | Returns true if the given \a option is enabled; otherwise, returns | 
|---|
| 131 | false. | 
|---|
| 132 |  | 
|---|
| 133 | \sa options, setOption() | 
|---|
| 134 | */ | 
|---|
| 135 | bool QPageSetupDialog::testOption(PageSetupDialogOption option) const | 
|---|
| 136 | { | 
|---|
| 137 | Q_D(const QPageSetupDialog); | 
|---|
| 138 | return (d->opts & option) != 0; | 
|---|
| 139 | } | 
|---|
| 140 |  | 
|---|
| 141 | /*! | 
|---|
| 142 | \property QPageSetupDialog::options | 
|---|
| 143 | \brief the various options that affect the look and feel of the dialog | 
|---|
| 144 | \since 4.5 | 
|---|
| 145 |  | 
|---|
| 146 | By default, all options are disabled. | 
|---|
| 147 |  | 
|---|
| 148 | Options should be set before showing the dialog. Setting them while the | 
|---|
| 149 | dialog is visible is not guaranteed to have an immediate effect on the | 
|---|
| 150 | dialog (depending on the option and on the platform). | 
|---|
| 151 |  | 
|---|
| 152 | \sa setOption(), testOption() | 
|---|
| 153 | */ | 
|---|
| 154 | void QPageSetupDialog::setOptions(PageSetupDialogOptions options) | 
|---|
| 155 | { | 
|---|
| 156 | Q_D(QPageSetupDialog); | 
|---|
| 157 |  | 
|---|
| 158 | PageSetupDialogOptions changed = (options ^ d->opts); | 
|---|
| 159 | if (!changed) | 
|---|
| 160 | return; | 
|---|
| 161 |  | 
|---|
| 162 | d->opts = options; | 
|---|
| 163 | } | 
|---|
| 164 |  | 
|---|
| 165 | QPageSetupDialog::PageSetupDialogOptions QPageSetupDialog::options() const | 
|---|
| 166 | { | 
|---|
| 167 | Q_D(const QPageSetupDialog); | 
|---|
| 168 | return d->opts; | 
|---|
| 169 | } | 
|---|
| 170 |  | 
|---|
| 171 | /*! | 
|---|
| 172 | \obsolete | 
|---|
| 173 |  | 
|---|
| 174 | Use setOption(\a option, true) instead. | 
|---|
| 175 | */ | 
|---|
| 176 | void QPageSetupDialog::addEnabledOption(PageSetupDialogOption option) | 
|---|
| 177 | { | 
|---|
| 178 | setOption(option, true); | 
|---|
| 179 | } | 
|---|
| 180 |  | 
|---|
| 181 | /*! | 
|---|
| 182 | \obsolete | 
|---|
| 183 |  | 
|---|
| 184 | Use setOptions(\a options) instead. | 
|---|
| 185 | */ | 
|---|
| 186 | void QPageSetupDialog::setEnabledOptions(PageSetupDialogOptions options) | 
|---|
| 187 | { | 
|---|
| 188 | setOptions(options); | 
|---|
| 189 | } | 
|---|
| 190 |  | 
|---|
| 191 | /*! | 
|---|
| 192 | \obsolete | 
|---|
| 193 |  | 
|---|
| 194 | Use options() instead. | 
|---|
| 195 | */ | 
|---|
| 196 | QPageSetupDialog::PageSetupDialogOptions QPageSetupDialog::enabledOptions() const | 
|---|
| 197 | { | 
|---|
| 198 | return options(); | 
|---|
| 199 | } | 
|---|
| 200 |  | 
|---|
| 201 | /*! | 
|---|
| 202 | \obsolete | 
|---|
| 203 |  | 
|---|
| 204 | Use testOption(\a option) instead. | 
|---|
| 205 | */ | 
|---|
| 206 | bool QPageSetupDialog::isOptionEnabled(PageSetupDialogOption option) const | 
|---|
| 207 | { | 
|---|
| 208 | return testOption(option); | 
|---|
| 209 | } | 
|---|
| 210 |  | 
|---|
| 211 | /*! | 
|---|
| 212 | \overload | 
|---|
| 213 | \since 4.5 | 
|---|
| 214 |  | 
|---|
| 215 | Opens the dialog and connects its accepted() signal to the slot specified | 
|---|
| 216 | by \a receiver and \a member. | 
|---|
| 217 |  | 
|---|
| 218 | The signal will be disconnected from the slot when the dialog is closed. | 
|---|
| 219 | */ | 
|---|
| 220 | void QPageSetupDialog::open(QObject *receiver, const char *member) | 
|---|
| 221 | { | 
|---|
| 222 | Q_D(QPageSetupDialog); | 
|---|
| 223 | connect(this, SIGNAL(accepted()), receiver, member); | 
|---|
| 224 | d->receiverToDisconnectOnClose = receiver; | 
|---|
| 225 | d->memberToDisconnectOnClose = member; | 
|---|
| 226 | QDialog::open(); | 
|---|
| 227 | } | 
|---|
| 228 |  | 
|---|
| 229 | #if defined(Q_WS_MAC) || defined(Q_OS_WIN) | 
|---|
| 230 | /*! \fn void QPageSetupDialog::setVisible(bool visible) | 
|---|
| 231 | \reimp | 
|---|
| 232 | */ | 
|---|
| 233 | #endif | 
|---|
| 234 |  | 
|---|
| 235 | QT_END_NAMESPACE | 
|---|
| 236 |  | 
|---|
| 237 | #endif | 
|---|