| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/dialogs/qdialog.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||
| 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 https://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at https://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 3 as published by the Free Software | - | ||||||||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||
| 24 | ** | - | ||||||||||||
| 25 | ** GNU General Public License Usage | - | ||||||||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||
| 35 | ** | - | ||||||||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 37 | ** | - | ||||||||||||
| 38 | ****************************************************************************/ | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | #include "qcolordialog.h" | - | ||||||||||||
| 41 | #include "qfontdialog.h" | - | ||||||||||||
| 42 | #include "qfiledialog.h" | - | ||||||||||||
| 43 | - | |||||||||||||
| 44 | #include "qevent.h" | - | ||||||||||||
| 45 | #include "qdesktopwidget.h" | - | ||||||||||||
| 46 | #include "qpushbutton.h" | - | ||||||||||||
| 47 | #include "qapplication.h" | - | ||||||||||||
| 48 | #include "qlayout.h" | - | ||||||||||||
| 49 | #include "qsizegrip.h" | - | ||||||||||||
| 50 | #include "qwhatsthis.h" | - | ||||||||||||
| 51 | #include "qmenu.h" | - | ||||||||||||
| 52 | #include "qcursor.h" | - | ||||||||||||
| 53 | #include "qmessagebox.h" | - | ||||||||||||
| 54 | #include "qerrormessage.h" | - | ||||||||||||
| 55 | #include <qpa/qplatformtheme.h> | - | ||||||||||||
| 56 | #include "private/qdialog_p.h" | - | ||||||||||||
| 57 | #include "private/qguiapplication_p.h" | - | ||||||||||||
| 58 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||
| 59 | #include "qaccessible.h" | - | ||||||||||||
| 60 | #endif | - | ||||||||||||
| 61 | - | |||||||||||||
| 62 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 63 | - | |||||||||||||
| 64 | static inline int themeDialogType(const QDialog *dialog) | - | ||||||||||||
| 65 | { | - | ||||||||||||
| 66 | #ifndef QT_NO_FILEDIALOG | - | ||||||||||||
| 67 | if (qobject_cast<const QFileDialog *>(dialog)) | - | ||||||||||||
| 68 | return QPlatformTheme::FileDialog; | - | ||||||||||||
| 69 | #endif | - | ||||||||||||
| 70 | #ifndef QT_NO_COLORDIALOG | - | ||||||||||||
| 71 | if (qobject_cast<const QColorDialog *>(dialog)) | - | ||||||||||||
| 72 | return QPlatformTheme::ColorDialog; | - | ||||||||||||
| 73 | #endif | - | ||||||||||||
| 74 | #ifndef QT_NO_FONTDIALOG | - | ||||||||||||
| 75 | if (qobject_cast<const QFontDialog *>(dialog)) | - | ||||||||||||
| 76 | return QPlatformTheme::FontDialog; | - | ||||||||||||
| 77 | #endif | - | ||||||||||||
| 78 | #ifndef QT_NO_MESSAGEBOX | - | ||||||||||||
| 79 | if (qobject_cast<const QMessageBox *>(dialog)) | - | ||||||||||||
| 80 | return QPlatformTheme::MessageDialog; | - | ||||||||||||
| 81 | #endif | - | ||||||||||||
| 82 | #ifndef QT_NO_ERRORMESSAGE | - | ||||||||||||
| 83 | if (qobject_cast<const QErrorMessage *>(dialog)) | - | ||||||||||||
| 84 | return QPlatformTheme::MessageDialog; | - | ||||||||||||
| 85 | #endif | - | ||||||||||||
| 86 | return -1; | - | ||||||||||||
| 87 | } | - | ||||||||||||
| 88 | - | |||||||||||||
| 89 | QDialogPrivate::~QDialogPrivate() | - | ||||||||||||
| 90 | { | - | ||||||||||||
| 91 | delete m_platformHelper; | - | ||||||||||||
| 92 | } never executed: end of block | 0 | ||||||||||||
| 93 | - | |||||||||||||
| 94 | QPlatformDialogHelper *QDialogPrivate::platformHelper() const | - | ||||||||||||
| 95 | { | - | ||||||||||||
| 96 | // Delayed creation of the platform, ensuring that | - | ||||||||||||
| 97 | // that qobject_cast<> on the dialog works in the plugin. | - | ||||||||||||
| 98 | if (!m_platformHelperCreated )&& canBeNativeDialog()) {
| 0 | ||||||||||||
| 99 | m_platformHelperCreated = true; | - | ||||||||||||
| 100 | QDialogPrivate *ncThis = const_cast<QDialogPrivate *>(this); | - | ||||||||||||
| 101 | QDialog *dialog = ncThis->q_func(); | - | ||||||||||||
| 102 | const int type = themeDialogType(dialog); | - | ||||||||||||
| 103 | if (type >= 0) {
| 0 | ||||||||||||
| 104 | m_platformHelper = QGuiApplicationPrivate::platformTheme() | - | ||||||||||||
| 105 | ->createPlatformDialogHelper(static_cast<QPlatformTheme::DialogType>(type)); | - | ||||||||||||
| 106 | if (m_platformHelper) {
| 0 | ||||||||||||
| 107 | QObject::connect(m_platformHelper, SIGNAL(accept()), dialog, SLOT(accept())); | - | ||||||||||||
| 108 | QObject::connect(m_platformHelper, SIGNAL(reject()), dialog, SLOT(reject())); | - | ||||||||||||
| 109 | ncThis->initHelper(m_platformHelper); | - | ||||||||||||
| 110 | } never executed: end of block | 0 | ||||||||||||
| 111 | } never executed: end of block | 0 | ||||||||||||
| 112 | } never executed: end of block | 0 | ||||||||||||
| 113 | return m_platformHelper; never executed: return m_platformHelper; | 0 | ||||||||||||
| 114 | } | - | ||||||||||||
| 115 | - | |||||||||||||
| 116 | bool QDialogPrivate::canBeNativeDialog() const | - | ||||||||||||
| 117 | { | - | ||||||||||||
| 118 | QDialogPrivate *ncThis = const_cast<QDialogPrivate *>(this); | - | ||||||||||||
| 119 | QDialog *dialog = ncThis->q_func(); | - | ||||||||||||
| 120 | const int type = themeDialogType(dialog); | - | ||||||||||||
| 121 | if (type >= 0) | - | ||||||||||||
| 122 | return QGuiApplicationPrivate::platformTheme() | - | ||||||||||||
| 123 | ->usePlatformNativeDialog(static_cast<QPlatformTheme::DialogType>(type)); | - | ||||||||||||
| 124 | return false; | - | ||||||||||||
| 125 | } | - | ||||||||||||
| 126 | - | |||||||||||||
| 127 | QWindow *QDialogPrivate::parentWindow() const | - | ||||||||||||
| 128 | { | - | ||||||||||||
| 129 | if (const QWidget *parent = q_func()->nativeParentWidget()) | - | ||||||||||||
| 130 | return parent->windowHandle(); | - | ||||||||||||
| 131 | return 0; | - | ||||||||||||
| 132 | } | - | ||||||||||||
| 133 | - | |||||||||||||
| 134 | bool QDialogPrivate::setNativeDialogVisible(bool visible) | - | ||||||||||||
| 135 | { | - | ||||||||||||
| 136 | if (QPlatformDialogHelper *helper = platformHelper()) { | - | ||||||||||||
| 137 | if (visible) { | - | ||||||||||||
| 138 | Q_Q(QDialog); | - | ||||||||||||
| 139 | helperPrepareShow(helper); | - | ||||||||||||
| 140 | nativeDialogInUse = helper->show(q->windowFlags(), q->windowModality(), parentWindow()); | - | ||||||||||||
| 141 | } else if (nativeDialogInUse) { | - | ||||||||||||
| 142 | helper->hide(); | - | ||||||||||||
| 143 | } | - | ||||||||||||
| 144 | } | - | ||||||||||||
| 145 | return nativeDialogInUse; | - | ||||||||||||
| 146 | } | - | ||||||||||||
| 147 | - | |||||||||||||
| 148 | QVariant QDialogPrivate::styleHint(QPlatformDialogHelper::StyleHint hint) const | - | ||||||||||||
| 149 | { | - | ||||||||||||
| 150 | if (const QPlatformDialogHelper *helper = platformHelper()) | - | ||||||||||||
| 151 | return helper->styleHint(hint); | - | ||||||||||||
| 152 | return QPlatformDialogHelper::defaultStyleHint(hint); | - | ||||||||||||
| 153 | } | - | ||||||||||||
| 154 | - | |||||||||||||
| 155 | void QDialogPrivate::deletePlatformHelper() | - | ||||||||||||
| 156 | { | - | ||||||||||||
| 157 | delete m_platformHelper; | - | ||||||||||||
| 158 | m_platformHelper = 0; | - | ||||||||||||
| 159 | m_platformHelperCreated = false; | - | ||||||||||||
| 160 | nativeDialogInUse = false; | - | ||||||||||||
| 161 | } | - | ||||||||||||
| 162 | - | |||||||||||||
| 163 | /*! | - | ||||||||||||
| 164 | \class QDialog | - | ||||||||||||
| 165 | \brief The QDialog class is the base class of dialog windows. | - | ||||||||||||
| 166 | - | |||||||||||||
| 167 | \ingroup dialog-classes | - | ||||||||||||
| 168 | \ingroup abstractwidgets | - | ||||||||||||
| 169 | \inmodule QtWidgets | - | ||||||||||||
| 170 | - | |||||||||||||
| 171 | A dialog window is a top-level window mostly used for short-term | - | ||||||||||||
| 172 | tasks and brief communications with the user. QDialogs may be | - | ||||||||||||
| 173 | modal or modeless. QDialogs can | - | ||||||||||||
| 174 | provide a \l{#return}{return value}, and they can have \l{#default}{default buttons}. QDialogs can also have a QSizeGrip in their | - | ||||||||||||
| 175 | lower-right corner, using setSizeGripEnabled(). | - | ||||||||||||
| 176 | - | |||||||||||||
| 177 | Note that QDialog (and any other widget that has type \c Qt::Dialog) uses | - | ||||||||||||
| 178 | the parent widget slightly differently from other classes in Qt. A dialog is | - | ||||||||||||
| 179 | always a top-level widget, but if it has a parent, its default location is | - | ||||||||||||
| 180 | centered on top of the parent's top-level widget (if it is not top-level | - | ||||||||||||
| 181 | itself). It will also share the parent's taskbar entry. | - | ||||||||||||
| 182 | - | |||||||||||||
| 183 | Use the overload of the QWidget::setParent() function to change | - | ||||||||||||
| 184 | the ownership of a QDialog widget. This function allows you to | - | ||||||||||||
| 185 | explicitly set the window flags of the reparented widget; using | - | ||||||||||||
| 186 | the overloaded function will clear the window flags specifying the | - | ||||||||||||
| 187 | window-system properties for the widget (in particular it will | - | ||||||||||||
| 188 | reset the Qt::Dialog flag). | - | ||||||||||||
| 189 | - | |||||||||||||
| 190 | \section1 Modal Dialogs | - | ||||||||||||
| 191 | - | |||||||||||||
| 192 | A \b{modal} dialog is a dialog that blocks input to other | - | ||||||||||||
| 193 | visible windows in the same application. Dialogs that are used to | - | ||||||||||||
| 194 | request a file name from the user or that are used to set | - | ||||||||||||
| 195 | application preferences are usually modal. Dialogs can be | - | ||||||||||||
| 196 | \l{Qt::ApplicationModal}{application modal} (the default) or | - | ||||||||||||
| 197 | \l{Qt::WindowModal}{window modal}. | - | ||||||||||||
| 198 | - | |||||||||||||
| 199 | When an application modal dialog is opened, the user must finish | - | ||||||||||||
| 200 | interacting with the dialog and close it before they can access | - | ||||||||||||
| 201 | any other window in the application. Window modal dialogs only | - | ||||||||||||
| 202 | block access to the window associated with the dialog, allowing | - | ||||||||||||
| 203 | the user to continue to use other windows in an application. | - | ||||||||||||
| 204 | - | |||||||||||||
| 205 | The most common way to display a modal dialog is to call its | - | ||||||||||||
| 206 | exec() function. When the user closes the dialog, exec() will | - | ||||||||||||
| 207 | provide a useful \l{#return}{return value}. Typically, | - | ||||||||||||
| 208 | to get the dialog to close and return the appropriate value, we | - | ||||||||||||
| 209 | connect a default button, e.g. \uicontrol OK, to the accept() slot and a | - | ||||||||||||
| 210 | \uicontrol Cancel button to the reject() slot. | - | ||||||||||||
| 211 | Alternatively you can call the done() slot with \c Accepted or | - | ||||||||||||
| 212 | \c Rejected. | - | ||||||||||||
| 213 | - | |||||||||||||
| 214 | An alternative is to call setModal(true) or setWindowModality(), | - | ||||||||||||
| 215 | then show(). Unlike exec(), show() returns control to the caller | - | ||||||||||||
| 216 | immediately. Calling setModal(true) is especially useful for | - | ||||||||||||
| 217 | progress dialogs, where the user must have the ability to interact | - | ||||||||||||
| 218 | with the dialog, e.g. to cancel a long running operation. If you | - | ||||||||||||
| 219 | use show() and setModal(true) together to perform a long operation, | - | ||||||||||||
| 220 | you must call QApplication::processEvents() periodically during | - | ||||||||||||
| 221 | processing to enable the user to interact with the dialog. (See | - | ||||||||||||
| 222 | QProgressDialog.) | - | ||||||||||||
| 223 | - | |||||||||||||
| 224 | \section1 Modeless Dialogs | - | ||||||||||||
| 225 | - | |||||||||||||
| 226 | A \b{modeless} dialog is a dialog that operates | - | ||||||||||||
| 227 | independently of other windows in the same application. Find and | - | ||||||||||||
| 228 | replace dialogs in word-processors are often modeless to allow the | - | ||||||||||||
| 229 | user to interact with both the application's main window and with | - | ||||||||||||
| 230 | the dialog. | - | ||||||||||||
| 231 | - | |||||||||||||
| 232 | Modeless dialogs are displayed using show(), which returns control | - | ||||||||||||
| 233 | to the caller immediately. | - | ||||||||||||
| 234 | - | |||||||||||||
| 235 | If you invoke the \l{QWidget::show()}{show()} function after hiding | - | ||||||||||||
| 236 | a dialog, the dialog will be displayed in its original position. This is | - | ||||||||||||
| 237 | because the window manager decides the position for windows that | - | ||||||||||||
| 238 | have not been explicitly placed by the programmer. To preserve the | - | ||||||||||||
| 239 | position of a dialog that has been moved by the user, save its position | - | ||||||||||||
| 240 | in your \l{QWidget::closeEvent()}{closeEvent()} handler and then | - | ||||||||||||
| 241 | move the dialog to that position, before showing it again. | - | ||||||||||||
| 242 | - | |||||||||||||
| 243 | \target default | - | ||||||||||||
| 244 | \section1 Default Button | - | ||||||||||||
| 245 | - | |||||||||||||
| 246 | A dialog's \e default button is the button that's pressed when the | - | ||||||||||||
| 247 | user presses Enter (Return). This button is used to signify that | - | ||||||||||||
| 248 | the user accepts the dialog's settings and wants to close the | - | ||||||||||||
| 249 | dialog. Use QPushButton::setDefault(), QPushButton::isDefault() | - | ||||||||||||
| 250 | and QPushButton::autoDefault() to set and control the dialog's | - | ||||||||||||
| 251 | default button. | - | ||||||||||||
| 252 | - | |||||||||||||
| 253 | \target escapekey | - | ||||||||||||
| 254 | \section1 Escape Key | - | ||||||||||||
| 255 | - | |||||||||||||
| 256 | If the user presses the Esc key in a dialog, QDialog::reject() | - | ||||||||||||
| 257 | will be called. This will cause the window to close: The \l{QCloseEvent}{close event} cannot be \l{QEvent::ignore()}{ignored}. | - | ||||||||||||
| 258 | - | |||||||||||||
| 259 | \section1 Extensibility | - | ||||||||||||
| 260 | - | |||||||||||||
| 261 | Extensibility is the ability to show the dialog in two ways: a | - | ||||||||||||
| 262 | partial dialog that shows the most commonly used options, and a | - | ||||||||||||
| 263 | full dialog that shows all the options. Typically an extensible | - | ||||||||||||
| 264 | dialog will initially appear as a partial dialog, but with a | - | ||||||||||||
| 265 | \uicontrol More toggle button. If the user presses the \uicontrol More button down, | - | ||||||||||||
| 266 | the dialog is expanded. The \l{Extension Example} shows how to achieve | - | ||||||||||||
| 267 | extensible dialogs using Qt. | - | ||||||||||||
| 268 | - | |||||||||||||
| 269 | \target return | - | ||||||||||||
| 270 | \section1 Return Value (Modal Dialogs) | - | ||||||||||||
| 271 | - | |||||||||||||
| 272 | Modal dialogs are often used in situations where a return value is | - | ||||||||||||
| 273 | required, e.g. to indicate whether the user pressed \uicontrol OK or | - | ||||||||||||
| 274 | \uicontrol Cancel. A dialog can be closed by calling the accept() or the | - | ||||||||||||
| 275 | reject() slots, and exec() will return \c Accepted or \c Rejected | - | ||||||||||||
| 276 | as appropriate. The exec() call returns the result of the dialog. | - | ||||||||||||
| 277 | The result is also available from result() if the dialog has not | - | ||||||||||||
| 278 | been destroyed. | - | ||||||||||||
| 279 | - | |||||||||||||
| 280 | In order to modify your dialog's close behavior, you can reimplement | - | ||||||||||||
| 281 | the functions accept(), reject() or done(). The | - | ||||||||||||
| 282 | \l{QWidget::closeEvent()}{closeEvent()} function should only be | - | ||||||||||||
| 283 | reimplemented to preserve the dialog's position or to override the | - | ||||||||||||
| 284 | standard close or reject behavior. | - | ||||||||||||
| 285 | - | |||||||||||||
| 286 | \target examples | - | ||||||||||||
| 287 | \section1 Code Examples | - | ||||||||||||
| 288 | - | |||||||||||||
| 289 | A modal dialog: | - | ||||||||||||
| 290 | - | |||||||||||||
| 291 | \snippet dialogs/dialogs.cpp 1 | - | ||||||||||||
| 292 | - | |||||||||||||
| 293 | A modeless dialog: | - | ||||||||||||
| 294 | - | |||||||||||||
| 295 | \snippet dialogs/dialogs.cpp 0 | - | ||||||||||||
| 296 | - | |||||||||||||
| 297 | \sa QDialogButtonBox, QTabWidget, QWidget, QProgressDialog, | - | ||||||||||||
| 298 | {fowler}{GUI Design Handbook: Dialogs, Standard}, {Extension Example}, | - | ||||||||||||
| 299 | {Standard Dialogs Example} | - | ||||||||||||
| 300 | */ | - | ||||||||||||
| 301 | - | |||||||||||||
| 302 | /*! \enum QDialog::DialogCode | - | ||||||||||||
| 303 | - | |||||||||||||
| 304 | The value returned by a modal dialog. | - | ||||||||||||
| 305 | - | |||||||||||||
| 306 | \value Accepted | - | ||||||||||||
| 307 | \value Rejected | - | ||||||||||||
| 308 | */ | - | ||||||||||||
| 309 | - | |||||||||||||
| 310 | /*! | - | ||||||||||||
| 311 | \property QDialog::sizeGripEnabled | - | ||||||||||||
| 312 | \brief whether the size grip is enabled | - | ||||||||||||
| 313 | - | |||||||||||||
| 314 | A QSizeGrip is placed in the bottom-right corner of the dialog when this | - | ||||||||||||
| 315 | property is enabled. By default, the size grip is disabled. | - | ||||||||||||
| 316 | */ | - | ||||||||||||
| 317 | - | |||||||||||||
| 318 | - | |||||||||||||
| 319 | /*! | - | ||||||||||||
| 320 | Constructs a dialog with parent \a parent. | - | ||||||||||||
| 321 | - | |||||||||||||
| 322 | A dialog is always a top-level widget, but if it has a parent, its | - | ||||||||||||
| 323 | default location is centered on top of the parent. It will also | - | ||||||||||||
| 324 | share the parent's taskbar entry. | - | ||||||||||||
| 325 | - | |||||||||||||
| 326 | The widget flags \a f are passed on to the QWidget constructor. | - | ||||||||||||
| 327 | If, for example, you don't want a What's This button in the title bar | - | ||||||||||||
| 328 | of the dialog, pass Qt::WindowTitleHint | Qt::WindowSystemMenuHint in \a f. | - | ||||||||||||
| 329 | - | |||||||||||||
| 330 | \sa QWidget::setWindowFlags() | - | ||||||||||||
| 331 | */ | - | ||||||||||||
| 332 | - | |||||||||||||
| 333 | QDialog::QDialog(QWidget *parent, Qt::WindowFlags f) | - | ||||||||||||
| 334 | : QWidget(*new QDialogPrivate, parent, | - | ||||||||||||
| 335 | f | ((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : Qt::WindowType(0))) | - | ||||||||||||
| 336 | { | - | ||||||||||||
| 337 | } | - | ||||||||||||
| 338 | - | |||||||||||||
| 339 | /*! | - | ||||||||||||
| 340 | \overload | - | ||||||||||||
| 341 | \internal | - | ||||||||||||
| 342 | */ | - | ||||||||||||
| 343 | QDialog::QDialog(QDialogPrivate &dd, QWidget *parent, Qt::WindowFlags f) | - | ||||||||||||
| 344 | : QWidget(dd, parent, f | ((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : Qt::WindowType(0))) | - | ||||||||||||
| 345 | { | - | ||||||||||||
| 346 | } | - | ||||||||||||
| 347 | - | |||||||||||||
| 348 | /*! | - | ||||||||||||
| 349 | Destroys the QDialog, deleting all its children. | - | ||||||||||||
| 350 | */ | - | ||||||||||||
| 351 | - | |||||||||||||
| 352 | QDialog::~QDialog() | - | ||||||||||||
| 353 | { | - | ||||||||||||
| 354 | QT_TRY { | - | ||||||||||||
| 355 | // Need to hide() here, as our (to-be) overridden hide() | - | ||||||||||||
| 356 | // will not be called in ~QWidget. | - | ||||||||||||
| 357 | hide(); | - | ||||||||||||
| 358 | } QT_CATCH(...) { dead code: { } | - | ||||||||||||
| 359 | // we're in the destructor - just swallow the exception dead code: { } | - | ||||||||||||
| 360 | } dead code: { } | - | ||||||||||||
| 361 | } | - | ||||||||||||
| 362 | - | |||||||||||||
| 363 | /*! | - | ||||||||||||
| 364 | \internal | - | ||||||||||||
| 365 | This function is called by the push button \a pushButton when it | - | ||||||||||||
| 366 | becomes the default button. If \a pushButton is 0, the dialogs | - | ||||||||||||
| 367 | default default button becomes the default button. This is what a | - | ||||||||||||
| 368 | push button calls when it loses focus. | - | ||||||||||||
| 369 | */ | - | ||||||||||||
| 370 | void QDialogPrivate::setDefault(QPushButton *pushButton) | - | ||||||||||||
| 371 | { | - | ||||||||||||
| 372 | Q_Q(QDialog); | - | ||||||||||||
| 373 | bool hasMain = false; | - | ||||||||||||
| 374 | QList<QPushButton*> list = q->findChildren<QPushButton*>(); | - | ||||||||||||
| 375 | for (int i=0; i<list.size(); ++i) { | - | ||||||||||||
| 376 | QPushButton *pb = list.at(i); | - | ||||||||||||
| 377 | if (pb->window() == q) { | - | ||||||||||||
| 378 | if (pb == mainDef) | - | ||||||||||||
| 379 | hasMain = true; | - | ||||||||||||
| 380 | if (pb != pushButton) | - | ||||||||||||
| 381 | pb->setDefault(false); | - | ||||||||||||
| 382 | } | - | ||||||||||||
| 383 | } | - | ||||||||||||
| 384 | if (!pushButton && hasMain) | - | ||||||||||||
| 385 | mainDef->setDefault(true); | - | ||||||||||||
| 386 | if (!hasMain) | - | ||||||||||||
| 387 | mainDef = pushButton; | - | ||||||||||||
| 388 | } | - | ||||||||||||
| 389 | - | |||||||||||||
| 390 | /*! | - | ||||||||||||
| 391 | \internal | - | ||||||||||||
| 392 | This function sets the default default push button to \a pushButton. | - | ||||||||||||
| 393 | This function is called by QPushButton::setDefault(). | - | ||||||||||||
| 394 | */ | - | ||||||||||||
| 395 | void QDialogPrivate::setMainDefault(QPushButton *pushButton) | - | ||||||||||||
| 396 | { | - | ||||||||||||
| 397 | mainDef = 0; | - | ||||||||||||
| 398 | setDefault(pushButton); | - | ||||||||||||
| 399 | } | - | ||||||||||||
| 400 | - | |||||||||||||
| 401 | /*! | - | ||||||||||||
| 402 | \internal | - | ||||||||||||
| 403 | Hides the default button indicator. Called when non auto-default | - | ||||||||||||
| 404 | push button get focus. | - | ||||||||||||
| 405 | */ | - | ||||||||||||
| 406 | void QDialogPrivate::hideDefault() | - | ||||||||||||
| 407 | { | - | ||||||||||||
| 408 | Q_Q(QDialog); | - | ||||||||||||
| 409 | QList<QPushButton*> list = q->findChildren<QPushButton*>(); | - | ||||||||||||
| 410 | for (int i=0; i<list.size(); ++i) { | - | ||||||||||||
| 411 | list.at(i)->setDefault(false); | - | ||||||||||||
| 412 | } | - | ||||||||||||
| 413 | } | - | ||||||||||||
| 414 | - | |||||||||||||
| 415 | void QDialogPrivate::resetModalitySetByOpen() | - | ||||||||||||
| 416 | { | - | ||||||||||||
| 417 | Q_Q(QDialog); | - | ||||||||||||
| 418 | if (resetModalityTo != -1 && !q->testAttribute(Qt::WA_SetWindowModality)) { | - | ||||||||||||
| 419 | // open() changed the window modality and the user didn't touch it afterwards; restore it | - | ||||||||||||
| 420 | q->setWindowModality(Qt::WindowModality(resetModalityTo)); | - | ||||||||||||
| 421 | q->setAttribute(Qt::WA_SetWindowModality, wasModalitySet); | - | ||||||||||||
| 422 | #ifdef Q_OS_MAC | - | ||||||||||||
| 423 | Q_ASSERT(resetModalityTo != Qt::WindowModal); | - | ||||||||||||
| 424 | q->setParent(q->parentWidget(), Qt::Dialog); | - | ||||||||||||
| 425 | #endif | - | ||||||||||||
| 426 | } | - | ||||||||||||
| 427 | resetModalityTo = -1; | - | ||||||||||||
| 428 | } | - | ||||||||||||
| 429 | - | |||||||||||||
| 430 | #if defined(Q_OS_WINCE) | - | ||||||||||||
| 431 | #ifdef Q_OS_WINCE_WM | - | ||||||||||||
| 432 | void QDialogPrivate::_q_doneAction() | - | ||||||||||||
| 433 | { | - | ||||||||||||
| 434 | //Done... | - | ||||||||||||
| 435 | QApplication::postEvent(q_func(), new QEvent(QEvent::OkRequest)); | - | ||||||||||||
| 436 | } | - | ||||||||||||
| 437 | #endif | - | ||||||||||||
| 438 | - | |||||||||||||
| 439 | /*! | - | ||||||||||||
| 440 | \reimp | - | ||||||||||||
| 441 | */ | - | ||||||||||||
| 442 | bool QDialog::event(QEvent *e) | - | ||||||||||||
| 443 | { | - | ||||||||||||
| 444 | bool result = QWidget::event(e); | - | ||||||||||||
| 445 | #ifdef Q_OS_WINCE | - | ||||||||||||
| 446 | if (e->type() == QEvent::OkRequest) { | - | ||||||||||||
| 447 | accept(); | - | ||||||||||||
| 448 | result = true; | - | ||||||||||||
| 449 | } | - | ||||||||||||
| 450 | #endif | - | ||||||||||||
| 451 | return result; | - | ||||||||||||
| 452 | } | - | ||||||||||||
| 453 | #endif | - | ||||||||||||
| 454 | - | |||||||||||||
| 455 | /*! | - | ||||||||||||
| 456 | In general returns the modal dialog's result code, \c Accepted or | - | ||||||||||||
| 457 | \c Rejected. | - | ||||||||||||
| 458 | - | |||||||||||||
| 459 | \note When called on a QMessageBox instance, the returned value is a | - | ||||||||||||
| 460 | value of the \l QMessageBox::StandardButton enum. | - | ||||||||||||
| 461 | - | |||||||||||||
| 462 | Do not call this function if the dialog was constructed with the | - | ||||||||||||
| 463 | Qt::WA_DeleteOnClose attribute. | - | ||||||||||||
| 464 | */ | - | ||||||||||||
| 465 | int QDialog::result() const | - | ||||||||||||
| 466 | { | - | ||||||||||||
| 467 | Q_D(const QDialog); | - | ||||||||||||
| 468 | return d->rescode; | - | ||||||||||||
| 469 | } | - | ||||||||||||
| 470 | - | |||||||||||||
| 471 | /*! | - | ||||||||||||
| 472 | \fn void QDialog::setResult(int i) | - | ||||||||||||
| 473 | - | |||||||||||||
| 474 | Sets the modal dialog's result code to \a i. | - | ||||||||||||
| 475 | - | |||||||||||||
| 476 | \note We recommend that you use one of the values defined by | - | ||||||||||||
| 477 | QDialog::DialogCode. | - | ||||||||||||
| 478 | */ | - | ||||||||||||
| 479 | void QDialog::setResult(int r) | - | ||||||||||||
| 480 | { | - | ||||||||||||
| 481 | Q_D(QDialog); | - | ||||||||||||
| 482 | d->rescode = r; | - | ||||||||||||
| 483 | } | - | ||||||||||||
| 484 | - | |||||||||||||
| 485 | /*! | - | ||||||||||||
| 486 | \since 4.5 | - | ||||||||||||
| 487 | - | |||||||||||||
| 488 | Shows the dialog as a \l{QDialog#Modal Dialogs}{window modal dialog}, | - | ||||||||||||
| 489 | returning immediately. | - | ||||||||||||
| 490 | - | |||||||||||||
| 491 | \sa exec(), show(), result(), setWindowModality() | - | ||||||||||||
| 492 | */ | - | ||||||||||||
| 493 | void QDialog::open() | - | ||||||||||||
| 494 | { | - | ||||||||||||
| 495 | Q_D(QDialog); | - | ||||||||||||
| 496 | - | |||||||||||||
| 497 | Qt::WindowModality modality = windowModality(); | - | ||||||||||||
| 498 | if (modality != Qt::WindowModal) { | - | ||||||||||||
| 499 | d->resetModalityTo = modality; | - | ||||||||||||
| 500 | d->wasModalitySet = testAttribute(Qt::WA_SetWindowModality); | - | ||||||||||||
| 501 | setWindowModality(Qt::WindowModal); | - | ||||||||||||
| 502 | setAttribute(Qt::WA_SetWindowModality, false); | - | ||||||||||||
| 503 | #ifdef Q_OS_MAC | - | ||||||||||||
| 504 | setParent(parentWidget(), Qt::Sheet); | - | ||||||||||||
| 505 | #endif | - | ||||||||||||
| 506 | } | - | ||||||||||||
| 507 | - | |||||||||||||
| 508 | setResult(0); | - | ||||||||||||
| 509 | show(); | - | ||||||||||||
| 510 | } | - | ||||||||||||
| 511 | - | |||||||||||||
| 512 | /*! | - | ||||||||||||
| 513 | Shows the dialog as a \l{QDialog#Modal Dialogs}{modal dialog}, | - | ||||||||||||
| 514 | blocking until the user closes it. The function returns a \l | - | ||||||||||||
| 515 | DialogCode result. | - | ||||||||||||
| 516 | - | |||||||||||||
| 517 | If the dialog is \l{Qt::ApplicationModal}{application modal}, users cannot | - | ||||||||||||
| 518 | interact with any other window in the same application until they close | - | ||||||||||||
| 519 | the dialog. If the dialog is \l{Qt::ApplicationModal}{window modal}, only | - | ||||||||||||
| 520 | interaction with the parent window is blocked while the dialog is open. | - | ||||||||||||
| 521 | By default, the dialog is application modal. | - | ||||||||||||
| 522 | - | |||||||||||||
| 523 | \sa open(), show(), result(), setWindowModality() | - | ||||||||||||
| 524 | */ | - | ||||||||||||
| 525 | - | |||||||||||||
| 526 | int QDialog::exec() | - | ||||||||||||
| 527 | { | - | ||||||||||||
| 528 | Q_D(QDialog); | - | ||||||||||||
| 529 | - | |||||||||||||
| 530 | if (Q_UNLIKELY(d->eventLoop))) {
| 0 | ||||||||||||
| 531 | qWarning("QDialog::exec: Recursive call detected"); | - | ||||||||||||
| 532 | return -1; never executed: return -1; | 0 | ||||||||||||
| 533 | } | - | ||||||||||||
| 534 | - | |||||||||||||
| 535 | bool deleteOnClose = testAttribute(Qt::WA_DeleteOnClose); | - | ||||||||||||
| 536 | setAttribute(Qt::WA_DeleteOnClose, false); | - | ||||||||||||
| 537 | - | |||||||||||||
| 538 | d->resetModalitySetByOpen(); | - | ||||||||||||
| 539 | - | |||||||||||||
| 540 | bool wasShowModal = testAttribute(Qt::WA_ShowModal); | - | ||||||||||||
| 541 | setAttribute(Qt::WA_ShowModal, true); | - | ||||||||||||
| 542 | setResult(0); | - | ||||||||||||
| 543 | - | |||||||||||||
| 544 | show(); | - | ||||||||||||
| 545 | - | |||||||||||||
| 546 | QPointer<QDialog> guard = this; | - | ||||||||||||
| 547 | if (d->nativeDialogInUse) {
| 0 | ||||||||||||
| 548 | d->platformHelper()->exec(); | - | ||||||||||||
| 549 | } else { never executed: end of block | 0 | ||||||||||||
| 550 | QEventLoop eventLoop; | - | ||||||||||||
| 551 | d->eventLoop = &eventLoop; | - | ||||||||||||
| 552 | (void) eventLoop.exec(QEventLoop::DialogExec); | - | ||||||||||||
| 553 | } never executed: end of block | 0 | ||||||||||||
| 554 | if (guard.isNull())
| 0 | ||||||||||||
| 555 | return QDialog::Rejected; never executed: return QDialog::Rejected; | 0 | ||||||||||||
| 556 | d->eventLoop = 0; | - | ||||||||||||
| 557 | - | |||||||||||||
| 558 | setAttribute(Qt::WA_ShowModal, wasShowModal); | - | ||||||||||||
| 559 | - | |||||||||||||
| 560 | int res = result(); | - | ||||||||||||
| 561 | if (d->nativeDialogInUse)
| 0 | ||||||||||||
| 562 | d->helperDone(static_cast<QDialog::DialogCode>(res), d->platformHelper()); never executed: d->helperDone(static_cast<QDialog::DialogCode>(res), d->platformHelper()); | 0 | ||||||||||||
| 563 | if (deleteOnClose)
| 0 | ||||||||||||
| 564 | delete this; never executed: delete this; | 0 | ||||||||||||
| 565 | return res; never executed: return res; | 0 | ||||||||||||
| 566 | } | - | ||||||||||||
| 567 | - | |||||||||||||
| 568 | /*! | - | ||||||||||||
| 569 | Closes the dialog and sets its result code to \a r. If this dialog | - | ||||||||||||
| 570 | is shown with exec(), done() causes the local event loop to finish, | - | ||||||||||||
| 571 | and exec() to return \a r. | - | ||||||||||||
| 572 | - | |||||||||||||
| 573 | As with QWidget::close(), done() deletes the dialog if the | - | ||||||||||||
| 574 | Qt::WA_DeleteOnClose flag is set. If the dialog is the application's | - | ||||||||||||
| 575 | main widget, the application terminates. If the dialog is the | - | ||||||||||||
| 576 | last window closed, the QApplication::lastWindowClosed() signal is | - | ||||||||||||
| 577 | emitted. | - | ||||||||||||
| 578 | - | |||||||||||||
| 579 | \sa accept(), reject(), QApplication::activeWindow(), QCoreApplication::quit() | - | ||||||||||||
| 580 | */ | - | ||||||||||||
| 581 | - | |||||||||||||
| 582 | void QDialog::done(int r) | - | ||||||||||||
| 583 | { | - | ||||||||||||
| 584 | Q_D(QDialog); | - | ||||||||||||
| 585 | hide(); | - | ||||||||||||
| 586 | setResult(r); | - | ||||||||||||
| 587 | - | |||||||||||||
| 588 | d->close_helper(QWidgetPrivate::CloseNoEvent); | - | ||||||||||||
| 589 | d->resetModalitySetByOpen(); | - | ||||||||||||
| 590 | - | |||||||||||||
| 591 | emit finished(r); | - | ||||||||||||
| 592 | if (r == Accepted) | - | ||||||||||||
| 593 | emit accepted(); | - | ||||||||||||
| 594 | else if (r == Rejected) | - | ||||||||||||
| 595 | emit rejected(); | - | ||||||||||||
| 596 | } | - | ||||||||||||
| 597 | - | |||||||||||||
| 598 | /*! | - | ||||||||||||
| 599 | Hides the modal dialog and sets the result code to \c Accepted. | - | ||||||||||||
| 600 | - | |||||||||||||
| 601 | \sa reject(), done() | - | ||||||||||||
| 602 | */ | - | ||||||||||||
| 603 | - | |||||||||||||
| 604 | void QDialog::accept() | - | ||||||||||||
| 605 | { | - | ||||||||||||
| 606 | done(Accepted); | - | ||||||||||||
| 607 | } | - | ||||||||||||
| 608 | - | |||||||||||||
| 609 | /*! | - | ||||||||||||
| 610 | Hides the modal dialog and sets the result code to \c Rejected. | - | ||||||||||||
| 611 | - | |||||||||||||
| 612 | \sa accept(), done() | - | ||||||||||||
| 613 | */ | - | ||||||||||||
| 614 | - | |||||||||||||
| 615 | void QDialog::reject() | - | ||||||||||||
| 616 | { | - | ||||||||||||
| 617 | done(Rejected); | - | ||||||||||||
| 618 | } | - | ||||||||||||
| 619 | - | |||||||||||||
| 620 | /*! \reimp */ | - | ||||||||||||
| 621 | bool QDialog::eventFilter(QObject *o, QEvent *e) | - | ||||||||||||
| 622 | { | - | ||||||||||||
| 623 | return QWidget::eventFilter(o, e); | - | ||||||||||||
| 624 | } | - | ||||||||||||
| 625 | - | |||||||||||||
| 626 | /***************************************************************************** | - | ||||||||||||
| 627 | Event handlers | - | ||||||||||||
| 628 | *****************************************************************************/ | - | ||||||||||||
| 629 | - | |||||||||||||
| 630 | #ifndef QT_NO_CONTEXTMENU | - | ||||||||||||
| 631 | /*! \reimp */ | - | ||||||||||||
| 632 | void QDialog::contextMenuEvent(QContextMenuEvent *e) | - | ||||||||||||
| 633 | { | - | ||||||||||||
| 634 | #if defined(QT_NO_WHATSTHIS) || defined(QT_NO_MENU) | - | ||||||||||||
| 635 | Q_UNUSED(e); | - | ||||||||||||
| 636 | #else | - | ||||||||||||
| 637 | QWidget *w = childAt(e->pos()); | - | ||||||||||||
| 638 | if (!w) { | - | ||||||||||||
| 639 | w = rect().contains(e->pos()) ? this : 0; | - | ||||||||||||
| 640 | if (!w) | - | ||||||||||||
| 641 | return; | - | ||||||||||||
| 642 | } | - | ||||||||||||
| 643 | while (w && w->whatsThis().size() == 0 && !w->testAttribute(Qt::WA_CustomWhatsThis)) | - | ||||||||||||
| 644 | w = w->isWindow() ? 0 : w->parentWidget(); | - | ||||||||||||
| 645 | if (w) { | - | ||||||||||||
| 646 | QPointer<QMenu> p = new QMenu(this); | - | ||||||||||||
| 647 | QAction *wt = p.data()->addAction(tr("What's This?")); | - | ||||||||||||
| 648 | if (p.data()->exec(e->globalPos()) == wt) { | - | ||||||||||||
| 649 | QHelpEvent e(QEvent::WhatsThis, w->rect().center(), | - | ||||||||||||
| 650 | w->mapToGlobal(w->rect().center())); | - | ||||||||||||
| 651 | QApplication::sendEvent(w, &e); | - | ||||||||||||
| 652 | } | - | ||||||||||||
| 653 | delete p.data(); | - | ||||||||||||
| 654 | } | - | ||||||||||||
| 655 | #endif | - | ||||||||||||
| 656 | } | - | ||||||||||||
| 657 | #endif // QT_NO_CONTEXTMENU | - | ||||||||||||
| 658 | - | |||||||||||||
| 659 | /*! \reimp */ | - | ||||||||||||
| 660 | void QDialog::keyPressEvent(QKeyEvent *e) | - | ||||||||||||
| 661 | { | - | ||||||||||||
| 662 | // Calls reject() if Escape is pressed. Simulates a button | - | ||||||||||||
| 663 | // click for the default button if Enter is pressed. Move focus | - | ||||||||||||
| 664 | // for the arrow keys. Ignore the rest. | - | ||||||||||||
| 665 | if (e->matches(QKeySequence::Cancel)) { | - | ||||||||||||
| 666 | reject(); | - | ||||||||||||
| 667 | } else | - | ||||||||||||
| 668 | if (!e->modifiers() || (e->modifiers() & Qt::KeypadModifier && e->key() == Qt::Key_Enter)) { | - | ||||||||||||
| 669 | switch (e->key()) { | - | ||||||||||||
| 670 | case Qt::Key_Enter: | - | ||||||||||||
| 671 | case Qt::Key_Return: { | - | ||||||||||||
| 672 | QList<QPushButton*> list = findChildren<QPushButton*>(); | - | ||||||||||||
| 673 | for (int i=0; i<list.size(); ++i) { | - | ||||||||||||
| 674 | QPushButton *pb = list.at(i); | - | ||||||||||||
| 675 | if (pb->isDefault() && pb->isVisible()) { | - | ||||||||||||
| 676 | if (pb->isEnabled()) | - | ||||||||||||
| 677 | pb->click(); | - | ||||||||||||
| 678 | return; | - | ||||||||||||
| 679 | } | - | ||||||||||||
| 680 | } | - | ||||||||||||
| 681 | } | - | ||||||||||||
| 682 | break; | - | ||||||||||||
| 683 | default: | - | ||||||||||||
| 684 | e->ignore(); | - | ||||||||||||
| 685 | return; | - | ||||||||||||
| 686 | } | - | ||||||||||||
| 687 | } else { | - | ||||||||||||
| 688 | e->ignore(); | - | ||||||||||||
| 689 | } | - | ||||||||||||
| 690 | } | - | ||||||||||||
| 691 | - | |||||||||||||
| 692 | /*! \reimp */ | - | ||||||||||||
| 693 | void QDialog::closeEvent(QCloseEvent *e) | - | ||||||||||||
| 694 | { | - | ||||||||||||
| 695 | #ifndef QT_NO_WHATSTHIS | - | ||||||||||||
| 696 | if (isModal() && QWhatsThis::inWhatsThisMode()) | - | ||||||||||||
| 697 | QWhatsThis::leaveWhatsThisMode(); | - | ||||||||||||
| 698 | #endif | - | ||||||||||||
| 699 | if (isVisible()) { | - | ||||||||||||
| 700 | QPointer<QObject> that = this; | - | ||||||||||||
| 701 | reject(); | - | ||||||||||||
| 702 | if (that && isVisible()) | - | ||||||||||||
| 703 | e->ignore(); | - | ||||||||||||
| 704 | } else { | - | ||||||||||||
| 705 | e->accept(); | - | ||||||||||||
| 706 | } | - | ||||||||||||
| 707 | } | - | ||||||||||||
| 708 | - | |||||||||||||
| 709 | /***************************************************************************** | - | ||||||||||||
| 710 | Geometry management. | - | ||||||||||||
| 711 | *****************************************************************************/ | - | ||||||||||||
| 712 | - | |||||||||||||
| 713 | /*! \reimp | - | ||||||||||||
| 714 | */ | - | ||||||||||||
| 715 | - | |||||||||||||
| 716 | void QDialog::setVisible(bool visible) | - | ||||||||||||
| 717 | { | - | ||||||||||||
| 718 | Q_D(QDialog); | - | ||||||||||||
| 719 | if (!testAttribute(Qt::WA_DontShowOnScreen) && d->canBeNativeDialog() && d->setNativeDialogVisible(visible)) | - | ||||||||||||
| 720 | return; | - | ||||||||||||
| 721 | - | |||||||||||||
| 722 | if (visible) { | - | ||||||||||||
| 723 | if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden)) | - | ||||||||||||
| 724 | return; | - | ||||||||||||
| 725 | - | |||||||||||||
| 726 | QWidget::setVisible(visible); | - | ||||||||||||
| 727 | showExtension(d->doShowExtension); | - | ||||||||||||
| 728 | QWidget *fw = window()->focusWidget(); | - | ||||||||||||
| 729 | if (!fw) | - | ||||||||||||
| 730 | fw = this; | - | ||||||||||||
| 731 | - | |||||||||||||
| 732 | /* | - | ||||||||||||
| 733 | The following block is to handle a special case, and does not | - | ||||||||||||
| 734 | really follow propper logic in concern of autoDefault and TAB | - | ||||||||||||
| 735 | order. However, it's here to ease usage for the users. If a | - | ||||||||||||
| 736 | dialog has a default QPushButton, and first widget in the TAB | - | ||||||||||||
| 737 | order also is a QPushButton, then we give focus to the main | - | ||||||||||||
| 738 | default QPushButton. This simplifies code for the developers, | - | ||||||||||||
| 739 | and actually catches most cases... If not, then they simply | - | ||||||||||||
| 740 | have to use [widget*]->setFocus() themselves... | - | ||||||||||||
| 741 | */ | - | ||||||||||||
| 742 | if (d->mainDef && fw->focusPolicy() == Qt::NoFocus) { | - | ||||||||||||
| 743 | QWidget *first = fw; | - | ||||||||||||
| 744 | while ((first = first->nextInFocusChain()) != fw && first->focusPolicy() == Qt::NoFocus) | - | ||||||||||||
| 745 | ; | - | ||||||||||||
| 746 | if (first != d->mainDef && qobject_cast<QPushButton*>(first)) | - | ||||||||||||
| 747 | d->mainDef->setFocus(); | - | ||||||||||||
| 748 | } | - | ||||||||||||
| 749 | if (!d->mainDef && isWindow()) { | - | ||||||||||||
| 750 | QWidget *w = fw; | - | ||||||||||||
| 751 | while ((w = w->nextInFocusChain()) != fw) { | - | ||||||||||||
| 752 | QPushButton *pb = qobject_cast<QPushButton *>(w); | - | ||||||||||||
| 753 | if (pb && pb->autoDefault() && pb->focusPolicy() != Qt::NoFocus) { | - | ||||||||||||
| 754 | pb->setDefault(true); | - | ||||||||||||
| 755 | break; | - | ||||||||||||
| 756 | } | - | ||||||||||||
| 757 | } | - | ||||||||||||
| 758 | } | - | ||||||||||||
| 759 | if (fw && !fw->hasFocus()) { | - | ||||||||||||
| 760 | QFocusEvent e(QEvent::FocusIn, Qt::TabFocusReason); | - | ||||||||||||
| 761 | QApplication::sendEvent(fw, &e); | - | ||||||||||||
| 762 | } | - | ||||||||||||
| 763 | - | |||||||||||||
| 764 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||
| 765 | QAccessibleEvent event(this, QAccessible::DialogStart); | - | ||||||||||||
| 766 | QAccessible::updateAccessibility(&event); | - | ||||||||||||
| 767 | #endif | - | ||||||||||||
| 768 | - | |||||||||||||
| 769 | } else { | - | ||||||||||||
| 770 | if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden)) | - | ||||||||||||
| 771 | return; | - | ||||||||||||
| 772 | - | |||||||||||||
| 773 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||
| 774 | if (isVisible()) { | - | ||||||||||||
| 775 | QAccessibleEvent event(this, QAccessible::DialogEnd); | - | ||||||||||||
| 776 | QAccessible::updateAccessibility(&event); | - | ||||||||||||
| 777 | } | - | ||||||||||||
| 778 | #endif | - | ||||||||||||
| 779 | - | |||||||||||||
| 780 | // Reimplemented to exit a modal event loop when the dialog is hidden. | - | ||||||||||||
| 781 | QWidget::setVisible(visible); | - | ||||||||||||
| 782 | if (d->eventLoop) | - | ||||||||||||
| 783 | d->eventLoop->exit(); | - | ||||||||||||
| 784 | } | - | ||||||||||||
| 785 | - | |||||||||||||
| 786 | const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme(); | - | ||||||||||||
| 787 | if (d->mainDef && isActiveWindow() | - | ||||||||||||
| 788 | && theme->themeHint(QPlatformTheme::DialogSnapToDefaultButton).toBool()) | - | ||||||||||||
| 789 | QCursor::setPos(d->mainDef->mapToGlobal(d->mainDef->rect().center())); | - | ||||||||||||
| 790 | } | - | ||||||||||||
| 791 | - | |||||||||||||
| 792 | /*!\reimp */ | - | ||||||||||||
| 793 | void QDialog::showEvent(QShowEvent *event) | - | ||||||||||||
| 794 | { | - | ||||||||||||
| 795 | if (!event->spontaneous() && !testAttribute(Qt::WA_Moved)) { | - | ||||||||||||
| 796 | Qt::WindowStates state = windowState(); | - | ||||||||||||
| 797 | adjustPosition(parentWidget()); | - | ||||||||||||
| 798 | setAttribute(Qt::WA_Moved, false); // not really an explicit position | - | ||||||||||||
| 799 | if (state != windowState()) | - | ||||||||||||
| 800 | setWindowState(state); | - | ||||||||||||
| 801 | } | - | ||||||||||||
| 802 | } | - | ||||||||||||
| 803 | - | |||||||||||||
| 804 | /*! \internal */ | - | ||||||||||||
| 805 | void QDialog::adjustPosition(QWidget* w) | - | ||||||||||||
| 806 | { | - | ||||||||||||
| 807 | - | |||||||||||||
| 808 | if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) | - | ||||||||||||
| 809 | if (theme->themeHint(QPlatformTheme::WindowAutoPlacement).toBool()) | - | ||||||||||||
| 810 | return; | - | ||||||||||||
| 811 | QPoint p(0, 0); | - | ||||||||||||
| 812 | int extraw = 0, extrah = 0, scrn = 0; | - | ||||||||||||
| 813 | if (w) | - | ||||||||||||
| 814 | w = w->window(); | - | ||||||||||||
| 815 | QRect desk; | - | ||||||||||||
| 816 | if (w) { | - | ||||||||||||
| 817 | scrn = QApplication::desktop()->screenNumber(w); | - | ||||||||||||
| 818 | } else if (QApplication::desktop()->isVirtualDesktop()) { | - | ||||||||||||
| 819 | scrn = QApplication::desktop()->screenNumber(QCursor::pos()); | - | ||||||||||||
| 820 | } else { | - | ||||||||||||
| 821 | scrn = QApplication::desktop()->screenNumber(this); | - | ||||||||||||
| 822 | } | - | ||||||||||||
| 823 | desk = QApplication::desktop()->availableGeometry(scrn); | - | ||||||||||||
| 824 | - | |||||||||||||
| 825 | QWidgetList list = QApplication::topLevelWidgets(); | - | ||||||||||||
| 826 | for (int i = 0; (extraw == 0 || extrah == 0) && i < list.size(); ++i) { | - | ||||||||||||
| 827 | QWidget * current = list.at(i); | - | ||||||||||||
| 828 | if (current->isVisible()) { | - | ||||||||||||
| 829 | int framew = current->geometry().x() - current->x(); | - | ||||||||||||
| 830 | int frameh = current->geometry().y() - current->y(); | - | ||||||||||||
| 831 | - | |||||||||||||
| 832 | extraw = qMax(extraw, framew); | - | ||||||||||||
| 833 | extrah = qMax(extrah, frameh); | - | ||||||||||||
| 834 | } | - | ||||||||||||
| 835 | } | - | ||||||||||||
| 836 | - | |||||||||||||
| 837 | // sanity check for decoration frames. With embedding, we | - | ||||||||||||
| 838 | // might get extraordinary values | - | ||||||||||||
| 839 | if (extraw == 0 || extrah == 0 || extraw >= 10 || extrah >= 40) { | - | ||||||||||||
| 840 | extrah = 40; | - | ||||||||||||
| 841 | extraw = 10; | - | ||||||||||||
| 842 | } | - | ||||||||||||
| 843 | - | |||||||||||||
| 844 | - | |||||||||||||
| 845 | if (w) { | - | ||||||||||||
| 846 | // Use pos() if the widget is embedded into a native window | - | ||||||||||||
| 847 | QPoint pp; | - | ||||||||||||
| 848 | if (w->windowHandle() && w->windowHandle()->property("_q_embedded_native_parent_handle").value<WId>()) | - | ||||||||||||
| 849 | pp = w->pos(); | - | ||||||||||||
| 850 | else | - | ||||||||||||
| 851 | pp = w->mapToGlobal(QPoint(0,0)); | - | ||||||||||||
| 852 | p = QPoint(pp.x() + w->width()/2, | - | ||||||||||||
| 853 | pp.y() + w->height()/ 2); | - | ||||||||||||
| 854 | } else { | - | ||||||||||||
| 855 | // p = middle of the desktop | - | ||||||||||||
| 856 | p = QPoint(desk.x() + desk.width()/2, desk.y() + desk.height()/2); | - | ||||||||||||
| 857 | } | - | ||||||||||||
| 858 | - | |||||||||||||
| 859 | // p = origin of this | - | ||||||||||||
| 860 | p = QPoint(p.x()-width()/2 - extraw, | - | ||||||||||||
| 861 | p.y()-height()/2 - extrah); | - | ||||||||||||
| 862 | - | |||||||||||||
| 863 | - | |||||||||||||
| 864 | if (p.x() + extraw + width() > desk.x() + desk.width()) | - | ||||||||||||
| 865 | p.setX(desk.x() + desk.width() - width() - extraw); | - | ||||||||||||
| 866 | if (p.x() < desk.x()) | - | ||||||||||||
| 867 | p.setX(desk.x()); | - | ||||||||||||
| 868 | - | |||||||||||||
| 869 | if (p.y() + extrah + height() > desk.y() + desk.height()) | - | ||||||||||||
| 870 | p.setY(desk.y() + desk.height() - height() - extrah); | - | ||||||||||||
| 871 | if (p.y() < desk.y()) | - | ||||||||||||
| 872 | p.setY(desk.y()); | - | ||||||||||||
| 873 | - | |||||||||||||
| 874 | // QTBUG-52735: Manually set the correct target screen since scaling in a | - | ||||||||||||
| 875 | // subsequent call to QWindow::resize() may otherwise use the wrong factor | - | ||||||||||||
| 876 | // if the screen changed notification is still in an event queue. | - | ||||||||||||
| 877 | if (scrn >= 0) { | - | ||||||||||||
| 878 | if (QWindow *window = windowHandle()) | - | ||||||||||||
| 879 | window->setScreen(QGuiApplication::screens().at(scrn)); | - | ||||||||||||
| 880 | } | - | ||||||||||||
| 881 | - | |||||||||||||
| 882 | move(p); | - | ||||||||||||
| 883 | } | - | ||||||||||||
| 884 | - | |||||||||||||
| 885 | /*! | - | ||||||||||||
| 886 | \obsolete | - | ||||||||||||
| 887 | - | |||||||||||||
| 888 | If \a orientation is Qt::Horizontal, the extension will be displayed | - | ||||||||||||
| 889 | to the right of the dialog's main area. If \a orientation is | - | ||||||||||||
| 890 | Qt::Vertical, the extension will be displayed below the dialog's main | - | ||||||||||||
| 891 | area. | - | ||||||||||||
| 892 | - | |||||||||||||
| 893 | Instead of using this functionality, we recommend that you simply call | - | ||||||||||||
| 894 | show() or hide() on the part of the dialog that you want to use as an | - | ||||||||||||
| 895 | extension. See the \l{Extension Example} for details. | - | ||||||||||||
| 896 | - | |||||||||||||
| 897 | \sa setExtension() | - | ||||||||||||
| 898 | */ | - | ||||||||||||
| 899 | void QDialog::setOrientation(Qt::Orientation orientation) | - | ||||||||||||
| 900 | { | - | ||||||||||||
| 901 | Q_D(QDialog); | - | ||||||||||||
| 902 | d->orientation = orientation; | - | ||||||||||||
| 903 | } | - | ||||||||||||
| 904 | - | |||||||||||||
| 905 | /*! | - | ||||||||||||
| 906 | \obsolete | - | ||||||||||||
| 907 | - | |||||||||||||
| 908 | Returns the dialog's extension orientation. | - | ||||||||||||
| 909 | - | |||||||||||||
| 910 | Instead of using this functionality, we recommend that you simply call | - | ||||||||||||
| 911 | show() or hide() on the part of the dialog that you want to use as an | - | ||||||||||||
| 912 | extension. See the \l{Extension Example} for details. | - | ||||||||||||
| 913 | - | |||||||||||||
| 914 | \sa extension() | - | ||||||||||||
| 915 | */ | - | ||||||||||||
| 916 | Qt::Orientation QDialog::orientation() const | - | ||||||||||||
| 917 | { | - | ||||||||||||
| 918 | Q_D(const QDialog); | - | ||||||||||||
| 919 | return d->orientation; | - | ||||||||||||
| 920 | } | - | ||||||||||||
| 921 | - | |||||||||||||
| 922 | /*! | - | ||||||||||||
| 923 | \obsolete | - | ||||||||||||
| 924 | - | |||||||||||||
| 925 | Sets the widget, \a extension, to be the dialog's extension, | - | ||||||||||||
| 926 | deleting any previous extension. The dialog takes ownership of the | - | ||||||||||||
| 927 | extension. Note that if 0 is passed any existing extension will be | - | ||||||||||||
| 928 | deleted. This function must only be called while the dialog is hidden. | - | ||||||||||||
| 929 | - | |||||||||||||
| 930 | Instead of using this functionality, we recommend that you simply call | - | ||||||||||||
| 931 | show() or hide() on the part of the dialog that you want to use as an | - | ||||||||||||
| 932 | extension. See the \l{Extension Example} for details. | - | ||||||||||||
| 933 | - | |||||||||||||
| 934 | \sa showExtension(), setOrientation() | - | ||||||||||||
| 935 | */ | - | ||||||||||||
| 936 | void QDialog::setExtension(QWidget* extension) | - | ||||||||||||
| 937 | { | - | ||||||||||||
| 938 | Q_D(QDialog); | - | ||||||||||||
| 939 | delete d->extension; | - | ||||||||||||
| 940 | d->extension = extension; | - | ||||||||||||
| 941 | - | |||||||||||||
| 942 | if (!extension) | - | ||||||||||||
| 943 | return; | - | ||||||||||||
| 944 | - | |||||||||||||
| 945 | if (extension->parentWidget() != this) | - | ||||||||||||
| 946 | extension->setParent(this); | - | ||||||||||||
| 947 | extension->hide(); | - | ||||||||||||
| 948 | } | - | ||||||||||||
| 949 | - | |||||||||||||
| 950 | /*! | - | ||||||||||||
| 951 | \obsolete | - | ||||||||||||
| 952 | - | |||||||||||||
| 953 | Returns the dialog's extension or 0 if no extension has been | - | ||||||||||||
| 954 | defined. | - | ||||||||||||
| 955 | - | |||||||||||||
| 956 | Instead of using this functionality, we recommend that you simply call | - | ||||||||||||
| 957 | show() or hide() on the part of the dialog that you want to use as an | - | ||||||||||||
| 958 | extension. See the \l{Extension Example} for details. | - | ||||||||||||
| 959 | - | |||||||||||||
| 960 | \sa showExtension(), setOrientation() | - | ||||||||||||
| 961 | */ | - | ||||||||||||
| 962 | QWidget* QDialog::extension() const | - | ||||||||||||
| 963 | { | - | ||||||||||||
| 964 | Q_D(const QDialog); | - | ||||||||||||
| 965 | return d->extension; | - | ||||||||||||
| 966 | } | - | ||||||||||||
| 967 | - | |||||||||||||
| 968 | - | |||||||||||||
| 969 | /*! | - | ||||||||||||
| 970 | \obsolete | - | ||||||||||||
| 971 | - | |||||||||||||
| 972 | If \a showIt is true, the dialog's extension is shown; otherwise the | - | ||||||||||||
| 973 | extension is hidden. | - | ||||||||||||
| 974 | - | |||||||||||||
| 975 | Instead of using this functionality, we recommend that you simply call | - | ||||||||||||
| 976 | show() or hide() on the part of the dialog that you want to use as an | - | ||||||||||||
| 977 | extension. See the \l{Extension Example} for details. | - | ||||||||||||
| 978 | - | |||||||||||||
| 979 | \sa show(), setExtension(), setOrientation() | - | ||||||||||||
| 980 | */ | - | ||||||||||||
| 981 | void QDialog::showExtension(bool showIt) | - | ||||||||||||
| 982 | { | - | ||||||||||||
| 983 | Q_D(QDialog); | - | ||||||||||||
| 984 | d->doShowExtension = showIt; | - | ||||||||||||
| 985 | if (!d->extension) | - | ||||||||||||
| 986 | return; | - | ||||||||||||
| 987 | if (!testAttribute(Qt::WA_WState_Visible)) | - | ||||||||||||
| 988 | return; | - | ||||||||||||
| 989 | if (d->extension->isVisible() == showIt) | - | ||||||||||||
| 990 | return; | - | ||||||||||||
| 991 | - | |||||||||||||
| 992 | if (showIt) { | - | ||||||||||||
| 993 | d->size = size(); | - | ||||||||||||
| 994 | d->min = minimumSize(); | - | ||||||||||||
| 995 | d->max = maximumSize(); | - | ||||||||||||
| 996 | if (layout()) | - | ||||||||||||
| 997 | layout()->setEnabled(false); | - | ||||||||||||
| 998 | QSize s(d->extension->sizeHint() | - | ||||||||||||
| 999 | .expandedTo(d->extension->minimumSize()) | - | ||||||||||||
| 1000 | .boundedTo(d->extension->maximumSize())); | - | ||||||||||||
| 1001 | if (d->orientation == Qt::Horizontal) { | - | ||||||||||||
| 1002 | int h = qMax(height(), s.height()); | - | ||||||||||||
| 1003 | d->extension->setGeometry(width(), 0, s.width(), h); | - | ||||||||||||
| 1004 | setFixedSize(width() + s.width(), h); | - | ||||||||||||
| 1005 | } else { | - | ||||||||||||
| 1006 | int w = qMax(width(), s.width()); | - | ||||||||||||
| 1007 | d->extension->setGeometry(0, height(), w, s.height()); | - | ||||||||||||
| 1008 | setFixedSize(w, height() + s.height()); | - | ||||||||||||
| 1009 | } | - | ||||||||||||
| 1010 | d->extension->show(); | - | ||||||||||||
| 1011 | #ifndef QT_NO_SIZEGRIP | - | ||||||||||||
| 1012 | const bool sizeGripEnabled = isSizeGripEnabled(); | - | ||||||||||||
| 1013 | setSizeGripEnabled(false); | - | ||||||||||||
| 1014 | d->sizeGripEnabled = sizeGripEnabled; | - | ||||||||||||
| 1015 | #endif | - | ||||||||||||
| 1016 | } else { | - | ||||||||||||
| 1017 | d->extension->hide(); | - | ||||||||||||
| 1018 | // workaround for CDE window manager that won't shrink with (-1,-1) | - | ||||||||||||
| 1019 | setMinimumSize(d->min.expandedTo(QSize(1, 1))); | - | ||||||||||||
| 1020 | setMaximumSize(d->max); | - | ||||||||||||
| 1021 | resize(d->size); | - | ||||||||||||
| 1022 | if (layout()) | - | ||||||||||||
| 1023 | layout()->setEnabled(true); | - | ||||||||||||
| 1024 | #ifndef QT_NO_SIZEGRIP | - | ||||||||||||
| 1025 | setSizeGripEnabled(d->sizeGripEnabled); | - | ||||||||||||
| 1026 | #endif | - | ||||||||||||
| 1027 | } | - | ||||||||||||
| 1028 | } | - | ||||||||||||
| 1029 | - | |||||||||||||
| 1030 | - | |||||||||||||
| 1031 | /*! \reimp */ | - | ||||||||||||
| 1032 | QSize QDialog::sizeHint() const | - | ||||||||||||
| 1033 | { | - | ||||||||||||
| 1034 | Q_D(const QDialog); | - | ||||||||||||
| 1035 | if (d->extension) { | - | ||||||||||||
| 1036 | if (d->orientation == Qt::Horizontal) | - | ||||||||||||
| 1037 | return QSize(QWidget::sizeHint().width(), | - | ||||||||||||
| 1038 | qMax(QWidget::sizeHint().height(),d->extension->sizeHint().height())); | - | ||||||||||||
| 1039 | else | - | ||||||||||||
| 1040 | return QSize(qMax(QWidget::sizeHint().width(), d->extension->sizeHint().width()), | - | ||||||||||||
| 1041 | QWidget::sizeHint().height()); | - | ||||||||||||
| 1042 | } | - | ||||||||||||
| 1043 | return QWidget::sizeHint(); | - | ||||||||||||
| 1044 | } | - | ||||||||||||
| 1045 | - | |||||||||||||
| 1046 | - | |||||||||||||
| 1047 | /*! \reimp */ | - | ||||||||||||
| 1048 | QSize QDialog::minimumSizeHint() const | - | ||||||||||||
| 1049 | { | - | ||||||||||||
| 1050 | Q_D(const QDialog); | - | ||||||||||||
| 1051 | if (d->extension) { | - | ||||||||||||
| 1052 | if (d->orientation == Qt::Horizontal) | - | ||||||||||||
| 1053 | return QSize(QWidget::minimumSizeHint().width(), | - | ||||||||||||
| 1054 | qMax(QWidget::minimumSizeHint().height(), d->extension->minimumSizeHint().height())); | - | ||||||||||||
| 1055 | else | - | ||||||||||||
| 1056 | return QSize(qMax(QWidget::minimumSizeHint().width(), d->extension->minimumSizeHint().width()), | - | ||||||||||||
| 1057 | QWidget::minimumSizeHint().height()); | - | ||||||||||||
| 1058 | } | - | ||||||||||||
| 1059 | - | |||||||||||||
| 1060 | return QWidget::minimumSizeHint(); | - | ||||||||||||
| 1061 | } | - | ||||||||||||
| 1062 | - | |||||||||||||
| 1063 | /*! | - | ||||||||||||
| 1064 | \property QDialog::modal | - | ||||||||||||
| 1065 | \brief whether show() should pop up the dialog as modal or modeless | - | ||||||||||||
| 1066 | - | |||||||||||||
| 1067 | By default, this property is \c false and show() pops up the dialog | - | ||||||||||||
| 1068 | as modeless. Setting his property to true is equivalent to setting | - | ||||||||||||
| 1069 | QWidget::windowModality to Qt::ApplicationModal. | - | ||||||||||||
| 1070 | - | |||||||||||||
| 1071 | exec() ignores the value of this property and always pops up the | - | ||||||||||||
| 1072 | dialog as modal. | - | ||||||||||||
| 1073 | - | |||||||||||||
| 1074 | \sa QWidget::windowModality, show(), exec() | - | ||||||||||||
| 1075 | */ | - | ||||||||||||
| 1076 | - | |||||||||||||
| 1077 | void QDialog::setModal(bool modal) | - | ||||||||||||
| 1078 | { | - | ||||||||||||
| 1079 | setAttribute(Qt::WA_ShowModal, modal); | - | ||||||||||||
| 1080 | } | - | ||||||||||||
| 1081 | - | |||||||||||||
| 1082 | - | |||||||||||||
| 1083 | bool QDialog::isSizeGripEnabled() const | - | ||||||||||||
| 1084 | { | - | ||||||||||||
| 1085 | #ifndef QT_NO_SIZEGRIP | - | ||||||||||||
| 1086 | Q_D(const QDialog); | - | ||||||||||||
| 1087 | return !!d->resizer; | - | ||||||||||||
| 1088 | #else | - | ||||||||||||
| 1089 | return false; | - | ||||||||||||
| 1090 | #endif | - | ||||||||||||
| 1091 | } | - | ||||||||||||
| 1092 | - | |||||||||||||
| 1093 | - | |||||||||||||
| 1094 | void QDialog::setSizeGripEnabled(bool enabled) | - | ||||||||||||
| 1095 | { | - | ||||||||||||
| 1096 | #ifdef QT_NO_SIZEGRIP | - | ||||||||||||
| 1097 | Q_UNUSED(enabled); | - | ||||||||||||
| 1098 | #else | - | ||||||||||||
| 1099 | Q_D(QDialog); | - | ||||||||||||
| 1100 | #ifndef QT_NO_SIZEGRIP | - | ||||||||||||
| 1101 | d->sizeGripEnabled = enabled; | - | ||||||||||||
| 1102 | if (enabled && d->doShowExtension) | - | ||||||||||||
| 1103 | return; | - | ||||||||||||
| 1104 | #endif | - | ||||||||||||
| 1105 | if (!enabled != !d->resizer) { | - | ||||||||||||
| 1106 | if (enabled) { | - | ||||||||||||
| 1107 | d->resizer = new QSizeGrip(this); | - | ||||||||||||
| 1108 | // adjustSize() processes all events, which is suboptimal | - | ||||||||||||
| 1109 | d->resizer->resize(d->resizer->sizeHint()); | - | ||||||||||||
| 1110 | if (isRightToLeft()) | - | ||||||||||||
| 1111 | d->resizer->move(rect().bottomLeft() -d->resizer->rect().bottomLeft()); | - | ||||||||||||
| 1112 | else | - | ||||||||||||
| 1113 | d->resizer->move(rect().bottomRight() -d->resizer->rect().bottomRight()); | - | ||||||||||||
| 1114 | d->resizer->raise(); | - | ||||||||||||
| 1115 | d->resizer->show(); | - | ||||||||||||
| 1116 | } else { | - | ||||||||||||
| 1117 | delete d->resizer; | - | ||||||||||||
| 1118 | d->resizer = 0; | - | ||||||||||||
| 1119 | } | - | ||||||||||||
| 1120 | } | - | ||||||||||||
| 1121 | #endif //QT_NO_SIZEGRIP | - | ||||||||||||
| 1122 | } | - | ||||||||||||
| 1123 | - | |||||||||||||
| 1124 | - | |||||||||||||
| 1125 | - | |||||||||||||
| 1126 | /*! \reimp */ | - | ||||||||||||
| 1127 | void QDialog::resizeEvent(QResizeEvent *) | - | ||||||||||||
| 1128 | { | - | ||||||||||||
| 1129 | #ifndef QT_NO_SIZEGRIP | - | ||||||||||||
| 1130 | Q_D(QDialog); | - | ||||||||||||
| 1131 | if (d->resizer) { | - | ||||||||||||
| 1132 | if (isRightToLeft()) | - | ||||||||||||
| 1133 | d->resizer->move(rect().bottomLeft() -d->resizer->rect().bottomLeft()); | - | ||||||||||||
| 1134 | else | - | ||||||||||||
| 1135 | d->resizer->move(rect().bottomRight() -d->resizer->rect().bottomRight()); | - | ||||||||||||
| 1136 | d->resizer->raise(); | - | ||||||||||||
| 1137 | } | - | ||||||||||||
| 1138 | #endif | - | ||||||||||||
| 1139 | } | - | ||||||||||||
| 1140 | - | |||||||||||||
| 1141 | /*! \fn void QDialog::finished(int result) | - | ||||||||||||
| 1142 | \since 4.1 | - | ||||||||||||
| 1143 | - | |||||||||||||
| 1144 | This signal is emitted when the dialog's \a result code has been | - | ||||||||||||
| 1145 | set, either by the user or by calling done(), accept(), or | - | ||||||||||||
| 1146 | reject(). | - | ||||||||||||
| 1147 | - | |||||||||||||
| 1148 | Note that this signal is \e not emitted when hiding the dialog | - | ||||||||||||
| 1149 | with hide() or setVisible(false). This includes deleting the | - | ||||||||||||
| 1150 | dialog while it is visible. | - | ||||||||||||
| 1151 | - | |||||||||||||
| 1152 | \sa accepted(), rejected() | - | ||||||||||||
| 1153 | */ | - | ||||||||||||
| 1154 | - | |||||||||||||
| 1155 | /*! \fn void QDialog::accepted() | - | ||||||||||||
| 1156 | \since 4.1 | - | ||||||||||||
| 1157 | - | |||||||||||||
| 1158 | This signal is emitted when the dialog has been accepted either by | - | ||||||||||||
| 1159 | the user or by calling accept() or done() with the | - | ||||||||||||
| 1160 | QDialog::Accepted argument. | - | ||||||||||||
| 1161 | - | |||||||||||||
| 1162 | Note that this signal is \e not emitted when hiding the dialog | - | ||||||||||||
| 1163 | with hide() or setVisible(false). This includes deleting the | - | ||||||||||||
| 1164 | dialog while it is visible. | - | ||||||||||||
| 1165 | - | |||||||||||||
| 1166 | \sa finished(), rejected() | - | ||||||||||||
| 1167 | */ | - | ||||||||||||
| 1168 | - | |||||||||||||
| 1169 | /*! \fn void QDialog::rejected() | - | ||||||||||||
| 1170 | \since 4.1 | - | ||||||||||||
| 1171 | - | |||||||||||||
| 1172 | This signal is emitted when the dialog has been rejected either by | - | ||||||||||||
| 1173 | the user or by calling reject() or done() with the | - | ||||||||||||
| 1174 | QDialog::Rejected argument. | - | ||||||||||||
| 1175 | - | |||||||||||||
| 1176 | Note that this signal is \e not emitted when hiding the dialog | - | ||||||||||||
| 1177 | with hide() or setVisible(false). This includes deleting the | - | ||||||||||||
| 1178 | dialog while it is visible. | - | ||||||||||||
| 1179 | - | |||||||||||||
| 1180 | \sa finished(), accepted() | - | ||||||||||||
| 1181 | */ | - | ||||||||||||
| 1182 | - | |||||||||||||
| 1183 | QT_END_NAMESPACE | - | ||||||||||||
| 1184 | #include "moc_qdialog.cpp" | - | ||||||||||||
| Source code | Switch to Preprocessed file |