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/kernel/qtooltip.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**
     
    7474
    7575    \ingroup helpsystem
    76     \mainclass
     76
    7777
    7878    The tip is a short piece of text reminding the user of the
     
    127127    bool eventFilter(QObject *, QEvent *);
    128128
    129     QBasicTimer hideTimer;
     129    QBasicTimer hideTimer, expireTimer;
     130
    130131    bool fadingOut;
    131132
     
    134135    void hideTipImmediately();
    135136    void setTipRect(QWidget *w, const QRect &r);
    136     void restartHideTimer();
     137    void restartExpireTimer();
    137138    bool tipChanged(const QPoint &pos, const QString &text, QObject *o);
    138139    void placeTip(const QPoint &pos, QWidget *w);
     
    183184    setAlignment(Qt::AlignLeft);
    184185    setIndent(1);
    185     setWordWrap(Qt::mightBeRichText(text));
    186186    qApp->installEventFilter(this);
    187187    setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0, this) / 255.0);
     
    191191}
    192192
    193 void QTipLabel::restartHideTimer()
     193void QTipLabel::restartExpireTimer()
    194194{
    195195    int time = 10000 + 40 * qMax(0, text().length()-100);
    196     hideTimer.start(time, this);
     196    expireTimer.start(time, this);
     197    hideTimer.stop();
    197198}
    198199
     
    200201{
    201202#ifndef QT_NO_STYLE_STYLESHEET
    202     if (styleSheetParent) {
     203    if (styleSheetParent){
    203204        disconnect(styleSheetParent, SIGNAL(destroyed()),
    204205                   QTipLabel::instance, SLOT(styleSheetParentDestroyed()));
     
    207208#endif
    208209
     210    setWordWrap(Qt::mightBeRichText(text));
    209211    setText(text);
    210212    QFontMetrics fm(font());
     
    214216        ++extra.rheight();
    215217    resize(sizeHint() + extra);
    216     restartHideTimer();
     218    restartExpireTimer();
    217219}
    218220
     
    258260void QTipLabel::hideTip()
    259261{
    260     hideTimer.start(300, this);
     262    if (!hideTimer.isActive())
     263        hideTimer.start(300, this);
    261264}
    262265
     
    279282void QTipLabel::timerEvent(QTimerEvent *e)
    280283{
    281     if (e->timerId() == hideTimer.timerId()){
     284    if (e->timerId() == hideTimer.timerId()
     285        || e->timerId() == expireTimer.timerId()){
    282286        hideTimer.stop();
     287        expireTimer.stop();
    283288#if defined(Q_WS_MAC) && !defined(QT_NO_EFFECTS)
    284289        if (QApplication::isEffectEnabled(Qt::UI_FadeTooltip)){
     
    286291            // The tip will not be deleted until a new tip is shown.
    287292
    288                         // DRSWAT - Cocoa
    289                         macWindowFade(qt_mac_window_for(this));
     293                        // DRSWAT - Cocoa
     294                        macWindowFade(qt_mac_window_for(this));
    290295            QTipLabel::instance->fadingOut = true; // will never be false again.
    291296        }
     
    427432void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect)
    428433{
    429     if (QTipLabel::instance){ // a tip does already exist
     434    if (QTipLabel::instance && QTipLabel::instance->isVisible()){ // a tip does already exist
    430435        if (text.isEmpty()){ // empty text means hide current tip
    431436            QTipLabel::instance->hideTip();
Note: See TracChangeset for help on using the changeset viewer.