Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/dialogs/qmessagebox.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    4646#include <QtGui/qdialogbuttonbox.h>
    4747#include "private/qlabel_p.h"
     48#include "private/qapplication_p.h"
    4849#include <QtCore/qlist.h>
    4950#include <QtCore/qdebug.h>
     
    6465#include <QtGui/qclipboard.h>
    6566
    66 #ifdef Q_OS_WINCE
     67#ifdef Q_WS_WINCE
    6768extern bool qt_wince_is_mobile();    //defined in qguifunctions_wince.cpp
    6869extern bool qt_wince_is_smartphone();//defined in qguifunctions_wince.cpp
     
    7374
    7475QT_BEGIN_NAMESPACE
    75 
    76 extern QHash<QByteArray, QFont> *qt_app_fonts_hash();
    7776
    7877enum Button { Old_Ok = 1, Old_Cancel = 2, Old_Yes = 3, Old_No = 4, Old_Abort = 5, Old_Retry = 6,
     
    153152    void retranslateStrings();
    154153
    155 #ifdef Q_OS_WINCE
     154#ifdef Q_WS_WINCE
    156155    void hideSpecial();
    157156#endif
     
    190189    QAbstractButton *detectedEscapeButton;
    191190    QLabel *informativeLabel;
     191#ifdef Q_OS_SYMBIAN
     192    QTextEdit *textEdit;
     193#endif
    192194    QPointer<QObject> receiverToDisconnectOnClose;
    193195    QByteArray memberToDisconnectOnClose;
     
    259261int QMessageBoxPrivate::layoutMinimumWidth()
    260262{
    261     Q_Q(QMessageBox);
    262 
    263     q->layout()->activate();
    264     return q->layout()->totalMinimumSize().width();
     263    layout->activate();
     264    return layout->totalMinimumSize().width();
    265265}
    266266
     
    273273
    274274    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)
    279276    // the width of the screen, less the window border.
    280277    int hardLimit = screenSize.width() - (q->frameGeometry().width() - q->geometry().width());
    281278#else
    282279    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();
    283283#endif
    284284#ifdef Q_WS_MAC
     
    288288#else
    289289    // note: ideally on windows, hard and soft limits but it breaks compat
    290 #ifndef Q_OS_WINCE
     290#ifndef Q_WS_WINCE
    291291    int softLimit = qMin(screenSize.width()/2, 500);
    292292#else
    293293    int softLimit = qMin(screenSize.width() * 3 / 4, 500);
    294 #endif //Q_OS_WINCE
     294#endif //Q_WS_WINCE
    295295#endif
    296296
     
    314314            width = hardLimit;
    315315        }
     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
    316325    }
    317326
     
    335344    }
    336345
    337     QFontMetrics fm(qApp->font("QWorkspaceTitleBar"));
     346    QFontMetrics fm(QApplication::font("QWorkspaceTitleBar"));
    338347    int windowTitleWidth = qMin(fm.width(q->windowTitle()) + 50, hardLimit);
    339348    if (windowTitleWidth > width)
    340349        width = windowTitleWidth;
    341350
    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();
    346355    q->setFixedSize(width, height);
    347356    QCoreApplication::removePostedEvents(q, QEvent::LayoutRequest);
     
    349358
    350359
    351 #ifdef Q_OS_WINCE
     360#ifdef Q_WS_WINCE
    352361/*!
    353362  \internal
     
    364373            QString text = pb->text();
    365374            text.remove(QChar::fromLatin1('&'));
    366             if (text == qApp->translate("QMessageBox", "OK" ))
     375            if (text == QApplication::translate("QMessageBox", "OK" ))
    367376                pb->setFixedSize(0,0);
    368377        }
     
    438447    the user or for asking the user a question and receiving an answer.
    439448
    440     \ingroup dialogs
    441     \mainclass
     449    \ingroup standard-dialogs
     450
    442451
    443452    A message box displays a primary \l{QMessageBox::text}{text} to
     
    704713    passed to the QDialog constructor.
    705714
    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.
    715719
    716720*/
     
    12111215            d_func()->retranslateStrings();
    12121216            break;
    1213 #ifdef Q_OS_WINCE
     1217#ifdef Q_WS_WINCE
    12141218        case QEvent::OkRequest:
    12151219        case QEvent::HelpRequest: {
    12161220          QString bName =
    12171221              (e->type() == QEvent::OkRequest)
    1218               ? qApp->translate("QMessageBox", "OK")
    1219               : qApp->translate("QMessageBox", "Help");
     1222              ? QApplication::translate("QMessageBox", "OK")
     1223              : QApplication::translate("QMessageBox", "Help");
    12201224          QList<QPushButton*> list = qFindChildren<QPushButton*>(this);
    12211225          for (int i=0; i<list.size(); ++i) {
     
    13161320            QString separator = QString::fromLatin1("---------------------------\n");
    13171321            QString textToCopy = separator;
    1318             separator.prepend(QLatin1String("\n"));
     1322            separator.prepend(QLatin1Char('\n'));
    13191323            textToCopy += windowTitle() + separator; // title
    13201324            textToCopy += d->label->text() + separator; // text
     
    13301334            textToCopy += buttonTexts + separator;
    13311335
    1332             qApp->clipboard()->setText(textToCopy);
     1336            QApplication::clipboard()->setText(textToCopy);
    13331337            return;
    13341338        }
     
    13541358}
    13551359
    1356 #ifdef Q_OS_WINCE
     1360#ifdef Q_WS_WINCE
    13571361/*!
    13581362    \reimp
     
    13711375    \overload
    13721376
    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().
    13751381
    13761382    The signal will be disconnected from the slot when the dialog is closed.
     
    14231429    if (d->autoAddOkButton) {
    14241430        addButton(Ok);
    1425 #if defined(Q_OS_WINCE)
     1431#if defined(Q_WS_WINCE)
    14261432        d->hideSpecial();
    14271433#endif
     
    16901696#endif
    16911697
    1692     QString translatedTextAboutQt;
    1693     translatedTextAboutQt = QMessageBox::tr(
     1698    QString translatedTextAboutQtCaption;
     1699    translatedTextAboutQtCaption = QMessageBox::tr(
    16941700        "<h3>About Qt</h3>"
    16951701        "<p>This program uses Qt version %1.</p>"
     1702        ).arg(QLatin1String(QT_VERSION_STR));
     1703    QString translatedTextAboutQtText;
     1704    translatedTextAboutQtText = QMessageBox::tr(
    16961705        "<p>Qt is a C++ toolkit for cross-platform application "
    16971706        "development.</p>"
     
    17021711        "<p>Qt is available under three different licensing options designed "
    17031712        "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 "
    17051714        "for development of proprietary/commercial software where you do not "
    17061715        "want to share any source code with third parties or otherwise cannot "
     
    17161725        "terms of the GNU GPL version 3.0 or where you are otherwise willing "
    17171726        "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> "
    17191728        "for an overview of Qt licensing.</p>"
    17201729        "<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> "
    17221731        "for more information.</p>"
    1723        ).arg(QLatin1String(QT_VERSION_STR));
    1724 
     1732        );
    17251733    QMessageBox *msgBox = new QMessageBox(parent);
    17261734    msgBox->setAttribute(Qt::WA_DeleteOnClose);
    17271735    msgBox->setWindowTitle(title.isEmpty() ? tr("About Qt") : title);
    1728     msgBox->setText(translatedTextAboutQt);
     1736    msgBox->setText(translatedTextAboutQtCaption);
     1737    msgBox->setInformativeText(translatedTextAboutQtText);
    17291738
    17301739    QPixmap pm(QLatin1String(":/trolltech/qmessagebox/images/qtlogo-64.png"));
    17311740    if (!pm.isNull())
    17321741        msgBox->setIconPixmap(pm);
    1733 #if defined(Q_OS_WINCE)
     1742#if defined(Q_WS_WINCE)
    17341743    msgBox->setDefaultButton(msgBox->addButton(QMessageBox::Ok));
    17351744#endif
     
    24542463        label->setWordWrap(true);
    24552464        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
    24562472        grid->addWidget(label, 1, 1, 1, 1);
     2473#endif
    24572474        d->informativeLabel = label;
    24582475    }
    24592476    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
    24602483    d->updateSize();
    24612484}
Note: See TracChangeset for help on using the changeset viewer.