Mercurial > hg > svapp
comparison framework/MainWindowBase.cpp @ 443:345d41a3567f tonioni
Revisit menu items without shortcuts, now that fixes are arriving in Qt
author | Chris Cannam |
---|---|
date | Wed, 25 Mar 2015 11:01:18 +0000 |
parents | 7fa74786dec5 |
children | ba789baf642b |
comparison
equal
deleted
inserted
replaced
442:88ae0e53a5da | 443:345d41a3567f |
---|---|
343 // i.e. that will not otherwise work. The downside is that if this | 343 // i.e. that will not otherwise work. The downside is that if this |
344 // bug is fixed in a future Qt release, we will start getting | 344 // bug is fixed in a future Qt release, we will start getting |
345 // "ambiguous shortcut" errors from the menu entry actions and | 345 // "ambiguous shortcut" errors from the menu entry actions and |
346 // will need to update the code.) | 346 // will need to update the code.) |
347 | 347 |
348 // Update: The bug was fixed in Qt 5.4 for shortcuts with no | |
349 // modifier, and I believe it is fixed in Qt 5.5 for shortcuts | |
350 // with Shift modifiers. The below reflects that | |
351 | |
352 #if (QT_VERSION < QT_VERSION_CHECK(5, 5, 0)) | |
353 | |
348 if (!m_menuShortcutMapper) { | 354 if (!m_menuShortcutMapper) { |
349 m_menuShortcutMapper = new QSignalMapper(this); | 355 m_menuShortcutMapper = new QSignalMapper(this); |
350 connect(m_menuShortcutMapper, SIGNAL(mapped(QObject *)), | 356 connect(m_menuShortcutMapper, SIGNAL(mapped(QObject *)), |
351 this, SLOT(menuActionMapperInvoked(QObject *))); | 357 this, SLOT(menuActionMapperInvoked(QObject *))); |
352 } | 358 } |
372 | 378 |
373 // Note that the set of "single-key shortcuts" that aren't | 379 // Note that the set of "single-key shortcuts" that aren't |
374 // working and that we need to handle here includes those | 380 // working and that we need to handle here includes those |
375 // with the Shift modifier mask as well as those with no | 381 // with the Shift modifier mask as well as those with no |
376 // modifier at all | 382 // modifier at all |
383 #if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) | |
384 // Nothing needed | |
385 if (false) { | |
386 #elif (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)) | |
387 if (sc.count() == 1 && | |
388 (sc[0] & Qt::KeyboardModifierMask) == Qt::ShiftModifier) { | |
389 #else | |
377 if (sc.count() == 1 && | 390 if (sc.count() == 1 && |
378 ((sc[0] & Qt::KeyboardModifierMask) == Qt::NoModifier || | 391 ((sc[0] & Qt::KeyboardModifierMask) == Qt::NoModifier || |
379 (sc[0] & Qt::KeyboardModifierMask) == Qt::ShiftModifier)) { | 392 (sc[0] & Qt::KeyboardModifierMask) == Qt::ShiftModifier)) { |
393 #endif | |
380 QShortcut *newSc = new QShortcut(sc, a->parentWidget()); | 394 QShortcut *newSc = new QShortcut(sc, a->parentWidget()); |
381 QObject::connect(newSc, SIGNAL(activated()), | 395 QObject::connect(newSc, SIGNAL(activated()), |
382 m_menuShortcutMapper, SLOT(map())); | 396 m_menuShortcutMapper, SLOT(map())); |
383 m_menuShortcutMapper->setMapping(newSc, a); | 397 m_menuShortcutMapper->setMapping(newSc, a); |
384 m_appShortcuts.push_back(newSc); | 398 m_appShortcuts.push_back(newSc); |
385 } | 399 } |
386 } | 400 } |
387 } | 401 } |
402 #endif | |
388 #endif | 403 #endif |
389 } | 404 } |
390 | 405 |
391 void | 406 void |
392 MainWindowBase::menuActionMapperInvoked(QObject *o) | 407 MainWindowBase::menuActionMapperInvoked(QObject *o) |