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/qmainwindowlayout_mac.mm

    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.
    78**
    89** $QT_BEGIN_LICENSE:LGPL$
    9 ** No Commercial Usage
    10 ** This file contains pre-release code and may not be distributed.
    11 ** You may use this file in accordance with the terms and conditions
    12 ** contained in the either Technology Preview License Agreement or the
    13 ** Beta Release License Agreement.
     10** Commercial Usage
     11** Licensees holding valid Qt Commercial licenses may use this file in
     12** accordance with the Qt Commercial License Agreement provided with the
     13** Software or, alternatively, in accordance with the terms contained in
     14** a written agreement between you and Nokia.
    1415**
    1516** GNU Lesser General Public License Usage
     
    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$
    39 **
    40 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
    41 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
    4239**
    4340****************************************************************************/
     
    330327{
    331328    bool useMacToolbar = layoutState.mainWindow->unifiedTitleAndToolBarOnMac();
    332     if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
    333 #ifndef QT_MAC_USE_COCOA
    334         if (useMacToolbar) {
    335             ChangeWindowAttributes(qt_mac_window_for(layoutState.mainWindow),
    336                                    kWindowUnifiedTitleAndToolbarAttribute, 0);
    337         } else {
    338             ChangeWindowAttributes(qt_mac_window_for(layoutState.mainWindow),
    339                                    0, kWindowUnifiedTitleAndToolbarAttribute);
    340         }
    341 #endif
    342         macWindowToolbarShow(layoutState.mainWindow, useMacToolbar);
    343     }
     329#ifndef QT_MAC_USE_COCOA
     330    if (useMacToolbar) {
     331        ChangeWindowAttributes(qt_mac_window_for(layoutState.mainWindow),
     332                               kWindowUnifiedTitleAndToolbarAttribute, 0);
     333    } else {
     334        ChangeWindowAttributes(qt_mac_window_for(layoutState.mainWindow),
     335                               0, kWindowUnifiedTitleAndToolbarAttribute);
     336    }
     337#endif
    344338
    345339    layoutState.mainWindow->setUpdatesEnabled(false);  // reduces a little bit of flicker, not all though
    346340    if (!useMacToolbar) {
    347         OSWindowRef windowRef = qt_mac_window_for(parentWidget());
    348         macWindowToolbarShow(parentWidget(), false);
     341        macWindowToolbarShow(layoutState.mainWindow, false);
    349342        // Move everything out of the HIToolbar into the main toolbar.
    350343        while (!qtoolbarsInUnifiedToolbarList.isEmpty()) {
     
    352345            layoutState.mainWindow->addToolBar(Qt::TopToolBarArea, qtoolbarsInUnifiedToolbarList.first());
    353346        }
    354         macWindowToolbarSet(windowRef, NULL);
     347        macWindowToolbarSet(qt_mac_window_for(layoutState.mainWindow), 0);
    355348    } else {
    356349        QList<QToolBar *> toolbars = layoutState.mainWindow->findChildren<QToolBar *>();
     
    362355            }
    363356        }
     357        syncUnifiedToolbarVisibility();
    364358    }
    365359    layoutState.mainWindow->setUpdatesEnabled(true);
     
    442436    NSString *toolbarID = kQToolBarNSToolbarIdentifier;
    443437    toolbarID = [toolbarID stringByAppendingFormat:@"%p", toolbar];
    444     cocoaItemIDToToolbarHash.insert(QCFString::toQString(CFStringRef(toolbarID)), toolbar);
     438    cocoaItemIDToToolbarHash.insert(qt_mac_NSStringToQString(toolbarID), toolbar);
    445439    [macToolbar insertItemWithItemIdentifier:toolbarID atIndex:beforeIndex];
    446440#endif
     
    470464            [[qt_mac_window_for(layoutState.mainWindow->window()) toolbar]
    471465                removeItemAtIndex:toolbarItemsCopy.indexOf(item)];
    472             // In Carbon this hash and list gets emptied via events. In Cocoa, we have to do it ourselves here.
    473             it = unifiedToolbarHash.erase(it);
    474             qtoolbarsInUnifiedToolbarList.removeAll(toolbar);
    475466#endif
    476467            break;
     
    490481void QMainWindowLayout::fixSizeInUnifiedToolbar(QToolBar *tb) const
    491482{
     483#ifdef QT_MAC_USE_COCOA
    492484    QHash<void *, QToolBar *>::const_iterator it = unifiedToolbarHash.constBegin();
    493485    NSToolbarItem *item = nil;
     
    503495        QWidgetItem layoutItem(tb);
    504496        QSize size = layoutItem.maximumSize();
    505         NSSize nssize = NSMakeSize(size.width(), size.height());
     497        NSSize nssize = NSMakeSize(size.width(), size.height() - 2);
    506498        [item setMaxSize:nssize];
    507499        size = layoutItem.minimumSize();
    508500        nssize.width = size.width();
    509         nssize.height = size.height();
     501        nssize.height = size.height() - 2;
    510502        [item setMinSize:nssize];
    511503    }
    512 }
     504#else
     505    Q_UNUSED(tb);
     506#endif
     507}
     508
     509void QMainWindowLayout::syncUnifiedToolbarVisibility()
     510{
     511    if (blockVisiblityCheck)
     512        return;
     513
     514    Q_ASSERT(layoutState.mainWindow->unifiedTitleAndToolBarOnMac());
     515    bool show = false;
     516    const int ToolBarCount = qtoolbarsInUnifiedToolbarList.count();
     517    for (int i = 0; i < ToolBarCount; ++i) {
     518        if (qtoolbarsInUnifiedToolbarList.at(i)->isVisible()) {
     519            show = true;
     520            break;
     521        }
     522    }
     523    macWindowToolbarShow(layoutState.mainWindow, show);
     524}
     525
    513526QT_END_NAMESPACE
Note: See TracChangeset for help on using the changeset viewer.