Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 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/qcocoamenu_mac.mm

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4747#include <private/qt_cocoa_helpers_mac_p.h>
    4848#include <private/qapplication_p.h>
     49#include <private/qaction_p.h>
    4950
    5051#include <QtGui/QMenu>
     
    7172    if (self) {
    7273        qmenu = menu;
     74        previousAction = 0;
    7375        [self setAutoenablesItems:NO];
    7476        [self setDelegate:self];
     
    8284
    8385    if (!item) {
    84         // ### According to the docs everything will be highlighted. Not sure what we should do in
    85         // Qt, so just return.
     86        if (previousAction) {
     87            qt_mac_clear_status_text(previousAction);
     88            previousAction = 0;
     89        }
    8690        return;
    8791    }
    8892
    89     if (QAction *action = reinterpret_cast<QAction *>([item tag]))
     93    if (QAction *action = reinterpret_cast<QAction *>([item tag])) {
     94        QMenu *qtmenu = static_cast<QT_MANGLE_NAMESPACE(QCocoaMenu) *>(menu)->qmenu;
     95        previousAction = action;
    9096        action->activate(QAction::Hover);
     97        qt_mac_menu_emit_hovered(qtmenu, action);
     98        action->showStatusText(0); // 0 widget -> action's parent
     99    }
    91100}
    92101
     
    101110}
    102111
    103 - (void)menuWillClose:(NSMenu*)menu;
     112- (void)menuDidClose:(NSMenu*)menu;
    104113{
    105114    qt_mac_emit_menuSignals(((QT_MANGLE_NAMESPACE(QCocoaMenu) *)menu)->qmenu, false);
     115    if (previousAction) {
     116        qt_mac_clear_status_text(previousAction);
     117        previousAction = 0;
     118    }
    106119}
    107120
     
    176189}
    177190
     191- (NSInteger)indexOfItemWithTarget:(id)anObject andAction:(SEL)actionSelector
     192{
     193     NSInteger index = [super indexOfItemWithTarget:anObject andAction:actionSelector];
     194     static SEL selForOFCP = NSSelectorFromString(@"orderFrontCharacterPalette:");
     195     if (index == -1 && selForOFCP == actionSelector) {
     196         // Check if the 'orderFrontCharacterPalette' SEL exists for QCocoaMenuLoader object
     197         QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
     198         return [super indexOfItemWithTarget:loader andAction:actionSelector];
     199     }
     200     return index;
     201}
     202
    178203@end
    179204
     
    195220    qt_mac_menus_open_count += delta;
    196221}
     222
     223void qt_mac_clear_status_text(QAction *action)
     224{
     225    action->d_func()->showStatusText(0, QString());
     226}
     227
     228void qt_mac_menu_emit_hovered(QMenu *menu, QAction *action)
     229{
     230    emit menu->hovered(action);
     231}
     232
     233
    197234QT_END_NAMESPACE
    198235
Note: See TracChangeset for help on using the changeset viewer.