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/qtoolbutton.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**
     
    105105bool QToolButtonPrivate::hasMenu() const
    106106{
    107     Q_Q(const QToolButton);
    108107    return ((defaultAction && defaultAction->menu())
    109108            || (menuAction && menuAction->menu())
    110             || q->actions().size() > (defaultAction ? 1 : 0));
     109            || actions.size() > (defaultAction ? 1 : 0));
    111110}
    112111#endif
     
    118117
    119118    \ingroup basicwidgets
    120     \mainclass
     119
    121120
    122121    A tool button is a special button that provides quick-access to
     
    279278    defaultAction = 0;
    280279#ifndef QT_NO_TOOLBAR
    281     if (qobject_cast<QToolBar*>(q->parentWidget()))
     280    if (qobject_cast<QToolBar*>(parent))
    282281        autoRaise = true;
    283282    else
     
    380379        option->features |= QStyleOptionToolButton::HasMenu;
    381380#endif
    382     option->toolButtonStyle = d->toolButtonStyle;
     381    if (d->toolButtonStyle == Qt::ToolButtonFollowStyle) {
     382        option->toolButtonStyle = Qt::ToolButtonStyle(style()->styleHint(QStyle::SH_ToolButtonStyle, option, this));
     383    } else
     384        option->toolButtonStyle = d->toolButtonStyle;
     385
     386    if (option->toolButtonStyle == Qt::ToolButtonTextBesideIcon) {
     387        // If the action is not prioritized, remove the text label to save space
     388        if (d->defaultAction && d->defaultAction->priority() < QAction::NormalPriority)
     389            option->toolButtonStyle = Qt::ToolButtonIconOnly;
     390    }
     391
    383392    if (d->icon.isNull() && d->arrowType == Qt::NoArrow && !forceNoText) {
    384393        if (!d->text.isEmpty())
     
    478487    The default is Qt::ToolButtonIconOnly.
    479488
     489    To have the style of toolbuttons follow the system settings (as available
     490    in GNOME and KDE desktop environments), set this property to Qt::ToolButtonFollowStyle.
     491
    480492    QToolButton automatically connects this slot to the relevant
    481493    signal in the QMainWindow in which is resides.
     
    860872    if (!hasMenu())
    861873        return; // no menu to show
    862 
    863     if (delay > 0 && popupMode == QToolButton::DelayedPopup)
     874    if (popupMode == QToolButton::MenuButtonPopup)
     875        return;
     876    else if (delay > 0 && !popupTimer.isActive() && popupMode == QToolButton::DelayedPopup)
    864877        popupTimer.start(delay, q);
    865878    else if (delay == 0 || popupMode == QToolButton::InstantPopup)
     
    884897        actualMenu = new QMenu(q);
    885898        mustDeleteActualMenu = true;
    886         QList<QAction*> actions = q->actions();
    887899        for(int i = 0; i < actions.size(); i++)
    888900            actualMenu->addAction(actions.at(i));
     
    892904    bool horizontal = true;
    893905#if !defined(QT_NO_TOOLBAR)
    894     QToolBar *tb = qobject_cast<QToolBar*>(q->parentWidget());
     906    QToolBar *tb = qobject_cast<QToolBar*>(parent);
    895907    if (tb && tb->orientation() == Qt::Vertical)
    896908        horizontal = false;
    897909#endif
    898910    QPoint p;
    899     QRect screen = qApp->desktop()->availableGeometry(q);
     911    QRect screen = QApplication::desktop()->availableGeometry(q);
    900912    QSize sh = ((QToolButton*)(QMenu*)actualMenu)->receivers(SIGNAL(aboutToShow()))? QSize() : actualMenu->sizeHint();
    901913    QRect rect = q->rect();
Note: See TracChangeset for help on using the changeset viewer.