changeset 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
files framework/MainWindowBase.cpp framework/MainWindowBase.h
diffstat 2 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Wed Aug 13 09:52:46 2014 +0100
+++ b/framework/MainWindowBase.cpp	Wed Aug 13 10:11:25 2014 +0100
@@ -277,9 +277,16 @@
 void
 MainWindowBase::finaliseMenus()
 {
+    cerr << "deleting mapper " << m_menuShortcutMapper << endl;
     delete m_menuShortcutMapper;
     m_menuShortcutMapper = 0;
 
+    foreach (QShortcut *sc, m_appShortcuts) {
+        cerr << "deleting shortcut " << sc << endl;
+        delete sc;
+    }
+    m_appShortcuts.clear();
+
     QMenuBar *mb = menuBar();
     QList<QMenu *> menus = mb->findChildren<QMenu *>();
     foreach (QMenu *menu, menus) {
@@ -349,8 +356,9 @@
             QShortcut *newSc = new QShortcut(sc, a->parentWidget());
             QObject::connect(newSc, SIGNAL(activated()),
                              m_menuShortcutMapper, SLOT(map()));
-            cerr << "setting mapping for action " << a << ", name " << a->text() << endl;
+            cerr << "setting mapping for action " << a << ", name " << a->text() << " on mapper " << m_menuShortcutMapper << " through shortcut " << newSc << endl;
             m_menuShortcutMapper->setMapping(newSc, a);
+            m_appShortcuts.push_back(newSc);
         }
     }
 #endif
@@ -359,6 +367,7 @@
 void
 MainWindowBase::menuActionMapperInvoked(QObject *o)
 {
+    cerr << "menuActionMapperInvoked from mapper " << sender() << endl;
     QAction *a = qobject_cast<QAction *>(o);
     if (a && a->isEnabled()) {
         cerr << "about to call trigger on action " << a << ", name " << a->text() << endl;
--- a/framework/MainWindowBase.h	Wed Aug 13 09:52:46 2014 +0100
+++ b/framework/MainWindowBase.h	Wed Aug 13 10:11:25 2014 +0100
@@ -60,6 +60,8 @@
 class KeyReference;
 class Labeller;
 class ModelDataTableDialog;
+class QSignalMapper;
+class QShortcut;
 
 /**
  * The base class for the SV main window.  This includes everything to
@@ -427,6 +429,8 @@
     // shortcuts on OS/X
     virtual void finaliseMenus();
     virtual void finaliseMenu(QMenu *);
+    QSignalMapper *m_menuShortcutMapper;
+    QList<QShortcut *> m_appShortcuts;
 
     virtual bool shouldCreateNewSessionForRDFAudio(bool *) { return true; }