Changeset 846 for trunk/src/gui/dialogs/qmessagebox.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/dialogs/qmessagebox.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 97 97 #ifndef QT_NO_CONTEXTMENU 98 98 QMenu *menu = createStandardContextMenu(); 99 menu-> exec(e->globalPos());100 delete menu;99 menu->setAttribute(Qt::WA_DeleteOnClose); 100 menu->popup(e->globalPos()); 101 101 #else 102 102 Q_UNUSED(e); … … 123 123 void setText(const QString &text) { textEdit->setPlainText(text); } 124 124 QString text() const { return textEdit->toPlainText(); } 125 QString label(DetailButtonLabel label)126 { return label == ShowLabel ? QMessageBox::tr("Show Details...")127 : QMessageBox::tr("Hide Details..."); }128 125 private: 129 126 TextEdit *textEdit; 130 127 }; 131 128 #endif // QT_NO_TEXTEDIT 129 130 class DetailButton : public QPushButton 131 { 132 public: 133 DetailButton(QWidget *parent) : QPushButton(label(ShowLabel), parent) 134 { 135 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 136 } 137 138 QString label(DetailButtonLabel label) const 139 { return label == ShowLabel ? QMessageBox::tr("Show Details...") : QMessageBox::tr("Hide Details..."); } 140 141 void setLabel(DetailButtonLabel lbl) 142 { setText(label(lbl)); } 143 144 QSize sizeHint() const 145 { 146 ensurePolished(); 147 QStyleOptionButton opt; 148 initStyleOption(&opt); 149 const QFontMetrics fm = fontMetrics(); 150 opt.text = label(ShowLabel); 151 QSize sz = fm.size(Qt::TextShowMnemonic, opt.text); 152 QSize ret = style()->sizeFromContents(QStyle::CT_PushButton, &opt, sz, this). 153 expandedTo(QApplication::globalStrut()); 154 opt.text = label(HideLabel); 155 sz = fm.size(Qt::TextShowMnemonic, opt.text); 156 ret.expandedTo(style()->sizeFromContents(QStyle::CT_PushButton, &opt, sz, this). 157 expandedTo(QApplication::globalStrut())); 158 return ret; 159 } 160 }; 161 132 162 133 163 class QMessageBoxPrivate : public QDialogPrivate … … 186 216 QPushButton *defaultButton; 187 217 QAbstractButton *clickedButton; 188 QPushButton *detailsButton;218 DetailButton *detailsButton; 189 219 #ifndef QT_NO_TEXTEDIT 190 220 QMessageBoxDetailsText *detailsText; … … 436 466 #ifndef QT_NO_TEXTEDIT 437 467 if (detailsButton && detailsText && button == detailsButton) { 438 detailsButton->set Text(detailsText->isHidden() ? detailsText->label(HideLabel) : detailsText->label(ShowLabel));468 detailsButton->setLabel(detailsText->isHidden() ? HideLabel : ShowLabel); 439 469 detailsText->setHidden(!detailsText->isHidden()); 440 470 updateSize(); … … 747 777 arguments are passed to the QDialog constructor. 748 778 749 If \a parent is 0, the message box is an \l{Qt::ApplicationModal} 750 {application modal} dialog box. If \a parent is a widget, the 751 message box is \l{Qt::WindowModal} {window modal} relative to \a 752 parent. 779 The message box is an \l{Qt::ApplicationModal} {application modal} 780 dialog box. 753 781 754 782 On Mac OS X, if \a parent is not 0 and you want your message box … … 1520 1548 {escape button} is returned. 1521 1549 1522 If \a parent is 0, the message box is an \l{Qt::ApplicationModal} 1523 {application modal} dialog box. If \a parent is a widget, the 1524 message box is \l{Qt::WindowModal} {window modal} relative to \a 1525 parent. 1550 The message box is an \l{Qt::ApplicationModal} {application modal} 1551 dialog box. 1526 1552 1527 1553 \sa question(), warning(), critical() … … 1550 1576 {escape button} is returned. 1551 1577 1552 If \a parent is 0, the message box is an \l{Qt::ApplicationModal} 1553 {application modal} dialog box. If \a parent is a widget, the 1554 message box is \l{Qt::WindowModal} {window modal} relative to \a 1555 parent. 1578 The message box is an \l{Qt::ApplicationModal} {application modal} 1579 dialog box. 1556 1580 1557 1581 \sa information(), warning(), critical() … … 1578 1602 {escape button} is returned. 1579 1603 1580 If \a parent is 0, the message box is an \l{Qt::ApplicationModal} 1581 {application modal} dialog box. If \a parent is a widget, the 1582 message box is \l{Qt::WindowModal} {window modal} relative to \a 1583 parent. 1604 The message box is an \l{Qt::ApplicationModal} {application modal} 1605 dialog box. 1584 1606 1585 1607 \sa question(), information(), critical() … … 1606 1628 {escape button} is returned. 1607 1629 1608 If \a parent is 0, the message box is an \l{Qt::ApplicationModal} 1609 {application modal} dialog box. If \a parent is a widget, the 1610 message box is \l{Qt::WindowModal} {window modal} relative to \a 1611 parent. 1630 The message box is an \l{Qt::ApplicationModal} {application modal} 1631 dialog box. 1612 1632 1613 1633 \warning Do not delete \a parent during the execution of the dialog. … … 1641 1661 The about box has a single button labelled "OK". On Mac OS X, the 1642 1662 about box is popped up as a modeless window; on other platforms, 1643 it is currently a windowmodal.1663 it is currently application modal. 1644 1664 1645 1665 \sa QWidget::windowIcon(), QApplication::activeWindow() … … 1694 1714 1695 1715 On Mac OS X, the about box is popped up as a modeless window; on 1696 other platforms, it is currently windowmodal.1716 other platforms, it is currently application modal. 1697 1717 1698 1718 \sa QApplication::aboutQt() … … 1742 1762 "<p>Please see <a href=\"http://qt.nokia.com/products/licensing\">qt.nokia.com/products/licensing</a> " 1743 1763 "for an overview of Qt licensing.</p>" 1744 "<p>Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).</p>"1764 "<p>Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).</p>" 1745 1765 "<p>Qt is a Nokia product. See <a href=\"http://qt.nokia.com/\">qt.nokia.com</a> " 1746 1766 "for more information.</p>" … … 1906 1926 #ifndef QT_NO_TEXTEDIT 1907 1927 if (detailsButton) 1908 detailsButton->set Text(detailsText->isHidden() ? detailsText->label(HideLabel) : detailsText->label(ShowLabel));1928 detailsButton->setLabel(detailsText->isHidden() ? HideLabel : ShowLabel); 1909 1929 #endif 1910 1930 } … … 1954 1974 \snippet doc/src/snippets/dialogs/dialogs.cpp 2 1955 1975 1956 If \a parent is 0, the message box is an \l{Qt::ApplicationModal} 1957 {application modal} dialog box. If \a parent is a widget, the 1958 message box is \l{Qt::WindowModal} {window modal} relative to \a 1959 parent. 1976 The message box is an \l{Qt::ApplicationModal} {application modal} 1977 dialog box. 1960 1978 1961 1979 The \a parent and \a f arguments are passed to … … 2006 2024 of the button that was clicked. 2007 2025 2008 If \a parent is 0, the message box is an \l{Qt::ApplicationModal} 2009 {application modal} dialog box. If \a parent is a widget, the 2010 message box is \l{Qt::WindowModal} {window modal} relative to \a 2011 parent. 2026 The message box is an \l{Qt::ApplicationModal} {application modal} 2027 dialog box. 2012 2028 2013 2029 \warning Do not delete \a parent during the execution of the dialog. … … 2044 2060 the relevant button. 2045 2061 2046 If \a parent is 0, the message box is an \l{Qt::ApplicationModal} 2047 {application modal} dialog box. If \a parent is a widget, the 2048 message box is \l{Qt::WindowModal} {window modal} relative to \a 2049 parent. 2062 The message box is an \l{Qt::ApplicationModal} {application modal} 2063 dialog box. 2050 2064 2051 2065 \warning Do not delete \a parent during the execution of the dialog. … … 2096 2110 of the button that was clicked. 2097 2111 2098 If \a parent is 0, the message box is an \l{Qt::ApplicationModal} 2099 {application modal} dialog box. If \a parent is a widget, the 2100 message box is \l{Qt::WindowModal} {window modal} relative to \a 2101 parent. 2112 The message box is an \l{Qt::ApplicationModal} {application modal} 2113 dialog box. 2102 2114 2103 2115 \warning Do not delete \a parent during the execution of the dialog. … … 2134 2146 the relevant button. 2135 2147 2136 If \a parent is 0, the message box is an \l{Qt::ApplicationModal} 2137 {application modal} dialog box. If \a parent is a widget, the 2138 message box is \l{Qt::WindowModal} {window modal} relative to \a 2139 parent. 2148 The message box is an \l{Qt::ApplicationModal} {application modal} 2149 dialog box. 2140 2150 2141 2151 \warning Do not delete \a parent during the execution of the dialog. … … 2186 2196 of the button that was clicked. 2187 2197 2188 If \a parent is 0, the message box is an \l{Qt::ApplicationModal} 2189 {application modal} dialog box. If \a parent is a widget, the 2190 message box is \l{Qt::WindowModal} {window modal} relative to \a 2191 parent. 2198 The message box is an \l{Qt::ApplicationModal} {application modal} 2199 dialog box. 2192 2200 2193 2201 \warning Do not delete \a parent during the execution of the dialog. … … 2224 2232 the relevant button. 2225 2233 2226 If \a parent is 0, the message box is an \l{Qt::ApplicationModal} 2227 {application modal} dialog box. If \a parent is a widget, the 2228 message box is \l{Qt::WindowModal} {window modal} relative to \a 2229 parent. 2234 The message box is an \l{Qt::ApplicationModal} {application modal} 2235 dialog box. 2230 2236 2231 2237 \warning Do not delete \a parent during the execution of the dialog. … … 2275 2281 of the button that was clicked. 2276 2282 2277 If \a parent is 0, the message box is an \l{Qt::ApplicationModal} 2278 {application modal} dialog box. If \a parent is a widget, the 2279 message box is \l{Qt::WindowModal} {window modal} relative to \a 2280 parent. 2283 The message box is an \l{Qt::ApplicationModal} {application modal} 2284 dialog box. 2281 2285 2282 2286 \warning Do not delete \a parent during the execution of the dialog. … … 2314 2318 the relevant button. 2315 2319 2316 If \a parent is 0, the message box is an \l{Qt::ApplicationModal} 2317 {application modal} dialog box. If \a parent is a widget, the 2318 message box is \l{Qt::WindowModal} {window modal} relative to \a 2319 parent. 2320 The message box is an \l{Qt::ApplicationModal} {application modal} 2321 dialog box. 2320 2322 2321 2323 \warning Do not delete \a parent during the execution of the dialog. … … 2414 2416 d->detailsText->hide(); 2415 2417 } 2416 if (!d->detailsButton) { 2417 d->detailsButton = new QPushButton(d->detailsText->label(ShowLabel), this); 2418 QPushButton hideDetails(d->detailsText->label(HideLabel)); 2419 d->detailsButton->setFixedSize(d->detailsButton->sizeHint().expandedTo(hideDetails.sizeHint())); 2420 } 2418 if (!d->detailsButton) 2419 d->detailsButton = new DetailButton(this); 2421 2420 d->detailsText->setText(text); 2422 2421 }
Note:
See TracChangeset
for help on using the changeset viewer.