comparison main/MainWindow.cpp @ 265:d55e4c0f7d9e

* Add playback controls to data edit dialog * Make data edit dialog close properly when layer is removed from view * More fixes to playback tracking & selection model in data edit dialog * Remove edit button from data edit dialog for now
author Chris Cannam
date Wed, 18 Jun 2008 15:53:23 +0000
parents 2b4a4b8c465a
children 52ef51ba9a74
comparison
equal deleted inserted replaced
264:15e6c49c759e 265:d55e4c0f7d9e
68 #include "widgets/CommandHistory.h" 68 #include "widgets/CommandHistory.h"
69 #include "base/Profiler.h" 69 #include "base/Profiler.h"
70 #include "base/Clipboard.h" 70 #include "base/Clipboard.h"
71 #include "base/UnitDatabase.h" 71 #include "base/UnitDatabase.h"
72 #include "layer/ColourDatabase.h" 72 #include "layer/ColourDatabase.h"
73 #include "widgets/ModelDataTableDialog.h"
73 74
74 // For version information 75 // For version information
75 #include "vamp/vamp.h" 76 #include "vamp/vamp.h"
76 #include "vamp-sdk/PluginBase.h" 77 #include "vamp-sdk/PluginBase.h"
77 #include "plugin/api/ladspa.h" 78 #include "plugin/api/ladspa.h"
129 m_rightButtonTransformsMenu(0), 130 m_rightButtonTransformsMenu(0),
130 m_rightButtonPlaybackMenu(0), 131 m_rightButtonPlaybackMenu(0),
131 m_soloAction(0), 132 m_soloAction(0),
132 m_soloModified(false), 133 m_soloModified(false),
133 m_prevSolo(false), 134 m_prevSolo(false),
135 m_rwdStartAction(0),
136 m_rwdAction(0),
134 m_ffwdAction(0), 137 m_ffwdAction(0),
135 m_rwdAction(0), 138 m_ffwdEndAction(0),
139 m_playAction(0),
140 m_playSelectionAction(0),
141 m_playLoopAction(0),
136 m_playControlsSpacer(0), 142 m_playControlsSpacer(0),
137 m_playControlsWidth(0), 143 m_playControlsWidth(0),
138 m_preferencesDialog(0), 144 m_preferencesDialog(0),
139 m_layerTreeDialog(0), 145 m_layerTreeDialog(0),
140 m_keyReference(new KeyReference()) 146 m_keyReference(new KeyReference())
1601 m_rightButtonMenu->addSeparator(); 1607 m_rightButtonMenu->addSeparator();
1602 m_rightButtonPlaybackMenu = m_rightButtonMenu->addMenu(tr("Playback")); 1608 m_rightButtonPlaybackMenu = m_rightButtonMenu->addMenu(tr("Playback"));
1603 1609
1604 QToolBar *toolbar = addToolBar(tr("Playback Toolbar")); 1610 QToolBar *toolbar = addToolBar(tr("Playback Toolbar"));
1605 1611
1606 QAction *rwdStartAction = toolbar->addAction(il.load("rewind-start"), 1612 m_rwdStartAction = toolbar->addAction(il.load("rewind-start"),
1607 tr("Rewind to Start")); 1613 tr("Rewind to Start"));
1608 rwdStartAction->setShortcut(tr("Home")); 1614 m_rwdStartAction->setShortcut(tr("Home"));
1609 rwdStartAction->setStatusTip(tr("Rewind to the start")); 1615 m_rwdStartAction->setStatusTip(tr("Rewind to the start"));
1610 connect(rwdStartAction, SIGNAL(triggered()), this, SLOT(rewindStart())); 1616 connect(m_rwdStartAction, SIGNAL(triggered()), this, SLOT(rewindStart()));
1611 connect(this, SIGNAL(canPlay(bool)), rwdStartAction, SLOT(setEnabled(bool))); 1617 connect(this, SIGNAL(canPlay(bool)), m_rwdStartAction, SLOT(setEnabled(bool)));
1612 1618
1613 QAction *m_rwdAction = toolbar->addAction(il.load("rewind"), 1619 m_rwdAction = toolbar->addAction(il.load("rewind"), tr("Rewind"));
1614 tr("Rewind"));
1615 m_rwdAction->setShortcut(tr("PgUp")); 1620 m_rwdAction->setShortcut(tr("PgUp"));
1616 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant or time ruler notch")); 1621 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant or time ruler notch"));
1617 connect(m_rwdAction, SIGNAL(triggered()), this, SLOT(rewind())); 1622 connect(m_rwdAction, SIGNAL(triggered()), this, SLOT(rewind()));
1618 connect(this, SIGNAL(canRewind(bool)), m_rwdAction, SLOT(setEnabled(bool))); 1623 connect(this, SIGNAL(canRewind(bool)), m_rwdAction, SLOT(setEnabled(bool)));
1619 1624
1620 QAction *playAction = toolbar->addAction(il.load("playpause"), 1625 m_playAction = toolbar->addAction(il.load("playpause"),
1621 tr("Play / Pause")); 1626 tr("Play / Pause"));
1622 playAction->setCheckable(true); 1627 m_playAction->setCheckable(true);
1623 playAction->setShortcut(tr("Space")); 1628 m_playAction->setShortcut(tr("Space"));
1624 playAction->setStatusTip(tr("Start or stop playback from the current position")); 1629 m_playAction->setStatusTip(tr("Start or stop playback from the current position"));
1625 connect(playAction, SIGNAL(triggered()), this, SLOT(play())); 1630 connect(m_playAction, SIGNAL(triggered()), this, SLOT(play()));
1626 connect(m_playSource, SIGNAL(playStatusChanged(bool)), 1631 connect(m_playSource, SIGNAL(playStatusChanged(bool)),
1627 playAction, SLOT(setChecked(bool))); 1632 m_playAction, SLOT(setChecked(bool)));
1628 connect(this, SIGNAL(canPlay(bool)), playAction, SLOT(setEnabled(bool))); 1633 connect(this, SIGNAL(canPlay(bool)), m_playAction, SLOT(setEnabled(bool)));
1629 1634
1630 m_ffwdAction = toolbar->addAction(il.load("ffwd"), 1635 m_ffwdAction = toolbar->addAction(il.load("ffwd"),
1631 tr("Fast Forward")); 1636 tr("Fast Forward"));
1632 m_ffwdAction->setShortcut(tr("PgDown")); 1637 m_ffwdAction->setShortcut(tr("PgDown"));
1633 m_ffwdAction->setStatusTip(tr("Fast-forward to the next time instant or time ruler notch")); 1638 m_ffwdAction->setStatusTip(tr("Fast-forward to the next time instant or time ruler notch"));
1634 connect(m_ffwdAction, SIGNAL(triggered()), this, SLOT(ffwd())); 1639 connect(m_ffwdAction, SIGNAL(triggered()), this, SLOT(ffwd()));
1635 connect(this, SIGNAL(canFfwd(bool)), m_ffwdAction, SLOT(setEnabled(bool))); 1640 connect(this, SIGNAL(canFfwd(bool)), m_ffwdAction, SLOT(setEnabled(bool)));
1636 1641
1637 QAction *ffwdEndAction = toolbar->addAction(il.load("ffwd-end"), 1642 m_ffwdEndAction = toolbar->addAction(il.load("ffwd-end"),
1638 tr("Fast Forward to End")); 1643 tr("Fast Forward to End"));
1639 ffwdEndAction->setShortcut(tr("End")); 1644 m_ffwdEndAction->setShortcut(tr("End"));
1640 ffwdEndAction->setStatusTip(tr("Fast-forward to the end")); 1645 m_ffwdEndAction->setStatusTip(tr("Fast-forward to the end"));
1641 connect(ffwdEndAction, SIGNAL(triggered()), this, SLOT(ffwdEnd())); 1646 connect(m_ffwdEndAction, SIGNAL(triggered()), this, SLOT(ffwdEnd()));
1642 connect(this, SIGNAL(canPlay(bool)), ffwdEndAction, SLOT(setEnabled(bool))); 1647 connect(this, SIGNAL(canPlay(bool)), m_ffwdEndAction, SLOT(setEnabled(bool)));
1643 1648
1644 toolbar = addToolBar(tr("Play Mode Toolbar")); 1649 toolbar = addToolBar(tr("Play Mode Toolbar"));
1645 1650
1646 QAction *psAction = toolbar->addAction(il.load("playselection"), 1651 m_playSelectionAction = toolbar->addAction(il.load("playselection"),
1647 tr("Constrain Playback to Selection")); 1652 tr("Constrain Playback to Selection"));
1648 psAction->setCheckable(true); 1653 m_playSelectionAction->setCheckable(true);
1649 psAction->setChecked(m_viewManager->getPlaySelectionMode()); 1654 m_playSelectionAction->setChecked(m_viewManager->getPlaySelectionMode());
1650 psAction->setShortcut(tr("s")); 1655 m_playSelectionAction->setShortcut(tr("s"));
1651 psAction->setStatusTip(tr("Constrain playback to the selected regions")); 1656 m_playSelectionAction->setStatusTip(tr("Constrain playback to the selected regions"));
1652 connect(m_viewManager, SIGNAL(playSelectionModeChanged(bool)), 1657 connect(m_viewManager, SIGNAL(playSelectionModeChanged(bool)),
1653 psAction, SLOT(setChecked(bool))); 1658 m_playSelectionAction, SLOT(setChecked(bool)));
1654 connect(psAction, SIGNAL(triggered()), this, SLOT(playSelectionToggled())); 1659 connect(m_playSelectionAction, SIGNAL(triggered()), this, SLOT(playSelectionToggled()));
1655 connect(this, SIGNAL(canPlaySelection(bool)), psAction, SLOT(setEnabled(bool))); 1660 connect(this, SIGNAL(canPlaySelection(bool)), m_playSelectionAction, SLOT(setEnabled(bool)));
1656 1661
1657 QAction *plAction = toolbar->addAction(il.load("playloop"), 1662 m_playLoopAction = toolbar->addAction(il.load("playloop"),
1658 tr("Loop Playback")); 1663 tr("Loop Playback"));
1659 plAction->setCheckable(true); 1664 m_playLoopAction->setCheckable(true);
1660 plAction->setChecked(m_viewManager->getPlayLoopMode()); 1665 m_playLoopAction->setChecked(m_viewManager->getPlayLoopMode());
1661 plAction->setShortcut(tr("l")); 1666 m_playLoopAction->setShortcut(tr("l"));
1662 plAction->setStatusTip(tr("Loop playback")); 1667 m_playLoopAction->setStatusTip(tr("Loop playback"));
1663 connect(m_viewManager, SIGNAL(playLoopModeChanged(bool)), 1668 connect(m_viewManager, SIGNAL(playLoopModeChanged(bool)),
1664 plAction, SLOT(setChecked(bool))); 1669 m_playLoopAction, SLOT(setChecked(bool)));
1665 connect(plAction, SIGNAL(triggered()), this, SLOT(playLoopToggled())); 1670 connect(m_playLoopAction, SIGNAL(triggered()), this, SLOT(playLoopToggled()));
1666 connect(this, SIGNAL(canPlay(bool)), plAction, SLOT(setEnabled(bool))); 1671 connect(this, SIGNAL(canPlay(bool)), m_playLoopAction, SLOT(setEnabled(bool)));
1667 1672
1668 m_soloAction = toolbar->addAction(il.load("solo"), 1673 m_soloAction = toolbar->addAction(il.load("solo"),
1669 tr("Solo Current Pane")); 1674 tr("Solo Current Pane"));
1670 m_soloAction->setCheckable(true); 1675 m_soloAction->setCheckable(true);
1671 m_soloAction->setChecked(m_viewManager->getPlaySoloMode()); 1676 m_soloAction->setChecked(m_viewManager->getPlaySoloMode());
1688 alAction, SLOT(setChecked(bool))); 1693 alAction, SLOT(setChecked(bool)));
1689 connect(alAction, SIGNAL(triggered()), this, SLOT(alignToggled())); 1694 connect(alAction, SIGNAL(triggered()), this, SLOT(alignToggled()));
1690 connect(this, SIGNAL(canAlign(bool)), alAction, SLOT(setEnabled(bool))); 1695 connect(this, SIGNAL(canAlign(bool)), alAction, SLOT(setEnabled(bool)));
1691 } 1696 }
1692 1697
1693 m_keyReference->registerShortcut(playAction); 1698 m_keyReference->registerShortcut(m_playAction);
1694 m_keyReference->registerShortcut(psAction); 1699 m_keyReference->registerShortcut(m_playSelectionAction);
1695 m_keyReference->registerShortcut(plAction); 1700 m_keyReference->registerShortcut(m_playLoopAction);
1696 m_keyReference->registerShortcut(m_soloAction); 1701 m_keyReference->registerShortcut(m_soloAction);
1697 if (alAction) m_keyReference->registerShortcut(alAction); 1702 if (alAction) m_keyReference->registerShortcut(alAction);
1698 m_keyReference->registerShortcut(m_rwdAction); 1703 m_keyReference->registerShortcut(m_rwdAction);
1699 m_keyReference->registerShortcut(m_ffwdAction); 1704 m_keyReference->registerShortcut(m_ffwdAction);
1700 m_keyReference->registerShortcut(rwdStartAction); 1705 m_keyReference->registerShortcut(m_rwdStartAction);
1701 m_keyReference->registerShortcut(ffwdEndAction); 1706 m_keyReference->registerShortcut(m_ffwdEndAction);
1702 1707
1703 menu->addAction(playAction); 1708 menu->addAction(m_playAction);
1704 menu->addAction(psAction); 1709 menu->addAction(m_playSelectionAction);
1705 menu->addAction(plAction); 1710 menu->addAction(m_playLoopAction);
1706 menu->addAction(m_soloAction); 1711 menu->addAction(m_soloAction);
1707 if (alAction) menu->addAction(alAction); 1712 if (alAction) menu->addAction(alAction);
1708 menu->addSeparator(); 1713 menu->addSeparator();
1709 menu->addAction(m_rwdAction); 1714 menu->addAction(m_rwdAction);
1710 menu->addAction(m_ffwdAction); 1715 menu->addAction(m_ffwdAction);
1711 menu->addSeparator(); 1716 menu->addSeparator();
1712 menu->addAction(rwdStartAction); 1717 menu->addAction(m_rwdStartAction);
1713 menu->addAction(ffwdEndAction); 1718 menu->addAction(m_ffwdEndAction);
1714 menu->addSeparator(); 1719 menu->addSeparator();
1715 1720
1716 m_rightButtonPlaybackMenu->addAction(playAction); 1721 m_rightButtonPlaybackMenu->addAction(m_playAction);
1717 m_rightButtonPlaybackMenu->addAction(psAction); 1722 m_rightButtonPlaybackMenu->addAction(m_playSelectionAction);
1718 m_rightButtonPlaybackMenu->addAction(plAction); 1723 m_rightButtonPlaybackMenu->addAction(m_playLoopAction);
1719 m_rightButtonPlaybackMenu->addAction(m_soloAction); 1724 m_rightButtonPlaybackMenu->addAction(m_soloAction);
1720 if (alAction) m_rightButtonPlaybackMenu->addAction(alAction); 1725 if (alAction) m_rightButtonPlaybackMenu->addAction(alAction);
1721 m_rightButtonPlaybackMenu->addSeparator(); 1726 m_rightButtonPlaybackMenu->addSeparator();
1722 m_rightButtonPlaybackMenu->addAction(m_rwdAction); 1727 m_rightButtonPlaybackMenu->addAction(m_rwdAction);
1723 m_rightButtonPlaybackMenu->addAction(m_ffwdAction); 1728 m_rightButtonPlaybackMenu->addAction(m_ffwdAction);
1724 m_rightButtonPlaybackMenu->addSeparator(); 1729 m_rightButtonPlaybackMenu->addSeparator();
1725 m_rightButtonPlaybackMenu->addAction(rwdStartAction); 1730 m_rightButtonPlaybackMenu->addAction(m_rwdStartAction);
1726 m_rightButtonPlaybackMenu->addAction(ffwdEndAction); 1731 m_rightButtonPlaybackMenu->addAction(m_ffwdEndAction);
1727 m_rightButtonPlaybackMenu->addSeparator(); 1732 m_rightButtonPlaybackMenu->addSeparator();
1728 1733
1729 QAction *fastAction = menu->addAction(tr("Speed Up")); 1734 QAction *fastAction = menu->addAction(tr("Speed Up"));
1730 fastAction->setShortcut(tr("Ctrl+PgUp")); 1735 fastAction->setShortcut(tr("Ctrl+PgUp"));
1731 fastAction->setStatusTip(tr("Time-stretch playback to speed it up without changing pitch")); 1736 fastAction->setStatusTip(tr("Time-stretch playback to speed it up without changing pitch"));
1812 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool))); 1817 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool)));
1813 group->addAction(action); 1818 group->addAction(action);
1814 m_keyReference->registerShortcut(action); 1819 m_keyReference->registerShortcut(action);
1815 m_toolActions[ViewManager::EraseMode] = action; 1820 m_toolActions[ViewManager::EraseMode] = action;
1816 1821
1817 action = toolbar->addAction(il.load("measure"), 1822 action = toolbar->addAction(il.load("measure"), tr("Measure"));
1818 tr("Measure"));
1819 action->setCheckable(true); 1823 action->setCheckable(true);
1820 action->setShortcut(tr("6")); 1824 action->setShortcut(tr("6"));
1821 action->setStatusTip(tr("Make measurements in layer")); 1825 action->setStatusTip(tr("Make measurements in layer"));
1822 connect(action, SIGNAL(triggered()), this, SLOT(toolMeasureSelected())); 1826 connect(action, SIGNAL(triggered()), this, SLOT(toolMeasureSelected()));
1823 connect(this, SIGNAL(canMeasureLayer(bool)), action, SLOT(setEnabled(bool))); 1827 connect(this, SIGNAL(canMeasureLayer(bool)), action, SLOT(setEnabled(bool)));
1826 m_toolActions[ViewManager::MeasureMode] = action; 1830 m_toolActions[ViewManager::MeasureMode] = action;
1827 1831
1828 toolNavigateSelected(); 1832 toolNavigateSelected();
1829 1833
1830 Pane::registerShortcuts(*m_keyReference); 1834 Pane::registerShortcuts(*m_keyReference);
1835 }
1836
1837 void
1838 MainWindow::connectLayerEditDialog(ModelDataTableDialog *dialog)
1839 {
1840 MainWindowBase::connectLayerEditDialog(dialog);
1841 QToolBar *toolbar = dialog->getPlayToolbar();
1842 if (toolbar) {
1843 toolbar->addAction(m_rwdStartAction);
1844 toolbar->addAction(m_rwdAction);
1845 toolbar->addAction(m_playAction);
1846 toolbar->addAction(m_ffwdAction);
1847 toolbar->addAction(m_ffwdEndAction);
1848 }
1831 } 1849 }
1832 1850
1833 void 1851 void
1834 MainWindow::updateMenuStates() 1852 MainWindow::updateMenuStates()
1835 { 1853 {