diff main/MainWindow.cpp @ 206:b4167bb2d2d4

* Add Align button to main window; use it
author Chris Cannam
date Thu, 25 Oct 2007 15:45:12 +0000
parents 0511f41a7ba7
children bb7faed0b2be
line wrap: on
line diff
--- a/main/MainWindow.cpp	Thu Oct 25 11:32:54 2007 +0000
+++ b/main/MainWindow.cpp	Thu Oct 25 15:45:12 2007 +0000
@@ -1606,10 +1606,21 @@
     connect(soAction, SIGNAL(triggered()), this, SLOT(playSoloToggled()));
     connect(this, SIGNAL(canPlay(bool)), soAction, SLOT(setEnabled(bool)));
 
+    QAction *alAction = toolbar->addAction(il.load("align"),
+                                           tr("Align File Timelines"));
+    alAction->setCheckable(true);
+    alAction->setChecked(m_viewManager->getAlignMode());
+//!!!    alAction->setStatusTip(tr("Align audio files as   //!!!??? what?
+    connect(m_viewManager, SIGNAL(alignModeChanged(bool)),
+            alAction, SLOT(setChecked(bool)));
+    connect(alAction, SIGNAL(triggered()), this, SLOT(alignToggled()));
+    connect(this, SIGNAL(canAlign(bool)), alAction, SLOT(setEnabled(bool)));
+
     m_keyReference->registerShortcut(playAction);
     m_keyReference->registerShortcut(psAction);
     m_keyReference->registerShortcut(plAction);
     m_keyReference->registerShortcut(soAction);
+    m_keyReference->registerShortcut(alAction);
     m_keyReference->registerShortcut(m_rwdAction);
     m_keyReference->registerShortcut(m_ffwdAction);
     m_keyReference->registerShortcut(rwdStartAction);
@@ -1619,6 +1630,7 @@
     menu->addAction(psAction);
     menu->addAction(plAction);
     menu->addAction(soAction);
+    menu->addAction(alAction);
     menu->addSeparator();
     menu->addAction(m_rwdAction);
     menu->addAction(m_ffwdAction);
@@ -1631,6 +1643,7 @@
     m_rightButtonPlaybackMenu->addAction(psAction);
     m_rightButtonPlaybackMenu->addAction(plAction);
     m_rightButtonPlaybackMenu->addAction(soAction);
+    m_rightButtonPlaybackMenu->addAction(alAction);
     m_rightButtonPlaybackMenu->addSeparator();
     m_rightButtonPlaybackMenu->addAction(m_rwdAction);
     m_rightButtonPlaybackMenu->addAction(m_ffwdAction);
@@ -1756,6 +1769,8 @@
     bool haveCurrentLayer =
         (haveCurrentPane &&
          (currentLayer != 0));
+    bool havePlayTarget =
+	(m_playTarget != 0);
     bool haveSelection = 
 	(m_viewManager &&
 	 !m_viewManager->getSelections().empty());
@@ -1769,6 +1784,8 @@
 	(haveCurrentLayer &&
 	 dynamic_cast<TimeValueLayer *>(currentLayer));
 
+    emit canAlign(havePlayTarget); //!!! only if Match plugin present
+
     emit canChangePlaybackSpeed(true);
     int v = m_playSpeed->value();
     emit canSpeedUpPlayback(v < m_playSpeed->maximum());
@@ -2887,6 +2904,35 @@
 }
 
 void
+MainWindow::alignToggled()
+{
+    QAction *action = dynamic_cast<QAction *>(sender());
+    
+    if (action) {
+	m_viewManager->setAlignMode(action->isChecked());
+    } else {
+	m_viewManager->setAlignMode(!m_viewManager->getAlignMode());
+    }
+
+    if (m_viewManager->getAlignMode()) {
+        m_document->alignModels();
+        m_document->setAutoAlignment(true);
+    } else {
+        m_document->setAutoAlignment(false);
+    }
+
+    for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
+
+	Pane *pane = m_paneStack->getPane(i);
+	if (!pane) continue;
+
+        pane->update();
+    }
+
+    //!!! and need solo enabled
+}
+
+void
 MainWindow::playSpeedChanged(int position)
 {
     PlaySpeedRangeMapper mapper(0, 200);