Mercurial > hg > svapp
comparison framework/MainWindowBase.cpp @ 391:9e31759254fe
Attempt to get rebuilt-shortcuts working on OS/X (unsuccessfully)
author | Chris Cannam |
---|---|
date | Wed, 13 Aug 2014 10:11:25 +0100 |
parents | 3e5c8a03bcb7 |
children | 75af0658be84 |
comparison
equal
deleted
inserted
replaced
390:3e5c8a03bcb7 | 391:9e31759254fe |
---|---|
275 } | 275 } |
276 | 276 |
277 void | 277 void |
278 MainWindowBase::finaliseMenus() | 278 MainWindowBase::finaliseMenus() |
279 { | 279 { |
280 cerr << "deleting mapper " << m_menuShortcutMapper << endl; | |
280 delete m_menuShortcutMapper; | 281 delete m_menuShortcutMapper; |
281 m_menuShortcutMapper = 0; | 282 m_menuShortcutMapper = 0; |
283 | |
284 foreach (QShortcut *sc, m_appShortcuts) { | |
285 cerr << "deleting shortcut " << sc << endl; | |
286 delete sc; | |
287 } | |
288 m_appShortcuts.clear(); | |
282 | 289 |
283 QMenuBar *mb = menuBar(); | 290 QMenuBar *mb = menuBar(); |
284 QList<QMenu *> menus = mb->findChildren<QMenu *>(); | 291 QList<QMenu *> menus = mb->findChildren<QMenu *>(); |
285 foreach (QMenu *menu, menus) { | 292 foreach (QMenu *menu, menus) { |
286 if (menu) finaliseMenu(menu); | 293 if (menu) finaliseMenu(menu); |
347 QKeySequence sc = a->shortcut(); | 354 QKeySequence sc = a->shortcut(); |
348 if (sc.count() == 1 && !(sc[0] & Qt::KeyboardModifierMask)) { | 355 if (sc.count() == 1 && !(sc[0] & Qt::KeyboardModifierMask)) { |
349 QShortcut *newSc = new QShortcut(sc, a->parentWidget()); | 356 QShortcut *newSc = new QShortcut(sc, a->parentWidget()); |
350 QObject::connect(newSc, SIGNAL(activated()), | 357 QObject::connect(newSc, SIGNAL(activated()), |
351 m_menuShortcutMapper, SLOT(map())); | 358 m_menuShortcutMapper, SLOT(map())); |
352 cerr << "setting mapping for action " << a << ", name " << a->text() << endl; | 359 cerr << "setting mapping for action " << a << ", name " << a->text() << " on mapper " << m_menuShortcutMapper << " through shortcut " << newSc << endl; |
353 m_menuShortcutMapper->setMapping(newSc, a); | 360 m_menuShortcutMapper->setMapping(newSc, a); |
361 m_appShortcuts.push_back(newSc); | |
354 } | 362 } |
355 } | 363 } |
356 #endif | 364 #endif |
357 } | 365 } |
358 | 366 |
359 void | 367 void |
360 MainWindowBase::menuActionMapperInvoked(QObject *o) | 368 MainWindowBase::menuActionMapperInvoked(QObject *o) |
361 { | 369 { |
370 cerr << "menuActionMapperInvoked from mapper " << sender() << endl; | |
362 QAction *a = qobject_cast<QAction *>(o); | 371 QAction *a = qobject_cast<QAction *>(o); |
363 if (a && a->isEnabled()) { | 372 if (a && a->isEnabled()) { |
364 cerr << "about to call trigger on action " << a << ", name " << a->text() << endl; | 373 cerr << "about to call trigger on action " << a << ", name " << a->text() << endl; |
365 a->trigger(); | 374 a->trigger(); |
366 } | 375 } |