diff main/MainWindow.cpp @ 217:69f83e36b8e5

* Add Erase tool and mode * Add icons for Normalize buttons in property boxes, and for Show Peaks * Add support for velocity in notes -- not yet reflected in display or editable in the note edit dialog, but they are imported from MIDI, played, and exported * Begin work on making pastes align pasted times (subtler than I thought)
author Chris Cannam
date Fri, 23 Nov 2007 16:48:23 +0000
parents 1fa0d271fd2c
children e6b581c7c246
line wrap: on
line diff
--- a/main/MainWindow.cpp	Thu Nov 22 14:13:20 2007 +0000
+++ b/main/MainWindow.cpp	Fri Nov 23 16:48:23 2007 +0000
@@ -1738,10 +1738,21 @@
     m_keyReference->registerShortcut(action);
     m_toolActions[ViewManager::DrawMode] = action;
 
+    action = toolbar->addAction(il.load("erase"),
+				tr("Erase"));
+    action->setCheckable(true);
+    action->setShortcut(tr("5"));
+    action->setStatusTip(tr("Erase items from layer"));
+    connect(action, SIGNAL(triggered()), this, SLOT(toolEraseSelected()));
+    connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
+    group->addAction(action);
+    m_keyReference->registerShortcut(action);
+    m_toolActions[ViewManager::EraseMode] = action;
+
     action = toolbar->addAction(il.load("measure"),
 				tr("Measure"));
     action->setCheckable(true);
-    action->setShortcut(tr("5"));
+    action->setShortcut(tr("6"));
     action->setStatusTip(tr("Make measurements in layer"));
     connect(action, SIGNAL(triggered()), this, SLOT(toolMeasureSelected()));
     connect(this, SIGNAL(canMeasureLayer(bool)), action, SLOT(setEnabled(bool)));
@@ -1749,14 +1760,6 @@
     m_keyReference->registerShortcut(action);
     m_toolActions[ViewManager::MeasureMode] = action;
 
-//    action = toolbar->addAction(il.load("text"),
-//				tr("Text"));
-//    action->setCheckable(true);
-//    action->setShortcut(tr("5"));
-//    connect(action, SIGNAL(triggered()), this, SLOT(toolTextSelected()));
-//    group->addAction(action);
-//    m_toolActions[ViewManager::TextMode] = action;
-
     toolNavigateSelected();
 
     Pane::registerShortcuts(*m_keyReference);
@@ -1899,17 +1902,17 @@
 }
 
 void
+MainWindow::toolEraseSelected()
+{
+    m_viewManager->setToolMode(ViewManager::EraseMode);
+}
+
+void
 MainWindow::toolMeasureSelected()
 {
     m_viewManager->setToolMode(ViewManager::MeasureMode);
 }
 
-//void
-//MainWindow::toolTextSelected()
-//{
-//    m_viewManager->setToolMode(ViewManager::TextMode);
-//}
-
 void
 MainWindow::importAudio()
 {
@@ -2824,15 +2827,19 @@
 	if (emptyTypes.find(type) != emptyTypes.end()) {
 
 	    newLayer = m_document->createEmptyLayer(type);
-	    m_toolActions[ViewManager::DrawMode]->trigger();
+            if (newLayer) {
+                m_toolActions[ViewManager::DrawMode]->trigger();
+            }
 
 	} else {
 
 	    newLayer = m_document->createMainModelLayer(type);
 	}
 
-	m_document->addLayerToView(pane, newLayer);
-	m_paneStack->setCurrentLayer(pane, newLayer);
+        if (newLayer) {
+            m_document->addLayerToView(pane, newLayer);
+            m_paneStack->setCurrentLayer(pane, newLayer);
+        }
 
 	return;
     }