comparison main/MainWindow.cpp @ 163:652b22dcd4ed

* Add mouse actions to key and mouse reference dialog * Use QDialogButtonBox in all dialogs, for proper button ordering across platforms (requires Qt 4.2) * Fix #1733610 program does not exit if preferences dialog visible on close
author Chris Cannam
date Thu, 05 Jul 2007 11:07:01 +0000
parents 9c9bce6440f5
children 75cafe7a9246
comparison
equal deleted inserted replaced
162:9c9bce6440f5 163:652b22dcd4ed
329 delete m_playTarget; 329 delete m_playTarget;
330 delete m_playSource; 330 delete m_playSource;
331 delete m_viewManager; 331 delete m_viewManager;
332 delete m_oscQueue; 332 delete m_oscQueue;
333 delete m_keyReference; 333 delete m_keyReference;
334 delete m_preferencesDialog;
334 Profiles::getInstance()->dump(); 335 Profiles::getInstance()->dump();
335 } 336 }
336 337
337 QString 338 QString
338 MainWindow::getOpenFileName(FileFinder::FileType type) 339 MainWindow::getOpenFileName(FileFinder::FileType type)
689 this, SLOT(insertInstant())); 690 this, SLOT(insertInstant()));
690 m_keyReference->registerAlternativeShortcut(action, shortcut); 691 m_keyReference->registerAlternativeShortcut(action, shortcut);
691 692
692 action = new QAction(tr("Insert Instants at Selection &Boundaries"), this); 693 action = new QAction(tr("Insert Instants at Selection &Boundaries"), this);
693 action->setShortcut(tr("Shift+Enter")); 694 action->setShortcut(tr("Shift+Enter"));
694 action->setStatusTip(tr("Insert new time instants at the start and end of the current selection, in a new layer if necessary")); 695 action->setStatusTip(tr("Insert new time instants at the start and end of the current selected regions, in a new layer if necessary"));
695 connect(action, SIGNAL(triggered()), this, SLOT(insertInstantsAtBoundaries())); 696 connect(action, SIGNAL(triggered()), this, SLOT(insertInstantsAtBoundaries()));
696 connect(this, SIGNAL(canInsertInstantsAtBoundaries(bool)), action, SLOT(setEnabled(bool))); 697 connect(this, SIGNAL(canInsertInstantsAtBoundaries(bool)), action, SLOT(setEnabled(bool)));
697 m_keyReference->registerShortcut(action); 698 m_keyReference->registerShortcut(action);
698 menu->addAction(action); 699 menu->addAction(action);
699 } 700 }
1125 1126
1126 if (isDefault) { 1127 if (isDefault) {
1127 action = new QAction(icon, actionText, this); 1128 action = new QAction(icon, actionText, this);
1128 if (!model || model == getMainModel()) { 1129 if (!model || model == getMainModel()) {
1129 action->setShortcut(shortcutText); 1130 action->setShortcut(shortcutText);
1130 m_keyReference->registerShortcut(action);
1131 } 1131 }
1132 } else { 1132 } else {
1133 action = new QAction(actionText, this); 1133 action = new QAction(actionText, this);
1134 } 1134 }
1135 1135
1191 setupExistingLayersMenus(); 1191 setupExistingLayersMenus();
1192 1192
1193 m_rightButtonLayerMenu->addSeparator(); 1193 m_rightButtonLayerMenu->addSeparator();
1194 menu->addSeparator(); 1194 menu->addSeparator();
1195 1195
1196 action = new QAction(tr("&Rename Layer..."), this); 1196 QAction *raction = new QAction(tr("&Rename Layer..."), this);
1197 action->setShortcut(tr("R")); 1197 raction->setShortcut(tr("R"));
1198 action->setStatusTip(tr("Rename the currently active layer")); 1198 raction->setStatusTip(tr("Rename the currently active layer"));
1199 connect(action, SIGNAL(triggered()), this, SLOT(renameCurrentLayer())); 1199 connect(raction, SIGNAL(triggered()), this, SLOT(renameCurrentLayer()));
1200 connect(this, SIGNAL(canRenameLayer(bool)), action, SLOT(setEnabled(bool))); 1200 connect(this, SIGNAL(canRenameLayer(bool)), raction, SLOT(setEnabled(bool)));
1201 m_keyReference->registerShortcut(action); 1201 menu->addAction(raction);
1202 menu->addAction(action); 1202 m_rightButtonLayerMenu->addAction(raction);
1203 m_rightButtonLayerMenu->addAction(action);
1204 1203
1205 action = new QAction(QIcon(":/icons/editdelete.png"), tr("&Delete Layer"), this); 1204 action = new QAction(QIcon(":/icons/editdelete.png"), tr("&Delete Layer"), this);
1206 action->setShortcut(tr("Ctrl+D")); 1205 action->setShortcut(tr("Ctrl+D"));
1207 action->setStatusTip(tr("Delete the currently active layer")); 1206 action->setStatusTip(tr("Delete the currently active layer"));
1208 connect(action, SIGNAL(triggered()), this, SLOT(deleteCurrentLayer())); 1207 connect(action, SIGNAL(triggered()), this, SLOT(deleteCurrentLayer()));
1209 connect(this, SIGNAL(canDeleteCurrentLayer(bool)), action, SLOT(setEnabled(bool))); 1208 connect(this, SIGNAL(canDeleteCurrentLayer(bool)), action, SLOT(setEnabled(bool)));
1210 m_keyReference->registerShortcut(action); 1209 m_keyReference->registerShortcut(action);
1211 menu->addAction(action); 1210 menu->addAction(action);
1212 m_rightButtonLayerMenu->addAction(action); 1211 m_rightButtonLayerMenu->addAction(action);
1212
1213 m_keyReference->registerShortcut(raction); // rename after delete, so delete layer goes next to delete pane
1213 } 1214 }
1214 1215
1215 void 1216 void
1216 MainWindow::setupTransformsMenu() 1217 MainWindow::setupTransformsMenu()
1217 { 1218 {
1434 action = new QAction(tr("Sonic Visualiser on the &Web"), this); 1435 action = new QAction(tr("Sonic Visualiser on the &Web"), this);
1435 action->setStatusTip(tr("Open the Sonic Visualiser website")); 1436 action->setStatusTip(tr("Open the Sonic Visualiser website"));
1436 connect(action, SIGNAL(triggered()), this, SLOT(website())); 1437 connect(action, SIGNAL(triggered()), this, SLOT(website()));
1437 menu->addAction(action); 1438 menu->addAction(action);
1438 1439
1439 action = new QAction(tr("&Key Reference"), this); 1440 action = new QAction(tr("&Key and Mouse Reference"), this);
1440 action->setShortcut(tr("F2")); 1441 action->setShortcut(tr("F2"));
1441 action->setStatusTip(tr("Open a window showing the keystrokes you can use in Sonic Visualiser")); 1442 action->setStatusTip(tr("Open a window showing the keystrokes you can use in Sonic Visualiser"));
1442 connect(action, SIGNAL(triggered()), this, SLOT(keyReference())); 1443 connect(action, SIGNAL(triggered()), this, SLOT(keyReference()));
1443 m_keyReference->registerShortcut(action); 1444 m_keyReference->registerShortcut(action);
1444 menu->addAction(action); 1445 menu->addAction(action);
1458 QAction *action = new QAction(files[i], this); 1459 QAction *action = new QAction(files[i], this);
1459 connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile())); 1460 connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile()));
1460 if (i == 0) { 1461 if (i == 0) {
1461 action->setShortcut(tr("Ctrl+R")); 1462 action->setShortcut(tr("Ctrl+R"));
1462 m_keyReference->registerShortcut 1463 m_keyReference->registerShortcut
1463 (action, tr("Re-open the most recently opened file")); 1464 (tr("Re-open"),
1465 action->shortcut(),
1466 tr("Re-open the current or most recently opened file"));
1464 } 1467 }
1465 m_recentFilesMenu->addAction(action); 1468 m_recentFilesMenu->addAction(action);
1466 } 1469 }
1467 } 1470 }
1468 1471
1481 continue; 1484 continue;
1482 } 1485 }
1483 if (i == 0) { 1486 if (i == 0) {
1484 ti->second->setShortcut(tr("Ctrl+T")); 1487 ti->second->setShortcut(tr("Ctrl+T"));
1485 m_keyReference->registerShortcut 1488 m_keyReference->registerShortcut
1486 (tr("Re-run the most recently run transform"), 1489 (tr("Repeat Transform"),
1487 ti->second->shortcut(), 1490 ti->second->shortcut(),
1488 ""); 1491 tr("Re-select the most recently run transform"));
1489 } 1492 }
1490 m_recentTransformsMenu->addAction(ti->second); 1493 m_recentTransformsMenu->addAction(ti->second);
1491 } 1494 }
1492 } 1495 }
1493 1496
1589 connect(this, SIGNAL(canPlay(bool)), rwdStartAction, SLOT(setEnabled(bool))); 1592 connect(this, SIGNAL(canPlay(bool)), rwdStartAction, SLOT(setEnabled(bool)));
1590 1593
1591 QAction *m_rwdAction = toolbar->addAction(QIcon(":/icons/rewind.png"), 1594 QAction *m_rwdAction = toolbar->addAction(QIcon(":/icons/rewind.png"),
1592 tr("Rewind")); 1595 tr("Rewind"));
1593 m_rwdAction->setShortcut(tr("PgUp")); 1596 m_rwdAction->setShortcut(tr("PgUp"));
1597 m_rwdAction->setStatusTip(tr("Rewind to the previous time instant or time ruler notch"));
1594 connect(m_rwdAction, SIGNAL(triggered()), this, SLOT(rewind())); 1598 connect(m_rwdAction, SIGNAL(triggered()), this, SLOT(rewind()));
1595 connect(this, SIGNAL(canRewind(bool)), m_rwdAction, SLOT(setEnabled(bool))); 1599 connect(this, SIGNAL(canRewind(bool)), m_rwdAction, SLOT(setEnabled(bool)));
1596 1600
1597 QAction *playAction = toolbar->addAction(QIcon(":/icons/playpause.png"), 1601 QAction *playAction = toolbar->addAction(QIcon(":/icons/playpause.png"),
1598 tr("Play / Pause")); 1602 tr("Play / Pause"));
1605 connect(this, SIGNAL(canPlay(bool)), playAction, SLOT(setEnabled(bool))); 1609 connect(this, SIGNAL(canPlay(bool)), playAction, SLOT(setEnabled(bool)));
1606 1610
1607 m_ffwdAction = toolbar->addAction(QIcon(":/icons/ffwd.png"), 1611 m_ffwdAction = toolbar->addAction(QIcon(":/icons/ffwd.png"),
1608 tr("Fast Forward")); 1612 tr("Fast Forward"));
1609 m_ffwdAction->setShortcut(tr("PgDown")); 1613 m_ffwdAction->setShortcut(tr("PgDown"));
1614 m_ffwdAction->setStatusTip(tr("Fast-forward to the next time instant or time ruler notch"));
1610 connect(m_ffwdAction, SIGNAL(triggered()), this, SLOT(ffwd())); 1615 connect(m_ffwdAction, SIGNAL(triggered()), this, SLOT(ffwd()));
1611 connect(this, SIGNAL(canFfwd(bool)), m_ffwdAction, SLOT(setEnabled(bool))); 1616 connect(this, SIGNAL(canFfwd(bool)), m_ffwdAction, SLOT(setEnabled(bool)));
1612 1617
1613 QAction *ffwdEndAction = toolbar->addAction(QIcon(":/icons/ffwd-end.png"), 1618 QAction *ffwdEndAction = toolbar->addAction(QIcon(":/icons/ffwd-end.png"),
1614 tr("Fast Forward to End")); 1619 tr("Fast Forward to End"));
1622 QAction *psAction = toolbar->addAction(QIcon(":/icons/playselection.png"), 1627 QAction *psAction = toolbar->addAction(QIcon(":/icons/playselection.png"),
1623 tr("Constrain Playback to Selection")); 1628 tr("Constrain Playback to Selection"));
1624 psAction->setCheckable(true); 1629 psAction->setCheckable(true);
1625 psAction->setChecked(m_viewManager->getPlaySelectionMode()); 1630 psAction->setChecked(m_viewManager->getPlaySelectionMode());
1626 psAction->setShortcut(tr("s")); 1631 psAction->setShortcut(tr("s"));
1627 psAction->setStatusTip(tr("Constrain playback to the selected area")); 1632 psAction->setStatusTip(tr("Constrain playback to the selected regions"));
1628 connect(m_viewManager, SIGNAL(playSelectionModeChanged(bool)), 1633 connect(m_viewManager, SIGNAL(playSelectionModeChanged(bool)),
1629 psAction, SLOT(setChecked(bool))); 1634 psAction, SLOT(setChecked(bool)));
1630 connect(psAction, SIGNAL(triggered()), this, SLOT(playSelectionToggled())); 1635 connect(psAction, SIGNAL(triggered()), this, SLOT(playSelectionToggled()));
1631 connect(this, SIGNAL(canPlaySelection(bool)), psAction, SLOT(setEnabled(bool))); 1636 connect(this, SIGNAL(canPlaySelection(bool)), psAction, SLOT(setEnabled(bool)));
1632 1637
1671 m_rightButtonPlaybackMenu->addAction(ffwdEndAction); 1676 m_rightButtonPlaybackMenu->addAction(ffwdEndAction);
1672 m_rightButtonPlaybackMenu->addSeparator(); 1677 m_rightButtonPlaybackMenu->addSeparator();
1673 1678
1674 QAction *fastAction = menu->addAction(tr("Speed Up")); 1679 QAction *fastAction = menu->addAction(tr("Speed Up"));
1675 fastAction->setShortcut(tr("Ctrl+PgUp")); 1680 fastAction->setShortcut(tr("Ctrl+PgUp"));
1681 fastAction->setStatusTip(tr("Time-stretch playback to speed it up without changing pitch"));
1676 connect(fastAction, SIGNAL(triggered()), this, SLOT(speedUpPlayback())); 1682 connect(fastAction, SIGNAL(triggered()), this, SLOT(speedUpPlayback()));
1677 connect(this, SIGNAL(canSpeedUpPlayback(bool)), fastAction, SLOT(setEnabled(bool))); 1683 connect(this, SIGNAL(canSpeedUpPlayback(bool)), fastAction, SLOT(setEnabled(bool)));
1678 1684
1679 QAction *slowAction = menu->addAction(tr("Slow Down")); 1685 QAction *slowAction = menu->addAction(tr("Slow Down"));
1680 slowAction->setShortcut(tr("Ctrl+PgDown")); 1686 slowAction->setShortcut(tr("Ctrl+PgDown"));
1687 slowAction->setStatusTip(tr("Time-stretch playback to slow it down without changing pitch"));
1681 connect(slowAction, SIGNAL(triggered()), this, SLOT(slowDownPlayback())); 1688 connect(slowAction, SIGNAL(triggered()), this, SLOT(slowDownPlayback()));
1682 connect(this, SIGNAL(canSlowDownPlayback(bool)), slowAction, SLOT(setEnabled(bool))); 1689 connect(this, SIGNAL(canSlowDownPlayback(bool)), slowAction, SLOT(setEnabled(bool)));
1683 1690
1684 QAction *normalAction = menu->addAction(tr("Restore Normal Speed")); 1691 QAction *normalAction = menu->addAction(tr("Restore Normal Speed"));
1685 normalAction->setShortcut(tr("Ctrl+Home")); 1692 normalAction->setShortcut(tr("Ctrl+Home"));
1693 normalAction->setStatusTip(tr("Restore non-time-stretched playback"));
1686 connect(normalAction, SIGNAL(triggered()), this, SLOT(restoreNormalPlayback())); 1694 connect(normalAction, SIGNAL(triggered()), this, SLOT(restoreNormalPlayback()));
1687 connect(this, SIGNAL(canChangePlaybackSpeed(bool)), normalAction, SLOT(setEnabled(bool))); 1695 connect(this, SIGNAL(canChangePlaybackSpeed(bool)), normalAction, SLOT(setEnabled(bool)));
1688 1696
1689 m_keyReference->registerShortcut(fastAction); 1697 m_keyReference->registerShortcut(fastAction);
1690 m_keyReference->registerShortcut(slowAction); 1698 m_keyReference->registerShortcut(slowAction);
1762 // connect(action, SIGNAL(triggered()), this, SLOT(toolTextSelected())); 1770 // connect(action, SIGNAL(triggered()), this, SLOT(toolTextSelected()));
1763 // group->addAction(action); 1771 // group->addAction(action);
1764 // m_toolActions[ViewManager::TextMode] = action; 1772 // m_toolActions[ViewManager::TextMode] = action;
1765 1773
1766 toolNavigateSelected(); 1774 toolNavigateSelected();
1775
1776 Pane::registerShortcuts(*m_keyReference);
1767 } 1777 }
1768 1778
1769 void 1779 void
1770 MainWindow::updateMenuStates() 1780 MainWindow::updateMenuStates()
1771 { 1781 {
3121 settings.beginGroup("MainWindow"); 3131 settings.beginGroup("MainWindow");
3122 settings.setValue("size", size()); 3132 settings.setValue("size", size());
3123 settings.setValue("position", pos()); 3133 settings.setValue("position", pos());
3124 settings.endGroup(); 3134 settings.endGroup();
3125 3135
3136 delete m_keyReference;
3137 m_keyReference = 0;
3138
3139 closeSession();
3140 if (m_preferencesDialog &&
3141 m_preferencesDialog->isVisible()) {
3142 m_preferencesDialog->applicationClosing(false);
3143 }
3144
3126 e->accept(); 3145 e->accept();
3127 return; 3146 return;
3128 } 3147 }
3129 3148
3130 bool 3149 bool
3131 MainWindow::commitData(bool mayAskUser) 3150 MainWindow::commitData(bool mayAskUser)
3132 { 3151 {
3133 if (mayAskUser) { 3152 if (mayAskUser) {
3134 return checkSaveModified(); 3153 bool rv = checkSaveModified();
3154 if (rv) {
3155 if (m_preferencesDialog &&
3156 m_preferencesDialog->isVisible()) {
3157 m_preferencesDialog->applicationClosing(false);
3158 }
3159 }
3160 return rv;
3135 } else { 3161 } else {
3162 if (m_preferencesDialog &&
3163 m_preferencesDialog->isVisible()) {
3164 m_preferencesDialog->applicationClosing(true);
3165 }
3136 if (!m_documentModified) return true; 3166 if (!m_documentModified) return true;
3137 3167
3138 // If we can't check with the user first, then we can't save 3168 // If we can't check with the user first, then we can't save
3139 // to the original session file (even if we have it) -- have 3169 // to the original session file (even if we have it) -- have
3140 // to use a temporary file 3170 // to use a temporary file