Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/widgets/qmainwindow.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
     
    4040****************************************************************************/
    4141
     42
     43
    4244#include "qmainwindow.h"
    4345#include "qmainwindowlayout_p.h"
     
    7779#ifdef Q_WS_MAC
    7880            , useHIToolBar(false)
     81
    7982#endif
    8083#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)
     
    8891#ifdef Q_WS_MAC
    8992    bool useHIToolBar;
     93
    9094#endif
    9195    void init();
     
    100104    uint cursorAdjusted : 1;
    101105#endif
     106
     107
     108
     109
     110
    102111};
    103112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
    104155void QMainWindowPrivate::init()
    105156{
    106157    Q_Q(QMainWindow);
    107     layout = new QMainWindowLayout(q);
     158
     159#ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS
     160    QGridLayout *topLayout = new QGridLayout(q);
     161    topLayout->setContentsMargins(0, 0, 0, 0);
     162
     163    layout = new QMainWindowLayout(q, topLayout);
     164
     165    topLayout->addItem(layout, 1, 1);
     166#else
     167    layout = new QMainWindowLayout(q, 0);
     168#endif
     169
    108170    const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q);
    109171    iconSize = QSize(metric, metric);
     
    443505QMenuBar *QMainWindow::menuBar() const
    444506{
    445     QMenuBar *menuBar = qobject_cast<QMenuBar *>(d_func()->layout->menuBar());
     507    QMenuBar *menuBar = qobject_cast<QMenuBar *>(->menuBar());
    446508    if (!menuBar) {
    447509        QMainWindow *self = const_cast<QMainWindow *>(this);
     
    462524void QMainWindow::setMenuBar(QMenuBar *menuBar)
    463525{
    464     Q_D(QMainWindow);
    465     if (d->layout->menuBar() && d->layout->menuBar() != menuBar) {
     526    QLayout *topLayout = layout();
     527
     528    if (topLayout->menuBar() && topLayout->menuBar() != menuBar) {
    466529        // Reparent corner widgets before we delete the old menu bar.
    467         QMenuBar *oldMenuBar = qobject_cast<QMenuBar *>(d->layout->menuBar());
     530        QMenuBar *oldMenuBar = qobject_cast<QMenuBar *>(ayout->menuBar());
    468531        if (menuBar) {
    469532            // TopLeftCorner widget.
     
    479542        oldMenuBar->deleteLater();
    480543    }
    481     d->layout->setMenuBar(menuBar);
     544    ayout->setMenuBar(menuBar);
    482545}
    483546
     
    13751438
    13761439        case QEvent::StyleChange:
     1440
     1441
     1442
    13771443            if (!d->explicitIconSize)
    13781444                setIconSize(QSize());
     
    14381504        disappear since it is considered to be part of the title bar. Qt 4.5 and up will now work around this by pulling
    14391505        the toolbars out and back into the regular toolbar and vice versa when you swap out.
    1440         However, a good practice would be that turning off the unified toolbar before you call
    1441         showFullScreen() and restoring it after you call showNormal().
    14421506    \endlist
    14431507
     
    14541518
    14551519    // ### Disable the unified toolbar when using anything but the native graphics system.
    1456     if (windowSurface())
     1520    // ### Disable when using alien widgets as well
     1521    if (windowSurface() || testAttribute(Qt::WA_NativeWindow) == false)
    14571522        return;
    14581523
     
    15361601#ifndef QT_NO_MENU
    15371602    QMenu *popup = createPopupMenu();
    1538     if (popup && !popup->isEmpty()) {
    1539         popup->exec(event->globalPos());
    1540         event->accept();
    1541     }
    1542     delete popup;
     1603    if (popup) {
     1604        if (!popup->isEmpty()) {
     1605            popup->setAttribute(Qt::WA_DeleteOnClose);
     1606            popup->popup(event->globalPos());
     1607            event->accept();
     1608        } else {
     1609            delete popup;
     1610        }
     1611    }
    15431612#endif
    15441613}
Note: See TracChangeset for help on using the changeset viewer.