Mercurial > hg > svapp
changeset 390:3e5c8a03bcb7
Associate the mapper with the MainWindowBase object, and recreate it each time we scan all menus -- allowing us to call finaliseMenus more than once if menu actions have changed
author | Chris Cannam |
---|---|
date | Wed, 13 Aug 2014 09:52:46 +0100 |
parents | 8cfc71c8ec4b |
children | 9e31759254fe |
files | framework/MainWindowBase.cpp |
diffstat | 1 files changed, 13 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp Wed Aug 13 09:09:16 2014 +0100 +++ b/framework/MainWindowBase.cpp Wed Aug 13 09:52:46 2014 +0100 @@ -155,7 +155,8 @@ m_lastPlayStatusSec(0), m_initialDarkBackground(false), m_defaultFfwdRwdStep(2, 0), - m_statusLabel(0) + m_statusLabel(0), + m_menuShortcutMapper(0) { Profiler profiler("MainWindowBase::MainWindowBase"); @@ -276,6 +277,9 @@ void MainWindowBase::finaliseMenus() { + delete m_menuShortcutMapper; + m_menuShortcutMapper = 0; + QMenuBar *mb = menuBar(); QList<QMenu *> menus = mb->findChildren<QMenu *>(); foreach (QMenu *menu, menus) { @@ -323,9 +327,11 @@ // "ambiguous shortcut" errors from the menu entry actions and // will need to update the code.) - QSignalMapper *mapper = new QSignalMapper(this); - - connect(mapper, SIGNAL(mapped(QObject *)), + if (!m_menuShortcutMapper) { + m_menuShortcutMapper = new QSignalMapper(this); + } + + connect(m_menuShortcutMapper, SIGNAL(mapped(QObject *)), this, SLOT(menuActionMapperInvoked(QObject *))); foreach (QAction *a, menu->actions()) { @@ -341,9 +347,10 @@ QKeySequence sc = a->shortcut(); if (sc.count() == 1 && !(sc[0] & Qt::KeyboardModifierMask)) { QShortcut *newSc = new QShortcut(sc, a->parentWidget()); - QObject::connect(newSc, SIGNAL(activated()), mapper, SLOT(map())); + QObject::connect(newSc, SIGNAL(activated()), + m_menuShortcutMapper, SLOT(map())); cerr << "setting mapping for action " << a << ", name " << a->text() << endl; - mapper->setMapping(newSc, a); + m_menuShortcutMapper->setMapping(newSc, a); } } #endif