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

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