OpenCoverage

qdialog.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/dialogs/qdialog.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
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-
62QT_BEGIN_NAMESPACE-
63-
64static inline int themeDialogType(const QDialog *dialog)-
65{-
66#ifndef QT_NO_FILEDIALOG-
67 if (qobject_cast<const QFileDialog *>(dialog))
qobject_cast<c...log *>(dialog)Description
TRUEnever evaluated
FALSEnever evaluated
0
68 return QPlatformTheme::FileDialog;
never executed: return QPlatformTheme::FileDialog;
0
69#endif-
70#ifndef QT_NO_COLORDIALOG-
71 if (qobject_cast<const QColorDialog *>(dialog))
qobject_cast<c...log *>(dialog)Description
TRUEnever evaluated
FALSEnever evaluated
0
72 return QPlatformTheme::ColorDialog;
never executed: return QPlatformTheme::ColorDialog;
0
73#endif-
74#ifndef QT_NO_FONTDIALOG-
75 if (qobject_cast<const QFontDialog *>(dialog))
qobject_cast<c...log *>(dialog)Description
TRUEnever evaluated
FALSEnever evaluated
0
76 return QPlatformTheme::FontDialog;
never executed: return QPlatformTheme::FontDialog;
0
77#endif-
78#ifndef QT_NO_MESSAGEBOX-
79 if (qobject_cast<const QMessageBox *>(dialog))
qobject_cast<c...Box *>(dialog)Description
TRUEnever evaluated
FALSEnever evaluated
0
80 return QPlatformTheme::MessageDialog;
never executed: return QPlatformTheme::MessageDialog;
0
81#endif-
82#ifndef QT_NO_ERRORMESSAGE-
83 if (qobject_cast<const QErrorMessage *>(dialog))
qobject_cast<c...age *>(dialog)Description
TRUEnever evaluated
FALSEnever evaluated
0
84 return QPlatformTheme::MessageDialog;
never executed: return QPlatformTheme::MessageDialog;
0
85#endif-
86 return -1;
never executed: return -1;
0
87}-
88-
89QDialogPrivate::~QDialogPrivate()-
90{-
91 delete m_platformHelper;-
92}
never executed: end of block
0
93-
94QPlatformDialogHelper *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()) {
!m_platformHelperCreatedDescription
TRUEnever evaluated
FALSEnever evaluated
canBeNativeDialog()Description
TRUEnever evaluated
FALSEnever evaluated
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) {
type >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
104 m_platformHelper = QGuiApplicationPrivate::platformTheme()-
105 ->createPlatformDialogHelper(static_cast<QPlatformTheme::DialogType>(type));-
106 if (m_platformHelper) {
m_platformHelperDescription
TRUEnever evaluated
FALSEnever evaluated
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-
116bool 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)
type >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
122 return QGuiApplicationPrivate::platformTheme()
never executed: return QGuiApplicationPrivate::platformTheme() ->usePlatformNativeDialog(static_cast<QPlatformTheme::DialogType>(type));
0
123 ->usePlatformNativeDialog(static_cast<QPlatformTheme::DialogType>(type));
never executed: return QGuiApplicationPrivate::platformTheme() ->usePlatformNativeDialog(static_cast<QPlatformTheme::DialogType>(type));
0
124 return false;
never executed: return false;
0
125}-
126-
127QWindow *QDialogPrivate::parentWindow() const-
128{-
129 if (const QWidget *parent = q_func()->nativeParentWidget())
const QWidget ...ParentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
130 return parent->windowHandle();
never executed: return parent->windowHandle();
0
131 return 0;
never executed: return 0;
0
132}-
133-
134bool QDialogPrivate::setNativeDialogVisible(bool visible)-
135{-
136 if (QPlatformDialogHelper *helper = platformHelper()) {
QPlatformDialo...atformHelper()Description
TRUEnever evaluated
FALSEnever evaluated
0
137 if (visible) {
visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
138 Q_Q(QDialog);-
139 helperPrepareShow(helper);-
140 nativeDialogInUse = helper->show(q->windowFlags(), q->windowModality(), parentWindow());-
141 } else if (nativeDialogInUse) {
never executed: end of block
nativeDialogInUseDescription
TRUEnever evaluated
FALSEnever evaluated
0
142 helper->hide();-
143 }
never executed: end of block
0
144 }
never executed: end of block
0
145 return nativeDialogInUse;
never executed: return nativeDialogInUse;
0
146}-
147-
148QVariant QDialogPrivate::styleHint(QPlatformDialogHelper::StyleHint hint) const-
149{-
150 if (const QPlatformDialogHelper *helper = platformHelper())
const QPlatfor...atformHelper()Description
TRUEnever evaluated
FALSEnever evaluated
0
151 return helper->styleHint(hint);
never executed: return helper->styleHint(hint);
0
152 return QPlatformDialogHelper::defaultStyleHint(hint);
never executed: return QPlatformDialogHelper::defaultStyleHint(hint);
0
153}-
154-
155void QDialogPrivate::deletePlatformHelper()-
156{-
157 delete m_platformHelper;-
158 m_platformHelper = 0;-
159 m_platformHelperCreated = false;-
160 nativeDialogInUse = false;-
161}
never executed: end of block
0
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-
333QDialog::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}
never executed: end of block
0
338-
339/*!-
340 \overload-
341 \internal-
342*/-
343QDialog::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}
never executed: end of block
0
347-
348/*!-
349 Destroys the QDialog, deleting all its children.-
350*/-
351-
352QDialog::~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(...) {
never executed: end of block
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*/-
370void 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) {
i<list.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
376 QPushButton *pb = list.at(i);-
377 if (pb->window() == q) {
pb->window() == qDescription
TRUEnever evaluated
FALSEnever evaluated
0
378 if (pb == mainDef)
pb == mainDefDescription
TRUEnever evaluated
FALSEnever evaluated
0
379 hasMain = true;
never executed: hasMain = true;
0
380 if (pb != pushButton)
pb != pushButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
381 pb->setDefault(false);
never executed: pb->setDefault(false);
0
382 }
never executed: end of block
0
383 }
never executed: end of block
0
384 if (!pushButton && hasMain)
!pushButtonDescription
TRUEnever evaluated
FALSEnever evaluated
hasMainDescription
TRUEnever evaluated
FALSEnever evaluated
0
385 mainDef->setDefault(true);
never executed: mainDef->setDefault(true);
0
386 if (!hasMain)
!hasMainDescription
TRUEnever evaluated
FALSEnever evaluated
0
387 mainDef = pushButton;
never executed: mainDef = pushButton;
0
388}
never executed: end of block
0
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*/-
395void QDialogPrivate::setMainDefault(QPushButton *pushButton)-
396{-
397 mainDef = 0;-
398 setDefault(pushButton);-
399}
never executed: end of block
0
400-
401/*!-
402 \internal-
403 Hides the default button indicator. Called when non auto-default-
404 push button get focus.-
405 */-
406void QDialogPrivate::hideDefault()-
407{-
408 Q_Q(QDialog);-
409 QList<QPushButton*> list = q->findChildren<QPushButton*>();-
410 for (int i=0; i<list.size(); ++i) {
i<list.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
411 list.at(i)->setDefault(false);-
412 }
never executed: end of block
0
413}
never executed: end of block
0
414-
415void QDialogPrivate::resetModalitySetByOpen()-
416{-
417 Q_Q(QDialog);-
418 if (resetModalityTo != -1 && !q->testAttribute(Qt::WA_SetWindowModality)) {
resetModalityTo != -1Description
TRUEnever evaluated
FALSEnever evaluated
!q->testAttrib...indowModality)Description
TRUEnever evaluated
FALSEnever evaluated
0
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 }
never executed: end of block
0
427 resetModalityTo = -1;-
428}
never executed: end of block
0
429-
430#if defined(Q_OS_WINCE)-
431#ifdef Q_OS_WINCE_WM-
432void QDialogPrivate::_q_doneAction()-
433{-
434 //Done...-
435 QApplication::postEvent(q_func(), new QEvent(QEvent::OkRequest));-
436}-
437#endif-
438-
439/*!-
440 \reimp-
441*/-
442bool 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*/-
465int QDialog::result() const-
466{-
467 Q_D(const QDialog);-
468 return d->rescode;
never executed: return d->rescode;
0
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*/-
479void QDialog::setResult(int r)-
480{-
481 Q_D(QDialog);-
482 d->rescode = r;-
483}
never executed: end of block
0
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*/-
493void QDialog::open()-
494{-
495 Q_D(QDialog);-
496-
497 Qt::WindowModality modality = windowModality();-
498 if (modality != Qt::WindowModal) {
modality != Qt::WindowModalDescription
TRUEnever evaluated
FALSEnever evaluated
0
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 }
never executed: end of block
0
507-
508 setResult(0);-
509 show();-
510}
never executed: end of block
0
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-
526int QDialog::exec()-
527{-
528 Q_D(QDialog);-
529-
530 if (Q_UNLIKELY(d->eventLoop)) {
__builtin_expe...tLoop), false)Description
TRUEnever evaluated
FALSEnever evaluated
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) {
d->nativeDialogInUseDescription
TRUEnever evaluated
FALSEnever evaluated
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())
guard.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
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)
d->nativeDialogInUseDescription
TRUEnever evaluated
FALSEnever evaluated
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)
deleteOnCloseDescription
TRUEnever evaluated
FALSEnever evaluated
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-
582void 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)
r == AcceptedDescription
TRUEnever evaluated
FALSEnever evaluated
0
593 emit accepted();
never executed: accepted();
0
594 else if (r == Rejected)
r == RejectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
595 emit rejected();
never executed: rejected();
0
596}
never executed: end of block
0
597-
598/*!-
599 Hides the modal dialog and sets the result code to \c Accepted.-
600-
601 \sa reject(), done()-
602*/-
603-
604void QDialog::accept()-
605{-
606 done(Accepted);-
607}
never executed: end of block
0
608-
609/*!-
610 Hides the modal dialog and sets the result code to \c Rejected.-
611-
612 \sa accept(), done()-
613*/-
614-
615void QDialog::reject()-
616{-
617 done(Rejected);-
618}
never executed: end of block
0
619-
620/*! \reimp */-
621bool QDialog::eventFilter(QObject *o, QEvent *e)-
622{-
623 return QWidget::eventFilter(o, e);
never executed: return QWidget::eventFilter(o, e);
0
624}-
625-
626/*****************************************************************************-
627 Event handlers-
628 *****************************************************************************/-
629-
630#ifndef QT_NO_CONTEXTMENU-
631/*! \reimp */-
632void 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) {
!wDescription
TRUEnever evaluated
FALSEnever evaluated
0
639 w = rect().contains(e->pos()) ? this : 0;
rect().contains(e->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
640 if (!w)
!wDescription
TRUEnever evaluated
FALSEnever evaluated
0
641 return;
never executed: return;
0
642 }
never executed: end of block
0
643 while (w && w->whatsThis().size() == 0 && !w->testAttribute(Qt::WA_CustomWhatsThis))
wDescription
TRUEnever evaluated
FALSEnever evaluated
w->whatsThis().size() == 0Description
TRUEnever evaluated
FALSEnever evaluated
!w->testAttrib...stomWhatsThis)Description
TRUEnever evaluated
FALSEnever evaluated
0
644 w = w->isWindow() ? 0 : w->parentWidget();
never executed: w = w->isWindow() ? 0 : w->parentWidget();
w->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
645 if (w) {
wDescription
TRUEnever evaluated
FALSEnever evaluated
0
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) {
p.data()->exec...alPos()) == wtDescription
TRUEnever evaluated
FALSEnever evaluated
0
649 QHelpEvent e(QEvent::WhatsThis, w->rect().center(),-
650 w->mapToGlobal(w->rect().center()));-
651 QApplication::sendEvent(w, &e);-
652 }
never executed: end of block
0
653 delete p.data();-
654 }
never executed: end of block
0
655#endif-
656}
never executed: end of block
0
657#endif // QT_NO_CONTEXTMENU-
658-
659/*! \reimp */-
660void 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)) {
e->matches(QKe...uence::Cancel)Description
TRUEnever evaluated
FALSEnever evaluated
0
666 reject();-
667 } else
never executed: end of block
0
668 if (!e->modifiers() || (e->modifiers() & Qt::KeypadModifier && e->key() == Qt::Key_Enter)) {
!e->modifiers()Description
TRUEnever evaluated
FALSEnever evaluated
e->modifiers()...KeypadModifierDescription
TRUEnever evaluated
FALSEnever evaluated
e->key() == Qt::Key_EnterDescription
TRUEnever evaluated
FALSEnever evaluated
0
669 switch (e->key()) {-
670 case Qt::Key_Enter:
never executed: case Qt::Key_Enter:
0
671 case Qt::Key_Return: {
never executed: case Qt::Key_Return:
0
672 QList<QPushButton*> list = findChildren<QPushButton*>();-
673 for (int i=0; i<list.size(); ++i) {
i<list.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
674 QPushButton *pb = list.at(i);-
675 if (pb->isDefault() && pb->isVisible()) {
pb->isDefault()Description
TRUEnever evaluated
FALSEnever evaluated
pb->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
676 if (pb->isEnabled())
pb->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
677 pb->click();
never executed: pb->click();
0
678 return;
never executed: return;
0
679 }-
680 }
never executed: end of block
0
681 }-
682 break;
never executed: break;
0
683 default:
never executed: default:
0
684 e->ignore();-
685 return;
never executed: return;
0
686 }-
687 } else {-
688 e->ignore();-
689 }
never executed: end of block
0
690}-
691-
692/*! \reimp */-
693void QDialog::closeEvent(QCloseEvent *e)-
694{-
695#ifndef QT_NO_WHATSTHIS-
696 if (isModal() && QWhatsThis::inWhatsThisMode())
isModal()Description
TRUEnever evaluated
FALSEnever evaluated
QWhatsThis::inWhatsThisMode()Description
TRUEnever evaluated
FALSEnever evaluated
0
697 QWhatsThis::leaveWhatsThisMode();
never executed: QWhatsThis::leaveWhatsThisMode();
0
698#endif-
699 if (isVisible()) {
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
700 QPointer<QObject> that = this;-
701 reject();-
702 if (that && isVisible())
thatDescription
TRUEnever evaluated
FALSEnever evaluated
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
703 e->ignore();
never executed: e->ignore();
0
704 } else {
never executed: end of block
0
705 e->accept();-
706 }
never executed: end of block
0
707}-
708-
709/*****************************************************************************-
710 Geometry management.-
711 *****************************************************************************/-
712-
713/*! \reimp-
714*/-
715-
716void QDialog::setVisible(bool visible)-
717{-
718 Q_D(QDialog);-
719 if (!testAttribute(Qt::WA_DontShowOnScreen) && d->canBeNativeDialog() && d->setNativeDialogVisible(visible))
!testAttribute...tShowOnScreen)Description
TRUEnever evaluated
FALSEnever evaluated
d->canBeNativeDialog()Description
TRUEnever evaluated
FALSEnever evaluated
d->setNativeDi...sible(visible)Description
TRUEnever evaluated
FALSEnever evaluated
0
720 return;
never executed: return;
0
721-
722 if (visible) {
visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
723 if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden))
testAttribute(...licitShowHide)Description
TRUEnever evaluated
FALSEnever evaluated
!testAttribute...WState_Hidden)Description
TRUEnever evaluated
FALSEnever evaluated
0
724 return;
never executed: return;
0
725-
726 QWidget::setVisible(visible);-
727 showExtension(d->doShowExtension);-
728 QWidget *fw = window()->focusWidget();-
729 if (!fw)
!fwDescription
TRUEnever evaluated
FALSEnever evaluated
0
730 fw = this;
never executed: fw = this;
0
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) {
d->mainDefDescription
TRUEnever evaluated
FALSEnever evaluated
fw->focusPolic...== Qt::NoFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
743 QWidget *first = fw;-
744 while ((first = first->nextInFocusChain()) != fw && first->focusPolicy() == Qt::NoFocus)
(first = first...Chain()) != fwDescription
TRUEnever evaluated
FALSEnever evaluated
first->focusPo...== Qt::NoFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
745 ;
never executed: ;
0
746 if (first != d->mainDef && qobject_cast<QPushButton*>(first))
first != d->mainDefDescription
TRUEnever evaluated
FALSEnever evaluated
qobject_cast<Q...utton*>(first)Description
TRUEnever evaluated
FALSEnever evaluated
0
747 d->mainDef->setFocus();
never executed: d->mainDef->setFocus();
0
748 }
never executed: end of block
0
749 if (!d->mainDef && isWindow()) {
!d->mainDefDescription
TRUEnever evaluated
FALSEnever evaluated
isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
750 QWidget *w = fw;-
751 while ((w = w->nextInFocusChain()) != fw) {
(w = w->nextIn...Chain()) != fwDescription
TRUEnever evaluated
FALSEnever evaluated
0
752 QPushButton *pb = qobject_cast<QPushButton *>(w);-
753 if (pb && pb->autoDefault() && pb->focusPolicy() != Qt::NoFocus) {
pbDescription
TRUEnever evaluated
FALSEnever evaluated
pb->autoDefault()Description
TRUEnever evaluated
FALSEnever evaluated
pb->focusPolic...!= Qt::NoFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
754 pb->setDefault(true);-
755 break;
never executed: break;
0
756 }-
757 }
never executed: end of block
0
758 }
never executed: end of block
0
759 if (fw && !fw->hasFocus()) {
fwDescription
TRUEnever evaluated
FALSEnever evaluated
!fw->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
760 QFocusEvent e(QEvent::FocusIn, Qt::TabFocusReason);-
761 QApplication::sendEvent(fw, &e);-
762 }
never executed: end of block
0
763-
764#ifndef QT_NO_ACCESSIBILITY-
765 QAccessibleEvent event(this, QAccessible::DialogStart);-
766 QAccessible::updateAccessibility(&event);-
767#endif-
768-
769 } else {
never executed: end of block
0
770 if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden))
testAttribute(...licitShowHide)Description
TRUEnever evaluated
FALSEnever evaluated
testAttribute(...WState_Hidden)Description
TRUEnever evaluated
FALSEnever evaluated
0
771 return;
never executed: return;
0
772-
773#ifndef QT_NO_ACCESSIBILITY-
774 if (isVisible()) {
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
775 QAccessibleEvent event(this, QAccessible::DialogEnd);-
776 QAccessible::updateAccessibility(&event);-
777 }
never executed: end of block
0
778#endif-
779-
780 // Reimplemented to exit a modal event loop when the dialog is hidden.-
781 QWidget::setVisible(visible);-
782 if (d->eventLoop)
d->eventLoopDescription
TRUEnever evaluated
FALSEnever evaluated
0
783 d->eventLoop->exit();
never executed: d->eventLoop->exit();
0
784 }
never executed: end of block
0
785-
786 const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme();-
787 if (d->mainDef && isActiveWindow()
d->mainDefDescription
TRUEnever evaluated
FALSEnever evaluated
isActiveWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
788 && theme->themeHint(QPlatformTheme::DialogSnapToDefaultButton).toBool())
theme->themeHi...tton).toBool()Description
TRUEnever evaluated
FALSEnever evaluated
0
789 QCursor::setPos(d->mainDef->mapToGlobal(d->mainDef->rect().center()));
never executed: QCursor::setPos(d->mainDef->mapToGlobal(d->mainDef->rect().center()));
0
790}
never executed: end of block
0
791-
792/*!\reimp */-
793void QDialog::showEvent(QShowEvent *event)-
794{-
795 if (!event->spontaneous() && !testAttribute(Qt::WA_Moved)) {
!event->spontaneous()Description
TRUEnever evaluated
FALSEnever evaluated
!testAttribute(Qt::WA_Moved)Description
TRUEnever evaluated
FALSEnever evaluated
0
796 Qt::WindowStates state = windowState();-
797 adjustPosition(parentWidget());-
798 setAttribute(Qt::WA_Moved, false); // not really an explicit position-
799 if (state != windowState())
state != windowState()Description
TRUEnever evaluated
FALSEnever evaluated
0
800 setWindowState(state);
never executed: setWindowState(state);
0
801 }
never executed: end of block
0
802}
never executed: end of block
0
803-
804/*! \internal */-
805void QDialog::adjustPosition(QWidget* w)-
806{-
807-
808 if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
const QPlatfor...latformTheme()Description
TRUEnever evaluated
FALSEnever evaluated
0
809 if (theme->themeHint(QPlatformTheme::WindowAutoPlacement).toBool())
theme->themeHi...ment).toBool()Description
TRUEnever evaluated
FALSEnever evaluated
0
810 return;
never executed: return;
0
811 QPoint p(0, 0);-
812 int extraw = 0, extrah = 0, scrn = 0;-
813 if (w)
wDescription
TRUEnever evaluated
FALSEnever evaluated
0
814 w = w->window();
never executed: w = w->window();
0
815 QRect desk;-
816 if (w) {
wDescription
TRUEnever evaluated
FALSEnever evaluated
0
817 scrn = QApplication::desktop()->screenNumber(w);-
818 } else if (QApplication::desktop()->isVirtualDesktop()) {
never executed: end of block
QApplication::...rtualDesktop()Description
TRUEnever evaluated
FALSEnever evaluated
0
819 scrn = QApplication::desktop()->screenNumber(QCursor::pos());-
820 } else {
never executed: end of block
0
821 scrn = QApplication::desktop()->screenNumber(this);-
822 }
never executed: end of block
0
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) {
extraw == 0Description
TRUEnever evaluated
FALSEnever evaluated
extrah == 0Description
TRUEnever evaluated
FALSEnever evaluated
i < list.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
827 QWidget * current = list.at(i);-
828 if (current->isVisible()) {
current->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
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 }
never executed: end of block
0
835 }
never executed: end of block
0
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) {
extraw == 0Description
TRUEnever evaluated
FALSEnever evaluated
extrah == 0Description
TRUEnever evaluated
FALSEnever evaluated
extraw >= 10Description
TRUEnever evaluated
FALSEnever evaluated
extrah >= 40Description
TRUEnever evaluated
FALSEnever evaluated
0
840 extrah = 40;-
841 extraw = 10;-
842 }
never executed: end of block
0
843-
844-
845 if (w) {
wDescription
TRUEnever evaluated
FALSEnever evaluated
0
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>())
w->windowHandle()Description
TRUEnever evaluated
FALSEnever evaluated
w->windowHandl...).value<WId>()Description
TRUEnever evaluated
FALSEnever evaluated
0
849 pp = w->pos();
never executed: pp = w->pos();
0
850 else-
851 pp = w->mapToGlobal(QPoint(0,0));
never executed: pp = w->mapToGlobal(QPoint(0,0));
0
852 p = QPoint(pp.x() + w->width()/2,-
853 pp.y() + w->height()/ 2);-
854 } else {
never executed: end of block
0
855 // p = middle of the desktop-
856 p = QPoint(desk.x() + desk.width()/2, desk.y() + desk.height()/2);-
857 }
never executed: end of block
0
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())
p.x() + extraw...+ desk.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
865 p.setX(desk.x() + desk.width() - width() - extraw);
never executed: p.setX(desk.x() + desk.width() - width() - extraw);
0
866 if (p.x() < desk.x())
p.x() < desk.x()Description
TRUEnever evaluated
FALSEnever evaluated
0
867 p.setX(desk.x());
never executed: p.setX(desk.x());
0
868-
869 if (p.y() + extrah + height() > desk.y() + desk.height())
p.y() + extrah... desk.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
870 p.setY(desk.y() + desk.height() - height() - extrah);
never executed: p.setY(desk.y() + desk.height() - height() - extrah);
0
871 if (p.y() < desk.y())
p.y() < desk.y()Description
TRUEnever evaluated
FALSEnever evaluated
0
872 p.setY(desk.y());
never executed: p.setY(desk.y());
0
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) {
scrn >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
878 if (QWindow *window = windowHandle())
QWindow *windo...windowHandle()Description
TRUEnever evaluated
FALSEnever evaluated
0
879 window->setScreen(QGuiApplication::screens().at(scrn));
never executed: window->setScreen(QGuiApplication::screens().at(scrn));
0
880 }
never executed: end of block
0
881-
882 move(p);-
883}
never executed: end of block
0
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*/-
899void QDialog::setOrientation(Qt::Orientation orientation)-
900{-
901 Q_D(QDialog);-
902 d->orientation = orientation;-
903}
never executed: end of block
0
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*/-
916Qt::Orientation QDialog::orientation() const-
917{-
918 Q_D(const QDialog);-
919 return d->orientation;
never executed: return d->orientation;
0
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*/-
936void QDialog::setExtension(QWidget* extension)-
937{-
938 Q_D(QDialog);-
939 delete d->extension;-
940 d->extension = extension;-
941-
942 if (!extension)
!extensionDescription
TRUEnever evaluated
FALSEnever evaluated
0
943 return;
never executed: return;
0
944-
945 if (extension->parentWidget() != this)
extension->par...dget() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
946 extension->setParent(this);
never executed: extension->setParent(this);
0
947 extension->hide();-
948}
never executed: end of block
0
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*/-
962QWidget* QDialog::extension() const-
963{-
964 Q_D(const QDialog);-
965 return d->extension;
never executed: return d->extension;
0
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*/-
981void QDialog::showExtension(bool showIt)-
982{-
983 Q_D(QDialog);-
984 d->doShowExtension = showIt;-
985 if (!d->extension)
!d->extensionDescription
TRUEnever evaluated
FALSEnever evaluated
0
986 return;
never executed: return;
0
987 if (!testAttribute(Qt::WA_WState_Visible))
!testAttribute...State_Visible)Description
TRUEnever evaluated
FALSEnever evaluated
0
988 return;
never executed: return;
0
989 if (d->extension->isVisible() == showIt)
d->extension->...le() == showItDescription
TRUEnever evaluated
FALSEnever evaluated
0
990 return;
never executed: return;
0
991-
992 if (showIt) {
showItDescription
TRUEnever evaluated
FALSEnever evaluated
0
993 d->size = size();-
994 d->min = minimumSize();-
995 d->max = maximumSize();-
996 if (layout())
layout()Description
TRUEnever evaluated
FALSEnever evaluated
0
997 layout()->setEnabled(false);
never executed: layout()->setEnabled(false);
0
998 QSize s(d->extension->sizeHint()-
999 .expandedTo(d->extension->minimumSize())-
1000 .boundedTo(d->extension->maximumSize()));-
1001 if (d->orientation == Qt::Horizontal) {
d->orientation...Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1002 int h = qMax(height(), s.height());-
1003 d->extension->setGeometry(width(), 0, s.width(), h);-
1004 setFixedSize(width() + s.width(), h);-
1005 } else {
never executed: end of block
0
1006 int w = qMax(width(), s.width());-
1007 d->extension->setGeometry(0, height(), w, s.height());-
1008 setFixedSize(w, height() + s.height());-
1009 }
never executed: end of block
0
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 {
never executed: end of block
0
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())
layout()Description
TRUEnever evaluated
FALSEnever evaluated
0
1023 layout()->setEnabled(true);
never executed: layout()->setEnabled(true);
0
1024#ifndef QT_NO_SIZEGRIP-
1025 setSizeGripEnabled(d->sizeGripEnabled);-
1026#endif-
1027 }
never executed: end of block
0
1028}-
1029-
1030-
1031/*! \reimp */-
1032QSize QDialog::sizeHint() const-
1033{-
1034 Q_D(const QDialog);-
1035 if (d->extension) {
d->extensionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1036 if (d->orientation == Qt::Horizontal)
d->orientation...Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1037 return QSize(QWidget::sizeHint().width(),
never executed: return QSize(QWidget::sizeHint().width(), qMax(QWidget::sizeHint().height(),d->extension->sizeHint().height()));
0
1038 qMax(QWidget::sizeHint().height(),d->extension->sizeHint().height()));
never executed: return QSize(QWidget::sizeHint().width(), qMax(QWidget::sizeHint().height(),d->extension->sizeHint().height()));
0
1039 else-
1040 return QSize(qMax(QWidget::sizeHint().width(), d->extension->sizeHint().width()),
never executed: return QSize(qMax(QWidget::sizeHint().width(), d->extension->sizeHint().width()), QWidget::sizeHint().height());
0
1041 QWidget::sizeHint().height());
never executed: return QSize(qMax(QWidget::sizeHint().width(), d->extension->sizeHint().width()), QWidget::sizeHint().height());
0
1042 }-
1043 return QWidget::sizeHint();
never executed: return QWidget::sizeHint();
0
1044}-
1045-
1046-
1047/*! \reimp */-
1048QSize QDialog::minimumSizeHint() const-
1049{-
1050 Q_D(const QDialog);-
1051 if (d->extension) {
d->extensionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1052 if (d->orientation == Qt::Horizontal)
d->orientation...Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1053 return QSize(QWidget::minimumSizeHint().width(),
never executed: return QSize(QWidget::minimumSizeHint().width(), qMax(QWidget::minimumSizeHint().height(), d->extension->minimumSizeHint().height()));
0
1054 qMax(QWidget::minimumSizeHint().height(), d->extension->minimumSizeHint().height()));
never executed: return QSize(QWidget::minimumSizeHint().width(), qMax(QWidget::minimumSizeHint().height(), d->extension->minimumSizeHint().height()));
0
1055 else-
1056 return QSize(qMax(QWidget::minimumSizeHint().width(), d->extension->minimumSizeHint().width()),
never executed: return QSize(qMax(QWidget::minimumSizeHint().width(), d->extension->minimumSizeHint().width()), QWidget::minimumSizeHint().height());
0
1057 QWidget::minimumSizeHint().height());
never executed: return QSize(qMax(QWidget::minimumSizeHint().width(), d->extension->minimumSizeHint().width()), QWidget::minimumSizeHint().height());
0
1058 }-
1059-
1060 return QWidget::minimumSizeHint();
never executed: return QWidget::minimumSizeHint();
0
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-
1077void QDialog::setModal(bool modal)-
1078{-
1079 setAttribute(Qt::WA_ShowModal, modal);-
1080}
never executed: end of block
0
1081-
1082-
1083bool QDialog::isSizeGripEnabled() const-
1084{-
1085#ifndef QT_NO_SIZEGRIP-
1086 Q_D(const QDialog);-
1087 return !!d->resizer;
never executed: return !!d->resizer;
0
1088#else-
1089 return false;-
1090#endif-
1091}-
1092-
1093-
1094void 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)
enabledDescription
TRUEnever evaluated
FALSEnever evaluated
d->doShowExtensionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1103 return;
never executed: return;
0
1104#endif-
1105 if (!enabled != !d->resizer) {
!enabled != !d->resizerDescription
TRUEnever evaluated
FALSEnever evaluated
0
1106 if (enabled) {
enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1107 d->resizer = new QSizeGrip(this);-
1108 // adjustSize() processes all events, which is suboptimal-
1109 d->resizer->resize(d->resizer->sizeHint());-
1110 if (isRightToLeft())
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
1111 d->resizer->move(rect().bottomLeft() -d->resizer->rect().bottomLeft());
never executed: d->resizer->move(rect().bottomLeft() -d->resizer->rect().bottomLeft());
0
1112 else-
1113 d->resizer->move(rect().bottomRight() -d->resizer->rect().bottomRight());
never executed: d->resizer->move(rect().bottomRight() -d->resizer->rect().bottomRight());
0
1114 d->resizer->raise();-
1115 d->resizer->show();-
1116 } else {
never executed: end of block
0
1117 delete d->resizer;-
1118 d->resizer = 0;-
1119 }
never executed: end of block
0
1120 }-
1121#endif //QT_NO_SIZEGRIP-
1122}
never executed: end of block
0
1123-
1124-
1125-
1126/*! \reimp */-
1127void QDialog::resizeEvent(QResizeEvent *)-
1128{-
1129#ifndef QT_NO_SIZEGRIP-
1130 Q_D(QDialog);-
1131 if (d->resizer) {
d->resizerDescription
TRUEnever evaluated
FALSEnever evaluated
0
1132 if (isRightToLeft())
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
1133 d->resizer->move(rect().bottomLeft() -d->resizer->rect().bottomLeft());
never executed: d->resizer->move(rect().bottomLeft() -d->resizer->rect().bottomLeft());
0
1134 else-
1135 d->resizer->move(rect().bottomRight() -d->resizer->rect().bottomRight());
never executed: d->resizer->move(rect().bottomRight() -d->resizer->rect().bottomRight());
0
1136 d->resizer->raise();-
1137 }
never executed: end of block
0
1138#endif-
1139}
never executed: end of block
0
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-
1183QT_END_NAMESPACE-
1184#include "moc_qdialog.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9