qmessagebox.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/dialogs/qmessagebox.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include <QtWidgets/qmessagebox.h>-
35-
36#ifndef QT_NO_MESSAGEBOX-
37-
38#include <QtWidgets/qdialogbuttonbox.h>-
39#include "private/qlabel_p.h"-
40#include "private/qapplication_p.h"-
41#include <QtCore/qlist.h>-
42#include <QtCore/qdebug.h>-
43#include <QtWidgets/qstyle.h>-
44#include <QtWidgets/qstyleoption.h>-
45#include <QtWidgets/qgridlayout.h>-
46#include <QtWidgets/qdesktopwidget.h>-
47#include <QtWidgets/qpushbutton.h>-
48#include <QtWidgets/qcheckbox.h>-
49#include <QtGui/qaccessible.h>-
50#include <QtGui/qicon.h>-
51#include <QtGui/qtextdocument.h>-
52#include <QtWidgets/qapplication.h>-
53#include <QtWidgets/qtextedit.h>-
54#include <QtWidgets/qtextbrowser.h>-
55#include <QtWidgets/qmenu.h>-
56#include "qdialog_p.h"-
57#include <QtGui/qfont.h>-
58#include <QtGui/qfontmetrics.h>-
59#include <QtGui/qclipboard.h>-
60-
61#ifdef Q_OS_WIN-
62# include <QtCore/qt_windows.h>-
63#include <qpa/qplatformnativeinterface.h>-
64#endif-
65-
66QT_BEGIN_NAMESPACE-
67-
68#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)-
69HMENU qt_getWindowsSystemMenu(const QWidget *w)-
70{-
71 if (QWindow *window = QApplicationPrivate::windowForWidget(w))-
72 if (void *handle = QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", window))-
73 return GetSystemMenu(reinterpret_cast<HWND>(handle), false);-
74 return 0;-
75}-
76#endif-
77-
78enum Button { Old_Ok = 1, Old_Cancel = 2, Old_Yes = 3, Old_No = 4, Old_Abort = 5, Old_Retry = 6,-
79 Old_Ignore = 7, Old_YesAll = 8, Old_NoAll = 9, Old_ButtonMask = 0xFF,-
80 NewButtonMask = 0xFFFFFC00 };-
81-
82enum DetailButtonLabel { ShowLabel = 0, HideLabel = 1 };-
83#ifndef QT_NO_TEXTEDIT-
84class QMessageBoxDetailsText : public QWidget-
85{-
86 Q_OBJECT-
87public:-
88 class TextEdit : public QTextEdit-
89 {-
90 public:-
91 TextEdit(QWidget *parent=0) : QTextEdit(parent) { }
never executed: end of block
0
92 void contextMenuEvent(QContextMenuEvent * e) Q_DECL_OVERRIDE-
93 {-
94#ifndef QT_NO_CONTEXTMENU-
95 QMenu *menu = createStandardContextMenu();-
96 menu->setAttribute(Qt::WA_DeleteOnClose);-
97 menu->popup(e->globalPos());-
98#else-
99 Q_UNUSED(e);-
100#endif-
101 }
never executed: end of block
0
102 };-
103-
104 QMessageBoxDetailsText(QWidget *parent=0)-
105 : QWidget(parent)-
106 , copyAvailable(false)-
107 {-
108 QVBoxLayout *layout = new QVBoxLayout;-
109 layout->setMargin(0);-
110 QFrame *line = new QFrame(this);-
111 line->setFrameShape(QFrame::HLine);-
112 line->setFrameShadow(QFrame::Sunken);-
113 layout->addWidget(line);-
114 textEdit = new TextEdit();-
115 textEdit->setFixedHeight(100);-
116 textEdit->setFocusPolicy(Qt::NoFocus);-
117 textEdit->setReadOnly(true);-
118 layout->addWidget(textEdit);-
119 setLayout(layout);-
120-
121 connect(textEdit, SIGNAL(copyAvailable(bool)),-
122 this, SLOT(textCopyAvailable(bool)));-
123 }
never executed: end of block
0
124 void setText(const QString &text) { textEdit->setPlainText(text); }
never executed: end of block
0
125 QString text() const { return textEdit->toPlainText(); }
never executed: return textEdit->toPlainText();
0
126-
127 bool copy()-
128 {-
129#ifdef QT_NO_CLIPBOARD-
130 return false;-
131#else-
132 if (!copyAvailable)
!copyAvailableDescription
TRUEnever evaluated
FALSEnever evaluated
0
133 return false;
never executed: return false;
0
134 textEdit->copy();-
135 return true;
never executed: return true;
0
136#endif-
137 }-
138-
139 void selectAll()-
140 {-
141 textEdit->selectAll();-
142 }
never executed: end of block
0
143-
144private slots:-
145 void textCopyAvailable(bool available)-
146 {-
147 copyAvailable = available;-
148 }
never executed: end of block
0
149-
150private:-
151 bool copyAvailable;-
152 TextEdit *textEdit;-
153};-
154#endif // QT_NO_TEXTEDIT-
155-
156class DetailButton : public QPushButton-
157{-
158public:-
159 DetailButton(QWidget *parent) : QPushButton(label(ShowLabel), parent)-
160 {-
161 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);-
162 }
never executed: end of block
0
163-
164 QString label(DetailButtonLabel label) const-
165 { return label == ShowLabel ? QMessageBox::tr("Show Details...") : QMessageBox::tr("Hide Details..."); }
never executed: return label == ShowLabel ? QMessageBox::tr("Show Details...") : QMessageBox::tr("Hide Details...");
label == ShowLabelDescription
TRUEnever evaluated
FALSEnever evaluated
0
166-
167 void setLabel(DetailButtonLabel lbl)-
168 { setText(label(lbl)); }
never executed: end of block
0
169-
170 QSize sizeHint() const Q_DECL_OVERRIDE-
171 {-
172 ensurePolished();-
173 QStyleOptionButton opt;-
174 initStyleOption(&opt);-
175 const QFontMetrics fm = fontMetrics();-
176 opt.text = label(ShowLabel);-
177 QSize sz = fm.size(Qt::TextShowMnemonic, opt.text);-
178 QSize ret = style()->sizeFromContents(QStyle::CT_PushButton, &opt, sz, this).-
179 expandedTo(QApplication::globalStrut());-
180 opt.text = label(HideLabel);-
181 sz = fm.size(Qt::TextShowMnemonic, opt.text);-
182 ret = ret.expandedTo(style()->sizeFromContents(QStyle::CT_PushButton, &opt, sz, this).-
183 expandedTo(QApplication::globalStrut()));-
184 return ret;
never executed: return ret;
0
185 }-
186};-
187-
188class QMessageBoxPrivate : public QDialogPrivate-
189{-
190 Q_DECLARE_PUBLIC(QMessageBox)-
191-
192public:-
193 QMessageBoxPrivate() : escapeButton(0), defaultButton(0), checkbox(0), clickedButton(0), detailsButton(0),-
194#ifndef QT_NO_TEXTEDIT-
195 detailsText(0),-
196#endif-
197 compatMode(false), autoAddOkButton(true),-
198 detectedEscapeButton(0), informativeLabel(0),-
199 options(new QMessageDialogOptions) { }
never executed: end of block
0
200-
201 void init(const QString &title = QString(), const QString &text = QString());-
202 void setupLayout();-
203 void _q_buttonClicked(QAbstractButton *);-
204 void _q_clicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role);-
205-
206 QAbstractButton *findButton(int button0, int button1, int button2, int flags);-
207 void addOldButtons(int button0, int button1, int button2);-
208-
209 QAbstractButton *abstractButtonForId(int id) const;-
210 int execReturnCode(QAbstractButton *button);-
211-
212 void detectEscapeButton();-
213 void updateSize();-
214 int layoutMinimumWidth();-
215 void retranslateStrings();-
216-
217#ifdef Q_OS_WINCE-
218 void hideSpecial();-
219#endif-
220 static int showOldMessageBox(QWidget *parent, QMessageBox::Icon icon,-
221 const QString &title, const QString &text,-
222 int button0, int button1, int button2);-
223 static int showOldMessageBox(QWidget *parent, QMessageBox::Icon icon,-
224 const QString &title, const QString &text,-
225 const QString &button0Text,-
226 const QString &button1Text,-
227 const QString &button2Text,-
228 int defaultButtonNumber,-
229 int escapeButtonNumber);-
230-
231 static QMessageBox::StandardButton showNewMessageBox(QWidget *parent,-
232 QMessageBox::Icon icon, const QString& title, const QString& text,-
233 QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton);-
234-
235 static QPixmap standardIcon(QMessageBox::Icon icon, QMessageBox *mb);-
236-
237 QLabel *label;-
238 QMessageBox::Icon icon;-
239 QLabel *iconLabel;-
240 QDialogButtonBox *buttonBox;-
241 QList<QAbstractButton *> customButtonList;-
242 QAbstractButton *escapeButton;-
243 QPushButton *defaultButton;-
244 QCheckBox *checkbox;-
245 QAbstractButton *clickedButton;-
246 DetailButton *detailsButton;-
247#ifndef QT_NO_TEXTEDIT-
248 QMessageBoxDetailsText *detailsText;-
249#endif-
250 bool compatMode;-
251 bool autoAddOkButton;-
252 QAbstractButton *detectedEscapeButton;-
253 QLabel *informativeLabel;-
254 QPointer<QObject> receiverToDisconnectOnClose;-
255 QByteArray memberToDisconnectOnClose;-
256 QByteArray signalToDisconnectOnClose;-
257 QSharedPointer<QMessageDialogOptions> options;-
258private:-
259 void initHelper(QPlatformDialogHelper *) Q_DECL_OVERRIDE;-
260 void helperPrepareShow(QPlatformDialogHelper *) Q_DECL_OVERRIDE;-
261 void helperDone(QDialog::DialogCode, QPlatformDialogHelper *) Q_DECL_OVERRIDE;-
262};-
263-
264void QMessageBoxPrivate::init(const QString &title, const QString &text)-
265{-
266 Q_Q(QMessageBox);-
267-
268 label = new QLabel;-
269 label->setObjectName(QLatin1String("qt_msgbox_label"));-
270 label->setTextInteractionFlags(Qt::TextInteractionFlags(q->style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, q)));-
271 label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);-
272 label->setOpenExternalLinks(true);-
273 iconLabel = new QLabel(q);-
274 iconLabel->setObjectName(QLatin1String("qt_msgboxex_icon_label"));-
275 iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);-
276-
277 buttonBox = new QDialogButtonBox;-
278 buttonBox->setObjectName(QLatin1String("qt_msgbox_buttonbox"));-
279 buttonBox->setCenterButtons(q->style()->styleHint(QStyle::SH_MessageBox_CenterButtons, 0, q));-
280 QObject::connect(buttonBox, SIGNAL(clicked(QAbstractButton*)),-
281 q, SLOT(_q_buttonClicked(QAbstractButton*)));-
282 setupLayout();-
283 if (!title.isEmpty() || !text.isEmpty()) {
!title.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
284 q->setWindowTitle(title);-
285 q->setText(text);-
286 }
never executed: end of block
0
287 q->setModal(true);-
288#ifdef Q_OS_MAC-
289 QFont f = q->font();-
290 f.setBold(true);-
291 label->setFont(f);-
292#endif-
293 icon = QMessageBox::NoIcon;-
294}
never executed: end of block
0
295-
296void QMessageBoxPrivate::setupLayout()-
297{-
298 Q_Q(QMessageBox);-
299 delete q->layout();-
300 QGridLayout *grid = new QGridLayout;-
301 bool hasIcon = iconLabel->pixmap() && !iconLabel->pixmap()->isNull();
iconLabel->pixmap()Description
TRUEnever evaluated
FALSEnever evaluated
!iconLabel->pixmap()->isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
302-
303 if (hasIcon)
hasIconDescription
TRUEnever evaluated
FALSEnever evaluated
0
304 grid->addWidget(iconLabel, 0, 0, 2, 1, Qt::AlignTop);
never executed: grid->addWidget(iconLabel, 0, 0, 2, 1, Qt::AlignTop);
0
305 iconLabel->setVisible(hasIcon);-
306#ifdef Q_OS_MAC-
307 QSpacerItem *indentSpacer = new QSpacerItem(14, 1, QSizePolicy::Fixed, QSizePolicy::Fixed);-
308#else-
309 QSpacerItem *indentSpacer = new QSpacerItem(hasIcon ? 7 : 15, 1, QSizePolicy::Fixed, QSizePolicy::Fixed);-
310#endif-
311 grid->addItem(indentSpacer, 0, hasIcon ? 1 : 0, 2, 1);-
312 grid->addWidget(label, 0, hasIcon ? 2 : 1, 1, 1);-
313 if (informativeLabel) {
informativeLabelDescription
TRUEnever evaluated
FALSEnever evaluated
0
314#ifndef Q_OS_MAC-
315 informativeLabel->setContentsMargins(0, 7, 0, 7);-
316#endif-
317 grid->addWidget(informativeLabel, 1, hasIcon ? 2 : 1, 1, 1);-
318 }
never executed: end of block
0
319 if (checkbox) {
checkboxDescription
TRUEnever evaluated
FALSEnever evaluated
0
320 grid->addWidget(checkbox, informativeLabel ? 2 : 1, hasIcon ? 2 : 1, 1, 1, Qt::AlignLeft);-
321#ifdef Q_OS_MAC-
322 grid->addItem(new QSpacerItem(1, 15, QSizePolicy::Fixed, QSizePolicy::Fixed), grid->rowCount(), 0);-
323#else-
324 grid->addItem(new QSpacerItem(1, 7, QSizePolicy::Fixed, QSizePolicy::Fixed), grid->rowCount(), 0);-
325#endif-
326 }
never executed: end of block
0
327#ifdef Q_OS_MAC-
328 grid->addWidget(buttonBox, grid->rowCount(), hasIcon ? 2 : 1, 1, 1);-
329 grid->setMargin(0);-
330 grid->setVerticalSpacing(8);-
331 grid->setHorizontalSpacing(0);-
332 q->setContentsMargins(24, 15, 24, 20);-
333 grid->setRowStretch(1, 100);-
334 grid->setRowMinimumHeight(2, 6);-
335#else-
336 grid->addWidget(buttonBox, grid->rowCount(), 0, 1, grid->columnCount());-
337#endif-
338 if (detailsText)
detailsTextDescription
TRUEnever evaluated
FALSEnever evaluated
0
339 grid->addWidget(detailsText, grid->rowCount(), 0, 1, grid->columnCount());
never executed: grid->addWidget(detailsText, grid->rowCount(), 0, 1, grid->columnCount());
0
340 grid->setSizeConstraint(QLayout::SetNoConstraint);-
341 q->setLayout(grid);-
342-
343 retranslateStrings();-
344 updateSize();-
345}
never executed: end of block
0
346-
347int QMessageBoxPrivate::layoutMinimumWidth()-
348{-
349 layout->activate();-
350 return layout->totalMinimumSize().width();
never executed: return layout->totalMinimumSize().width();
0
351}-
352-
353void QMessageBoxPrivate::updateSize()-
354{-
355 Q_Q(QMessageBox);-
356-
357 if (!q->isVisible())
!q->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
358 return;
never executed: return;
0
359-
360 QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size();-
361#if defined(Q_OS_WINCE)-
362 // the width of the screen, less the window border.-
363 int hardLimit = screenSize.width() - (q->frameGeometry().width() - q->geometry().width());-
364#else-
365 int hardLimit = qMin(screenSize.width() - 480, 1000); // can never get bigger than this-
366 // on small screens allows the messagebox be the same size as the screen-
367 if (screenSize.width() <= 1024)
screenSize.width() <= 1024Description
TRUEnever evaluated
FALSEnever evaluated
0
368 hardLimit = screenSize.width();
never executed: hardLimit = screenSize.width();
0
369#endif-
370#ifdef Q_OS_MAC-
371 int softLimit = qMin(screenSize.width()/2, 420);-
372#else-
373 // note: ideally on windows, hard and soft limits but it breaks compat-
374#ifndef Q_OS_WINCE-
375 int softLimit = qMin(screenSize.width()/2, 500);-
376#else-
377 int softLimit = qMin(screenSize.width() * 3 / 4, 500);-
378#endif //Q_OS_WINCE-
379#endif-
380-
381 if (informativeLabel)
informativeLabelDescription
TRUEnever evaluated
FALSEnever evaluated
0
382 informativeLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
never executed: informativeLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
0
383-
384 label->setWordWrap(false); // makes the label return min size-
385 int width = layoutMinimumWidth();-
386-
387 if (width > softLimit) {
width > softLimitDescription
TRUEnever evaluated
FALSEnever evaluated
0
388 label->setWordWrap(true);-
389 width = qMax(softLimit, layoutMinimumWidth());-
390-
391 if (width > hardLimit) {
width > hardLimitDescription
TRUEnever evaluated
FALSEnever evaluated
0
392 label->d_func()->ensureTextControl();-
393 if (QWidgetTextControl *control = label->d_func()->control) {
QWidgetTextCon...unc()->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
394 QTextOption opt = control->document()->defaultTextOption();-
395 opt.setWrapMode(QTextOption::WrapAnywhere);-
396 control->document()->setDefaultTextOption(opt);-
397 }
never executed: end of block
0
398 width = hardLimit;-
399 }
never executed: end of block
0
400 }
never executed: end of block
0
401-
402 if (informativeLabel) {
informativeLabelDescription
TRUEnever evaluated
FALSEnever evaluated
0
403 label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);-
404 QSizePolicy policy(QSizePolicy::Minimum, QSizePolicy::Preferred);-
405 policy.setHeightForWidth(true);-
406 informativeLabel->setSizePolicy(policy);-
407 width = qMax(width, layoutMinimumWidth());-
408 if (width > hardLimit) { // longest word is really big, so wrap anywhere
width > hardLimitDescription
TRUEnever evaluated
FALSEnever evaluated
0
409 informativeLabel->d_func()->ensureTextControl();-
410 if (QWidgetTextControl *control = informativeLabel->d_func()->control) {
QWidgetTextCon...unc()->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
411 QTextOption opt = control->document()->defaultTextOption();-
412 opt.setWrapMode(QTextOption::WrapAnywhere);-
413 control->document()->setDefaultTextOption(opt);-
414 }
never executed: end of block
0
415 width = hardLimit;-
416 }
never executed: end of block
0
417 policy.setHeightForWidth(label->wordWrap());-
418 label->setSizePolicy(policy);-
419 }
never executed: end of block
0
420-
421 QFontMetrics fm(QApplication::font("QMdiSubWindowTitleBar"));-
422 int windowTitleWidth = qMin(fm.width(q->windowTitle()) + 50, hardLimit);-
423 if (windowTitleWidth > width)
windowTitleWidth > widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
424 width = windowTitleWidth;
never executed: width = windowTitleWidth;
0
425-
426 layout->activate();-
427 int height = (layout->hasHeightForWidth())
(layout->hasHeightForWidth())Description
TRUEnever evaluated
FALSEnever evaluated
0
428 ? layout->totalHeightForWidth(width)-
429 : layout->totalMinimumSize().height();-
430-
431 q->setFixedSize(width, height);-
432 QCoreApplication::removePostedEvents(q, QEvent::LayoutRequest);-
433}
never executed: end of block
0
434-
435-
436#ifdef Q_OS_WINCE-
437/*!-
438 \internal-
439 Hides special buttons which are rather shown in the title bar-
440 on WinCE, to conserve screen space.-
441*/-
442-
443void QMessageBoxPrivate::hideSpecial()-
444{-
445 Q_Q(QMessageBox);-
446 QList<QPushButton*> list = q->findChildren<QPushButton*>();-
447 for (int i=0; i<list.size(); ++i) {-
448 QPushButton *pb = list.at(i);-
449 QString text = pb->text();-
450 text.remove(QChar::fromLatin1('&'));-
451 if (text == QApplication::translate("QMessageBox", "OK" ))-
452 pb->setFixedSize(0,0);-
453 }-
454}-
455#endif-
456-
457static int oldButton(int button)-
458{-
459 switch (button & QMessageBox::ButtonMask) {-
460 case QMessageBox::Ok:
never executed: case QMessageBox::Ok:
0
461 return Old_Ok;
never executed: return Old_Ok;
0
462 case QMessageBox::Cancel:
never executed: case QMessageBox::Cancel:
0
463 return Old_Cancel;
never executed: return Old_Cancel;
0
464 case QMessageBox::Yes:
never executed: case QMessageBox::Yes:
0
465 return Old_Yes;
never executed: return Old_Yes;
0
466 case QMessageBox::No:
never executed: case QMessageBox::No:
0
467 return Old_No;
never executed: return Old_No;
0
468 case QMessageBox::Abort:
never executed: case QMessageBox::Abort:
0
469 return Old_Abort;
never executed: return Old_Abort;
0
470 case QMessageBox::Retry:
never executed: case QMessageBox::Retry:
0
471 return Old_Retry;
never executed: return Old_Retry;
0
472 case QMessageBox::Ignore:
never executed: case QMessageBox::Ignore:
0
473 return Old_Ignore;
never executed: return Old_Ignore;
0
474 case QMessageBox::YesToAll:
never executed: case QMessageBox::YesToAll:
0
475 return Old_YesAll;
never executed: return Old_YesAll;
0
476 case QMessageBox::NoToAll:
never executed: case QMessageBox::NoToAll:
0
477 return Old_NoAll;
never executed: return Old_NoAll;
0
478 default:
never executed: default:
0
479 return 0;
never executed: return 0;
0
480 }-
481}-
482-
483int QMessageBoxPrivate::execReturnCode(QAbstractButton *button)-
484{-
485 int ret = buttonBox->standardButton(button);-
486 if (ret == QMessageBox::NoButton) {
ret == QMessageBox::NoButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
487 ret = customButtonList.indexOf(button); // if button == 0, correctly sets ret = -1-
488 } else if (compatMode) {
never executed: end of block
compatModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
489 ret = oldButton(ret);-
490 }
never executed: end of block
0
491 return ret;
never executed: return ret;
0
492}-
493-
494void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)-
495{-
496 Q_Q(QMessageBox);-
497#ifndef QT_NO_TEXTEDIT-
498 if (detailsButton && detailsText && button == detailsButton) {
detailsButtonDescription
TRUEnever evaluated
FALSEnever evaluated
detailsTextDescription
TRUEnever evaluated
FALSEnever evaluated
button == detailsButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
499 detailsButton->setLabel(detailsText->isHidden() ? HideLabel : ShowLabel);-
500 detailsText->setHidden(!detailsText->isHidden());-
501 updateSize();-
502 } else
never executed: end of block
0
503#endif-
504 {-
505 clickedButton = button;-
506 q->done(execReturnCode(button)); // does not trigger closeEvent-
507 emit q->buttonClicked(button);-
508-
509 if (receiverToDisconnectOnClose) {
receiverToDisconnectOnCloseDescription
TRUEnever evaluated
FALSEnever evaluated
0
510 QObject::disconnect(q, signalToDisconnectOnClose, receiverToDisconnectOnClose,-
511 memberToDisconnectOnClose);-
512 receiverToDisconnectOnClose = 0;-
513 }
never executed: end of block
0
514 signalToDisconnectOnClose.clear();-
515 memberToDisconnectOnClose.clear();-
516 }
never executed: end of block
0
517}-
518-
519void QMessageBoxPrivate::_q_clicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role)-
520{-
521 Q_UNUSED(role);-
522 Q_Q(QMessageBox);-
523 q->done(button);-
524}
never executed: end of block
0
525-
526/*!-
527 \class QMessageBox-
528-
529 \brief The QMessageBox class provides a modal dialog for informing-
530 the user or for asking the user a question and receiving an answer.-
531-
532 \ingroup standard-dialogs-
533 \inmodule QtWidgets-
534-
535 A message box displays a primary \l{QMessageBox::text}{text} to-
536 alert the user to a situation, an \l{QMessageBox::informativeText}-
537 {informative text} to further explain the alert or to ask the user-
538 a question, and an optional \l{QMessageBox::detailedText}-
539 {detailed text} to provide even more data if the user requests-
540 it. A message box can also display an \l{QMessageBox::icon} {icon}-
541 and \l{QMessageBox::standardButtons} {standard buttons} for-
542 accepting a user response.-
543-
544 Two APIs for using QMessageBox are provided, the property-based-
545 API, and the static functions. Calling one of the static functions-
546 is the simpler approach, but it is less flexible than using the-
547 property-based API, and the result is less informative. Using the-
548 property-based API is recommended.-
549-
550 \section1 The Property-based API-
551-
552 To use the property-based API, construct an instance of-
553 QMessageBox, set the desired properties, and call exec() to show-
554 the message. The simplest configuration is to set only the-
555 \l{QMessageBox::text} {message text} property.-
556-
557 \snippet code/src_gui_dialogs_qmessagebox.cpp 5-
558-
559 The user must click the \uicontrol{OK} button to dismiss the message-
560 box. The rest of the GUI is blocked until the message box is-
561 dismissed.-
562-
563 \image msgbox1.png-
564-
565 A better approach than just alerting the user to an event is to-
566 also ask the user what to do about it. Store the question in the-
567 \l{QMessageBox::informativeText} {informative text} property, and-
568 set the \l{QMessageBox::standardButtons} {standard buttons}-
569 property to the set of buttons you want as the set of user-
570 responses. The buttons are specified by combining values from-
571 StandardButtons using the bitwise OR operator. The display order-
572 for the buttons is platform-dependent. For example, on Windows,-
573 \uicontrol{Save} is displayed to the left of \uicontrol{Cancel}, whereas on-
574 Mac OS, the order is reversed.-
575-
576 Mark one of your standard buttons to be your-
577 \l{QMessageBox::defaultButton()} {default button}.-
578-
579 \snippet code/src_gui_dialogs_qmessagebox.cpp 6-
580-
581 This is the approach recommended in the-
582 \l{http://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/AppleHIGuidelines/Windows/Windows.html#//apple_ref/doc/uid/20000961-BABCAJID}-
583 {\macos Guidelines}. Similar guidelines apply for the other-
584 platforms, but note the different ways the-
585 \l{QMessageBox::informativeText} {informative text} is handled for-
586 different platforms.-
587-
588 \image msgbox2.png-
589-
590 The exec() slot returns the StandardButtons value of the button-
591 that was clicked.-
592-
593 \snippet code/src_gui_dialogs_qmessagebox.cpp 7-
594-
595 To give the user more information to help him answer the question,-
596 set the \l{QMessageBox::detailedText} {detailed text} property. If-
597 the \l{QMessageBox::detailedText} {detailed text} property is set,-
598 the \uicontrol{Show Details...} button will be shown.-
599-
600 \image msgbox3.png-
601-
602 Clicking the \uicontrol{Show Details...} button displays the detailed text.-
603-
604 \image msgbox4.png-
605-
606 \section2 Rich Text and the Text Format Property-
607-
608 The \l{QMessageBox::detailedText} {detailed text} property is-
609 always interpreted as plain text. The \l{QMessageBox::text} {main-
610 text} and \l{QMessageBox::informativeText} {informative text}-
611 properties can be either plain text or rich text. These strings-
612 are interpreted according to the setting of the-
613 \l{QMessageBox::textFormat} {text format} property. The default-
614 setting is \l{Qt::AutoText} {auto-text}.-
615-
616 Note that for some plain text strings containing XML-
617 meta-characters, the auto-text \l{Qt::mightBeRichText()} {rich-
618 text detection test} may fail causing your plain text string to be-
619 interpreted incorrectly as rich text. In these rare cases, use-
620 Qt::convertFromPlainText() to convert your plain text string to a-
621 visually equivalent rich text string, or set the-
622 \l{QMessageBox::textFormat} {text format} property explicitly with-
623 setTextFormat().-
624-
625 \section2 Severity Levels and the Icon and Pixmap Properties-
626-
627 QMessageBox supports four predefined message severity levels, or message-
628 types, which really only differ in the predefined icon they each show.-
629 Specify one of the four predefined message types by setting the-
630 \l{QMessageBox::icon}{icon} property to one of the-
631 \l{QMessageBox::Icon}{predefined icons}. The following rules are-
632 guidelines:-
633-
634 \table-
635 \row-
636 \li \image qmessagebox-quest.png-
637 \li \l Question-
638 \li For asking a question during normal operations.-
639 \row-
640 \li \image qmessagebox-info.png-
641 \li \l Information-
642 \li For reporting information about normal operations.-
643 \row-
644 \li \image qmessagebox-warn.png-
645 \li \l Warning-
646 \li For reporting non-critical errors.-
647 \row-
648 \li \image qmessagebox-crit.png-
649 \li \l Critical-
650 \li For reporting critical errors.-
651 \endtable-
652-
653 \l{QMessageBox::Icon}{Predefined icons} are not defined by QMessageBox, but-
654 provided by the style. The default value is \l{QMessageBox::NoIcon}-
655 {No Icon}. The message boxes are otherwise the same for all cases. When-
656 using a standard icon, use the one recommended in the table, or use the-
657 one recommended by the style guidelines for your platform. If none of the-
658 standard icons is right for your message box, you can use a custom icon by-
659 setting the \l{QMessageBox::iconPixmap}{icon pixmap} property instead of-
660 setting the \l{QMessageBox::icon}{icon} property.-
661-
662 In summary, to set an icon, use \e{either} setIcon() for one of the-
663 standard icons, \e{or} setIconPixmap() for a custom icon.-
664-
665 \section1 The Static Functions API-
666-
667 Building message boxes with the static functions API, although-
668 convenient, is less flexible than using the property-based API,-
669 because the static function signatures lack parameters for setting-
670 the \l{QMessageBox::informativeText} {informative text} and-
671 \l{QMessageBox::detailedText} {detailed text} properties. One-
672 work-around for this has been to use the \c{title} parameter as-
673 the message box main text and the \c{text} parameter as the-
674 message box informative text. Because this has the obvious-
675 drawback of making a less readable message box, platform-
676 guidelines do not recommend it. The \e{Microsoft Windows User-
677 Interface Guidelines} recommend using the-
678 \l{QCoreApplication::applicationName} {application name} as the-
679 \l{QMessageBox::setWindowTitle()} {window's title}, which means-
680 that if you have an informative text in addition to your main-
681 text, you must concatenate it to the \c{text} parameter.-
682-
683 Note that the static function signatures have changed with respect-
684 to their button parameters, which are now used to set the-
685 \l{QMessageBox::standardButtons} {standard buttons} and the-
686 \l{QMessageBox::defaultButton()} {default button}.-
687-
688 Static functions are available for creating information(),-
689 question(), warning(), and critical() message boxes.-
690-
691 \snippet code/src_gui_dialogs_qmessagebox.cpp 0-
692-
693 The \l{dialogs/standarddialogs}{Standard Dialogs} example shows-
694 how to use QMessageBox and the other built-in Qt dialogs.-
695-
696 \section1 Advanced Usage-
697-
698 If the \l{QMessageBox::StandardButtons} {standard buttons} are not-
699 flexible enough for your message box, you can use the addButton()-
700 overload that takes a text and a ButtonRole to add custom-
701 buttons. The ButtonRole is used by QMessageBox to determine the-
702 ordering of the buttons on screen (which varies according to the-
703 platform). You can test the value of clickedButton() after calling-
704 exec(). For example,-
705-
706 \snippet code/src_gui_dialogs_qmessagebox.cpp 2-
707-
708 \section1 Default and Escape Keys-
709-
710 The default button (i.e., the button activated when \uicontrol Enter is-
711 pressed) can be specified using setDefaultButton(). If a default-
712 button is not specified, QMessageBox tries to find one based on-
713 the \l{ButtonRole} {button roles} of the buttons used in the-
714 message box.-
715-
716 The escape button (the button activated when \uicontrol Esc is pressed)-
717 can be specified using setEscapeButton(). If an escape button is-
718 not specified, QMessageBox tries to find one using these rules:-
719-
720 \list 1-
721-
722 \li If there is only one button, it is the button activated when-
723 \uicontrol Esc is pressed.-
724-
725 \li If there is a \l Cancel button, it is the button activated when-
726 \uicontrol Esc is pressed.-
727-
728 \li If there is exactly one button having either-
729 \l{QMessageBox::RejectRole} {the Reject role} or the-
730 \l{QMessageBox::NoRole} {the No role}, it is the button-
731 activated when \uicontrol Esc is pressed.-
732-
733 \endlist-
734-
735 When an escape button can't be determined using these rules,-
736 pressing \uicontrol Esc has no effect.-
737-
738 \sa QDialogButtonBox, {fowler}{GUI Design Handbook: Message Box}, {Standard Dialogs Example}, {Application Example}-
739*/-
740-
741/*!-
742 \enum QMessageBox::StandardButton-
743 \since 4.2-
744-
745 These enums describe flags for standard buttons. Each button has a-
746 defined \l ButtonRole.-
747-
748 \value Ok An "OK" button defined with the \l AcceptRole.-
749 \value Open An "Open" button defined with the \l AcceptRole.-
750 \value Save A "Save" button defined with the \l AcceptRole.-
751 \value Cancel A "Cancel" button defined with the \l RejectRole.-
752 \value Close A "Close" button defined with the \l RejectRole.-
753 \value Discard A "Discard" or "Don't Save" button, depending on the platform,-
754 defined with the \l DestructiveRole.-
755 \value Apply An "Apply" button defined with the \l ApplyRole.-
756 \value Reset A "Reset" button defined with the \l ResetRole.-
757 \value RestoreDefaults A "Restore Defaults" button defined with the \l ResetRole.-
758 \value Help A "Help" button defined with the \l HelpRole.-
759 \value SaveAll A "Save All" button defined with the \l AcceptRole.-
760 \value Yes A "Yes" button defined with the \l YesRole.-
761 \value YesToAll A "Yes to All" button defined with the \l YesRole.-
762 \value No A "No" button defined with the \l NoRole.-
763 \value NoToAll A "No to All" button defined with the \l NoRole.-
764 \value Abort An "Abort" button defined with the \l RejectRole.-
765 \value Retry A "Retry" button defined with the \l AcceptRole.-
766 \value Ignore An "Ignore" button defined with the \l AcceptRole.-
767-
768 \value NoButton An invalid button.-
769-
770 \omitvalue FirstButton-
771 \omitvalue LastButton-
772-
773 The following values are obsolete:-
774-
775 \value YesAll Use YesToAll instead.-
776 \value NoAll Use NoToAll instead.-
777 \value Default Use the \c defaultButton argument of-
778 information(), warning(), etc. instead, or call-
779 setDefaultButton().-
780 \value Escape Call setEscapeButton() instead.-
781 \value FlagMask-
782 \value ButtonMask-
783-
784 \sa ButtonRole, standardButtons-
785*/-
786-
787/*!-
788 \fn void QMessageBox::buttonClicked(QAbstractButton *button)-
789-
790 This signal is emitted whenever a button is clicked inside the QMessageBox.-
791 The button that was clicked in returned in \a button.-
792*/-
793-
794/*!-
795 Constructs a message box with no text and no buttons. \a parent is-
796 passed to the QDialog constructor.-
797-
798 On \macos, if you want your message box to appear-
799 as a Qt::Sheet of its \a parent, set the message box's-
800 \l{setWindowModality()} {window modality} to Qt::WindowModal or use open().-
801 Otherwise, the message box will be a standard dialog.-
802-
803*/-
804QMessageBox::QMessageBox(QWidget *parent)-
805 : QDialog(*new QMessageBoxPrivate, parent, Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)-
806{-
807 Q_D(QMessageBox);-
808 d->init();-
809}
never executed: end of block
0
810-
811/*!-
812 Constructs a message box with the given \a icon, \a title, \a-
813 text, and standard \a buttons. Standard or custom buttons can be-
814 added at any time using addButton(). The \a parent and \a f-
815 arguments are passed to the QDialog constructor.-
816-
817 The message box is an \l{Qt::ApplicationModal} {application modal}-
818 dialog box.-
819-
820 On \macos, if \a parent is not 0 and you want your message box-
821 to appear as a Qt::Sheet of that parent, set the message box's-
822 \l{setWindowModality()} {window modality} to Qt::WindowModal-
823 (default). Otherwise, the message box will be a standard dialog.-
824-
825 \sa setWindowTitle(), setText(), setIcon(), setStandardButtons()-
826*/-
827QMessageBox::QMessageBox(Icon icon, const QString &title, const QString &text,-
828 StandardButtons buttons, QWidget *parent,-
829 Qt::WindowFlags f)-
830: QDialog(*new QMessageBoxPrivate, parent, f | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)-
831{-
832 Q_D(QMessageBox);-
833 d->init(title, text);-
834 setIcon(icon);-
835 if (buttons != NoButton)
buttons != NoButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
836 setStandardButtons(buttons);
never executed: setStandardButtons(buttons);
0
837}
never executed: end of block
0
838-
839/*!-
840 Destroys the message box.-
841*/-
842QMessageBox::~QMessageBox()-
843{-
844}-
845-
846/*!-
847 \since 4.2-
848-
849 Adds the given \a button to the message box with the specified \a-
850 role.-
851-
852 \sa removeButton(), button(), setStandardButtons()-
853*/-
854void QMessageBox::addButton(QAbstractButton *button, ButtonRole role)-
855{-
856 Q_D(QMessageBox);-
857 if (!button)
!buttonDescription
TRUEnever evaluated
FALSEnever evaluated
0
858 return;
never executed: return;
0
859 removeButton(button);-
860 d->buttonBox->addButton(button, (QDialogButtonBox::ButtonRole)role);-
861 d->customButtonList.append(button);-
862 d->autoAddOkButton = false;-
863}
never executed: end of block
0
864-
865/*!-
866 \since 4.2-
867 \overload-
868-
869 Creates a button with the given \a text, adds it to the message box for the-
870 specified \a role, and returns it.-
871*/-
872QPushButton *QMessageBox::addButton(const QString& text, ButtonRole role)-
873{-
874 Q_D(QMessageBox);-
875 QPushButton *pushButton = new QPushButton(text);-
876 addButton(pushButton, role);-
877 d->updateSize();-
878 return pushButton;
never executed: return pushButton;
0
879}-
880-
881/*!-
882 \since 4.2-
883 \overload-
884-
885 Adds a standard \a button to the message box if it is valid to do so, and-
886 returns the push button.-
887-
888 \sa setStandardButtons()-
889*/-
890QPushButton *QMessageBox::addButton(StandardButton button)-
891{-
892 Q_D(QMessageBox);-
893 QPushButton *pushButton = d->buttonBox->addButton((QDialogButtonBox::StandardButton)button);-
894 if (pushButton)
pushButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
895 d->autoAddOkButton = false;
never executed: d->autoAddOkButton = false;
0
896 return pushButton;
never executed: return pushButton;
0
897}-
898-
899/*!-
900 \since 4.2-
901-
902 Removes \a button from the button box without deleting it.-
903-
904 \sa addButton(), setStandardButtons()-
905*/-
906void QMessageBox::removeButton(QAbstractButton *button)-
907{-
908 Q_D(QMessageBox);-
909 d->customButtonList.removeAll(button);-
910 if (d->escapeButton == button)
d->escapeButton == buttonDescription
TRUEnever evaluated
FALSEnever evaluated
0
911 d->escapeButton = 0;
never executed: d->escapeButton = 0;
0
912 if (d->defaultButton == button)
d->defaultButton == buttonDescription
TRUEnever evaluated
FALSEnever evaluated
0
913 d->defaultButton = 0;
never executed: d->defaultButton = 0;
0
914 d->buttonBox->removeButton(button);-
915 d->updateSize();-
916}
never executed: end of block
0
917-
918/*!-
919 \property QMessageBox::standardButtons-
920 \brief collection of standard buttons in the message box-
921 \since 4.2-
922-
923 This property controls which standard buttons are used by the message box.-
924-
925 By default, this property contains no standard buttons.-
926-
927 \sa addButton()-
928*/-
929void QMessageBox::setStandardButtons(StandardButtons buttons)-
930{-
931 Q_D(QMessageBox);-
932 d->buttonBox->setStandardButtons(QDialogButtonBox::StandardButtons(int(buttons)));-
933-
934 QList<QAbstractButton *> buttonList = d->buttonBox->buttons();-
935 if (!buttonList.contains(d->escapeButton))
!buttonList.co...>escapeButton)Description
TRUEnever evaluated
FALSEnever evaluated
0
936 d->escapeButton = 0;
never executed: d->escapeButton = 0;
0
937 if (!buttonList.contains(d->defaultButton))
!buttonList.co...defaultButton)Description
TRUEnever evaluated
FALSEnever evaluated
0
938 d->defaultButton = 0;
never executed: d->defaultButton = 0;
0
939 d->autoAddOkButton = false;-
940 d->updateSize();-
941}
never executed: end of block
0
942-
943QMessageBox::StandardButtons QMessageBox::standardButtons() const-
944{-
945 Q_D(const QMessageBox);-
946 return QMessageBox::StandardButtons(int(d->buttonBox->standardButtons()));
never executed: return QMessageBox::StandardButtons(int(d->buttonBox->standardButtons()));
0
947}-
948-
949/*!-
950 \since 4.2-
951-
952 Returns the standard button enum value corresponding to the given \a button,-
953 or NoButton if the given \a button isn't a standard button.-
954-
955 \sa button(), standardButtons()-
956*/-
957QMessageBox::StandardButton QMessageBox::standardButton(QAbstractButton *button) const-
958{-
959 Q_D(const QMessageBox);-
960 return (QMessageBox::StandardButton)d->buttonBox->standardButton(button);
never executed: return (QMessageBox::StandardButton)d->buttonBox->standardButton(button);
0
961}-
962-
963/*!-
964 \since 4.2-
965-
966 Returns a pointer corresponding to the standard button \a which,-
967 or 0 if the standard button doesn't exist in this message box.-
968-
969 \sa standardButtons, standardButton()-
970*/-
971QAbstractButton *QMessageBox::button(StandardButton which) const-
972{-
973 Q_D(const QMessageBox);-
974 return d->buttonBox->button(QDialogButtonBox::StandardButton(which));
never executed: return d->buttonBox->button(QDialogButtonBox::StandardButton(which));
0
975}-
976-
977/*!-
978 \since 4.2-
979-
980 Returns the button that is activated when escape is pressed.-
981-
982 By default, QMessageBox attempts to automatically detect an-
983 escape button as follows:-
984-
985 \list 1-
986 \li If there is only one button, it is made the escape button.-
987 \li If there is a \l Cancel button, it is made the escape button.-
988 \li On \macos only, if there is exactly one button with the role-
989 QMessageBox::RejectRole, it is made the escape button.-
990 \endlist-
991-
992 When an escape button could not be automatically detected, pressing-
993 \uicontrol Esc has no effect.-
994-
995 \sa addButton()-
996*/-
997QAbstractButton *QMessageBox::escapeButton() const-
998{-
999 Q_D(const QMessageBox);-
1000 return d->escapeButton;
never executed: return d->escapeButton;
0
1001}-
1002-
1003/*!-
1004 \since 4.2-
1005-
1006 Sets the button that gets activated when the \uicontrol Escape key is-
1007 pressed to \a button.-
1008-
1009 \sa addButton(), clickedButton()-
1010*/-
1011void QMessageBox::setEscapeButton(QAbstractButton *button)-
1012{-
1013 Q_D(QMessageBox);-
1014 if (d->buttonBox->buttons().contains(button))
d->buttonBox->...ntains(button)Description
TRUEnever evaluated
FALSEnever evaluated
0
1015 d->escapeButton = button;
never executed: d->escapeButton = button;
0
1016}
never executed: end of block
0
1017-
1018/*!-
1019 \since 4.3-
1020-
1021 Sets the buttons that gets activated when the \uicontrol Escape key is-
1022 pressed to \a button.-
1023-
1024 \sa addButton(), clickedButton()-
1025*/-
1026void QMessageBox::setEscapeButton(QMessageBox::StandardButton button)-
1027{-
1028 Q_D(QMessageBox);-
1029 setEscapeButton(d->buttonBox->button(QDialogButtonBox::StandardButton(button)));-
1030}
never executed: end of block
0
1031-
1032void QMessageBoxPrivate::detectEscapeButton()-
1033{-
1034 if (escapeButton) { // escape button explicitly set
escapeButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
1035 detectedEscapeButton = escapeButton;-
1036 return;
never executed: return;
0
1037 }-
1038-
1039 // Cancel button automatically becomes escape button-
1040 detectedEscapeButton = buttonBox->button(QDialogButtonBox::Cancel);-
1041 if (detectedEscapeButton)
detectedEscapeButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
1042 return;
never executed: return;
0
1043-
1044 // If there is only one button, make it the escape button-
1045 const QList<QAbstractButton *> buttons = buttonBox->buttons();-
1046 if (buttons.count() == 1) {
buttons.count() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1047 detectedEscapeButton = buttons.first();-
1048 return;
never executed: return;
0
1049 }-
1050-
1051 // if the message box has one RejectRole button, make it the escape button-
1052 for (int i = 0; i < buttons.count(); i++) {
i < buttons.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1053 if (buttonBox->buttonRole(buttons.at(i)) == QDialogButtonBox::RejectRole) {
buttonBox->but...ox::RejectRoleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1054 if (detectedEscapeButton) { // already detected!
detectedEscapeButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
1055 detectedEscapeButton = 0;-
1056 break;
never executed: break;
0
1057 }-
1058 detectedEscapeButton = buttons.at(i);-
1059 }
never executed: end of block
0
1060 }
never executed: end of block
0
1061 if (detectedEscapeButton)
detectedEscapeButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
1062 return;
never executed: return;
0
1063-
1064 // if the message box has one NoRole button, make it the escape button-
1065 for (int i = 0; i < buttons.count(); i++) {
i < buttons.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1066 if (buttonBox->buttonRole(buttons.at(i)) == QDialogButtonBox::NoRole) {
buttonBox->but...tonBox::NoRoleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1067 if (detectedEscapeButton) { // already detected!
detectedEscapeButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
1068 detectedEscapeButton = 0;-
1069 break;
never executed: break;
0
1070 }-
1071 detectedEscapeButton = buttons.at(i);-
1072 }
never executed: end of block
0
1073 }
never executed: end of block
0
1074}
never executed: end of block
0
1075-
1076/*!-
1077 \since 4.2-
1078-
1079 Returns the button that was clicked by the user,-
1080 or 0 if the user hit the \uicontrol Esc key and-
1081 no \l{setEscapeButton()}{escape button} was set.-
1082-
1083 If exec() hasn't been called yet, returns 0.-
1084-
1085 Example:-
1086-
1087 \snippet code/src_gui_dialogs_qmessagebox.cpp 3-
1088-
1089 \sa standardButton(), button()-
1090*/-
1091QAbstractButton *QMessageBox::clickedButton() const-
1092{-
1093 Q_D(const QMessageBox);-
1094 return d->clickedButton;
never executed: return d->clickedButton;
0
1095}-
1096-
1097/*!-
1098 \since 4.2-
1099-
1100 Returns the button that should be the message box's-
1101 \l{QPushButton::setDefault()}{default button}. Returns 0-
1102 if no default button was set.-
1103-
1104 \sa addButton(), QPushButton::setDefault()-
1105*/-
1106QPushButton *QMessageBox::defaultButton() const-
1107{-
1108 Q_D(const QMessageBox);-
1109 return d->defaultButton;
never executed: return d->defaultButton;
0
1110}-
1111-
1112/*!-
1113 \since 4.2-
1114-
1115 Sets the message box's \l{QPushButton::setDefault()}{default button}-
1116 to \a button.-
1117-
1118 \sa addButton(), QPushButton::setDefault()-
1119*/-
1120void QMessageBox::setDefaultButton(QPushButton *button)-
1121{-
1122 Q_D(QMessageBox);-
1123 if (!d->buttonBox->buttons().contains(button))
!d->buttonBox-...ntains(button)Description
TRUEnever evaluated
FALSEnever evaluated
0
1124 return;
never executed: return;
0
1125 d->defaultButton = button;-
1126 button->setDefault(true);-
1127 button->setFocus();-
1128}
never executed: end of block
0
1129-
1130/*!-
1131 \since 4.3-
1132-
1133 Sets the message box's \l{QPushButton::setDefault()}{default button}-
1134 to \a button.-
1135-
1136 \sa addButton(), QPushButton::setDefault()-
1137*/-
1138void QMessageBox::setDefaultButton(QMessageBox::StandardButton button)-
1139{-
1140 Q_D(QMessageBox);-
1141 setDefaultButton(d->buttonBox->button(QDialogButtonBox::StandardButton(button)));-
1142}
never executed: end of block
0
1143-
1144/*! \since 5.2-
1145-
1146 Sets the checkbox \a cb on the message dialog. The message box takes ownership of the checkbox.-
1147 The argument \a cb can be 0 to remove an existing checkbox from the message box.-
1148-
1149 \sa checkBox()-
1150*/-
1151-
1152void QMessageBox::setCheckBox(QCheckBox *cb)-
1153{-
1154 Q_D(QMessageBox);-
1155-
1156 if (cb == d->checkbox)
cb == d->checkboxDescription
TRUEnever evaluated
FALSEnever evaluated
0
1157 return;
never executed: return;
0
1158-
1159 if (d->checkbox) {
d->checkboxDescription
TRUEnever evaluated
FALSEnever evaluated
0
1160 d->checkbox->hide();-
1161 layout()->removeWidget(d->checkbox);-
1162 if (d->checkbox->parentWidget() == this) {
d->checkbox->p...dget() == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1163 d->checkbox->setParent(0);-
1164 d->checkbox->deleteLater();-
1165 }
never executed: end of block
0
1166 }
never executed: end of block
0
1167 d->checkbox = cb;-
1168 if (d->checkbox) {
d->checkboxDescription
TRUEnever evaluated
FALSEnever evaluated
0
1169 QSizePolicy sp = d->checkbox->sizePolicy();-
1170 sp.setHorizontalPolicy(QSizePolicy::MinimumExpanding);-
1171 d->checkbox->setSizePolicy(sp);-
1172 }
never executed: end of block
0
1173 d->setupLayout();-
1174}
never executed: end of block
0
1175-
1176-
1177/*! \since 5.2-
1178-
1179 Returns the checkbox shown on the dialog. This is 0 if no checkbox is set.-
1180 \sa setCheckBox()-
1181*/-
1182-
1183QCheckBox* QMessageBox::checkBox() const-
1184{-
1185 Q_D(const QMessageBox);-
1186 return d->checkbox;
never executed: return d->checkbox;
0
1187}-
1188-
1189/*!-
1190 \property QMessageBox::text-
1191 \brief the message box text to be displayed.-
1192-
1193 The text will be interpreted either as a plain text or as rich text,-
1194 depending on the text format setting (\l QMessageBox::textFormat).-
1195 The default setting is Qt::AutoText, i.e., the message box will try-
1196 to auto-detect the format of the text.-
1197-
1198 The default value of this property is an empty string.-
1199-
1200 \sa textFormat, QMessageBox::informativeText, QMessageBox::detailedText-
1201*/-
1202QString QMessageBox::text() const-
1203{-
1204 Q_D(const QMessageBox);-
1205 return d->label->text();
never executed: return d->label->text();
0
1206}-
1207-
1208void QMessageBox::setText(const QString &text)-
1209{-
1210 Q_D(QMessageBox);-
1211 d->label->setText(text);-
1212 d->label->setWordWrap(d->label->textFormat() == Qt::RichText-
1213 || (d->label->textFormat() == Qt::AutoText && Qt::mightBeRichText(text)));-
1214 d->updateSize();-
1215}
never executed: end of block
0
1216-
1217/*!-
1218 \enum QMessageBox::Icon-
1219-
1220 This enum has the following values:-
1221-
1222 \value NoIcon the message box does not have any icon.-
1223-
1224 \value Question an icon indicating that-
1225 the message is asking a question.-
1226-
1227 \value Information an icon indicating that-
1228 the message is nothing out of the ordinary.-
1229-
1230 \value Warning an icon indicating that the-
1231 message is a warning, but can be dealt with.-
1232-
1233 \value Critical an icon indicating that-
1234 the message represents a critical problem.-
1235-
1236*/-
1237-
1238/*!-
1239 \property QMessageBox::icon-
1240 \brief the message box's icon-
1241-
1242 The icon of the message box can be specified with one of the-
1243 values:-
1244-
1245 \list-
1246 \li QMessageBox::NoIcon-
1247 \li QMessageBox::Question-
1248 \li QMessageBox::Information-
1249 \li QMessageBox::Warning-
1250 \li QMessageBox::Critical-
1251 \endlist-
1252-
1253 The default is QMessageBox::NoIcon.-
1254-
1255 The pixmap used to display the actual icon depends on the current-
1256 \l{QWidget::style()} {GUI style}. You can also set a custom pixmap-
1257 for the icon by setting the \l{QMessageBox::iconPixmap} {icon-
1258 pixmap} property.-
1259-
1260 \sa iconPixmap-
1261*/-
1262QMessageBox::Icon QMessageBox::icon() const-
1263{-
1264 Q_D(const QMessageBox);-
1265 return d->icon;
never executed: return d->icon;
0
1266}-
1267-
1268void QMessageBox::setIcon(Icon icon)-
1269{-
1270 Q_D(QMessageBox);-
1271 setIconPixmap(QMessageBoxPrivate::standardIcon((QMessageBox::Icon)icon,-
1272 this));-
1273 d->icon = icon;-
1274}
never executed: end of block
0
1275-
1276/*!-
1277 \property QMessageBox::iconPixmap-
1278 \brief the current icon-
1279-
1280 The icon currently used by the message box. Note that it's often-
1281 hard to draw one pixmap that looks appropriate in all GUI styles;-
1282 you may want to supply a different pixmap for each platform.-
1283-
1284 By default, this property is undefined.-
1285-
1286 \sa icon-
1287*/-
1288QPixmap QMessageBox::iconPixmap() const-
1289{-
1290 Q_D(const QMessageBox);-
1291 if (d->iconLabel && d->iconLabel->pixmap())
d->iconLabelDescription
TRUEnever evaluated
FALSEnever evaluated
d->iconLabel->pixmap()Description
TRUEnever evaluated
FALSEnever evaluated
0
1292 return *d->iconLabel->pixmap();
never executed: return *d->iconLabel->pixmap();
0
1293 return QPixmap();
never executed: return QPixmap();
0
1294}-
1295-
1296void QMessageBox::setIconPixmap(const QPixmap &pixmap)-
1297{-
1298 Q_D(QMessageBox);-
1299 d->iconLabel->setPixmap(pixmap);-
1300 d->icon = NoIcon;-
1301 d->setupLayout();-
1302}
never executed: end of block
0
1303-
1304/*!-
1305 \property QMessageBox::textFormat-
1306 \brief the format of the text displayed by the message box-
1307-
1308 The current text format used by the message box. See the \l-
1309 Qt::TextFormat enum for an explanation of the possible options.-
1310-
1311 The default format is Qt::AutoText.-
1312-
1313 \sa setText()-
1314*/-
1315Qt::TextFormat QMessageBox::textFormat() const-
1316{-
1317 Q_D(const QMessageBox);-
1318 return d->label->textFormat();
never executed: return d->label->textFormat();
0
1319}-
1320-
1321void QMessageBox::setTextFormat(Qt::TextFormat format)-
1322{-
1323 Q_D(QMessageBox);-
1324 d->label->setTextFormat(format);-
1325 d->label->setWordWrap(format == Qt::RichText-
1326 || (format == Qt::AutoText && Qt::mightBeRichText(d->label->text())));-
1327 d->updateSize();-
1328}
never executed: end of block
0
1329-
1330/*!-
1331 \property QMessageBox::textInteractionFlags-
1332 \since 5.1-
1333-
1334 Specifies how the label of the message box should interact with user-
1335 input.-
1336-
1337 The default value depends on the style.-
1338-
1339 \sa QStyle::SH_MessageBox_TextInteractionFlags-
1340*/-
1341-
1342Qt::TextInteractionFlags QMessageBox::textInteractionFlags() const-
1343{-
1344 Q_D(const QMessageBox);-
1345 return d->label->textInteractionFlags();
never executed: return d->label->textInteractionFlags();
0
1346}-
1347-
1348void QMessageBox::setTextInteractionFlags(Qt::TextInteractionFlags flags)-
1349{-
1350 Q_D(QMessageBox);-
1351 d->label->setTextInteractionFlags(flags);-
1352}
never executed: end of block
0
1353-
1354/*!-
1355 \reimp-
1356*/-
1357bool QMessageBox::event(QEvent *e)-
1358{-
1359 bool result =QDialog::event(e);-
1360 switch (e->type()) {-
1361 case QEvent::LayoutRequest:
never executed: case QEvent::LayoutRequest:
0
1362 d_func()->updateSize();-
1363 break;
never executed: break;
0
1364 case QEvent::LanguageChange:
never executed: case QEvent::LanguageChange:
0
1365 d_func()->retranslateStrings();-
1366 break;
never executed: break;
0
1367#ifdef Q_OS_WINCE-
1368 case QEvent::OkRequest:-
1369 case QEvent::HelpRequest: {-
1370 QString bName =-
1371 (e->type() == QEvent::OkRequest)-
1372 ? QApplication::translate("QMessageBox", "OK")-
1373 : QApplication::translate("QMessageBox", "Help");-
1374 QList<QPushButton*> list = findChildren<QPushButton*>();-
1375 for (int i=0; i<list.size(); ++i) {-
1376 QPushButton *pb = list.at(i);-
1377 if (pb->text() == bName) {-
1378 if (pb->isEnabled())-
1379 pb->click();-
1380 return pb->isEnabled();-
1381 }-
1382 }-
1383 }-
1384#endif-
1385 default:
never executed: default:
0
1386 break;
never executed: break;
0
1387 }-
1388 return result;
never executed: return result;
0
1389}-
1390-
1391/*!-
1392 \reimp-
1393*/-
1394void QMessageBox::resizeEvent(QResizeEvent *event)-
1395{-
1396 QDialog::resizeEvent(event);-
1397}
never executed: end of block
0
1398-
1399/*!-
1400 \reimp-
1401*/-
1402void QMessageBox::closeEvent(QCloseEvent *e)-
1403{-
1404 Q_D(QMessageBox);-
1405 if (!d->detectedEscapeButton) {
!d->detectedEscapeButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
1406 e->ignore();-
1407 return;
never executed: return;
0
1408 }-
1409 QDialog::closeEvent(e);-
1410 d->clickedButton = d->detectedEscapeButton;-
1411 setResult(d->execReturnCode(d->detectedEscapeButton));-
1412}
never executed: end of block
0
1413-
1414/*!-
1415 \reimp-
1416*/-
1417void QMessageBox::changeEvent(QEvent *ev)-
1418{-
1419 Q_D(QMessageBox);-
1420 switch (ev->type()) {-
1421 case QEvent::StyleChange:
never executed: case QEvent::StyleChange:
0
1422 {-
1423 if (d->icon != NoIcon)
d->icon != NoIconDescription
TRUEnever evaluated
FALSEnever evaluated
0
1424 setIcon(d->icon);
never executed: setIcon(d->icon);
0
1425 Qt::TextInteractionFlags flags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, this));-
1426 d->label->setTextInteractionFlags(flags);-
1427 d->buttonBox->setCenterButtons(style()->styleHint(QStyle::SH_MessageBox_CenterButtons, 0, this));-
1428 if (d->informativeLabel)
d->informativeLabelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1429 d->informativeLabel->setTextInteractionFlags(flags);
never executed: d->informativeLabel->setTextInteractionFlags(flags);
0
1430 // intentional fall through-
1431 }-
1432 case QEvent::FontChange:
code before this statement never executed: case QEvent::FontChange:
never executed: case QEvent::FontChange:
0
1433 case QEvent::ApplicationFontChange:
never executed: case QEvent::ApplicationFontChange:
0
1434#ifdef Q_OS_MAC-
1435 {-
1436 QFont f = font();-
1437 f.setBold(true);-
1438 d->label->setFont(f);-
1439 }-
1440#endif-
1441 default:
never executed: default:
0
1442 break;
never executed: break;
0
1443 }-
1444 QDialog::changeEvent(ev);-
1445}
never executed: end of block
0
1446-
1447/*!-
1448 \reimp-
1449*/-
1450void QMessageBox::keyPressEvent(QKeyEvent *e)-
1451{-
1452 Q_D(QMessageBox);-
1453-
1454 if (e->matches(QKeySequence::Cancel)) {
e->matches(QKe...uence::Cancel)Description
TRUEnever evaluated
FALSEnever evaluated
0
1455 if (d->detectedEscapeButton) {
d->detectedEscapeButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
1456#ifdef Q_OS_MAC-
1457 d->detectedEscapeButton->animateClick();-
1458#else-
1459 d->detectedEscapeButton->click();-
1460#endif-
1461 }
never executed: end of block
0
1462 return;
never executed: return;
0
1463 }-
1464-
1465-
1466#if !defined(QT_NO_CLIPBOARD) && !defined(QT_NO_SHORTCUT)-
1467-
1468#if !defined(QT_NO_TEXTEDIT)-
1469 if (e == QKeySequence::Copy) {
e == QKeySequence::CopyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1470 if (d->detailsText && d->detailsText->isVisible() && d->detailsText->copy()) {
d->detailsTextDescription
TRUEnever evaluated
FALSEnever evaluated
d->detailsText->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
d->detailsText->copy()Description
TRUEnever evaluated
FALSEnever evaluated
0
1471 e->setAccepted(true);-
1472 return;
never executed: return;
0
1473 }-
1474 } else if (e == QKeySequence::SelectAll && d->detailsText && d->detailsText->isVisible()) {
never executed: end of block
e == QKeySequence::SelectAllDescription
TRUEnever evaluated
FALSEnever evaluated
d->detailsTextDescription
TRUEnever evaluated
FALSEnever evaluated
d->detailsText->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
1475 d->detailsText->selectAll();-
1476 e->setAccepted(true);-
1477 return;
never executed: return;
0
1478 }-
1479#endif // !QT_NO_TEXTEDIT-
1480-
1481#if defined(Q_OS_WIN)-
1482 if (e == QKeySequence::Copy) {-
1483 QString separator = QString::fromLatin1("---------------------------\n");-
1484 QString textToCopy = separator;-
1485 separator.prepend(QLatin1Char('\n'));-
1486 textToCopy += windowTitle() + separator; // title-
1487 textToCopy += d->label->text() + separator; // text-
1488-
1489 if (d->informativeLabel)-
1490 textToCopy += d->informativeLabel->text() + separator;-
1491-
1492 QString buttonTexts;-
1493 QList<QAbstractButton *> buttons = d->buttonBox->buttons();-
1494 for (int i = 0; i < buttons.count(); i++) {-
1495 buttonTexts += buttons[i]->text() + QLatin1String(" ");-
1496 }-
1497 textToCopy += buttonTexts + separator;-
1498#ifndef QT_NO_TEXTEDIT-
1499 if (d->detailsText)-
1500 textToCopy += d->detailsText->text() + separator;-
1501#endif-
1502 QApplication::clipboard()->setText(textToCopy);-
1503 return;-
1504 }-
1505#endif // Q_OS_WIN-
1506-
1507#endif // !QT_NO_CLIPBOARD && !QT_NO_SHORTCUT-
1508-
1509#ifndef QT_NO_SHORTCUT-
1510 if (!(e->modifiers() & (Qt::AltModifier | Qt::ControlModifier | Qt::MetaModifier))) {
!(e->modifiers...MetaModifier))Description
TRUEnever evaluated
FALSEnever evaluated
0
1511 int key = e->key() & ~Qt::MODIFIER_MASK;-
1512 if (key) {
keyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1513 const QList<QAbstractButton *> buttons = d->buttonBox->buttons();-
1514 for (int i = 0; i < buttons.count(); ++i) {
i < buttons.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1515 QAbstractButton *pb = buttons.at(i);-
1516 QKeySequence shortcut = pb->shortcut();-
1517 if (!shortcut.isEmpty() && key == int(shortcut[0] & ~Qt::MODIFIER_MASK)) {
!shortcut.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
key == int(sho...MODIFIER_MASK)Description
TRUEnever evaluated
FALSEnever evaluated
0
1518 pb->animateClick();-
1519 return;
never executed: return;
0
1520 }-
1521 }
never executed: end of block
0
1522 }
never executed: end of block
0
1523 }
never executed: end of block
0
1524#endif-
1525 QDialog::keyPressEvent(e);-
1526}
never executed: end of block
0
1527-
1528#ifdef Q_OS_WINCE-
1529/*!-
1530 \reimp-
1531*/-
1532void QMessageBox::setVisible(bool visible)-
1533{-
1534 Q_D(QMessageBox);-
1535 if (visible)-
1536 d->hideSpecial();-
1537 QDialog::setVisible(visible);-
1538}-
1539#endif-
1540-
1541-
1542/*!-
1543 \overload-
1544-
1545 Opens the dialog and connects its finished() or buttonClicked() signal to-
1546 the slot specified by \a receiver and \a member. If the slot in \a member-
1547 has a pointer for its first parameter the connection is to buttonClicked(),-
1548 otherwise the connection is to finished().-
1549-
1550 The signal will be disconnected from the slot when the dialog is closed.-
1551*/-
1552void QMessageBox::open(QObject *receiver, const char *member)-
1553{-
1554 Q_D(QMessageBox);-
1555 const char *signal = member && strchr(member, '*') ? SIGNAL(buttonClicked(QAbstractButton*))
memberDescription
TRUEnever evaluated
FALSEnever evaluated
strchr(member, '*')Description
TRUEnever evaluated
FALSEnever evaluated
0
1556 : SIGNAL(finished(int));-
1557 connect(this, signal, receiver, member);-
1558 d->signalToDisconnectOnClose = signal;-
1559 d->receiverToDisconnectOnClose = receiver;-
1560 d->memberToDisconnectOnClose = member;-
1561 QDialog::open();-
1562}
never executed: end of block
0
1563-
1564/*!-
1565 \since 4.5-
1566-
1567 Returns a list of all the buttons that have been added to the message box.-
1568-
1569 \sa buttonRole(), addButton(), removeButton()-
1570*/-
1571QList<QAbstractButton *> QMessageBox::buttons() const-
1572{-
1573 Q_D(const QMessageBox);-
1574 return d->buttonBox->buttons();
never executed: return d->buttonBox->buttons();
0
1575}-
1576-
1577/*!-
1578 \since 4.5-
1579-
1580 Returns the button role for the specified \a button. This function returns-
1581 \l InvalidRole if \a button is 0 or has not been added to the message box.-
1582-
1583 \sa buttons(), addButton()-
1584*/-
1585QMessageBox::ButtonRole QMessageBox::buttonRole(QAbstractButton *button) const-
1586{-
1587 Q_D(const QMessageBox);-
1588 return QMessageBox::ButtonRole(d->buttonBox->buttonRole(button));
never executed: return QMessageBox::ButtonRole(d->buttonBox->buttonRole(button));
0
1589}-
1590-
1591/*!-
1592 \reimp-
1593*/-
1594void QMessageBox::showEvent(QShowEvent *e)-
1595{-
1596 Q_D(QMessageBox);-
1597 if (d->autoAddOkButton) {
d->autoAddOkButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
1598 addButton(Ok);-
1599#if defined(Q_OS_WINCE)-
1600 d->hideSpecial();-
1601#endif-
1602 }
never executed: end of block
0
1603 if (d->detailsButton)
d->detailsButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
1604 addButton(d->detailsButton, QMessageBox::ActionRole);
never executed: addButton(d->detailsButton, QMessageBox::ActionRole);
0
1605 d->detectEscapeButton();-
1606 d->updateSize();-
1607-
1608#ifndef QT_NO_ACCESSIBILITY-
1609 QAccessibleEvent event(this, QAccessible::Alert);-
1610 QAccessible::updateAccessibility(&event);-
1611#endif-
1612#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)-
1613 if (const HMENU systemMenu = qt_getWindowsSystemMenu(this)) {-
1614 EnableMenuItem(systemMenu, SC_CLOSE, d->detectedEscapeButton ?-
1615 MF_BYCOMMAND|MF_ENABLED : MF_BYCOMMAND|MF_GRAYED);-
1616 }-
1617#endif-
1618 QDialog::showEvent(e);-
1619}
never executed: end of block
0
1620-
1621-
1622static QMessageBox::StandardButton showNewMessageBox(QWidget *parent,-
1623 QMessageBox::Icon icon,-
1624 const QString& title, const QString& text,-
1625 QMessageBox::StandardButtons buttons,-
1626 QMessageBox::StandardButton defaultButton)-
1627{-
1628 // necessary for source compatibility with Qt 4.0 and 4.1-
1629 // handles (Yes, No) and (Yes|Default, No)-
1630 if (defaultButton && !(buttons & defaultButton))
defaultButtonDescription
TRUEnever evaluated
FALSEnever evaluated
!(buttons & defaultButton)Description
TRUEnever evaluated
FALSEnever evaluated
0
1631 return (QMessageBox::StandardButton)
never executed: return (QMessageBox::StandardButton) QMessageBoxPrivate::showOldMessageBox(parent, icon, title, text, int(buttons), int(defaultButton), 0);
0
1632 QMessageBoxPrivate::showOldMessageBox(parent, icon, title,
never executed: return (QMessageBox::StandardButton) QMessageBoxPrivate::showOldMessageBox(parent, icon, title, text, int(buttons), int(defaultButton), 0);
0
1633 text, int(buttons),
never executed: return (QMessageBox::StandardButton) QMessageBoxPrivate::showOldMessageBox(parent, icon, title, text, int(buttons), int(defaultButton), 0);
0
1634 int(defaultButton), 0);
never executed: return (QMessageBox::StandardButton) QMessageBoxPrivate::showOldMessageBox(parent, icon, title, text, int(buttons), int(defaultButton), 0);
0
1635-
1636 QMessageBox msgBox(icon, title, text, QMessageBox::NoButton, parent);-
1637 QDialogButtonBox *buttonBox = msgBox.findChild<QDialogButtonBox*>();-
1638 Q_ASSERT(buttonBox != 0);-
1639-
1640 uint mask = QMessageBox::FirstButton;-
1641 while (mask <= QMessageBox::LastButton) {
mask <= QMessa...ox::LastButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
1642 uint sb = buttons & mask;-
1643 mask <<= 1;-
1644 if (!sb)
!sbDescription
TRUEnever evaluated
FALSEnever evaluated
0
1645 continue;
never executed: continue;
0
1646 QPushButton *button = msgBox.addButton((QMessageBox::StandardButton)sb);-
1647 // Choose the first accept role as the default-
1648 if (msgBox.defaultButton())
msgBox.defaultButton()Description
TRUEnever evaluated
FALSEnever evaluated
0
1649 continue;
never executed: continue;
0
1650 if ((defaultButton == QMessageBox::NoButton && buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole)
defaultButton ...eBox::NoButtonDescription
TRUEnever evaluated
FALSEnever evaluated
buttonBox->but...ox::AcceptRoleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1651 || (defaultButton != QMessageBox::NoButton && sb == uint(defaultButton)))
defaultButton ...eBox::NoButtonDescription
TRUEnever evaluated
FALSEnever evaluated
sb == uint(defaultButton)Description
TRUEnever evaluated
FALSEnever evaluated
0
1652 msgBox.setDefaultButton(button);
never executed: msgBox.setDefaultButton(button);
0
1653 }
never executed: end of block
0
1654 if (msgBox.exec() == -1)
msgBox.exec() == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1655 return QMessageBox::Cancel;
never executed: return QMessageBox::Cancel;
0
1656 return msgBox.standardButton(msgBox.clickedButton());
never executed: return msgBox.standardButton(msgBox.clickedButton());
0
1657}-
1658-
1659/*!-
1660 \since 4.2-
1661-
1662 Opens an information message box with the given \a title and-
1663 \a text in front of the specified \a parent widget.-
1664-
1665 The standard \a buttons are added to the message box.-
1666 \a defaultButton specifies the button used when \uicontrol Enter is pressed.-
1667 \a defaultButton must refer to a button that was given in \a buttons.-
1668 If \a defaultButton is QMessageBox::NoButton, QMessageBox-
1669 chooses a suitable default automatically.-
1670-
1671 Returns the identity of the standard button that was clicked. If-
1672 \uicontrol Esc was pressed instead, the \l{Default and Escape Keys}-
1673 {escape button} is returned.-
1674-
1675 The message box is an \l{Qt::ApplicationModal}{application modal}-
1676 dialog box.-
1677-
1678 \warning Do not delete \a parent during the execution of the dialog.-
1679 If you want to do this, you should create the dialog-
1680 yourself using one of the QMessageBox constructors.-
1681-
1682 \sa question(), warning(), critical()-
1683*/-
1684QMessageBox::StandardButton QMessageBox::information(QWidget *parent, const QString &title,-
1685 const QString& text, StandardButtons buttons,-
1686 StandardButton defaultButton)-
1687{-
1688 return showNewMessageBox(parent, Information, title, text, buttons,
never executed: return showNewMessageBox(parent, Information, title, text, buttons, defaultButton);
0
1689 defaultButton);
never executed: return showNewMessageBox(parent, Information, title, text, buttons, defaultButton);
0
1690}-
1691-
1692-
1693/*!-
1694 \since 4.2-
1695-
1696 Opens a question message box with the given \a title and \a-
1697 text in front of the specified \a parent widget.-
1698-
1699 The standard \a buttons are added to the message box. \a-
1700 defaultButton specifies the button used when \uicontrol Enter is-
1701 pressed. \a defaultButton must refer to a button that was given in \a buttons.-
1702 If \a defaultButton is QMessageBox::NoButton, QMessageBox-
1703 chooses a suitable default automatically.-
1704-
1705 Returns the identity of the standard button that was clicked. If-
1706 \uicontrol Esc was pressed instead, the \l{Default and Escape Keys}-
1707 {escape button} is returned.-
1708-
1709 The message box is an \l{Qt::ApplicationModal} {application modal}-
1710 dialog box.-
1711-
1712 \warning Do not delete \a parent during the execution of the dialog.-
1713 If you want to do this, you should create the dialog-
1714 yourself using one of the QMessageBox constructors.-
1715-
1716 \sa information(), warning(), critical()-
1717*/-
1718QMessageBox::StandardButton QMessageBox::question(QWidget *parent, const QString &title,-
1719 const QString& text, StandardButtons buttons,-
1720 StandardButton defaultButton)-
1721{-
1722 return showNewMessageBox(parent, Question, title, text, buttons, defaultButton);
never executed: return showNewMessageBox(parent, Question, title, text, buttons, defaultButton);
0
1723}-
1724-
1725/*!-
1726 \since 4.2-
1727-
1728 Opens a warning message box with the given \a title and \a-
1729 text in front of the specified \a parent widget.-
1730-
1731 The standard \a buttons are added to the message box. \a-
1732 defaultButton specifies the button used when \uicontrol Enter is-
1733 pressed. \a defaultButton must refer to a button that was given in \a buttons.-
1734 If \a defaultButton is QMessageBox::NoButton, QMessageBox-
1735 chooses a suitable default automatically.-
1736-
1737 Returns the identity of the standard button that was clicked. If-
1738 \uicontrol Esc was pressed instead, the \l{Default and Escape Keys}-
1739 {escape button} is returned.-
1740-
1741 The message box is an \l{Qt::ApplicationModal} {application modal}-
1742 dialog box.-
1743-
1744 \warning Do not delete \a parent during the execution of the dialog.-
1745 If you want to do this, you should create the dialog-
1746 yourself using one of the QMessageBox constructors.-
1747-
1748 \sa question(), information(), critical()-
1749*/-
1750QMessageBox::StandardButton QMessageBox::warning(QWidget *parent, const QString &title,-
1751 const QString& text, StandardButtons buttons,-
1752 StandardButton defaultButton)-
1753{-
1754 return showNewMessageBox(parent, Warning, title, text, buttons, defaultButton);
never executed: return showNewMessageBox(parent, Warning, title, text, buttons, defaultButton);
0
1755}-
1756-
1757/*!-
1758 \since 4.2-
1759-
1760 Opens a critical message box with the given \a title and \a-
1761 text in front of the specified \a parent widget.-
1762-
1763 The standard \a buttons are added to the message box. \a-
1764 defaultButton specifies the button used when \uicontrol Enter is-
1765 pressed. \a defaultButton must refer to a button that was given in \a buttons.-
1766 If \a defaultButton is QMessageBox::NoButton, QMessageBox-
1767 chooses a suitable default automatically.-
1768-
1769 Returns the identity of the standard button that was clicked. If-
1770 \uicontrol Esc was pressed instead, the \l{Default and Escape Keys}-
1771 {escape button} is returned.-
1772-
1773 The message box is an \l{Qt::ApplicationModal} {application modal}-
1774 dialog box.-
1775-
1776 \warning Do not delete \a parent during the execution of the dialog.-
1777 If you want to do this, you should create the dialog-
1778 yourself using one of the QMessageBox constructors.-
1779-
1780 \sa question(), warning(), information()-
1781*/-
1782QMessageBox::StandardButton QMessageBox::critical(QWidget *parent, const QString &title,-
1783 const QString& text, StandardButtons buttons,-
1784 StandardButton defaultButton)-
1785{-
1786 return showNewMessageBox(parent, Critical, title, text, buttons, defaultButton);
never executed: return showNewMessageBox(parent, Critical, title, text, buttons, defaultButton);
0
1787}-
1788-
1789/*!-
1790 Displays a simple about box with title \a title and text \a-
1791 text. The about box's parent is \a parent.-
1792-
1793 about() looks for a suitable icon in four locations:-
1794-
1795 \list 1-
1796 \li It prefers \l{QWidget::windowIcon()}{parent->icon()}-
1797 if that exists.-
1798 \li If not, it tries the top-level widget containing \a parent.-
1799 \li If that fails, it tries the \l{QApplication::activeWindow()}{active window.}-
1800 \li As a last resort it uses the Information icon.-
1801 \endlist-
1802-
1803 The about box has a single button labelled "OK". On \macos, the-
1804 about box is popped up as a modeless window; on other platforms,-
1805 it is currently application modal.-
1806-
1807 \sa QWidget::windowIcon(), QApplication::activeWindow()-
1808*/-
1809void QMessageBox::about(QWidget *parent, const QString &title, const QString &text)-
1810{-
1811#ifdef Q_OS_MAC-
1812 static QPointer<QMessageBox> oldMsgBox;-
1813-
1814 if (oldMsgBox && oldMsgBox->text() == text) {-
1815 oldMsgBox->show();-
1816 oldMsgBox->raise();-
1817 oldMsgBox->activateWindow();-
1818 return;-
1819 }-
1820#endif-
1821-
1822 QMessageBox *msgBox = new QMessageBox(title, text, Information, 0, 0, 0, parent-
1823#ifdef Q_OS_MAC-
1824 , Qt::WindowTitleHint | Qt::WindowSystemMenuHint-
1825#endif-
1826 );-
1827 msgBox->setAttribute(Qt::WA_DeleteOnClose);-
1828 QIcon icon = msgBox->windowIcon();-
1829 QSize size = icon.actualSize(QSize(64, 64));-
1830 msgBox->setIconPixmap(icon.pixmap(size));-
1831-
1832 // should perhaps be a style hint-
1833#ifdef Q_OS_MAC-
1834 oldMsgBox = msgBox;-
1835#if 0-
1836 // ### doesn't work until close button is enabled in title bar-
1837 msgBox->d_func()->autoAddOkButton = false;-
1838#else-
1839 msgBox->d_func()->buttonBox->setCenterButtons(true);-
1840#endif-
1841 msgBox->show();-
1842#else-
1843 msgBox->exec();-
1844#endif-
1845}
never executed: end of block
0
1846-
1847/*!-
1848 Displays a simple message box about Qt, with the given \a title-
1849 and centered over \a parent (if \a parent is not 0). The message-
1850 includes the version number of Qt being used by the application.-
1851-
1852 This is useful for inclusion in the \uicontrol Help menu of an application,-
1853 as shown in the \l{mainwindows/menus}{Menus} example.-
1854-
1855 QApplication provides this functionality as a slot.-
1856-
1857 On \macos, the about box is popped up as a modeless window; on-
1858 other platforms, it is currently application modal.-
1859-
1860 \sa QApplication::aboutQt()-
1861*/-
1862void QMessageBox::aboutQt(QWidget *parent, const QString &title)-
1863{-
1864#ifdef Q_OS_MAC-
1865 static QPointer<QMessageBox> oldMsgBox;-
1866-
1867 if (oldMsgBox) {-
1868 oldMsgBox->show();-
1869 oldMsgBox->raise();-
1870 oldMsgBox->activateWindow();-
1871 return;-
1872 }-
1873#endif-
1874-
1875 QString translatedTextAboutQtCaption;-
1876 translatedTextAboutQtCaption = QMessageBox::tr(-
1877 "<h3>About Qt</h3>"-
1878 "<p>This program uses Qt version %1.</p>"-
1879 ).arg(QLatin1String(QT_VERSION_STR));-
1880 QString translatedTextAboutQtText;-
1881 translatedTextAboutQtText = QMessageBox::tr(-
1882 "<p>Qt is a C++ toolkit for cross-platform application "-
1883 "development.</p>"-
1884 "<p>Qt provides single-source portability across all major desktop "-
1885 "operating systems. It is also available for embedded Linux and other "-
1886 "embedded and mobile operating systems.</p>"-
1887 "<p>Qt is available under three different licensing options designed "-
1888 "to accommodate the needs of our various users.</p>"-
1889 "<p>Qt licensed under our commercial license agreement is appropriate "-
1890 "for development of proprietary/commercial software where you do not "-
1891 "want to share any source code with third parties or otherwise cannot "-
1892 "comply with the terms of the GNU LGPL version 3 or GNU LGPL version 2.1.</p>"-
1893 "<p>Qt licensed under the GNU LGPL version 3 is appropriate for the "-
1894 "development of Qt&nbsp;applications provided you can comply with the terms "-
1895 "and conditions of the GNU LGPL version 3.</p>"-
1896 "<p>Qt licensed under the GNU LGPL version 2.1 is appropriate for the "-
1897 "development of Qt&nbsp;applications provided you can comply with the terms "-
1898 "and conditions of the GNU LGPL version 2.1.</p>"-
1899 "<p>Please see <a href=\"http://%2/\">%2</a> "-
1900 "for an overview of Qt licensing.</p>"-
1901 "<p>Copyright (C) %1 The Qt Company Ltd and other "-
1902 "contributors.</p>"-
1903 "<p>Qt and the Qt logo are trademarks of The Qt Company Ltd.</p>"-
1904 "<p>Qt is The Qt Company Ltd product developed as an open source "-
1905 "project. See <a href=\"http://%3/\">%3</a> for more information.</p>"-
1906 ).arg(QStringLiteral("2017"),
never executed: return qstring_literal_temp;
0
1907 QStringLiteral("qt.io/licensing"),
never executed: return qstring_literal_temp;
0
1908 QStringLiteral("qt.io"));
never executed: return qstring_literal_temp;
0
1909 QMessageBox *msgBox = new QMessageBox(parent);-
1910 msgBox->setAttribute(Qt::WA_DeleteOnClose);-
1911 msgBox->setWindowTitle(title.isEmpty() ? tr("About Qt") : title);-
1912 msgBox->setText(translatedTextAboutQtCaption);-
1913 msgBox->setInformativeText(translatedTextAboutQtText);-
1914-
1915 QPixmap pm(QLatin1String(":/qt-project.org/qmessagebox/images/qtlogo-64.png"));-
1916 if (!pm.isNull())
!pm.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1917 msgBox->setIconPixmap(pm);
never executed: msgBox->setIconPixmap(pm);
0
1918#if defined(Q_OS_WINCE)-
1919 msgBox->setDefaultButton(msgBox->addButton(QMessageBox::Ok));-
1920#endif-
1921-
1922 // should perhaps be a style hint-
1923#ifdef Q_OS_MAC-
1924 oldMsgBox = msgBox;-
1925#if 0-
1926 // ### doesn't work until close button is enabled in title bar-
1927 msgBox->d_func()->autoAddOkButton = false;-
1928#else-
1929 msgBox->d_func()->buttonBox->setCenterButtons(true);-
1930#endif-
1931 msgBox->show();-
1932#else-
1933 msgBox->exec();-
1934#endif-
1935}
never executed: end of block
0
1936-
1937/////////////////////////////////////////////////////////////////////////////////////////-
1938// Source and binary compatibility routines for 4.0 and 4.1-
1939-
1940static QMessageBox::StandardButton newButton(int button)-
1941{-
1942 // this is needed for source compatibility with Qt 4.0 and 4.1-
1943 if (button == QMessageBox::NoButton || (button & NewButtonMask))
button == QMes...eBox::NoButtonDescription
TRUEnever evaluated
FALSEnever evaluated
(button & NewButtonMask)Description
TRUEnever evaluated
FALSEnever evaluated
0
1944 return QMessageBox::StandardButton(button & QMessageBox::ButtonMask);
never executed: return QMessageBox::StandardButton(button & QMessageBox::ButtonMask);
0
1945-
1946#if QT_VERSION < 0x050000-
1947 // this is needed for binary compatibility with Qt 4.0 and 4.1-
1948 switch (button & Old_ButtonMask) {-
1949 case Old_Ok:-
1950 return QMessageBox::Ok;-
1951 case Old_Cancel:-
1952 return QMessageBox::Cancel;-
1953 case Old_Yes:-
1954 return QMessageBox::Yes;-
1955 case Old_No:-
1956 return QMessageBox::No;-
1957 case Old_Abort:-
1958 return QMessageBox::Abort;-
1959 case Old_Retry:-
1960 return QMessageBox::Retry;-
1961 case Old_Ignore:-
1962 return QMessageBox::Ignore;-
1963 case Old_YesAll:-
1964 return QMessageBox::YesToAll;-
1965 case Old_NoAll:-
1966 return QMessageBox::NoToAll;-
1967 default:-
1968 return QMessageBox::NoButton;-
1969 }-
1970#else-
1971 return QMessageBox::NoButton;
never executed: return QMessageBox::NoButton;
0
1972#endif-
1973}-
1974-
1975static bool detectedCompat(int button0, int button1, int button2)-
1976{-
1977 if (button0 != 0 && !(button0 & NewButtonMask))
button0 != 0Description
TRUEnever evaluated
FALSEnever evaluated
!(button0 & NewButtonMask)Description
TRUEnever evaluated
FALSEnever evaluated
0
1978 return true;
never executed: return true;
0
1979 if (button1 != 0 && !(button1 & NewButtonMask))
button1 != 0Description
TRUEnever evaluated
FALSEnever evaluated
!(button1 & NewButtonMask)Description
TRUEnever evaluated
FALSEnever evaluated
0
1980 return true;
never executed: return true;
0
1981 if (button2 != 0 && !(button2 & NewButtonMask))
button2 != 0Description
TRUEnever evaluated
FALSEnever evaluated
!(button2 & NewButtonMask)Description
TRUEnever evaluated
FALSEnever evaluated
0
1982 return true;
never executed: return true;
0
1983 return false;
never executed: return false;
0
1984}-
1985-
1986QAbstractButton *QMessageBoxPrivate::findButton(int button0, int button1, int button2, int flags)-
1987{-
1988 Q_Q(QMessageBox);-
1989 int button = 0;-
1990-
1991 if (button0 & flags) {
button0 & flagsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1992 button = button0;-
1993 } else if (button1 & flags) {
never executed: end of block
button1 & flagsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1994 button = button1;-
1995 } else if (button2 & flags) {
never executed: end of block
button2 & flagsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1996 button = button2;-
1997 }
never executed: end of block
0
1998 return q->button(newButton(button));
never executed: return q->button(newButton(button));
0
1999}-
2000-
2001void QMessageBoxPrivate::addOldButtons(int button0, int button1, int button2)-
2002{-
2003 Q_Q(QMessageBox);-
2004 q->addButton(newButton(button0));-
2005 q->addButton(newButton(button1));-
2006 q->addButton(newButton(button2));-
2007 q->setDefaultButton(-
2008 static_cast<QPushButton *>(findButton(button0, button1, button2, QMessageBox::Default)));-
2009 q->setEscapeButton(findButton(button0, button1, button2, QMessageBox::Escape));-
2010 compatMode = detectedCompat(button0, button1, button2);-
2011}
never executed: end of block
0
2012-
2013QAbstractButton *QMessageBoxPrivate::abstractButtonForId(int id) const-
2014{-
2015 Q_Q(const QMessageBox);-
2016 QAbstractButton *result = customButtonList.value(id);-
2017 if (result)
resultDescription
TRUEnever evaluated
FALSEnever evaluated
0
2018 return result;
never executed: return result;
0
2019 if (id & QMessageBox::FlagMask) // for compatibility with Qt 4.0/4.1 (even if it is silly)
id & QMessageBox::FlagMaskDescription
TRUEnever evaluated
FALSEnever evaluated
0
2020 return 0;
never executed: return 0;
0
2021 return q->button(newButton(id));
never executed: return q->button(newButton(id));
0
2022}-
2023-
2024int QMessageBoxPrivate::showOldMessageBox(QWidget *parent, QMessageBox::Icon icon,-
2025 const QString &title, const QString &text,-
2026 int button0, int button1, int button2)-
2027{-
2028 QMessageBox messageBox(icon, title, text, QMessageBox::NoButton, parent);-
2029 messageBox.d_func()->addOldButtons(button0, button1, button2);-
2030 return messageBox.exec();
never executed: return messageBox.exec();
0
2031}-
2032-
2033int QMessageBoxPrivate::showOldMessageBox(QWidget *parent, QMessageBox::Icon icon,-
2034 const QString &title, const QString &text,-
2035 const QString &button0Text,-
2036 const QString &button1Text,-
2037 const QString &button2Text,-
2038 int defaultButtonNumber,-
2039 int escapeButtonNumber)-
2040{-
2041 QMessageBox messageBox(icon, title, text, QMessageBox::NoButton, parent);-
2042 QString myButton0Text = button0Text;-
2043 if (myButton0Text.isEmpty())
myButton0Text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2044 myButton0Text = QDialogButtonBox::tr("OK");
never executed: myButton0Text = QDialogButtonBox::tr("OK");
0
2045 messageBox.addButton(myButton0Text, QMessageBox::ActionRole);-
2046 if (!button1Text.isEmpty())
!button1Text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2047 messageBox.addButton(button1Text, QMessageBox::ActionRole);
never executed: messageBox.addButton(button1Text, QMessageBox::ActionRole);
0
2048 if (!button2Text.isEmpty())
!button2Text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2049 messageBox.addButton(button2Text, QMessageBox::ActionRole);
never executed: messageBox.addButton(button2Text, QMessageBox::ActionRole);
0
2050-
2051 const QList<QAbstractButton *> &buttonList = messageBox.d_func()->customButtonList;-
2052 messageBox.setDefaultButton(static_cast<QPushButton *>(buttonList.value(defaultButtonNumber)));-
2053 messageBox.setEscapeButton(buttonList.value(escapeButtonNumber));-
2054-
2055 return messageBox.exec();
never executed: return messageBox.exec();
0
2056}-
2057-
2058void QMessageBoxPrivate::retranslateStrings()-
2059{-
2060#ifndef QT_NO_TEXTEDIT-
2061 if (detailsButton)
detailsButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
2062 detailsButton->setLabel(detailsText->isHidden() ? ShowLabel : HideLabel);
never executed: detailsButton->setLabel(detailsText->isHidden() ? ShowLabel : HideLabel);
0
2063#endif-
2064}
never executed: end of block
0
2065-
2066/*!-
2067 \obsolete-
2068-
2069 Constructs a message box with a \a title, a \a text, an \a icon,-
2070 and up to three buttons.-
2071-
2072 The \a icon must be one of the following:-
2073 \list-
2074 \li QMessageBox::NoIcon-
2075 \li QMessageBox::Question-
2076 \li QMessageBox::Information-
2077 \li QMessageBox::Warning-
2078 \li QMessageBox::Critical-
2079 \endlist-
2080-
2081 Each button, \a button0, \a button1 and \a button2, can have one-
2082 of the following values:-
2083 \list-
2084 \li QMessageBox::NoButton-
2085 \li QMessageBox::Ok-
2086 \li QMessageBox::Cancel-
2087 \li QMessageBox::Yes-
2088 \li QMessageBox::No-
2089 \li QMessageBox::Abort-
2090 \li QMessageBox::Retry-
2091 \li QMessageBox::Ignore-
2092 \li QMessageBox::YesAll-
2093 \li QMessageBox::NoAll-
2094 \endlist-
2095-
2096 Use QMessageBox::NoButton for the later parameters to have fewer-
2097 than three buttons in your message box. If you don't specify any-
2098 buttons at all, QMessageBox will provide an Ok button.-
2099-
2100 One of the buttons can be OR-ed with the QMessageBox::Default-
2101 flag to make it the default button (clicked when Enter is-
2102 pressed).-
2103-
2104 One of the buttons can be OR-ed with the QMessageBox::Escape flag-
2105 to make it the cancel or close button (clicked when \uicontrol Esc is-
2106 pressed).-
2107-
2108 \snippet dialogs/dialogs.cpp 2-
2109-
2110 The message box is an \l{Qt::ApplicationModal} {application modal}-
2111 dialog box.-
2112-
2113 The \a parent and \a f arguments are passed to-
2114 the QDialog constructor.-
2115-
2116 \sa setWindowTitle(), setText(), setIcon()-
2117*/-
2118QMessageBox::QMessageBox(const QString &title, const QString &text, Icon icon,-
2119 int button0, int button1, int button2, QWidget *parent,-
2120 Qt::WindowFlags f)-
2121 : QDialog(*new QMessageBoxPrivate, parent,-
2122 f /*| Qt::MSWindowsFixedSizeDialogHint #### */| Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)-
2123{-
2124 Q_D(QMessageBox);-
2125 d->init(title, text);-
2126 setIcon(icon);-
2127 d->addOldButtons(button0, button1, button2);-
2128}
never executed: end of block
0
2129-
2130/*!-
2131 \obsolete-
2132-
2133 Opens an information message box with the given \a title and the-
2134 \a text. The dialog may have up to three buttons. Each of the-
2135 buttons, \a button0, \a button1 and \a button2 may be set to one-
2136 of the following values:-
2137-
2138 \list-
2139 \li QMessageBox::NoButton-
2140 \li QMessageBox::Ok-
2141 \li QMessageBox::Cancel-
2142 \li QMessageBox::Yes-
2143 \li QMessageBox::No-
2144 \li QMessageBox::Abort-
2145 \li QMessageBox::Retry-
2146 \li QMessageBox::Ignore-
2147 \li QMessageBox::YesAll-
2148 \li QMessageBox::NoAll-
2149 \endlist-
2150-
2151 If you don't want all three buttons, set the last button, or last-
2152 two buttons to QMessageBox::NoButton.-
2153-
2154 One button can be OR-ed with QMessageBox::Default, and one-
2155 button can be OR-ed with QMessageBox::Escape.-
2156-
2157 Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.)-
2158 of the button that was clicked.-
2159-
2160 The message box is an \l{Qt::ApplicationModal} {application modal}-
2161 dialog box.-
2162-
2163 \warning Do not delete \a parent during the execution of the dialog.-
2164 If you want to do this, you should create the dialog-
2165 yourself using one of the QMessageBox constructors.-
2166-
2167 \sa question(), warning(), critical()-
2168*/-
2169int QMessageBox::information(QWidget *parent, const QString &title, const QString& text,-
2170 int button0, int button1, int button2)-
2171{-
2172 return QMessageBoxPrivate::showOldMessageBox(parent, Information, title, text,
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Information, title, text, button0, button1, button2);
0
2173 button0, button1, button2);
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Information, title, text, button0, button1, button2);
0
2174}-
2175-
2176/*!-
2177 \obsolete-
2178 \overload-
2179-
2180 Displays an information message box with the given \a title and-
2181 \a text, as well as one, two or three buttons. Returns the index-
2182 of the button that was clicked (0, 1 or 2).-
2183-
2184 \a button0Text is the text of the first button, and is optional.-
2185 If \a button0Text is not supplied, "OK" (translated) will be-
2186 used. \a button1Text is the text of the second button, and is-
2187 optional. \a button2Text is the text of the third button, and is-
2188 optional. \a defaultButtonNumber (0, 1 or 2) is the index of the-
2189 default button; pressing Return or Enter is the same as clicking-
2190 the default button. It defaults to 0 (the first button). \a-
2191 escapeButtonNumber is the index of the escape button; pressing-
2192 \uicontrol Esc is the same as clicking this button. It defaults to -1;-
2193 supply 0, 1 or 2 to make pressing \uicontrol Esc equivalent to clicking-
2194 the relevant button.-
2195-
2196 The message box is an \l{Qt::ApplicationModal} {application modal}-
2197 dialog box.-
2198-
2199 \warning Do not delete \a parent during the execution of the dialog.-
2200 If you want to do this, you should create the dialog-
2201 yourself using one of the QMessageBox constructors.-
2202-
2203 \sa question(), warning(), critical()-
2204*/-
2205-
2206int QMessageBox::information(QWidget *parent, const QString &title, const QString& text,-
2207 const QString& button0Text, const QString& button1Text,-
2208 const QString& button2Text, int defaultButtonNumber,-
2209 int escapeButtonNumber)-
2210{-
2211 return QMessageBoxPrivate::showOldMessageBox(parent, Information, title, text,
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Information, title, text, button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber);
0
2212 button0Text, button1Text, button2Text,
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Information, title, text, button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber);
0
2213 defaultButtonNumber, escapeButtonNumber);
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Information, title, text, button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber);
0
2214}-
2215-
2216/*!-
2217 \obsolete-
2218-
2219 Opens a question message box with the given \a title and \a text.-
2220 The dialog may have up to three buttons. Each of the buttons, \a-
2221 button0, \a button1 and \a button2 may be set to one of the-
2222 following values:-
2223-
2224 \list-
2225 \li QMessageBox::NoButton-
2226 \li QMessageBox::Ok-
2227 \li QMessageBox::Cancel-
2228 \li QMessageBox::Yes-
2229 \li QMessageBox::No-
2230 \li QMessageBox::Abort-
2231 \li QMessageBox::Retry-
2232 \li QMessageBox::Ignore-
2233 \li QMessageBox::YesAll-
2234 \li QMessageBox::NoAll-
2235 \endlist-
2236-
2237 If you don't want all three buttons, set the last button, or last-
2238 two buttons to QMessageBox::NoButton.-
2239-
2240 One button can be OR-ed with QMessageBox::Default, and one-
2241 button can be OR-ed with QMessageBox::Escape.-
2242-
2243 Returns the identity (QMessageBox::Yes, or QMessageBox::No, etc.)-
2244 of the button that was clicked.-
2245-
2246 The message box is an \l{Qt::ApplicationModal} {application modal}-
2247 dialog box.-
2248-
2249 \warning Do not delete \a parent during the execution of the dialog.-
2250 If you want to do this, you should create the dialog-
2251 yourself using one of the QMessageBox constructors.-
2252-
2253 \sa information(), warning(), critical()-
2254*/-
2255int QMessageBox::question(QWidget *parent, const QString &title, const QString& text,-
2256 int button0, int button1, int button2)-
2257{-
2258 return QMessageBoxPrivate::showOldMessageBox(parent, Question, title, text,
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Question, title, text, button0, button1, button2);
0
2259 button0, button1, button2);
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Question, title, text, button0, button1, button2);
0
2260}-
2261-
2262/*!-
2263 \obsolete-
2264 \overload-
2265-
2266 Displays a question message box with the given \a title and \a-
2267 text, as well as one, two or three buttons. Returns the index of-
2268 the button that was clicked (0, 1 or 2).-
2269-
2270 \a button0Text is the text of the first button, and is optional.-
2271 If \a button0Text is not supplied, "OK" (translated) will be used.-
2272 \a button1Text is the text of the second button, and is optional.-
2273 \a button2Text is the text of the third button, and is optional.-
2274 \a defaultButtonNumber (0, 1 or 2) is the index of the default-
2275 button; pressing Return or Enter is the same as clicking the-
2276 default button. It defaults to 0 (the first button). \a-
2277 escapeButtonNumber is the index of the Escape button; pressing-
2278 Escape is the same as clicking this button. It defaults to -1;-
2279 supply 0, 1 or 2 to make pressing Escape equivalent to clicking-
2280 the relevant button.-
2281-
2282 The message box is an \l{Qt::ApplicationModal} {application modal}-
2283 dialog box.-
2284-
2285 \warning Do not delete \a parent during the execution of the dialog.-
2286 If you want to do this, you should create the dialog-
2287 yourself using one of the QMessageBox constructors.-
2288-
2289 \sa information(), warning(), critical()-
2290*/-
2291int QMessageBox::question(QWidget *parent, const QString &title, const QString& text,-
2292 const QString& button0Text, const QString& button1Text,-
2293 const QString& button2Text, int defaultButtonNumber,-
2294 int escapeButtonNumber)-
2295{-
2296 return QMessageBoxPrivate::showOldMessageBox(parent, Question, title, text,
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Question, title, text, button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber);
0
2297 button0Text, button1Text, button2Text,
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Question, title, text, button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber);
0
2298 defaultButtonNumber, escapeButtonNumber);
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Question, title, text, button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber);
0
2299}-
2300-
2301-
2302/*!-
2303 \obsolete-
2304-
2305 Opens a warning message box with the given \a title and \a text.-
2306 The dialog may have up to three buttons. Each of the button-
2307 parameters, \a button0, \a button1 and \a button2 may be set to-
2308 one of the following values:-
2309-
2310 \list-
2311 \li QMessageBox::NoButton-
2312 \li QMessageBox::Ok-
2313 \li QMessageBox::Cancel-
2314 \li QMessageBox::Yes-
2315 \li QMessageBox::No-
2316 \li QMessageBox::Abort-
2317 \li QMessageBox::Retry-
2318 \li QMessageBox::Ignore-
2319 \li QMessageBox::YesAll-
2320 \li QMessageBox::NoAll-
2321 \endlist-
2322-
2323 If you don't want all three buttons, set the last button, or last-
2324 two buttons to QMessageBox::NoButton.-
2325-
2326 One button can be OR-ed with QMessageBox::Default, and one-
2327 button can be OR-ed with QMessageBox::Escape.-
2328-
2329 Returns the identity (QMessageBox::Ok or QMessageBox::No or ...)-
2330 of the button that was clicked.-
2331-
2332 The message box is an \l{Qt::ApplicationModal} {application modal}-
2333 dialog box.-
2334-
2335 \warning Do not delete \a parent during the execution of the dialog.-
2336 If you want to do this, you should create the dialog-
2337 yourself using one of the QMessageBox constructors.-
2338-
2339 \sa information(), question(), critical()-
2340*/-
2341int QMessageBox::warning(QWidget *parent, const QString &title, const QString& text,-
2342 int button0, int button1, int button2)-
2343{-
2344 return QMessageBoxPrivate::showOldMessageBox(parent, Warning, title, text,
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Warning, title, text, button0, button1, button2);
0
2345 button0, button1, button2);
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Warning, title, text, button0, button1, button2);
0
2346}-
2347-
2348/*!-
2349 \obsolete-
2350 \overload-
2351-
2352 Displays a warning message box with the given \a title and \a-
2353 text, as well as one, two, or three buttons. Returns the number-
2354 of the button that was clicked (0, 1, or 2).-
2355-
2356 \a button0Text is the text of the first button, and is optional.-
2357 If \a button0Text is not supplied, "OK" (translated) will be used.-
2358 \a button1Text is the text of the second button, and is optional,-
2359 and \a button2Text is the text of the third button, and is-
2360 optional. \a defaultButtonNumber (0, 1 or 2) is the index of the-
2361 default button; pressing Return or Enter is the same as clicking-
2362 the default button. It defaults to 0 (the first button). \a-
2363 escapeButtonNumber is the index of the Escape button; pressing-
2364 Escape is the same as clicking this button. It defaults to -1;-
2365 supply 0, 1, or 2 to make pressing Escape equivalent to clicking-
2366 the relevant button.-
2367-
2368 The message box is an \l{Qt::ApplicationModal} {application modal}-
2369 dialog box.-
2370-
2371 \warning Do not delete \a parent during the execution of the dialog.-
2372 If you want to do this, you should create the dialog-
2373 yourself using one of the QMessageBox constructors.-
2374-
2375 \sa information(), question(), critical()-
2376*/-
2377int QMessageBox::warning(QWidget *parent, const QString &title, const QString& text,-
2378 const QString& button0Text, const QString& button1Text,-
2379 const QString& button2Text, int defaultButtonNumber,-
2380 int escapeButtonNumber)-
2381{-
2382 return QMessageBoxPrivate::showOldMessageBox(parent, Warning, title, text,
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Warning, title, text, button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber);
0
2383 button0Text, button1Text, button2Text,
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Warning, title, text, button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber);
0
2384 defaultButtonNumber, escapeButtonNumber);
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Warning, title, text, button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber);
0
2385}-
2386-
2387/*!-
2388 \obsolete-
2389-
2390 Opens a critical message box with the given \a title and \a text.-
2391 The dialog may have up to three buttons. Each of the button-
2392 parameters, \a button0, \a button1 and \a button2 may be set to-
2393 one of the following values:-
2394-
2395 \list-
2396 \li QMessageBox::NoButton-
2397 \li QMessageBox::Ok-
2398 \li QMessageBox::Cancel-
2399 \li QMessageBox::Yes-
2400 \li QMessageBox::No-
2401 \li QMessageBox::Abort-
2402 \li QMessageBox::Retry-
2403 \li QMessageBox::Ignore-
2404 \li QMessageBox::YesAll-
2405 \li QMessageBox::NoAll-
2406 \endlist-
2407-
2408 If you don't want all three buttons, set the last button, or last-
2409 two buttons to QMessageBox::NoButton.-
2410-
2411 One button can be OR-ed with QMessageBox::Default, and one-
2412 button can be OR-ed with QMessageBox::Escape.-
2413-
2414 Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.)-
2415 of the button that was clicked.-
2416-
2417 The message box is an \l{Qt::ApplicationModal} {application modal}-
2418 dialog box.-
2419-
2420 \warning Do not delete \a parent during the execution of the dialog.-
2421 If you want to do this, you should create the dialog-
2422 yourself using one of the QMessageBox constructors.-
2423-
2424 \sa information(), question(), warning()-
2425*/-
2426-
2427int QMessageBox::critical(QWidget *parent, const QString &title, const QString& text,-
2428 int button0, int button1, int button2)-
2429{-
2430 return QMessageBoxPrivate::showOldMessageBox(parent, Critical, title, text,
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Critical, title, text, button0, button1, button2);
0
2431 button0, button1, button2);
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Critical, title, text, button0, button1, button2);
0
2432}-
2433-
2434/*!-
2435 \obsolete-
2436 \overload-
2437-
2438 Displays a critical error message box with the given \a title and-
2439 \a text, as well as one, two, or three buttons. Returns the-
2440 number of the button that was clicked (0, 1 or 2).-
2441-
2442 \a button0Text is the text of the first button, and is optional.-
2443 If \a button0Text is not supplied, "OK" (translated) will be used.-
2444 \a button1Text is the text of the second button, and is optional,-
2445 and \a button2Text is the text of the third button, and is-
2446 optional. \a defaultButtonNumber (0, 1 or 2) is the index of the-
2447 default button; pressing Return or Enter is the same as clicking-
2448 the default button. It defaults to 0 (the first button). \a-
2449 escapeButtonNumber is the index of the Escape button; pressing-
2450 Escape is the same as clicking this button. It defaults to -1;-
2451 supply 0, 1, or 2 to make pressing Escape equivalent to clicking-
2452 the relevant button.-
2453-
2454 The message box is an \l{Qt::ApplicationModal} {application modal}-
2455 dialog box.-
2456-
2457 \warning Do not delete \a parent during the execution of the dialog.-
2458 If you want to do this, you should create the dialog-
2459 yourself using one of the QMessageBox constructors.-
2460-
2461 \sa information(), question(), warning()-
2462*/-
2463int QMessageBox::critical(QWidget *parent, const QString &title, const QString& text,-
2464 const QString& button0Text, const QString& button1Text,-
2465 const QString& button2Text, int defaultButtonNumber,-
2466 int escapeButtonNumber)-
2467{-
2468 return QMessageBoxPrivate::showOldMessageBox(parent, Critical, title, text,
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Critical, title, text, button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber);
0
2469 button0Text, button1Text, button2Text,
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Critical, title, text, button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber);
0
2470 defaultButtonNumber, escapeButtonNumber);
never executed: return QMessageBoxPrivate::showOldMessageBox(parent, Critical, title, text, button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber);
0
2471}-
2472-
2473-
2474/*!-
2475 \obsolete-
2476-
2477 Returns the text of the message box button \a button, or-
2478 an empty string if the message box does not contain the button.-
2479-
2480 Use button() and QPushButton::text() instead.-
2481*/-
2482QString QMessageBox::buttonText(int button) const-
2483{-
2484 Q_D(const QMessageBox);-
2485-
2486 if (QAbstractButton *abstractButton = d->abstractButtonForId(button)) {
QAbstractButto...nForId(button)Description
TRUEnever evaluated
FALSEnever evaluated
0
2487 return abstractButton->text();
never executed: return abstractButton->text();
0
2488 } else if (d->buttonBox->buttons().isEmpty() && (button == Ok || button == Old_Ok)) {
d->buttonBox->...ns().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
button == OkDescription
TRUEnever evaluated
FALSEnever evaluated
button == Old_OkDescription
TRUEnever evaluated
FALSEnever evaluated
0
2489 // for compatibility with Qt 4.0/4.1-
2490 return QDialogButtonBox::tr("OK");
never executed: return QDialogButtonBox::tr("OK");
0
2491 }-
2492 return QString();
never executed: return QString();
0
2493}-
2494-
2495/*!-
2496 \obsolete-
2497-
2498 Sets the text of the message box button \a button to \a text.-
2499 Setting the text of a button that is not in the message box is-
2500 silently ignored.-
2501-
2502 Use addButton() instead.-
2503*/-
2504void QMessageBox::setButtonText(int button, const QString &text)-
2505{-
2506 Q_D(QMessageBox);-
2507 if (QAbstractButton *abstractButton = d->abstractButtonForId(button)) {
QAbstractButto...nForId(button)Description
TRUEnever evaluated
FALSEnever evaluated
0
2508 abstractButton->setText(text);-
2509 } else if (d->buttonBox->buttons().isEmpty() && (button == Ok || button == Old_Ok)) {
never executed: end of block
d->buttonBox->...ns().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
button == OkDescription
TRUEnever evaluated
FALSEnever evaluated
button == Old_OkDescription
TRUEnever evaluated
FALSEnever evaluated
0
2510 // for compatibility with Qt 4.0/4.1-
2511 addButton(QMessageBox::Ok)->setText(text);-
2512 }
never executed: end of block
0
2513}
never executed: end of block
0
2514-
2515#ifndef QT_NO_TEXTEDIT-
2516/*!-
2517 \property QMessageBox::detailedText-
2518 \brief the text to be displayed in the details area.-
2519 \since 4.2-
2520-
2521 The text will be interpreted as a plain text.-
2522-
2523 By default, this property contains an empty string.-
2524-
2525 \sa QMessageBox::text, QMessageBox::informativeText-
2526*/-
2527QString QMessageBox::detailedText() const-
2528{-
2529 Q_D(const QMessageBox);-
2530 return d->detailsText ? d->detailsText->text() : QString();
never executed: return d->detailsText ? d->detailsText->text() : QString();
d->detailsTextDescription
TRUEnever evaluated
FALSEnever evaluated
0
2531}-
2532-
2533void QMessageBox::setDetailedText(const QString &text)-
2534{-
2535 Q_D(QMessageBox);-
2536 if (text.isEmpty()) {
text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2537 if (d->detailsText) {
d->detailsTextDescription
TRUEnever evaluated
FALSEnever evaluated
0
2538 d->detailsText->hide();-
2539 d->detailsText->deleteLater();-
2540 }
never executed: end of block
0
2541 d->detailsText = 0;-
2542 removeButton(d->detailsButton);-
2543 if (d->detailsButton) {
d->detailsButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
2544 d->detailsButton->hide();-
2545 d->detailsButton->deleteLater();-
2546 }
never executed: end of block
0
2547 d->detailsButton = 0;-
2548 } else {
never executed: end of block
0
2549 if (!d->detailsText) {
!d->detailsTextDescription
TRUEnever evaluated
FALSEnever evaluated
0
2550 d->detailsText = new QMessageBoxDetailsText(this);-
2551 d->detailsText->hide();-
2552 }
never executed: end of block
0
2553 if (!d->detailsButton) {
!d->detailsButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
2554 const bool autoAddOkButton = d->autoAddOkButton; // QTBUG-39334, addButton() clears the flag.-
2555 d->detailsButton = new DetailButton(this);-
2556 addButton(d->detailsButton, QMessageBox::ActionRole);-
2557 d->autoAddOkButton = autoAddOkButton;-
2558 }
never executed: end of block
0
2559 d->detailsText->setText(text);-
2560 }
never executed: end of block
0
2561 d->setupLayout();-
2562}
never executed: end of block
0
2563#endif // QT_NO_TEXTEDIT-
2564-
2565/*!-
2566 \property QMessageBox::informativeText-
2567-
2568 \brief the informative text that provides a fuller description for-
2569 the message-
2570-
2571 \since 4.2-
2572-
2573 Infromative text can be used to expand upon the text() to give more-
2574 information to the user. On the Mac, this text appears in small-
2575 system font below the text(). On other platforms, it is simply-
2576 appended to the existing text.-
2577-
2578 By default, this property contains an empty string.-
2579-
2580 \sa QMessageBox::text, QMessageBox::detailedText-
2581*/-
2582QString QMessageBox::informativeText() const-
2583{-
2584 Q_D(const QMessageBox);-
2585 return d->informativeLabel ? d->informativeLabel->text() : QString();
never executed: return d->informativeLabel ? d->informativeLabel->text() : QString();
d->informativeLabelDescription
TRUEnever evaluated
FALSEnever evaluated
0
2586}-
2587-
2588void QMessageBox::setInformativeText(const QString &text)-
2589{-
2590 Q_D(QMessageBox);-
2591 if (text.isEmpty()) {
text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2592 if (d->informativeLabel) {
d->informativeLabelDescription
TRUEnever evaluated
FALSEnever evaluated
0
2593 d->informativeLabel->hide();-
2594 d->informativeLabel->deleteLater();-
2595 }
never executed: end of block
0
2596 d->informativeLabel = 0;-
2597 } else {
never executed: end of block
0
2598 if (!d->informativeLabel) {
!d->informativeLabelDescription
TRUEnever evaluated
FALSEnever evaluated
0
2599 QLabel *label = new QLabel;-
2600 label->setObjectName(QLatin1String("qt_msgbox_informativelabel"));-
2601 label->setTextInteractionFlags(Qt::TextInteractionFlags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, this)));-
2602 label->setAlignment(Qt::AlignTop | Qt::AlignLeft);-
2603 label->setOpenExternalLinks(true);-
2604 label->setWordWrap(true);-
2605#ifdef Q_OS_MAC-
2606 // apply a smaller font the information label on the mac-
2607 label->setFont(qt_app_fonts_hash()->value("QTipLabel"));-
2608#endif-
2609 label->setWordWrap(true);-
2610 d->informativeLabel = label;-
2611 }
never executed: end of block
0
2612 d->informativeLabel->setText(text);-
2613 }
never executed: end of block
0
2614 d->setupLayout();-
2615}
never executed: end of block
0
2616-
2617/*!-
2618 \since 4.2-
2619-
2620 This function shadows QWidget::setWindowTitle().-
2621-
2622 Sets the title of the message box to \a title. On \macos,-
2623 the window title is ignored (as required by the \macos-
2624 Guidelines).-
2625*/-
2626void QMessageBox::setWindowTitle(const QString &title)-
2627{-
2628 // Message boxes on the mac do not have a title-
2629#ifndef Q_OS_MAC-
2630 QDialog::setWindowTitle(title);-
2631#else-
2632 Q_UNUSED(title);-
2633#endif-
2634}
never executed: end of block
0
2635-
2636-
2637/*!-
2638 \since 4.2-
2639-
2640 This function shadows QWidget::setWindowModality().-
2641-
2642 Sets the modality of the message box to \a windowModality.-
2643-
2644 On \macos, if the modality is set to Qt::WindowModal and the message box-
2645 has a parent, then the message box will be a Qt::Sheet, otherwise the-
2646 message box will be a standard dialog.-
2647*/-
2648void QMessageBox::setWindowModality(Qt::WindowModality windowModality)-
2649{-
2650 QDialog::setWindowModality(windowModality);-
2651-
2652 if (parentWidget() && windowModality == Qt::WindowModal)
parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
windowModality...t::WindowModalDescription
TRUEnever evaluated
FALSEnever evaluated
0
2653 setParent(parentWidget(), Qt::Sheet);
never executed: setParent(parentWidget(), Qt::Sheet);
0
2654 else-
2655 setParent(parentWidget(), Qt::Dialog);
never executed: setParent(parentWidget(), Qt::Dialog);
0
2656 setDefaultButton(d_func()->defaultButton);-
2657}
never executed: end of block
0
2658-
2659-
2660QPixmap QMessageBoxPrivate::standardIcon(QMessageBox::Icon icon, QMessageBox *mb)-
2661{-
2662 QStyle *style = mb ? mb->style() : QApplication::style();
mbDescription
TRUEnever evaluated
FALSEnever evaluated
0
2663 int iconSize = style->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, mb);-
2664 QIcon tmpIcon;-
2665 switch (icon) {-
2666 case QMessageBox::Information:
never executed: case QMessageBox::Information:
0
2667 tmpIcon = style->standardIcon(QStyle::SP_MessageBoxInformation, 0, mb);-
2668 break;
never executed: break;
0
2669 case QMessageBox::Warning:
never executed: case QMessageBox::Warning:
0
2670 tmpIcon = style->standardIcon(QStyle::SP_MessageBoxWarning, 0, mb);-
2671 break;
never executed: break;
0
2672 case QMessageBox::Critical:
never executed: case QMessageBox::Critical:
0
2673 tmpIcon = style->standardIcon(QStyle::SP_MessageBoxCritical, 0, mb);-
2674 break;
never executed: break;
0
2675 case QMessageBox::Question:
never executed: case QMessageBox::Question:
0
2676 tmpIcon = style->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mb);-
2677 default:
code before this statement never executed: default:
never executed: default:
0
2678 break;
never executed: break;
0
2679 }-
2680 if (!tmpIcon.isNull()) {
!tmpIcon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2681 QWindow *window = Q_NULLPTR;-
2682 if (mb) {
mbDescription
TRUEnever evaluated
FALSEnever evaluated
0
2683 window = mb->windowHandle();-
2684 if (!window) {
!windowDescription
TRUEnever evaluated
FALSEnever evaluated
0
2685 if (const QWidget *nativeParent = mb->nativeParentWidget())
const QWidget ...ParentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
2686 window = nativeParent->windowHandle();
never executed: window = nativeParent->windowHandle();
0
2687 }
never executed: end of block
0
2688 }
never executed: end of block
0
2689 return tmpIcon.pixmap(window, QSize(iconSize, iconSize));
never executed: return tmpIcon.pixmap(window, QSize(iconSize, iconSize));
0
2690 }-
2691 return QPixmap();
never executed: return QPixmap();
0
2692}-
2693-
2694void QMessageBoxPrivate::initHelper(QPlatformDialogHelper *h)-
2695{-
2696 Q_Q(QMessageBox);-
2697 QObject::connect(h, SIGNAL(clicked(QPlatformDialogHelper::StandardButton,QPlatformDialogHelper::ButtonRole)),-
2698 q, SLOT(_q_clicked(QPlatformDialogHelper::StandardButton,QPlatformDialogHelper::ButtonRole)));-
2699 static_cast<QPlatformMessageDialogHelper *>(h)->setOptions(options);-
2700}
never executed: end of block
0
2701-
2702static QMessageDialogOptions::Icon helperIcon(QMessageBox::Icon i)-
2703{-
2704 switch (i) {-
2705 case QMessageBox::NoIcon:
never executed: case QMessageBox::NoIcon:
0
2706 return QMessageDialogOptions::NoIcon;
never executed: return QMessageDialogOptions::NoIcon;
0
2707 case QMessageBox::Information:
never executed: case QMessageBox::Information:
0
2708 return QMessageDialogOptions::Information;
never executed: return QMessageDialogOptions::Information;
0
2709 case QMessageBox::Warning:
never executed: case QMessageBox::Warning:
0
2710 return QMessageDialogOptions::Warning;
never executed: return QMessageDialogOptions::Warning;
0
2711 case QMessageBox::Critical:
never executed: case QMessageBox::Critical:
0
2712 return QMessageDialogOptions::Critical;
never executed: return QMessageDialogOptions::Critical;
0
2713 case QMessageBox::Question:
never executed: case QMessageBox::Question:
0
2714 return QMessageDialogOptions::Question;
never executed: return QMessageDialogOptions::Question;
0
2715 }-
2716 return QMessageDialogOptions::NoIcon;
never executed: return QMessageDialogOptions::NoIcon;
0
2717}-
2718-
2719static QPlatformDialogHelper::StandardButtons helperStandardButtons(QMessageBox * q)-
2720{-
2721 QPlatformDialogHelper::StandardButtons buttons(int(q->standardButtons()));-
2722 return buttons;
never executed: return buttons;
0
2723}-
2724-
2725void QMessageBoxPrivate::helperPrepareShow(QPlatformDialogHelper *)-
2726{-
2727 Q_Q(QMessageBox);-
2728 options->setWindowTitle(q->windowTitle());-
2729 options->setText(q->text());-
2730 options->setInformativeText(q->informativeText());-
2731 options->setDetailedText(q->detailedText());-
2732 options->setIcon(helperIcon(q->icon()));-
2733 options->setStandardButtons(helperStandardButtons(q));-
2734}
never executed: end of block
0
2735-
2736void QMessageBoxPrivate::helperDone(QDialog::DialogCode code, QPlatformDialogHelper *)-
2737{-
2738 Q_Q(QMessageBox);-
2739 clickedButton = q->button(QMessageBox::StandardButton(code));-
2740}
never executed: end of block
0
2741-
2742/*!-
2743 \obsolete-
2744-
2745 Returns the pixmap used for a standard icon. This allows the-
2746 pixmaps to be used in more complex message boxes. \a icon-
2747 specifies the required icon, e.g. QMessageBox::Question,-
2748 QMessageBox::Information, QMessageBox::Warning or-
2749 QMessageBox::Critical.-
2750-
2751 Call QStyle::standardIcon() with QStyle::SP_MessageBoxInformation etc.-
2752 instead.-
2753*/-
2754-
2755QPixmap QMessageBox::standardIcon(Icon icon)-
2756{-
2757 return QMessageBoxPrivate::standardIcon(icon, 0);
never executed: return QMessageBoxPrivate::standardIcon(icon, 0);
0
2758}-
2759-
2760/*!-
2761 \typedef QMessageBox::Button-
2762 \obsolete-
2763-
2764 Use QMessageBox::StandardButton instead.-
2765*/-
2766-
2767/*!-
2768 \fn int QMessageBox::information(QWidget *parent, const QString &title,-
2769 const QString& text, StandardButton button0,-
2770 StandardButton button1)-
2771 \fn int QMessageBox::warning(QWidget *parent, const QString &title,-
2772 const QString& text, StandardButton button0,-
2773 StandardButton button1)-
2774 \fn int QMessageBox::critical(QWidget *parent, const QString &title,-
2775 const QString& text, StandardButton button0,-
2776 StandardButton button1)-
2777 \fn int QMessageBox::question(QWidget *parent, const QString &title,-
2778 const QString& text, StandardButton button0,-
2779 StandardButton button1)-
2780 \internal-
2781-
2782 ### Needed for Qt 4 source compatibility-
2783*/-
2784-
2785/*!-
2786 \fn int QMessageBox::exec()-
2787-
2788 Shows the message box as a \l{QDialog#Modal Dialogs}{modal dialog},-
2789 blocking until the user closes it.-
2790-
2791 When using a QMessageBox with standard buttons, this functions returns a-
2792 \l StandardButton value indicating the standard button that was clicked.-
2793 When using QMessageBox with custom buttons, this function returns an-
2794 opaque value; use clickedButton() to determine which button was clicked.-
2795-
2796 \note The result() function returns also \l StandardButton value instead-
2797 of \l QDialog::DialogCode.-
2798-
2799 Users cannot interact with any other window in the same-
2800 application until they close the dialog, either by clicking a-
2801 button or by using a mechanism provided by the window system.-
2802-
2803 \sa show(), result()-
2804*/-
2805-
2806QT_END_NAMESPACE-
2807-
2808#include "moc_qmessagebox.cpp"-
2809#include "qmessagebox.moc"-
2810-
2811#endif // QT_NO_MESSAGEBOX-
Source codeSwitch to Preprocessed file

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