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/widgets/qpushbutton.cpp

    r306 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information ([email protected])
     4** All rights reserved.
     5** Contact: Nokia Corporation ([email protected])
    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
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    6464#endif
    6565
     66
    6667#include "private/qpushbutton_p.h"
    6768
     
    7475
    7576    \ingroup basicwidgets
    76     \mainclass
     77
    7778
    7879    The push button, or command button, is perhaps the most commonly
     
    388389{
    389390    Q_D(const QPushButton);
    390     if (d->sizeHint.isValid())
     391    if (d->sizeHint.isValid())
    391392        return d->sizeHint;
     393
    392394    ensurePolished();
    393395
     
    528530
    529531    if (menu && !d->menu) {
    530         disconnect(this, SIGNAL(pressed()), this, SLOT(_q_popupPressed()));
    531         connect(this, SIGNAL(pressed()), this, SLOT(_q_popupPressed()));
     532        connect(this, SIGNAL(pressed()), this, SLOT(_q_popupPressed()), Qt::UniqueConnection);
    532533    }
    533534    if (d->menu)
     
    576577
    577578    menu->setNoReplayFor(q);
     579
     580
     581
     582
     583
     584
     585
     586
     587
     588
     589
     590
     591
     592
     593
     594
     595
     596
     597
     598
    578599    bool horizontal = true;
    579600#if !defined(QT_NO_TOOLBAR)
    580     QToolBar *tb = qobject_cast<QToolBar*>(q->parentWidget());
     601    QToolBar *tb = qobject_cast<QToolBar*>();
    581602    if (tb && tb->orientation() == Qt::Vertical)
    582603        horizontal = false;
    583604#endif
     605
    584606    QWidgetItem item(q);
    585607    QRect rect = item.geometry();
     
    591613    int y = globalPos.y();
    592614    if (horizontal) {
    593         if (globalPos.y() + rect.height() + menuSize.height() <= qApp->desktop()->height()) {
     615        if (globalPos.y() + rect.height() + menuSize.height() <= height()) {
    594616            y += rect.height();
    595617        } else {
     
    599621            x += rect.width() - menuSize.width();
    600622    } else {
    601         if (globalPos.x() + rect.width() + menu->sizeHint().width() <= qApp->desktop()->width())
     623        if (globalPos.x() + rect.width() + menu->sizeHint().width() <= width())
    602624            x += rect.width();
    603625        else
    604626            x -= menuSize.width();
    605627    }
    606     QPointer<QPushButton> guard(q);
    607 
    608     //Because of a delay in menu effects, we must keep track of the
    609     //menu visibility to avoid flicker on button release
    610     menuOpen = true;
    611     menu->exec(QPoint(x, y));
    612     if (guard) {
    613         menuOpen = false;
    614         // on some platforms (e.g. OS/2) QPushButton::focusOutEvent() may be called
    615         // before we return from exec() above (for example, as a result of window
    616         // deactivation). It will set down to false but since menuOpen won't be
    617         // false yet, the button will be redrawn as sunken still. Simple setDown(false)
    618         // won't do anything in this case so we need to call update() instead to make
    619         // sure the button is redrawn as unsunken.
    620         if (down)
    621             q->setDown(false);
    622         else
    623             q->update();
    624     }
    625 }
     628
     629    return QPoint(x,y);
     630}
     631
    626632#endif // QT_NO_MENU
    627633
     
    668674                d->resetLayoutItemMargins();
    669675                updateGeometry();
     676
     677
    670678    }
    671679    return QAbstractButton::event(e);
Note: See TracChangeset for help on using the changeset viewer.