1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
8 ** |
8 ** |
56 #include <QtGui/qaccessible.h> |
56 #include <QtGui/qaccessible.h> |
57 #include <QtGui/qicon.h> |
57 #include <QtGui/qicon.h> |
58 #include <QtGui/qtextdocument.h> |
58 #include <QtGui/qtextdocument.h> |
59 #include <QtGui/qapplication.h> |
59 #include <QtGui/qapplication.h> |
60 #include <QtGui/qtextedit.h> |
60 #include <QtGui/qtextedit.h> |
|
61 #include <QtGui/qtextbrowser.h> |
61 #include <QtGui/qmenu.h> |
62 #include <QtGui/qmenu.h> |
62 #include "qdialog_p.h" |
63 #include "qdialog_p.h" |
63 #include <QtGui/qfont.h> |
64 #include <QtGui/qfont.h> |
64 #include <QtGui/qfontmetrics.h> |
65 #include <QtGui/qfontmetrics.h> |
65 #include <QtGui/qclipboard.h> |
66 #include <QtGui/qclipboard.h> |
|
67 |
|
68 #ifndef QT_NO_STYLE_S60 |
|
69 #include <qs60style.h> |
|
70 #endif |
66 |
71 |
67 #ifdef Q_WS_WINCE |
72 #ifdef Q_WS_WINCE |
68 extern bool qt_wince_is_mobile(); //defined in qguifunctions_wince.cpp |
73 extern bool qt_wince_is_mobile(); //defined in qguifunctions_wince.cpp |
69 extern bool qt_wince_is_smartphone();//defined in qguifunctions_wince.cpp |
74 extern bool qt_wince_is_smartphone();//defined in qguifunctions_wince.cpp |
70 extern bool qt_wince_is_pocket_pc(); //defined in qguifunctions_wince.cpp |
75 extern bool qt_wince_is_pocket_pc(); //defined in qguifunctions_wince.cpp |
186 #endif |
191 #endif |
187 bool compatMode; |
192 bool compatMode; |
188 bool autoAddOkButton; |
193 bool autoAddOkButton; |
189 QAbstractButton *detectedEscapeButton; |
194 QAbstractButton *detectedEscapeButton; |
190 QLabel *informativeLabel; |
195 QLabel *informativeLabel; |
191 #ifdef Q_OS_SYMBIAN |
196 #if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) |
192 QTextEdit *textEdit; |
197 QTextBrowser *textBrowser; |
193 #endif |
198 #endif |
194 QPointer<QObject> receiverToDisconnectOnClose; |
199 QPointer<QObject> receiverToDisconnectOnClose; |
195 QByteArray memberToDisconnectOnClose; |
200 QByteArray memberToDisconnectOnClose; |
196 QByteArray signalToDisconnectOnClose; |
201 QByteArray signalToDisconnectOnClose; |
197 }; |
202 }; |
311 opt.setWrapMode(QTextOption::WrapAnywhere); |
316 opt.setWrapMode(QTextOption::WrapAnywhere); |
312 control->document()->setDefaultTextOption(opt); |
317 control->document()->setDefaultTextOption(opt); |
313 } |
318 } |
314 width = hardLimit; |
319 width = hardLimit; |
315 } |
320 } |
|
321 } |
316 #ifdef Q_WS_S60 |
322 #ifdef Q_WS_S60 |
317 // in S60 portait messageBoxes should always occupy maximum width |
323 // in S60 portait messageBoxes should always occupy maximum width |
318 if (QApplication::desktop()->size().height() > QApplication::desktop()->size().width()){ |
324 if (QApplication::desktop()->size().height() > QApplication::desktop()->size().width()){ |
319 width = hardLimit; |
325 width = hardLimit; |
320 } else { |
326 } else { |
321 // in landscape the messageBoxes should be of same width as in portrait |
327 // in landscape the messageBoxes should be of same width as in portrait |
322 width = qMin(QApplication::desktop()->size().height(), hardLimit); |
328 width = qMin(QApplication::desktop()->size().height(), hardLimit); |
323 } |
329 } |
324 #endif |
330 #endif |
325 } |
|
326 |
331 |
327 if (informativeLabel) { |
332 if (informativeLabel) { |
328 label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); |
333 label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); |
329 QSizePolicy policy(QSizePolicy::Minimum, QSizePolicy::Preferred); |
334 QSizePolicy policy(QSizePolicy::Minimum, QSizePolicy::Preferred); |
330 policy.setHeightForWidth(true); |
335 policy.setHeightForWidth(true); |
350 |
355 |
351 layout->activate(); |
356 layout->activate(); |
352 int height = (layout->hasHeightForWidth()) |
357 int height = (layout->hasHeightForWidth()) |
353 ? layout->totalHeightForWidth(width) |
358 ? layout->totalHeightForWidth(width) |
354 : layout->totalMinimumSize().height(); |
359 : layout->totalMinimumSize().height(); |
|
360 |
|
361 #ifndef QT_NO_STYLE_S60 |
|
362 QS60Style *s60Style = 0; |
|
363 s60Style = qobject_cast<QS60Style *>(QApplication::style()); |
|
364 |
|
365 //use custom pixel metric to deduce the minimum height of the messagebox |
|
366 if (s60Style) |
|
367 height = qMax(height, s60Style->pixelMetric((QStyle::PixelMetric)PM_MessageBoxHeight)); |
|
368 #endif |
|
369 |
355 q->setFixedSize(width, height); |
370 q->setFixedSize(width, height); |
356 QCoreApplication::removePostedEvents(q, QEvent::LayoutRequest); |
371 QCoreApplication::removePostedEvents(q, QEvent::LayoutRequest); |
357 } |
372 } |
358 |
373 |
359 |
374 |
1724 "use such applications in combination with software subject to the " |
1739 "use such applications in combination with software subject to the " |
1725 "terms of the GNU GPL version 3.0 or where you are otherwise willing " |
1740 "terms of the GNU GPL version 3.0 or where you are otherwise willing " |
1726 "to comply with the terms of the GNU GPL version 3.0.</p>" |
1741 "to comply with the terms of the GNU GPL version 3.0.</p>" |
1727 "<p>Please see <a href=\"http://qt.nokia.com/products/licensing\">qt.nokia.com/products/licensing</a> " |
1742 "<p>Please see <a href=\"http://qt.nokia.com/products/licensing\">qt.nokia.com/products/licensing</a> " |
1728 "for an overview of Qt licensing.</p>" |
1743 "for an overview of Qt licensing.</p>" |
1729 "<p>Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).</p>" |
1744 "<p>Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).</p>" |
1730 "<p>Qt is a Nokia product. See <a href=\"http://qt.nokia.com/\">qt.nokia.com</a> " |
1745 "<p>Qt is a Nokia product. See <a href=\"http://qt.nokia.com/\">qt.nokia.com</a> " |
1731 "for more information.</p>" |
1746 "for more information.</p>" |
1732 ); |
1747 ); |
1733 QMessageBox *msgBox = new QMessageBox(parent); |
1748 QMessageBox *msgBox = new QMessageBox(parent); |
1734 msgBox->setAttribute(Qt::WA_DeleteOnClose); |
1749 msgBox->setAttribute(Qt::WA_DeleteOnClose); |
2460 // apply a smaller font the information label on the mac |
2475 // apply a smaller font the information label on the mac |
2461 label->setFont(qt_app_fonts_hash()->value("QTipLabel")); |
2476 label->setFont(qt_app_fonts_hash()->value("QTipLabel")); |
2462 #endif |
2477 #endif |
2463 label->setWordWrap(true); |
2478 label->setWordWrap(true); |
2464 QGridLayout *grid = static_cast<QGridLayout *>(layout()); |
2479 QGridLayout *grid = static_cast<QGridLayout *>(layout()); |
2465 #ifdef Q_OS_SYMBIAN |
2480 #if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) |
2466 label->hide(); |
2481 label->hide(); |
2467 QTextEdit *textEdit = new QTextEdit(this); |
2482 QTextBrowser *textBrowser = new QTextBrowser(this); |
2468 textEdit->setReadOnly(true); |
2483 textBrowser->setOpenExternalLinks(true); |
2469 grid->addWidget(textEdit, 1, 1, 1, 1); |
2484 grid->addWidget(textBrowser, 1, 1, 1, 1); |
2470 d->textEdit = textEdit; |
2485 d->textBrowser = textBrowser; |
2471 #else |
2486 #else |
2472 grid->addWidget(label, 1, 1, 1, 1); |
2487 grid->addWidget(label, 1, 1, 1, 1); |
2473 #endif |
2488 #endif |
2474 d->informativeLabel = label; |
2489 d->informativeLabel = label; |
2475 } |
2490 } |
2476 d->informativeLabel->setText(text); |
2491 d->informativeLabel->setText(text); |
2477 |
2492 |
2478 #ifdef Q_OS_SYMBIAN |
2493 #if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) |
2479 //We need to put the informative label inside textEdit to enable scrolling of long texts. |
2494 //We need to put the informative label inside textBrowser to enable scrolling of long texts. |
2480 d->textEdit->setText(d->informativeLabel->text()); |
2495 d->textBrowser->setText(d->informativeLabel->text()); |
2481 #endif |
2496 #endif |
2482 |
2497 |
2483 d->updateSize(); |
2498 d->updateSize(); |
2484 } |
2499 } |
2485 |
2500 |