| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/dialogs/qerrormessage.cpp | 
| Source code | Switch to Preprocessed file | 
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
| 16 | ** | - | ||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
| 25 | ** | - | ||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
| 29 | ** | - | ||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 31 | ** | - | ||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | #include "qerrormessage.h" | - | ||||||||||||
| 35 | - | |||||||||||||
| 36 | #ifndef QT_NO_ERRORMESSAGE | - | ||||||||||||
| 37 | - | |||||||||||||
| 38 | #include "qapplication.h" | - | ||||||||||||
| 39 | #include "qcheckbox.h" | - | ||||||||||||
| 40 | #include "qlabel.h" | - | ||||||||||||
| 41 | #include "qlayout.h" | - | ||||||||||||
| 42 | #include "qmessagebox.h" | - | ||||||||||||
| 43 | #include "qpushbutton.h" | - | ||||||||||||
| 44 | #include "qstringlist.h" | - | ||||||||||||
| 45 | #include "qtextedit.h" | - | ||||||||||||
| 46 | #include "qdialog_p.h" | - | ||||||||||||
| 47 | #include "qpixmap.h" | - | ||||||||||||
| 48 | #include "qmetaobject.h" | - | ||||||||||||
| 49 | #include "qthread.h" | - | ||||||||||||
| 50 | #include "qset.h" | - | ||||||||||||
| 51 | - | |||||||||||||
| 52 | #include <queue> | - | ||||||||||||
| 53 | - | |||||||||||||
| 54 | #include <stdio.h> | - | ||||||||||||
| 55 | #include <stdlib.h> | - | ||||||||||||
| 56 | - | |||||||||||||
| 57 | #ifdef Q_OS_WINCE | - | ||||||||||||
| 58 | extern bool qt_wince_is_mobile(); //defined in qguifunctions_wince.cpp | - | ||||||||||||
| 59 | extern bool qt_wince_is_high_dpi(); //defined in qguifunctions_wince.cpp | - | ||||||||||||
| 60 | #endif | - | ||||||||||||
| 61 | - | |||||||||||||
| 62 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 63 | - | |||||||||||||
| 64 | class QErrorMessagePrivate : public QDialogPrivate | - | ||||||||||||
| 65 | { | - | ||||||||||||
| 66 | Q_DECLARE_PUBLIC(QErrorMessage) | - | ||||||||||||
| 67 | public: | - | ||||||||||||
| 68 | QPushButton * ok; | - | ||||||||||||
| 69 | QCheckBox * again; | - | ||||||||||||
| 70 | QTextEdit * errors; | - | ||||||||||||
| 71 | QLabel * icon; | - | ||||||||||||
| 72 | std::queue<QPair<QString, QString> > pending; | - | ||||||||||||
| 73 | QSet<QString> doNotShow; | - | ||||||||||||
| 74 | QSet<QString> doNotShowType; | - | ||||||||||||
| 75 | QString currentMessage; | - | ||||||||||||
| 76 | QString currentType; | - | ||||||||||||
| 77 | - | |||||||||||||
| 78 | bool isMessageToBeShown(const QString &message, const QString &type) const; | - | ||||||||||||
| 79 | bool nextPending(); | - | ||||||||||||
| 80 | void retranslateStrings(); | - | ||||||||||||
| 81 | }; | - | ||||||||||||
| 82 | - | |||||||||||||
| 83 | namespace { | - | ||||||||||||
| 84 | class QErrorMessageTextView : public QTextEdit | - | ||||||||||||
| 85 | { | - | ||||||||||||
| 86 | public: | - | ||||||||||||
| 87 | QErrorMessageTextView(QWidget *parent) | - | ||||||||||||
| 88 |         : QTextEdit(parent) { setReadOnly(true); } never executed:  end of block | 0 | ||||||||||||
| 89 | - | |||||||||||||
| 90 | virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE; | - | ||||||||||||
| 91 | virtual QSize sizeHint() const Q_DECL_OVERRIDE; | - | ||||||||||||
| 92 | }; | - | ||||||||||||
| 93 | } // unnamed namespace | - | ||||||||||||
| 94 | - | |||||||||||||
| 95 | QSize QErrorMessageTextView::minimumSizeHint() const | - | ||||||||||||
| 96 | { | - | ||||||||||||
| 97 | #ifdef Q_OS_WINCE | - | ||||||||||||
| 98 | if (qt_wince_is_mobile()) | - | ||||||||||||
| 99 | if (qt_wince_is_high_dpi()) | - | ||||||||||||
| 100 | return QSize(200, 200); | - | ||||||||||||
| 101 | else | - | ||||||||||||
| 102 | return QSize(100, 100); | - | ||||||||||||
| 103 | else | - | ||||||||||||
| 104 | return QSize(70, 70); | - | ||||||||||||
| 105 | #else | - | ||||||||||||
| 106 |     return QSize(50, 50); never executed:  return QSize(50, 50); | 0 | ||||||||||||
| 107 | #endif | - | ||||||||||||
| 108 | } | - | ||||||||||||
| 109 | - | |||||||||||||
| 110 | QSize QErrorMessageTextView::sizeHint() const | - | ||||||||||||
| 111 | { | - | ||||||||||||
| 112 | #ifdef Q_OS_WINCE | - | ||||||||||||
| 113 | if (qt_wince_is_mobile()) | - | ||||||||||||
| 114 | if (qt_wince_is_high_dpi()) | - | ||||||||||||
| 115 | return QSize(400, 200); | - | ||||||||||||
| 116 | else | - | ||||||||||||
| 117 | return QSize(320, 120); | - | ||||||||||||
| 118 | else | - | ||||||||||||
| 119 | return QSize(300, 100); | - | ||||||||||||
| 120 | #else | - | ||||||||||||
| 121 |     return QSize(250, 75); never executed:  return QSize(250, 75); | 0 | ||||||||||||
| 122 | #endif //Q_OS_WINCE | - | ||||||||||||
| 123 | } | - | ||||||||||||
| 124 | - | |||||||||||||
| 125 | /*! | - | ||||||||||||
| 126 | \class QErrorMessage | - | ||||||||||||
| 127 | - | |||||||||||||
| 128 | \brief The QErrorMessage class provides an error message display dialog. | - | ||||||||||||
| 129 | - | |||||||||||||
| 130 | \ingroup standard-dialog | - | ||||||||||||
| 131 | \inmodule QtWidgets | - | ||||||||||||
| 132 | - | |||||||||||||
| 133 | An error message widget consists of a text label and a checkbox. The | - | ||||||||||||
| 134 | checkbox lets the user control whether the same error message will be | - | ||||||||||||
| 135 | displayed again in the future, typically displaying the text, | - | ||||||||||||
| 136 | "Show this message again" translated into the appropriate local | - | ||||||||||||
| 137 | language. | - | ||||||||||||
| 138 | - | |||||||||||||
| 139 | For production applications, the class can be used to display messages which | - | ||||||||||||
| 140 | the user only needs to see once. To use QErrorMessage like this, you create | - | ||||||||||||
| 141 | the dialog in the usual way, and show it by calling the showMessage() slot or | - | ||||||||||||
| 142 | connecting signals to it. | - | ||||||||||||
| 143 | - | |||||||||||||
| 144 | The static qtHandler() function installs a message handler | - | ||||||||||||
| 145 | using qInstallMessageHandler() and creates a QErrorMessage that displays | - | ||||||||||||
| 146 | qDebug(), qWarning() and qFatal() messages. This is most useful in | - | ||||||||||||
| 147 | environments where no console is available to display warnings and | - | ||||||||||||
| 148 | error messages. | - | ||||||||||||
| 149 | - | |||||||||||||
| 150 | In both cases QErrorMessage will queue pending messages and display | - | ||||||||||||
| 151 | them in order, with each new message being shown as soon as the user | - | ||||||||||||
| 152 | has accepted the previous message. Once the user has specified that a | - | ||||||||||||
| 153 | message is not to be shown again it is automatically skipped, and the | - | ||||||||||||
| 154 | dialog will show the next appropriate message in the queue. | - | ||||||||||||
| 155 | - | |||||||||||||
| 156 | The \l{dialogs/standarddialogs}{Standard Dialogs} example shows | - | ||||||||||||
| 157 | how to use QErrorMessage as well as other built-in Qt dialogs. | - | ||||||||||||
| 158 | - | |||||||||||||
| 159 | \image qerrormessage.png | - | ||||||||||||
| 160 | - | |||||||||||||
| 161 | \sa QMessageBox, QStatusBar::showMessage(), {Standard Dialogs Example} | - | ||||||||||||
| 162 | */ | - | ||||||||||||
| 163 | - | |||||||||||||
| 164 | static QErrorMessage * qtMessageHandler = 0; | - | ||||||||||||
| 165 | - | |||||||||||||
| 166 | static void deleteStaticcQErrorMessage() // post-routine | - | ||||||||||||
| 167 | { | - | ||||||||||||
| 168 |     if (qtMessageHandler) {
  | 0 | ||||||||||||
| 169 | delete qtMessageHandler; | - | ||||||||||||
| 170 | qtMessageHandler = 0; | - | ||||||||||||
| 171 |     } never executed:  end of block | 0 | ||||||||||||
| 172 | } never executed:  end of block | 0 | ||||||||||||
| 173 | - | |||||||||||||
| 174 | static bool metFatal = false; | - | ||||||||||||
| 175 | - | |||||||||||||
| 176 | static void jump(QtMsgType t, const QMessageLogContext & /*context*/, const QString &m) | - | ||||||||||||
| 177 | { | - | ||||||||||||
| 178 |     if (!qtMessageHandler)
  | 0 | ||||||||||||
| 179 |         return; never executed:  return; | 0 | ||||||||||||
| 180 | - | |||||||||||||
| 181 | QString rich; | - | ||||||||||||
| 182 | - | |||||||||||||
| 183 | switch (t) { | - | ||||||||||||
| 184 |     case QtDebugMsg: never executed:  case QtDebugMsg: | 0 | ||||||||||||
| 185 |     default: never executed:  default: | 0 | ||||||||||||
| 186 | rich = QErrorMessage::tr("Debug Message:"); | - | ||||||||||||
| 187 |         break; never executed:  break; | 0 | ||||||||||||
| 188 |     case QtWarningMsg: never executed:  case QtWarningMsg: | 0 | ||||||||||||
| 189 | rich = QErrorMessage::tr("Warning:"); | - | ||||||||||||
| 190 |         break; never executed:  break; | 0 | ||||||||||||
| 191 |     case QtFatalMsg: never executed:  case QtFatalMsg: | 0 | ||||||||||||
| 192 | rich = QErrorMessage::tr("Fatal Error:"); | - | ||||||||||||
| 193 |     } never executed:  end of block | 0 | ||||||||||||
| 194 | rich = QString::fromLatin1("<p><b>%1</b></p>").arg(rich); | - | ||||||||||||
| 195 | rich += Qt::convertFromPlainText(m, Qt::WhiteSpaceNormal); | - | ||||||||||||
| 196 | - | |||||||||||||
| 197 | // ### work around text engine quirk | - | ||||||||||||
| 198 |     if (rich.endsWith(QLatin1String("</p>")))
  | 0 | ||||||||||||
| 199 |         rich.chop(4); never executed:  rich.chop(4); | 0 | ||||||||||||
| 200 | - | |||||||||||||
| 201 |     if (!metFatal) {
  | 0 | ||||||||||||
| 202 |         if (QThread::currentThread() == qApp->thread()) {
  | 0 | ||||||||||||
| 203 | qtMessageHandler->showMessage(rich); | - | ||||||||||||
| 204 |         } else { never executed:  end of block | 0 | ||||||||||||
| 205 | QMetaObject::invokeMethod(qtMessageHandler, | - | ||||||||||||
| 206 | "showMessage", | - | ||||||||||||
| 207 | Qt::QueuedConnection, | - | ||||||||||||
| 208 | Q_ARG(QString, rich)); | - | ||||||||||||
| 209 |         } never executed:  end of block | 0 | ||||||||||||
| 210 | metFatal = (t == QtFatalMsg); | - | ||||||||||||
| 211 |     } never executed:  end of block | 0 | ||||||||||||
| 212 | } never executed:  end of block | 0 | ||||||||||||
| 213 | - | |||||||||||||
| 214 | - | |||||||||||||
| 215 | /*! | - | ||||||||||||
| 216 | Constructs and installs an error handler window with the given \a | - | ||||||||||||
| 217 | parent. | - | ||||||||||||
| 218 | */ | - | ||||||||||||
| 219 | - | |||||||||||||
| 220 | QErrorMessage::QErrorMessage(QWidget * parent) | - | ||||||||||||
| 221 | : QDialog(*new QErrorMessagePrivate, parent) | - | ||||||||||||
| 222 | { | - | ||||||||||||
| 223 | Q_D(QErrorMessage); | - | ||||||||||||
| 224 | - | |||||||||||||
| 225 | d->icon = new QLabel(this); | - | ||||||||||||
| 226 | d->errors = new QErrorMessageTextView(this); | - | ||||||||||||
| 227 | d->again = new QCheckBox(this); | - | ||||||||||||
| 228 | d->ok = new QPushButton(this); | - | ||||||||||||
| 229 | QGridLayout * grid = new QGridLayout(this); | - | ||||||||||||
| 230 | - | |||||||||||||
| 231 | connect(d->ok, SIGNAL(clicked()), this, SLOT(accept())); | - | ||||||||||||
| 232 | - | |||||||||||||
| 233 | grid->addWidget(d->icon, 0, 0, Qt::AlignTop); | - | ||||||||||||
| 234 | grid->addWidget(d->errors, 0, 1); | - | ||||||||||||
| 235 | grid->addWidget(d->again, 1, 1, Qt::AlignTop); | - | ||||||||||||
| 236 | grid->addWidget(d->ok, 2, 0, 1, 2, Qt::AlignCenter); | - | ||||||||||||
| 237 | grid->setColumnStretch(1, 42); | - | ||||||||||||
| 238 | grid->setRowStretch(0, 42); | - | ||||||||||||
| 239 | - | |||||||||||||
| 240 | #ifndef QT_NO_MESSAGEBOX | - | ||||||||||||
| 241 | d->icon->setPixmap(QMessageBox::standardIcon(QMessageBox::Information)); | - | ||||||||||||
| 242 | d->icon->setAlignment(Qt::AlignHCenter | Qt::AlignTop); | - | ||||||||||||
| 243 | #endif | - | ||||||||||||
| 244 | d->again->setChecked(true); | - | ||||||||||||
| 245 | #if defined(Q_OS_WINCE) | - | ||||||||||||
| 246 | d->ok->setFixedSize(0,0); | - | ||||||||||||
| 247 | #endif | - | ||||||||||||
| 248 | d->ok->setFocus(); | - | ||||||||||||
| 249 | - | |||||||||||||
| 250 | d->retranslateStrings(); | - | ||||||||||||
| 251 | } never executed:  end of block | 0 | ||||||||||||
| 252 | - | |||||||||||||
| 253 | - | |||||||||||||
| 254 | /*! | - | ||||||||||||
| 255 | Destroys the error message dialog. | - | ||||||||||||
| 256 | */ | - | ||||||||||||
| 257 | - | |||||||||||||
| 258 | QErrorMessage::~QErrorMessage() | - | ||||||||||||
| 259 | { | - | ||||||||||||
| 260 |     if (this == qtMessageHandler) {
  | 0 | ||||||||||||
| 261 | qtMessageHandler = 0; | - | ||||||||||||
| 262 | QtMessageHandler tmp = qInstallMessageHandler(0); | - | ||||||||||||
| 263 | // in case someone else has later stuck in another... | - | ||||||||||||
| 264 |         if (tmp != jump)
  | 0 | ||||||||||||
| 265 |             qInstallMessageHandler(tmp); never executed:  qInstallMessageHandler(tmp); | 0 | ||||||||||||
| 266 |     } never executed:  end of block | 0 | ||||||||||||
| 267 | } never executed:  end of block | 0 | ||||||||||||
| 268 | - | |||||||||||||
| 269 | - | |||||||||||||
| 270 | /*! \reimp */ | - | ||||||||||||
| 271 | - | |||||||||||||
| 272 | void QErrorMessage::done(int a) | - | ||||||||||||
| 273 | { | - | ||||||||||||
| 274 | Q_D(QErrorMessage); | - | ||||||||||||
| 275 |     if (!d->again->isChecked()) {
  | 0 | ||||||||||||
| 276 |         if (d->currentType.isEmpty()) {
  | 0 | ||||||||||||
| 277 |             if (!d->currentMessage.isEmpty())
  | 0 | ||||||||||||
| 278 |                 d->doNotShow.insert(d->currentMessage); never executed:  d->doNotShow.insert(d->currentMessage); | 0 | ||||||||||||
| 279 |         } else { never executed:  end of block | 0 | ||||||||||||
| 280 | d->doNotShowType.insert(d->currentType); | - | ||||||||||||
| 281 |         } never executed:  end of block | 0 | ||||||||||||
| 282 | } | - | ||||||||||||
| 283 | d->currentMessage.clear(); | - | ||||||||||||
| 284 | d->currentType.clear(); | - | ||||||||||||
| 285 |     if (!d->nextPending()) {
  | 0 | ||||||||||||
| 286 | QDialog::done(a); | - | ||||||||||||
| 287 |         if (this == qtMessageHandler && metFatal)
 
  | 0 | ||||||||||||
| 288 |             exit(1); never executed:  exit(1); | 0 | ||||||||||||
| 289 |     } never executed:  end of block | 0 | ||||||||||||
| 290 | } never executed:  end of block | 0 | ||||||||||||
| 291 | - | |||||||||||||
| 292 | - | |||||||||||||
| 293 | /*! | - | ||||||||||||
| 294 | Returns a pointer to a QErrorMessage object that outputs the | - | ||||||||||||
| 295 | default Qt messages. This function creates such an object, if there | - | ||||||||||||
| 296 | isn't one already. | - | ||||||||||||
| 297 | */ | - | ||||||||||||
| 298 | - | |||||||||||||
| 299 | QErrorMessage * QErrorMessage::qtHandler() | - | ||||||||||||
| 300 | { | - | ||||||||||||
| 301 |     if (!qtMessageHandler) {
  | 0 | ||||||||||||
| 302 | qtMessageHandler = new QErrorMessage(0); | - | ||||||||||||
| 303 | qAddPostRoutine(deleteStaticcQErrorMessage); // clean up | - | ||||||||||||
| 304 | qtMessageHandler->setWindowTitle(QApplication::applicationName()); | - | ||||||||||||
| 305 | qInstallMessageHandler(jump); | - | ||||||||||||
| 306 |     } never executed:  end of block | 0 | ||||||||||||
| 307 |     return qtMessageHandler; never executed:  return qtMessageHandler; | 0 | ||||||||||||
| 308 | } | - | ||||||||||||
| 309 | - | |||||||||||||
| 310 | - | |||||||||||||
| 311 | /*! \internal */ | - | ||||||||||||
| 312 | - | |||||||||||||
| 313 | bool QErrorMessagePrivate::isMessageToBeShown(const QString &message, const QString &type) const | - | ||||||||||||
| 314 | { | - | ||||||||||||
| 315 |     return !message.isEmpty() never executed:  return !message.isEmpty() && (type.isEmpty() ? !doNotShow.contains(message) : !doNotShowType.contains(type));
  | 0 | ||||||||||||
| 316 |         && (type.isEmpty() ? !doNotShow.contains(message) : !doNotShowType.contains(type)); never executed:  return !message.isEmpty() && (type.isEmpty() ? !doNotShow.contains(message) : !doNotShowType.contains(type));
 
  | 0 | ||||||||||||
| 317 | } | - | ||||||||||||
| 318 | - | |||||||||||||
| 319 | bool QErrorMessagePrivate::nextPending() | - | ||||||||||||
| 320 | { | - | ||||||||||||
| 321 |     while (!pending.empty()) {
  | 0 | ||||||||||||
| 322 | QPair<QString,QString> &pendingMessage = pending.front(); | - | ||||||||||||
| 323 | QString message = qMove(pendingMessage.first); | - | ||||||||||||
| 324 | QString type = qMove(pendingMessage.second); | - | ||||||||||||
| 325 | pending.pop(); | - | ||||||||||||
| 326 |         if (isMessageToBeShown(message, type)) {
  | 0 | ||||||||||||
| 327 | #ifndef QT_NO_TEXTHTMLPARSER | - | ||||||||||||
| 328 | errors->setHtml(message); | - | ||||||||||||
| 329 | #else | - | ||||||||||||
| 330 | errors->setPlainText(message); | - | ||||||||||||
| 331 | #endif | - | ||||||||||||
| 332 | currentMessage = qMove(message); | - | ||||||||||||
| 333 | currentType = qMove(type); | - | ||||||||||||
| 334 |             return true; never executed:  return true; | 0 | ||||||||||||
| 335 | } | - | ||||||||||||
| 336 |     } never executed:  end of block | 0 | ||||||||||||
| 337 |     return false; never executed:  return false; | 0 | ||||||||||||
| 338 | } | - | ||||||||||||
| 339 | - | |||||||||||||
| 340 | - | |||||||||||||
| 341 | /*! | - | ||||||||||||
| 342 | Shows the given message, \a message, and returns immediately. If the user | - | ||||||||||||
| 343 | has requested for the message not to be shown again, this function does | - | ||||||||||||
| 344 | nothing. | - | ||||||||||||
| 345 | - | |||||||||||||
| 346 | Normally, the message is displayed immediately. However, if there are | - | ||||||||||||
| 347 | pending messages, it will be queued to be displayed later. | - | ||||||||||||
| 348 | */ | - | ||||||||||||
| 349 | - | |||||||||||||
| 350 | void QErrorMessage::showMessage(const QString &message) | - | ||||||||||||
| 351 | { | - | ||||||||||||
| 352 | showMessage(message, QString()); | - | ||||||||||||
| 353 | } never executed:  end of block | 0 | ||||||||||||
| 354 | - | |||||||||||||
| 355 | /*! | - | ||||||||||||
| 356 | \since 4.5 | - | ||||||||||||
| 357 | \overload | - | ||||||||||||
| 358 | - | |||||||||||||
| 359 | Shows the given message, \a message, and returns immediately. If the user | - | ||||||||||||
| 360 | has requested for messages of type, \a type, not to be shown again, this | - | ||||||||||||
| 361 | function does nothing. | - | ||||||||||||
| 362 | - | |||||||||||||
| 363 | Normally, the message is displayed immediately. However, if there are | - | ||||||||||||
| 364 | pending messages, it will be queued to be displayed later. | - | ||||||||||||
| 365 | - | |||||||||||||
| 366 | \sa showMessage() | - | ||||||||||||
| 367 | */ | - | ||||||||||||
| 368 | - | |||||||||||||
| 369 | void QErrorMessage::showMessage(const QString &message, const QString &type) | - | ||||||||||||
| 370 | { | - | ||||||||||||
| 371 | Q_D(QErrorMessage); | - | ||||||||||||
| 372 |     if (!d->isMessageToBeShown(message, type))
  | 0 | ||||||||||||
| 373 |         return; never executed:  return; | 0 | ||||||||||||
| 374 | d->pending.push(qMakePair(message, type)); | - | ||||||||||||
| 375 |     if (!isVisible() && d->nextPending())
 
  | 0 | ||||||||||||
| 376 |         show(); never executed:  show(); | 0 | ||||||||||||
| 377 | } never executed:  end of block | 0 | ||||||||||||
| 378 | - | |||||||||||||
| 379 | /*! | - | ||||||||||||
| 380 | \reimp | - | ||||||||||||
| 381 | */ | - | ||||||||||||
| 382 | void QErrorMessage::changeEvent(QEvent *e) | - | ||||||||||||
| 383 | { | - | ||||||||||||
| 384 | Q_D(QErrorMessage); | - | ||||||||||||
| 385 |     if (e->type() == QEvent::LanguageChange) {
  | 0 | ||||||||||||
| 386 | d->retranslateStrings(); | - | ||||||||||||
| 387 |     } never executed:  end of block | 0 | ||||||||||||
| 388 | QDialog::changeEvent(e); | - | ||||||||||||
| 389 | } never executed:  end of block | 0 | ||||||||||||
| 390 | - | |||||||||||||
| 391 | void QErrorMessagePrivate::retranslateStrings() | - | ||||||||||||
| 392 | { | - | ||||||||||||
| 393 | again->setText(QErrorMessage::tr("&Show this message again")); | - | ||||||||||||
| 394 | ok->setText(QErrorMessage::tr("&OK")); | - | ||||||||||||
| 395 | } never executed:  end of block | 0 | ||||||||||||
| 396 | - | |||||||||||||
| 397 | QT_END_NAMESPACE | - | ||||||||||||
| 398 | - | |||||||||||||
| 399 | #include "moc_qerrormessage.cpp" | - | ||||||||||||
| 400 | - | |||||||||||||
| 401 | #endif // QT_NO_ERRORMESSAGE | - | ||||||||||||
| Source code | Switch to Preprocessed file |