diff options
author | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2010-05-04 11:59:27 (GMT) |
---|---|---|
committer | Qt Commercial Integration <QtCommercial@digia.com> | 2012-01-31 10:24:49 (GMT) |
commit | 2aa4384cca06ea84ba6edf77c6a2d65c8800a7b3 (patch) | |
tree | 9eff41d818828fb90732100a6dd7a66b7d2881ba /src/gui/widgets | |
parent | bd42cec380ea2f5a91632377111edced7edac901 (diff) | |
download | Qt-2aa4384cca06ea84ba6edf77c6a2d65c8800a7b3.zip Qt-2aa4384cca06ea84ba6edf77c6a2d65c8800a7b3.tar.gz Qt-2aa4384cca06ea84ba6edf77c6a2d65c8800a7b3.tar.bz2 |
Cocoa: QShortcut(Qt::Key_Enter) does not show in the menu bar
The reason is that cocoa expects the unicode control character for
"enter", rather than the glyph showing an arrow. So rather than
using the glyph-table from QKeySequence, we should use a table
containing a mapping from Qt::Key to Cocoa control key. Luckily,
such a table exists allready in qt_cocoa_helpers, but reversed (
cocoa key to Qt::Key). So this patch creates a function that
binds all this together.
Reviewed-by: cduclos
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/qmenu_mac.mm | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 9f7b130..014c6aa 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -1254,15 +1254,11 @@ QMenuPrivate::QMacMenuPrivate::addAction(QMacMenuAction *action, QMacMenuAction NSString *keySequenceToKeyEqivalent(const QKeySequence &accel) { quint32 accel_key = (accel[0] & ~(Qt::MODIFIER_MASK | Qt::UNICODE_ACCEL)); - extern QChar qt_macSymbolForQtKey(int key); // qkeysequence.cpp - QChar keyEquiv = qt_macSymbolForQtKey(accel_key); - if (keyEquiv.isNull()) { - if (accel_key >= Qt::Key_F1 && accel_key <= Qt::Key_F15) - keyEquiv = (accel_key - Qt::Key_F1) + NSF1FunctionKey; - else - keyEquiv = unichar(QChar(accel_key).toLower().unicode()); - } - return [NSString stringWithCharacters:&keyEquiv.unicode() length:1]; + extern QChar qtKey2CocoaKey(Qt::Key key); + QChar cocoa_key = qtKey2CocoaKey(Qt::Key(accel_key)); + if (cocoa_key.isNull()) + cocoa_key = QChar(accel_key).toLower().unicode(); + return [NSString stringWithCharacters:&cocoa_key.unicode() length:1]; } // return the cocoa modifier mask for the QKeySequence (currently only looks at the first one). |