Changeset 561 for trunk/src/gui/dialogs/qmessagebox.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/dialogs/qmessagebox.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 46 46 #include <QtGui/qdialogbuttonbox.h> 47 47 #include "private/qlabel_p.h" 48 #include "private/qapplication_p.h" 48 49 #include <QtCore/qlist.h> 49 50 #include <QtCore/qdebug.h> … … 64 65 #include <QtGui/qclipboard.h> 65 66 66 #ifdef Q_ OS_WINCE67 #ifdef Q_WS_WINCE 67 68 extern bool qt_wince_is_mobile(); //defined in qguifunctions_wince.cpp 68 69 extern bool qt_wince_is_smartphone();//defined in qguifunctions_wince.cpp … … 73 74 74 75 QT_BEGIN_NAMESPACE 75 76 extern QHash<QByteArray, QFont> *qt_app_fonts_hash();77 76 78 77 enum Button { Old_Ok = 1, Old_Cancel = 2, Old_Yes = 3, Old_No = 4, Old_Abort = 5, Old_Retry = 6, … … 153 152 void retranslateStrings(); 154 153 155 #ifdef Q_ OS_WINCE154 #ifdef Q_WS_WINCE 156 155 void hideSpecial(); 157 156 #endif … … 190 189 QAbstractButton *detectedEscapeButton; 191 190 QLabel *informativeLabel; 191 #ifdef Q_OS_SYMBIAN 192 QTextEdit *textEdit; 193 #endif 192 194 QPointer<QObject> receiverToDisconnectOnClose; 193 195 QByteArray memberToDisconnectOnClose; … … 259 261 int QMessageBoxPrivate::layoutMinimumWidth() 260 262 { 261 Q_Q(QMessageBox); 262 263 q->layout()->activate(); 264 return q->layout()->totalMinimumSize().width(); 263 layout->activate(); 264 return layout->totalMinimumSize().width(); 265 265 } 266 266 … … 273 273 274 274 QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size(); 275 #ifdef Q_WS_QWS 276 // the width of the screen, less the window border. 277 int hardLimit = screenSize.width() - (q->frameGeometry().width() - q->geometry().width()); 278 #elif defined(Q_OS_WINCE) 275 #if defined(Q_WS_QWS) || defined(Q_WS_WINCE) || defined(Q_OS_SYMBIAN) 279 276 // the width of the screen, less the window border. 280 277 int hardLimit = screenSize.width() - (q->frameGeometry().width() - q->geometry().width()); 281 278 #else 282 279 int hardLimit = qMin(screenSize.width() - 480, 1000); // can never get bigger than this 280 // on small screens allows the messagebox be the same size as the screen 281 if (screenSize.width() <= 1024) 282 hardLimit = screenSize.width(); 283 283 #endif 284 284 #ifdef Q_WS_MAC … … 288 288 #else 289 289 // note: ideally on windows, hard and soft limits but it breaks compat 290 #ifndef Q_ OS_WINCE290 #ifndef Q_WS_WINCE 291 291 int softLimit = qMin(screenSize.width()/2, 500); 292 292 #else 293 293 int softLimit = qMin(screenSize.width() * 3 / 4, 500); 294 #endif //Q_ OS_WINCE294 #endif //Q_WS_WINCE 295 295 #endif 296 296 … … 314 314 width = hardLimit; 315 315 } 316 #ifdef Q_WS_S60 317 // in S60 portait messageBoxes should always occupy maximum width 318 if (QApplication::desktop()->size().height() > QApplication::desktop()->size().width()){ 319 width = hardLimit; 320 } else { 321 // in landscape the messageBoxes should be of same width as in portrait 322 width = qMin(QApplication::desktop()->size().height(), hardLimit); 323 } 324 #endif 316 325 } 317 326 … … 335 344 } 336 345 337 QFontMetrics fm( qApp->font("QWorkspaceTitleBar"));346 QFontMetrics fm(QApplication::font("QWorkspaceTitleBar")); 338 347 int windowTitleWidth = qMin(fm.width(q->windowTitle()) + 50, hardLimit); 339 348 if (windowTitleWidth > width) 340 349 width = windowTitleWidth; 341 350 342 q->layout()->activate();343 int height = ( q->layout()->hasHeightForWidth())344 ? q->layout()->totalHeightForWidth(width)345 : q->layout()->totalMinimumSize().height();351 layout->activate(); 352 int height = (layout->hasHeightForWidth()) 353 ? layout->totalHeightForWidth(width) 354 : layout->totalMinimumSize().height(); 346 355 q->setFixedSize(width, height); 347 356 QCoreApplication::removePostedEvents(q, QEvent::LayoutRequest); … … 349 358 350 359 351 #ifdef Q_ OS_WINCE360 #ifdef Q_WS_WINCE 352 361 /*! 353 362 \internal … … 364 373 QString text = pb->text(); 365 374 text.remove(QChar::fromLatin1('&')); 366 if (text == qApp->translate("QMessageBox", "OK" ))375 if (text == QApplication::translate("QMessageBox", "OK" )) 367 376 pb->setFixedSize(0,0); 368 377 } … … 438 447 the user or for asking the user a question and receiving an answer. 439 448 440 \ingroup dialogs441 \mainclass 449 \ingroup standard-dialogs 450 442 451 443 452 A message box displays a primary \l{QMessageBox::text}{text} to … … 704 713 passed to the QDialog constructor. 705 714 706 If \a parent is 0, the message box is an \l{Qt::ApplicationModal} 707 {application modal} dialog box. If \a parent is a widget, the 708 message box is \l{Qt::WindowModal} {window modal} relative to \a 709 parent. 710 711 On Mac OS X, if \a parent is not 0 and you want your message box 712 to appear as a Qt::Sheet of that parent, set the message box's 713 \l{setWindowModality()} {window modality} to Qt::WindowModal 714 (default). Otherwise, the message box will be a standard dialog. 715 On Mac OS X, if you want your message box to appear 716 as a Qt::Sheet of its \a parent, set the message box's 717 \l{setWindowModality()} {window modality} to Qt::WindowModal or use open(). 718 Otherwise, the message box will be a standard dialog. 715 719 716 720 */ … … 1211 1215 d_func()->retranslateStrings(); 1212 1216 break; 1213 #ifdef Q_ OS_WINCE1217 #ifdef Q_WS_WINCE 1214 1218 case QEvent::OkRequest: 1215 1219 case QEvent::HelpRequest: { 1216 1220 QString bName = 1217 1221 (e->type() == QEvent::OkRequest) 1218 ? qApp->translate("QMessageBox", "OK")1219 : qApp->translate("QMessageBox", "Help");1222 ? QApplication::translate("QMessageBox", "OK") 1223 : QApplication::translate("QMessageBox", "Help"); 1220 1224 QList<QPushButton*> list = qFindChildren<QPushButton*>(this); 1221 1225 for (int i=0; i<list.size(); ++i) { … … 1316 1320 QString separator = QString::fromLatin1("---------------------------\n"); 1317 1321 QString textToCopy = separator; 1318 separator.prepend(QLatin1 String("\n"));1322 separator.prepend(QLatin1Char('\n')); 1319 1323 textToCopy += windowTitle() + separator; // title 1320 1324 textToCopy += d->label->text() + separator; // text … … 1330 1334 textToCopy += buttonTexts + separator; 1331 1335 1332 qApp->clipboard()->setText(textToCopy);1336 QApplication::clipboard()->setText(textToCopy); 1333 1337 return; 1334 1338 } … … 1354 1358 } 1355 1359 1356 #ifdef Q_ OS_WINCE1360 #ifdef Q_WS_WINCE 1357 1361 /*! 1358 1362 \reimp … … 1371 1375 \overload 1372 1376 1373 Opens the dialog and connects its accepted() signal to the slot specified 1374 by \a receiver and \a member. 1377 Opens the dialog and connects its finished() or buttonClicked() signal to 1378 the slot specified by \a receiver and \a member. If the slot in \a member 1379 has a pointer for its first parameter the connection is to buttonClicked(), 1380 otherwise the connection is to finished(). 1375 1381 1376 1382 The signal will be disconnected from the slot when the dialog is closed. … … 1423 1429 if (d->autoAddOkButton) { 1424 1430 addButton(Ok); 1425 #if defined(Q_ OS_WINCE)1431 #if defined(Q_WS_WINCE) 1426 1432 d->hideSpecial(); 1427 1433 #endif … … 1690 1696 #endif 1691 1697 1692 QString translatedTextAboutQt ;1693 translatedTextAboutQt = QMessageBox::tr(1698 QString translatedTextAboutQtCaption; 1699 translatedTextAboutQtCaption = QMessageBox::tr( 1694 1700 "<h3>About Qt</h3>" 1695 1701 "<p>This program uses Qt version %1.</p>" 1702 ).arg(QLatin1String(QT_VERSION_STR)); 1703 QString translatedTextAboutQtText; 1704 translatedTextAboutQtText = QMessageBox::tr( 1696 1705 "<p>Qt is a C++ toolkit for cross-platform application " 1697 1706 "development.</p>" … … 1702 1711 "<p>Qt is available under three different licensing options designed " 1703 1712 "to accommodate the needs of our various users.</p>" 1704 " Qt licensed under our commercial license agreement is appropriate "1713 "<p>Qt licensed under our commercial license agreement is appropriate " 1705 1714 "for development of proprietary/commercial software where you do not " 1706 1715 "want to share any source code with third parties or otherwise cannot " … … 1716 1725 "terms of the GNU GPL version 3.0 or where you are otherwise willing " 1717 1726 "to comply with the terms of the GNU GPL version 3.0.</p>" 1718 "<p>Please see <a href=\"http:// www.qtsoftware.com/products/licensing\">www.qtsoftware.com/products/licensing</a> "1727 "<p>Please see <a href=\"http://qt.nokia.com/products/licensing\">qt.nokia.com/products/licensing</a> " 1719 1728 "for an overview of Qt licensing.</p>" 1720 1729 "<p>Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).</p>" 1721 "<p>Qt is a Nokia product. See <a href=\"http:// www.qtsoftware.com/qt/\">www.qtsoftware.com/qt</a> "1730 "<p>Qt is a Nokia product. See <a href=\"http://qt.nokia.com/\">qt.nokia.com</a> " 1722 1731 "for more information.</p>" 1723 ).arg(QLatin1String(QT_VERSION_STR)); 1724 1732 ); 1725 1733 QMessageBox *msgBox = new QMessageBox(parent); 1726 1734 msgBox->setAttribute(Qt::WA_DeleteOnClose); 1727 1735 msgBox->setWindowTitle(title.isEmpty() ? tr("About Qt") : title); 1728 msgBox->setText(translatedTextAboutQt); 1736 msgBox->setText(translatedTextAboutQtCaption); 1737 msgBox->setInformativeText(translatedTextAboutQtText); 1729 1738 1730 1739 QPixmap pm(QLatin1String(":/trolltech/qmessagebox/images/qtlogo-64.png")); 1731 1740 if (!pm.isNull()) 1732 1741 msgBox->setIconPixmap(pm); 1733 #if defined(Q_ OS_WINCE)1742 #if defined(Q_WS_WINCE) 1734 1743 msgBox->setDefaultButton(msgBox->addButton(QMessageBox::Ok)); 1735 1744 #endif … … 2454 2463 label->setWordWrap(true); 2455 2464 QGridLayout *grid = static_cast<QGridLayout *>(layout()); 2465 #ifdef Q_OS_SYMBIAN 2466 label->hide(); 2467 QTextEdit *textEdit = new QTextEdit(this); 2468 textEdit->setReadOnly(true); 2469 grid->addWidget(textEdit, 1, 1, 1, 1); 2470 d->textEdit = textEdit; 2471 #else 2456 2472 grid->addWidget(label, 1, 1, 1, 1); 2473 #endif 2457 2474 d->informativeLabel = label; 2458 2475 } 2459 2476 d->informativeLabel->setText(text); 2477 2478 #ifdef Q_OS_SYMBIAN 2479 //We need to put the informative label inside textEdit to enable scrolling of long texts. 2480 d->textEdit->setText(d->informativeLabel->text()); 2481 #endif 2482 2460 2483 d->updateSize(); 2461 2484 }
Note:
See TracChangeset
for help on using the changeset viewer.