Mercurial > hg > sonic-visualiser
comparison main/MainWindow.cpp @ 1770:893f556cd5c9
Untabify
author | Chris Cannam |
---|---|
date | Thu, 01 Mar 2018 18:02:33 +0000 |
parents | 076aca59192f |
children | b660b2fa8411 |
comparison
equal
deleted
inserted
replaced
1769:0698743f52a4 | 1770:893f556cd5c9 |
---|---|
247 m_playSpeed->setObjectName(tr("Playback Speed")); | 247 m_playSpeed->setObjectName(tr("Playback Speed")); |
248 m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper); | 248 m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper); |
249 m_playSpeed->setDefaultValue(60); | 249 m_playSpeed->setDefaultValue(60); |
250 m_playSpeed->setShowToolTip(true); | 250 m_playSpeed->setShowToolTip(true); |
251 connect(m_playSpeed, SIGNAL(valueChanged(int)), | 251 connect(m_playSpeed, SIGNAL(valueChanged(int)), |
252 this, SLOT(playSpeedChanged(int))); | 252 this, SLOT(playSpeedChanged(int))); |
253 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | 253 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); |
254 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | 254 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); |
255 | 255 |
256 m_mainLevelPan = new LevelPanToolButton(frame); | 256 m_mainLevelPan = new LevelPanToolButton(frame); |
257 connect(m_mainLevelPan, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | 257 connect(m_mainLevelPan, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); |
388 // if the user is running any desktop environment other than Unity | 388 // if the user is running any desktop environment other than Unity |
389 // (in which the faux single-menubar appears). The user has a | 389 // (in which the faux single-menubar appears). The user has a |
390 // workaround, to remove the appmenu-qt5 package, but that is | 390 // workaround, to remove the appmenu-qt5 package, but that is |
391 // awkward and the problem is so severe that it merits disabling | 391 // awkward and the problem is so severe that it merits disabling |
392 // the system menubar integration altogether. Like this: | 392 // the system menubar integration altogether. Like this: |
393 menuBar()->setNativeMenuBar(false); // fix #1039 | 393 menuBar()->setNativeMenuBar(false); // fix #1039 |
394 #endif | 394 #endif |
395 | 395 |
396 m_rightButtonMenu = new QMenu(); | 396 m_rightButtonMenu = new QMenu(); |
397 | 397 |
398 // We don't want tear-off enabled on the right-button menu. | 398 // We don't want tear-off enabled on the right-button menu. |
551 connect(action, SIGNAL(triggered()), this, SLOT(saveSession())); | 551 connect(action, SIGNAL(triggered()), this, SLOT(saveSession())); |
552 connect(this, SIGNAL(canSave(bool)), action, SLOT(setEnabled(bool))); | 552 connect(this, SIGNAL(canSave(bool)), action, SLOT(setEnabled(bool))); |
553 m_keyReference->registerShortcut(action); | 553 m_keyReference->registerShortcut(action); |
554 menu->addAction(action); | 554 menu->addAction(action); |
555 toolbar->addAction(action); | 555 toolbar->addAction(action); |
556 | 556 |
557 icon = il.load("filesaveas"); | 557 icon = il.load("filesaveas"); |
558 action = new QAction(icon, tr("Save Session &As..."), this); | 558 action = new QAction(icon, tr("Save Session &As..."), this); |
559 action->setShortcut(tr("Ctrl+Shift+S")); | 559 action->setShortcut(tr("Ctrl+Shift+S")); |
560 action->setStatusTip(tr("Save the current session into a new %1 session file").arg(QApplication::applicationName())); | 560 action->setStatusTip(tr("Save the current session into a new %1 session file").arg(QApplication::applicationName())); |
561 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionAs())); | 561 connect(action, SIGNAL(triggered()), this, SLOT(saveSessionAs())); |
657 | 657 |
658 action = new QAction(tr("&Preferences..."), this); | 658 action = new QAction(tr("&Preferences..."), this); |
659 action->setStatusTip(tr("Adjust the application preferences")); | 659 action->setStatusTip(tr("Adjust the application preferences")); |
660 connect(action, SIGNAL(triggered()), this, SLOT(preferences())); | 660 connect(action, SIGNAL(triggered()), this, SLOT(preferences())); |
661 menu->addAction(action); | 661 menu->addAction(action); |
662 | 662 |
663 menu->addSeparator(); | 663 menu->addSeparator(); |
664 action = new QAction(il.load("exit"), | 664 action = new QAction(il.load("exit"), |
665 tr("&Quit"), this); | 665 tr("&Quit"), this); |
666 action->setShortcut(tr("Ctrl+Q")); | 666 action->setShortcut(tr("Ctrl+Q")); |
667 action->setStatusTip(tr("Exit %1").arg(QApplication::applicationName())); | 667 action->setStatusTip(tr("Exit %1").arg(QApplication::applicationName())); |
744 connect(action, SIGNAL(triggered()), this, SLOT(selectAll())); | 744 connect(action, SIGNAL(triggered()), this, SLOT(selectAll())); |
745 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool))); | 745 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool))); |
746 m_keyReference->registerShortcut(action); | 746 m_keyReference->registerShortcut(action); |
747 menu->addAction(action); | 747 menu->addAction(action); |
748 m_rightButtonMenu->addAction(action); | 748 m_rightButtonMenu->addAction(action); |
749 | 749 |
750 action = new QAction(tr("Select &Visible Range"), this); | 750 action = new QAction(tr("Select &Visible Range"), this); |
751 action->setShortcut(tr("Ctrl+Shift+A")); | 751 action->setShortcut(tr("Ctrl+Shift+A")); |
752 action->setStatusTip(tr("Select the time range corresponding to the current window width")); | 752 action->setStatusTip(tr("Select the time range corresponding to the current window width")); |
753 connect(action, SIGNAL(triggered()), this, SLOT(selectVisible())); | 753 connect(action, SIGNAL(triggered()), this, SLOT(selectVisible())); |
754 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool))); | 754 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool))); |
755 m_keyReference->registerShortcut(action); | 755 m_keyReference->registerShortcut(action); |
756 menu->addAction(action); | 756 menu->addAction(action); |
757 | 757 |
758 action = new QAction(tr("Select to &Start"), this); | 758 action = new QAction(tr("Select to &Start"), this); |
759 action->setShortcut(tr("Shift+Left")); | 759 action->setShortcut(tr("Shift+Left")); |
760 action->setStatusTip(tr("Select from the start of the session to the current playback position")); | 760 action->setStatusTip(tr("Select from the start of the session to the current playback position")); |
761 connect(action, SIGNAL(triggered()), this, SLOT(selectToStart())); | 761 connect(action, SIGNAL(triggered()), this, SLOT(selectToStart())); |
762 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool))); | 762 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool))); |
763 m_keyReference->registerShortcut(action); | 763 m_keyReference->registerShortcut(action); |
764 menu->addAction(action); | 764 menu->addAction(action); |
765 | 765 |
766 action = new QAction(tr("Select to &End"), this); | 766 action = new QAction(tr("Select to &End"), this); |
767 action->setShortcut(tr("Shift+Right")); | 767 action->setShortcut(tr("Shift+Right")); |
768 action->setStatusTip(tr("Select from the current playback position to the end of the session")); | 768 action->setStatusTip(tr("Select from the current playback position to the end of the session")); |
769 connect(action, SIGNAL(triggered()), this, SLOT(selectToEnd())); | 769 connect(action, SIGNAL(triggered()), this, SLOT(selectToEnd())); |
770 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool))); | 770 connect(this, SIGNAL(canSelect(bool)), action, SLOT(setEnabled(bool))); |
908 m_scrollLeftAction->setStatusTip(tr("Scroll the current pane to the left")); | 908 m_scrollLeftAction->setStatusTip(tr("Scroll the current pane to the left")); |
909 connect(m_scrollLeftAction, SIGNAL(triggered()), this, SLOT(scrollLeft())); | 909 connect(m_scrollLeftAction, SIGNAL(triggered()), this, SLOT(scrollLeft())); |
910 connect(this, SIGNAL(canScroll(bool)), m_scrollLeftAction, SLOT(setEnabled(bool))); | 910 connect(this, SIGNAL(canScroll(bool)), m_scrollLeftAction, SLOT(setEnabled(bool))); |
911 m_keyReference->registerShortcut(m_scrollLeftAction); | 911 m_keyReference->registerShortcut(m_scrollLeftAction); |
912 menu->addAction(m_scrollLeftAction); | 912 menu->addAction(m_scrollLeftAction); |
913 | 913 |
914 m_scrollRightAction = new QAction(tr("Scroll &Right"), this); | 914 m_scrollRightAction = new QAction(tr("Scroll &Right"), this); |
915 m_scrollRightAction->setShortcut(tr("Right")); | 915 m_scrollRightAction->setShortcut(tr("Right")); |
916 m_scrollRightAction->setStatusTip(tr("Scroll the current pane to the right")); | 916 m_scrollRightAction->setStatusTip(tr("Scroll the current pane to the right")); |
917 connect(m_scrollRightAction, SIGNAL(triggered()), this, SLOT(scrollRight())); | 917 connect(m_scrollRightAction, SIGNAL(triggered()), this, SLOT(scrollRight())); |
918 connect(this, SIGNAL(canScroll(bool)), m_scrollRightAction, SLOT(setEnabled(bool))); | 918 connect(this, SIGNAL(canScroll(bool)), m_scrollRightAction, SLOT(setEnabled(bool))); |
919 m_keyReference->registerShortcut(m_scrollRightAction); | 919 m_keyReference->registerShortcut(m_scrollRightAction); |
920 menu->addAction(m_scrollRightAction); | 920 menu->addAction(m_scrollRightAction); |
921 | 921 |
922 action = new QAction(tr("&Jump Left"), this); | 922 action = new QAction(tr("&Jump Left"), this); |
923 action->setShortcut(tr("Ctrl+Left")); | 923 action->setShortcut(tr("Ctrl+Left")); |
924 action->setStatusTip(tr("Scroll the current pane a big step to the left")); | 924 action->setStatusTip(tr("Scroll the current pane a big step to the left")); |
925 connect(action, SIGNAL(triggered()), this, SLOT(jumpLeft())); | 925 connect(action, SIGNAL(triggered()), this, SLOT(jumpLeft())); |
926 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); | 926 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); |
927 m_keyReference->registerShortcut(action); | 927 m_keyReference->registerShortcut(action); |
928 menu->addAction(action); | 928 menu->addAction(action); |
929 | 929 |
930 action = new QAction(tr("J&ump Right"), this); | 930 action = new QAction(tr("J&ump Right"), this); |
931 action->setShortcut(tr("Ctrl+Right")); | 931 action->setShortcut(tr("Ctrl+Right")); |
932 action->setStatusTip(tr("Scroll the current pane a big step to the right")); | 932 action->setStatusTip(tr("Scroll the current pane a big step to the right")); |
933 connect(action, SIGNAL(triggered()), this, SLOT(jumpRight())); | 933 connect(action, SIGNAL(triggered()), this, SLOT(jumpRight())); |
934 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); | 934 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); |
940 action->setStatusTip(tr("Scroll the current pane to the left without moving the playback cursor or other panes")); | 940 action->setStatusTip(tr("Scroll the current pane to the left without moving the playback cursor or other panes")); |
941 connect(action, SIGNAL(triggered()), this, SLOT(peekLeft())); | 941 connect(action, SIGNAL(triggered()), this, SLOT(peekLeft())); |
942 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); | 942 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); |
943 m_keyReference->registerShortcut(action); | 943 m_keyReference->registerShortcut(action); |
944 menu->addAction(action); | 944 menu->addAction(action); |
945 | 945 |
946 action = new QAction(tr("Peek Right"), this); | 946 action = new QAction(tr("Peek Right"), this); |
947 action->setShortcut(tr("Alt+Right")); | 947 action->setShortcut(tr("Alt+Right")); |
948 action->setStatusTip(tr("Scroll the current pane to the right without moving the playback cursor or other panes")); | 948 action->setStatusTip(tr("Scroll the current pane to the right without moving the playback cursor or other panes")); |
949 connect(action, SIGNAL(triggered()), this, SLOT(peekRight())); | 949 connect(action, SIGNAL(triggered()), this, SLOT(peekRight())); |
950 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); | 950 connect(this, SIGNAL(canScroll(bool)), action, SLOT(setEnabled(bool))); |
961 m_zoomInAction->setStatusTip(tr("Increase the zoom level")); | 961 m_zoomInAction->setStatusTip(tr("Increase the zoom level")); |
962 connect(m_zoomInAction, SIGNAL(triggered()), this, SLOT(zoomIn())); | 962 connect(m_zoomInAction, SIGNAL(triggered()), this, SLOT(zoomIn())); |
963 connect(this, SIGNAL(canZoom(bool)), m_zoomInAction, SLOT(setEnabled(bool))); | 963 connect(this, SIGNAL(canZoom(bool)), m_zoomInAction, SLOT(setEnabled(bool))); |
964 m_keyReference->registerShortcut(m_zoomInAction); | 964 m_keyReference->registerShortcut(m_zoomInAction); |
965 menu->addAction(m_zoomInAction); | 965 menu->addAction(m_zoomInAction); |
966 | 966 |
967 m_zoomOutAction = new QAction(il.load("zoom-out"), | 967 m_zoomOutAction = new QAction(il.load("zoom-out"), |
968 tr("Zoom &Out"), this); | 968 tr("Zoom &Out"), this); |
969 m_zoomOutAction->setShortcut(tr("Down")); | 969 m_zoomOutAction->setShortcut(tr("Down")); |
970 m_zoomOutAction->setStatusTip(tr("Decrease the zoom level")); | 970 m_zoomOutAction->setStatusTip(tr("Decrease the zoom level")); |
971 connect(m_zoomOutAction, SIGNAL(triggered()), this, SLOT(zoomOut())); | 971 connect(m_zoomOutAction, SIGNAL(triggered()), this, SLOT(zoomOut())); |
972 connect(this, SIGNAL(canZoom(bool)), m_zoomOutAction, SLOT(setEnabled(bool))); | 972 connect(this, SIGNAL(canZoom(bool)), m_zoomOutAction, SLOT(setEnabled(bool))); |
973 m_keyReference->registerShortcut(m_zoomOutAction); | 973 m_keyReference->registerShortcut(m_zoomOutAction); |
974 menu->addAction(m_zoomOutAction); | 974 menu->addAction(m_zoomOutAction); |
975 | 975 |
976 action = new QAction(tr("Restore &Default Zoom"), this); | 976 action = new QAction(tr("Restore &Default Zoom"), this); |
977 action->setStatusTip(tr("Restore the zoom level to the default")); | 977 action->setStatusTip(tr("Restore the zoom level to the default")); |
978 connect(action, SIGNAL(triggered()), this, SLOT(zoomDefault())); | 978 connect(action, SIGNAL(triggered()), this, SLOT(zoomDefault())); |
979 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool))); | 979 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool))); |
980 menu->addAction(action); | 980 menu->addAction(action); |
1115 | 1115 |
1116 void | 1116 void |
1117 MainWindow::setupPaneAndLayerMenus() | 1117 MainWindow::setupPaneAndLayerMenus() |
1118 { | 1118 { |
1119 if (m_paneMenu) { | 1119 if (m_paneMenu) { |
1120 m_paneActions.clear(); | 1120 m_paneActions.clear(); |
1121 m_paneMenu->clear(); | 1121 m_paneMenu->clear(); |
1122 } else { | 1122 } else { |
1123 m_paneMenu = menuBar()->addMenu(tr("&Pane")); | 1123 m_paneMenu = menuBar()->addMenu(tr("&Pane")); |
1124 m_paneMenu->setTearOffEnabled(true); | 1124 m_paneMenu->setTearOffEnabled(true); |
1125 } | 1125 } |
1126 | 1126 |
1127 if (m_layerMenu) { | 1127 if (m_layerMenu) { |
1128 m_layerActions.clear(); | 1128 m_layerActions.clear(); |
1129 m_layerMenu->clear(); | 1129 m_layerMenu->clear(); |
1130 } else { | 1130 } else { |
1131 m_layerMenu = menuBar()->addMenu(tr("&Layer")); | 1131 m_layerMenu = menuBar()->addMenu(tr("&Layer")); |
1132 m_layerMenu->setTearOffEnabled(true); | 1132 m_layerMenu->setTearOffEnabled(true); |
1133 } | 1133 } |
1134 | 1134 |
1135 if (m_rightButtonLayerMenu) { | 1135 if (m_rightButtonLayerMenu) { |
1136 m_rightButtonLayerMenu->clear(); | 1136 m_rightButtonLayerMenu->clear(); |
1160 menu = m_layerMenu; | 1160 menu = m_layerMenu; |
1161 | 1161 |
1162 // menu->addSeparator(); | 1162 // menu->addSeparator(); |
1163 | 1163 |
1164 LayerFactory::LayerTypeSet emptyLayerTypes = | 1164 LayerFactory::LayerTypeSet emptyLayerTypes = |
1165 LayerFactory::getInstance()->getValidEmptyLayerTypes(); | 1165 LayerFactory::getInstance()->getValidEmptyLayerTypes(); |
1166 | 1166 |
1167 for (LayerFactory::LayerTypeSet::iterator i = emptyLayerTypes.begin(); | 1167 for (LayerFactory::LayerTypeSet::iterator i = emptyLayerTypes.begin(); |
1168 i != emptyLayerTypes.end(); ++i) { | 1168 i != emptyLayerTypes.end(); ++i) { |
1169 | 1169 |
1170 QIcon icon; | 1170 QIcon icon; |
1171 QString mainText, tipText, channelText; | 1171 QString mainText, tipText, channelText; |
1172 LayerFactory::LayerType type = *i; | 1172 LayerFactory::LayerType type = *i; |
1173 QString name = LayerFactory::getInstance()->getLayerPresentationName(type); | 1173 QString name = LayerFactory::getInstance()->getLayerPresentationName(type); |
1174 | 1174 |
1175 icon = il.load(LayerFactory::getInstance()->getLayerIconName(type)); | 1175 icon = il.load(LayerFactory::getInstance()->getLayerIconName(type)); |
1176 | 1176 |
1177 mainText = tr("Add New %1 Layer").arg(name); | 1177 mainText = tr("Add New %1 Layer").arg(name); |
1178 tipText = tr("Add a new empty layer of type %1").arg(name); | 1178 tipText = tr("Add a new empty layer of type %1").arg(name); |
1179 | 1179 |
1180 action = new QAction(icon, mainText, this); | 1180 action = new QAction(icon, mainText, this); |
1181 action->setStatusTip(tipText); | 1181 action->setStatusTip(tipText); |
1182 | 1182 |
1183 if (type == LayerFactory::Text) { | 1183 if (type == LayerFactory::Text) { |
1184 action->setShortcut(tr("T")); | 1184 action->setShortcut(tr("T")); |
1185 m_keyReference->registerShortcut(action); | 1185 m_keyReference->registerShortcut(action); |
1186 } | 1186 } |
1187 | 1187 |
1188 connect(action, SIGNAL(triggered()), this, SLOT(addLayer())); | 1188 connect(action, SIGNAL(triggered()), this, SLOT(addLayer())); |
1189 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool))); | 1189 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool))); |
1190 m_layerActions[action] = LayerConfiguration(type); | 1190 m_layerActions[action] = LayerConfiguration(type); |
1191 menu->addAction(action); | 1191 menu->addAction(action); |
1192 m_rightButtonLayerMenu->addAction(action); | 1192 m_rightButtonLayerMenu->addAction(action); |
1193 } | 1193 } |
1194 | 1194 |
1195 m_rightButtonLayerMenu->addSeparator(); | 1195 m_rightButtonLayerMenu->addSeparator(); |
1196 menu->addSeparator(); | 1196 menu->addSeparator(); |
1197 | 1197 |
1198 LayerFactory::LayerType backgroundTypes[] = { | 1198 LayerFactory::LayerType backgroundTypes[] = { |
1199 LayerFactory::Waveform, | 1199 LayerFactory::Waveform, |
1200 LayerFactory::Spectrogram, | 1200 LayerFactory::Spectrogram, |
1201 LayerFactory::MelodicRangeSpectrogram, | 1201 LayerFactory::MelodicRangeSpectrogram, |
1202 LayerFactory::PeakFrequencySpectrogram, | 1202 LayerFactory::PeakFrequencySpectrogram, |
1203 LayerFactory::Spectrum | 1203 LayerFactory::Spectrum |
1204 }; | 1204 }; |
1205 | 1205 |
1206 std::vector<Model *> models; | 1206 std::vector<Model *> models; |
1207 if (m_document) models = m_document->getTransformInputModels(); | 1207 if (m_document) models = m_document->getTransformInputModels(); |
1209 if (models.empty()) { | 1209 if (models.empty()) { |
1210 models.push_back(getMainModel()); // probably 0 | 1210 models.push_back(getMainModel()); // probably 0 |
1211 } | 1211 } |
1212 | 1212 |
1213 for (unsigned int i = 0; | 1213 for (unsigned int i = 0; |
1214 i < sizeof(backgroundTypes)/sizeof(backgroundTypes[0]); ++i) { | 1214 i < sizeof(backgroundTypes)/sizeof(backgroundTypes[0]); ++i) { |
1215 | 1215 |
1216 const int paneMenuType = 0, layerMenuType = 1; | 1216 const int paneMenuType = 0, layerMenuType = 1; |
1217 | 1217 |
1218 for (int menuType = paneMenuType; menuType <= layerMenuType; ++menuType) { | 1218 for (int menuType = paneMenuType; menuType <= layerMenuType; ++menuType) { |
1219 | 1219 |
1220 if (menuType == paneMenuType) menu = m_paneMenu; | 1220 if (menuType == paneMenuType) menu = m_paneMenu; |
1221 else menu = m_layerMenu; | 1221 else menu = m_layerMenu; |
1222 | 1222 |
1223 QMenu *submenu = 0; | 1223 QMenu *submenu = 0; |
1224 | 1224 |
1225 QIcon icon; | 1225 QIcon icon; |
1226 QString mainText, shortcutText, tipText, channelText; | 1226 QString mainText, shortcutText, tipText, channelText; |
1227 LayerFactory::LayerType type = backgroundTypes[i]; | 1227 LayerFactory::LayerType type = backgroundTypes[i]; |
1228 bool mono = true; | 1228 bool mono = true; |
1246 shortcutText = tr("Shift+W"); | 1246 shortcutText = tr("Shift+W"); |
1247 tipText = tr("Add a new layer showing a waveform view"); | 1247 tipText = tr("Add a new layer showing a waveform view"); |
1248 } | 1248 } |
1249 mono = false; | 1249 mono = false; |
1250 break; | 1250 break; |
1251 | 1251 |
1252 case LayerFactory::Spectrogram: | 1252 case LayerFactory::Spectrogram: |
1253 icon = il.load("spectrogram"); | 1253 icon = il.load("spectrogram"); |
1254 mainText = tr("Add Spectro&gram"); | 1254 mainText = tr("Add Spectro&gram"); |
1255 if (menuType == paneMenuType) { | 1255 if (menuType == paneMenuType) { |
1256 shortcutText = tr("G"); | 1256 shortcutText = tr("G"); |
1258 } else { | 1258 } else { |
1259 shortcutText = tr("Shift+G"); | 1259 shortcutText = tr("Shift+G"); |
1260 tipText = tr("Add a new layer showing a spectrogram"); | 1260 tipText = tr("Add a new layer showing a spectrogram"); |
1261 } | 1261 } |
1262 break; | 1262 break; |
1263 | 1263 |
1264 case LayerFactory::MelodicRangeSpectrogram: | 1264 case LayerFactory::MelodicRangeSpectrogram: |
1265 icon = il.load("spectrogram"); | 1265 icon = il.load("spectrogram"); |
1266 mainText = tr("Add &Melodic Range Spectrogram"); | 1266 mainText = tr("Add &Melodic Range Spectrogram"); |
1267 if (menuType == paneMenuType) { | 1267 if (menuType == paneMenuType) { |
1268 shortcutText = tr("M"); | 1268 shortcutText = tr("M"); |
1270 } else { | 1270 } else { |
1271 shortcutText = tr("Shift+M"); | 1271 shortcutText = tr("Shift+M"); |
1272 tipText = tr("Add a new layer showing a spectrogram set up for an overview of note pitches"); | 1272 tipText = tr("Add a new layer showing a spectrogram set up for an overview of note pitches"); |
1273 } | 1273 } |
1274 break; | 1274 break; |
1275 | 1275 |
1276 case LayerFactory::PeakFrequencySpectrogram: | 1276 case LayerFactory::PeakFrequencySpectrogram: |
1277 icon = il.load("spectrogram"); | 1277 icon = il.load("spectrogram"); |
1278 mainText = tr("Add Pea&k Frequency Spectrogram"); | 1278 mainText = tr("Add Pea&k Frequency Spectrogram"); |
1279 if (menuType == paneMenuType) { | 1279 if (menuType == paneMenuType) { |
1280 shortcutText = tr("K"); | 1280 shortcutText = tr("K"); |
1419 connect(this, SIGNAL(canAddLayer(bool)), | 1419 connect(this, SIGNAL(canAddLayer(bool)), |
1420 action, SLOT(setEnabled(bool))); | 1420 action, SLOT(setEnabled(bool))); |
1421 m_layerActions[action] = LayerConfiguration(type, 0, 0); | 1421 m_layerActions[action] = LayerConfiguration(type, 0, 0); |
1422 m_rightButtonLayerMenu->addAction(action); | 1422 m_rightButtonLayerMenu->addAction(action); |
1423 } | 1423 } |
1424 } | 1424 } |
1425 } | 1425 } |
1426 } | 1426 } |
1427 } | 1427 } |
1428 | 1428 |
1429 m_rightButtonLayerMenu->addSeparator(); | 1429 m_rightButtonLayerMenu->addSeparator(); |
1430 | 1430 |
1431 menu = m_paneMenu; | 1431 menu = m_paneMenu; |
1536 if (m_transformsMenu) { | 1536 if (m_transformsMenu) { |
1537 m_transformActions.clear(); | 1537 m_transformActions.clear(); |
1538 m_transformActionsReverse.clear(); | 1538 m_transformActionsReverse.clear(); |
1539 m_transformsMenu->clear(); | 1539 m_transformsMenu->clear(); |
1540 } else { | 1540 } else { |
1541 m_transformsMenu = menuBar()->addMenu(tr("&Transform")); | 1541 m_transformsMenu = menuBar()->addMenu(tr("&Transform")); |
1542 m_transformsMenu->setTearOffEnabled(true); | 1542 m_transformsMenu->setTearOffEnabled(true); |
1543 m_transformsMenu->setSeparatorsCollapsible(true); | 1543 m_transformsMenu->setSeparatorsCollapsible(true); |
1544 } | 1544 } |
1545 | 1545 |
1546 TransformFactory *factory = TransformFactory::getInstance(); | 1546 TransformFactory *factory = TransformFactory::getInstance(); |
1669 seenNames.insert(name); | 1669 seenNames.insert(name); |
1670 } | 1670 } |
1671 } | 1671 } |
1672 | 1672 |
1673 for (unsigned int i = 0; i < transforms.size(); ++i) { | 1673 for (unsigned int i = 0; i < transforms.size(); ++i) { |
1674 | 1674 |
1675 QString name = transforms[i].name; | 1675 QString name = transforms[i].name; |
1676 if (name == "") name = transforms[i].identifier; | 1676 if (name == "") name = transforms[i].identifier; |
1677 | 1677 |
1678 // cerr << "Plugin Name: " << name << endl; | 1678 // cerr << "Plugin Name: " << name << endl; |
1679 | 1679 |
1680 TransformDescription::Type type = transforms[i].type; | 1680 TransformDescription::Type type = transforms[i].type; |
1681 QString typeStr = factory->getTransformTypeName(type); | 1681 QString typeStr = factory->getTransformTypeName(type); |
1698 else name = QString("%1: %2") | 1698 else name = QString("%1: %2") |
1699 .arg(pluginName) | 1699 .arg(pluginName) |
1700 .arg(output); | 1700 .arg(output); |
1701 } | 1701 } |
1702 | 1702 |
1703 QAction *action = new QAction(tr("%1...").arg(name), this); | 1703 QAction *action = new QAction(tr("%1...").arg(name), this); |
1704 connect(action, SIGNAL(triggered()), this, SLOT(addLayer())); | 1704 connect(action, SIGNAL(triggered()), this, SLOT(addLayer())); |
1705 m_transformActions[action] = transforms[i].identifier; | 1705 m_transformActions[action] = transforms[i].identifier; |
1706 m_transformActionsReverse[transforms[i].identifier] = action; | 1706 m_transformActionsReverse[transforms[i].identifier] = action; |
1707 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool))); | 1707 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool))); |
1708 | 1708 |
1709 action->setStatusTip(transforms[i].longDescription); | 1709 action->setStatusTip(transforms[i].longDescription); |
1710 | 1710 |
1711 if (categoryMenus[type].find(category) == categoryMenus[type].end()) { | 1711 if (categoryMenus[type].find(category) == categoryMenus[type].end()) { |
1712 cerr << "WARNING: MainWindow::setupMenus: Internal error: " | 1712 cerr << "WARNING: MainWindow::setupMenus: Internal error: " |
1836 m_keyReference->registerShortcut | 1836 m_keyReference->registerShortcut |
1837 (tr("Re-open"), | 1837 (tr("Re-open"), |
1838 action->shortcut().toString(), | 1838 action->shortcut().toString(), |
1839 tr("Re-open the current or most recently opened file")); | 1839 tr("Re-open the current or most recently opened file")); |
1840 } | 1840 } |
1841 m_recentFilesMenu->addAction(action); | 1841 m_recentFilesMenu->addAction(action); |
1842 } | 1842 } |
1843 } | 1843 } |
1844 | 1844 |
1845 void | 1845 void |
1846 MainWindow::setupTemplatesMenu() | 1846 MainWindow::setupTemplatesMenu() |
1914 ti->second->shortcut().toString(), | 1914 ti->second->shortcut().toString(), |
1915 tr("Re-select the most recently run transform")); | 1915 tr("Re-select the most recently run transform")); |
1916 } else { | 1916 } else { |
1917 ti->second->setShortcut(QString("")); | 1917 ti->second->setShortcut(QString("")); |
1918 } | 1918 } |
1919 m_recentTransformsMenu->addAction(ti->second); | 1919 m_recentTransformsMenu->addAction(ti->second); |
1920 } | 1920 } |
1921 } | 1921 } |
1922 | 1922 |
1923 void | 1923 void |
1924 MainWindow::setupExistingLayersMenus() | 1924 MainWindow::setupExistingLayersMenus() |
1941 | 1941 |
1942 LayerFactory *factory = LayerFactory::getInstance(); | 1942 LayerFactory *factory = LayerFactory::getInstance(); |
1943 | 1943 |
1944 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) { | 1944 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) { |
1945 | 1945 |
1946 Pane *pane = m_paneStack->getPane(i); | 1946 Pane *pane = m_paneStack->getPane(i); |
1947 if (!pane) continue; | 1947 if (!pane) continue; |
1948 | 1948 |
1949 for (int j = 0; j < pane->getLayerCount(); ++j) { | 1949 for (int j = 0; j < pane->getLayerCount(); ++j) { |
1950 | 1950 |
1951 Layer *layer = pane->getLayer(j); | 1951 Layer *layer = pane->getLayer(j); |
1952 if (!layer) continue; | 1952 if (!layer) continue; |
1953 if (observedLayers.find(layer) != observedLayers.end()) { | 1953 if (observedLayers.find(layer) != observedLayers.end()) { |
1954 // cerr << "found duplicate layer " << layer << endl; | 1954 // cerr << "found duplicate layer " << layer << endl; |
1955 continue; | 1955 continue; |
1956 } | 1956 } |
1957 | 1957 |
1958 // cerr << "found new layer " << layer << " (name = " | 1958 // cerr << "found new layer " << layer << " (name = " |
1959 // << layer->getLayerPresentationName() << ")" << endl; | 1959 // << layer->getLayerPresentationName() << ")" << endl; |
1960 | 1960 |
1961 orderedLayers.push_back(layer); | 1961 orderedLayers.push_back(layer); |
1962 observedLayers.insert(layer); | 1962 observedLayers.insert(layer); |
1963 | 1963 |
1964 if (factory->isLayerSliceable(layer)) { | 1964 if (factory->isLayerSliceable(layer)) { |
1965 sliceableLayers.insert(layer); | 1965 sliceableLayers.insert(layer); |
1966 } | 1966 } |
1967 } | 1967 } |
1968 } | 1968 } |
1969 | 1969 |
1970 map<QString, int> observedNames; | 1970 map<QString, int> observedNames; |
1971 | 1971 |
1972 for (size_t i = 0; i < orderedLayers.size(); ++i) { | 1972 for (size_t i = 0; i < orderedLayers.size(); ++i) { |
1973 | 1973 |
1974 Layer *layer = orderedLayers[i]; | 1974 Layer *layer = orderedLayers[i]; |
1975 | 1975 |
1976 QString name = layer->getLayerPresentationName(); | 1976 QString name = layer->getLayerPresentationName(); |
1977 int n = ++observedNames[name]; | 1977 int n = ++observedNames[name]; |
1978 if (n > 1) name = QString("%1 <%2>").arg(name).arg(n); | 1978 if (n > 1) name = QString("%1 <%2>").arg(name).arg(n); |
1979 | 1979 |
1980 QIcon icon = il.load(factory->getLayerIconName | 1980 QIcon icon = il.load(factory->getLayerIconName |
1981 (factory->getLayerType(layer))); | 1981 (factory->getLayerType(layer))); |
1982 | 1982 |
1983 QAction *action = new QAction(icon, name, this); | 1983 QAction *action = new QAction(icon, name, this); |
1984 connect(action, SIGNAL(triggered()), this, SLOT(addLayer())); | 1984 connect(action, SIGNAL(triggered()), this, SLOT(addLayer())); |
1985 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool))); | 1985 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool))); |
1986 m_existingLayerActions[action] = layer; | 1986 m_existingLayerActions[action] = layer; |
1987 | 1987 |
1988 m_existingLayersMenu->addAction(action); | 1988 m_existingLayersMenu->addAction(action); |
1989 | 1989 |
1990 if (sliceableLayers.find(layer) != sliceableLayers.end()) { | 1990 if (sliceableLayers.find(layer) != sliceableLayers.end()) { |
1991 action = new QAction(icon, name, this); | 1991 action = new QAction(icon, name, this); |
1992 connect(action, SIGNAL(triggered()), this, SLOT(addLayer())); | 1992 connect(action, SIGNAL(triggered()), this, SLOT(addLayer())); |
1993 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool))); | 1993 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool))); |
2037 m_playAction->setCheckable(true); | 2037 m_playAction->setCheckable(true); |
2038 m_playAction->setShortcut(tr("Space")); | 2038 m_playAction->setShortcut(tr("Space")); |
2039 m_playAction->setStatusTip(tr("Start or stop playback from the current position")); | 2039 m_playAction->setStatusTip(tr("Start or stop playback from the current position")); |
2040 connect(m_playAction, SIGNAL(triggered()), this, SLOT(play())); | 2040 connect(m_playAction, SIGNAL(triggered()), this, SLOT(play())); |
2041 connect(m_playSource, SIGNAL(playStatusChanged(bool)), | 2041 connect(m_playSource, SIGNAL(playStatusChanged(bool)), |
2042 m_playAction, SLOT(setChecked(bool))); | 2042 m_playAction, SLOT(setChecked(bool))); |
2043 connect(m_playSource, SIGNAL(playStatusChanged(bool)), | 2043 connect(m_playSource, SIGNAL(playStatusChanged(bool)), |
2044 this, SLOT(playStatusChanged(bool))); | 2044 this, SLOT(playStatusChanged(bool))); |
2045 connect(this, SIGNAL(canPlay(bool)), m_playAction, SLOT(setEnabled(bool))); | 2045 connect(this, SIGNAL(canPlay(bool)), m_playAction, SLOT(setEnabled(bool))); |
2046 | 2046 |
2047 m_ffwdAction = toolbar->addAction(il.load("ffwd"), | 2047 m_ffwdAction = toolbar->addAction(il.load("ffwd"), |
2069 m_recordAction->setCheckable(true); | 2069 m_recordAction->setCheckable(true); |
2070 m_recordAction->setShortcut(tr("Ctrl+Space")); | 2070 m_recordAction->setShortcut(tr("Ctrl+Space")); |
2071 m_recordAction->setStatusTip(tr("Record a new audio file")); | 2071 m_recordAction->setStatusTip(tr("Record a new audio file")); |
2072 connect(m_recordAction, SIGNAL(triggered()), this, SLOT(record())); | 2072 connect(m_recordAction, SIGNAL(triggered()), this, SLOT(record())); |
2073 connect(m_recordTarget, SIGNAL(recordStatusChanged(bool)), | 2073 connect(m_recordTarget, SIGNAL(recordStatusChanged(bool)), |
2074 m_recordAction, SLOT(setChecked(bool))); | 2074 m_recordAction, SLOT(setChecked(bool))); |
2075 connect(this, SIGNAL(canRecord(bool)), | 2075 connect(this, SIGNAL(canRecord(bool)), |
2076 m_recordAction, SLOT(setEnabled(bool))); | 2076 m_recordAction, SLOT(setEnabled(bool))); |
2077 | 2077 |
2078 toolbar = addToolBar(tr("Play Mode Toolbar")); | 2078 toolbar = addToolBar(tr("Play Mode Toolbar")); |
2079 | 2079 |
2232 (tr("Edit"), tr("Double-Click Left"), | 2232 (tr("Edit"), tr("Double-Click Left"), |
2233 tr("Double-click left button on an item to edit it")); | 2233 tr("Double-click left button on an item to edit it")); |
2234 | 2234 |
2235 m_keyReference->setCategory(tr("Tool Selection")); | 2235 m_keyReference->setCategory(tr("Tool Selection")); |
2236 action = toolbar->addAction(il.load("select"), | 2236 action = toolbar->addAction(il.load("select"), |
2237 tr("Select")); | 2237 tr("Select")); |
2238 action->setCheckable(true); | 2238 action->setCheckable(true); |
2239 action->setShortcut(tr("2")); | 2239 action->setShortcut(tr("2")); |
2240 action->setStatusTip(tr("Select ranges")); | 2240 action->setStatusTip(tr("Select ranges")); |
2241 connect(action, SIGNAL(triggered()), this, SLOT(toolSelectSelected())); | 2241 connect(action, SIGNAL(triggered()), this, SLOT(toolSelectSelected())); |
2242 group->addAction(action); | 2242 group->addAction(action); |
2261 (tr("Fine Select"), tr("Shift+Left"), | 2261 (tr("Fine Select"), tr("Shift+Left"), |
2262 tr("Shift-click left button and drag to select without snapping to items or grid")); | 2262 tr("Shift-click left button and drag to select without snapping to items or grid")); |
2263 | 2263 |
2264 m_keyReference->setCategory(tr("Tool Selection")); | 2264 m_keyReference->setCategory(tr("Tool Selection")); |
2265 action = toolbar->addAction(il.load("move"), | 2265 action = toolbar->addAction(il.load("move"), |
2266 tr("Edit")); | 2266 tr("Edit")); |
2267 action->setCheckable(true); | 2267 action->setCheckable(true); |
2268 action->setShortcut(tr("3")); | 2268 action->setShortcut(tr("3")); |
2269 action->setStatusTip(tr("Edit items in layer")); | 2269 action->setStatusTip(tr("Edit items in layer")); |
2270 connect(action, SIGNAL(triggered()), this, SLOT(toolEditSelected())); | 2270 connect(action, SIGNAL(triggered()), this, SLOT(toolEditSelected())); |
2271 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool))); | 2271 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool))); |
2282 (tr("Edit"), tr("Double-Click Left"), | 2282 (tr("Edit"), tr("Double-Click Left"), |
2283 tr("Double-click left button on an item to edit it")); | 2283 tr("Double-click left button on an item to edit it")); |
2284 | 2284 |
2285 m_keyReference->setCategory(tr("Tool Selection")); | 2285 m_keyReference->setCategory(tr("Tool Selection")); |
2286 action = toolbar->addAction(il.load("draw"), | 2286 action = toolbar->addAction(il.load("draw"), |
2287 tr("Draw")); | 2287 tr("Draw")); |
2288 action->setCheckable(true); | 2288 action->setCheckable(true); |
2289 action->setShortcut(tr("4")); | 2289 action->setShortcut(tr("4")); |
2290 action->setStatusTip(tr("Draw new items in layer")); | 2290 action->setStatusTip(tr("Draw new items in layer")); |
2291 connect(action, SIGNAL(triggered()), this, SLOT(toolDrawSelected())); | 2291 connect(action, SIGNAL(triggered()), this, SLOT(toolDrawSelected())); |
2292 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool))); | 2292 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool))); |
2300 (tr("Draw"), tr("Left"), | 2300 (tr("Draw"), tr("Left"), |
2301 tr("Click left button and drag to create new item")); | 2301 tr("Click left button and drag to create new item")); |
2302 | 2302 |
2303 m_keyReference->setCategory(tr("Tool Selection")); | 2303 m_keyReference->setCategory(tr("Tool Selection")); |
2304 action = toolbar->addAction(il.load("erase"), | 2304 action = toolbar->addAction(il.load("erase"), |
2305 tr("Erase")); | 2305 tr("Erase")); |
2306 action->setCheckable(true); | 2306 action->setCheckable(true); |
2307 action->setShortcut(tr("5")); | 2307 action->setShortcut(tr("5")); |
2308 action->setStatusTip(tr("Erase items from layer")); | 2308 action->setStatusTip(tr("Erase items from layer")); |
2309 connect(action, SIGNAL(triggered()), this, SLOT(toolEraseSelected())); | 2309 connect(action, SIGNAL(triggered()), this, SLOT(toolEraseSelected())); |
2310 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool))); | 2310 connect(this, SIGNAL(canEditLayer(bool)), action, SLOT(setEnabled(bool))); |
2375 (currentPane != 0); | 2375 (currentPane != 0); |
2376 bool haveCurrentLayer = | 2376 bool haveCurrentLayer = |
2377 (haveCurrentPane && | 2377 (haveCurrentPane && |
2378 (currentLayer != 0)); | 2378 (currentLayer != 0)); |
2379 bool havePlayTarget = | 2379 bool havePlayTarget = |
2380 (m_playTarget != 0 || m_audioIO != 0); | 2380 (m_playTarget != 0 || m_audioIO != 0); |
2381 bool haveSelection = | 2381 bool haveSelection = |
2382 (m_viewManager && | 2382 (m_viewManager && |
2383 !m_viewManager->getSelections().empty()); | 2383 !m_viewManager->getSelections().empty()); |
2384 bool haveCurrentEditableLayer = | 2384 bool haveCurrentEditableLayer = |
2385 (haveCurrentLayer && | 2385 (haveCurrentLayer && |
2386 currentLayer->isLayerEditable()); | 2386 currentLayer->isLayerEditable()); |
2387 bool haveCurrentTimeInstantsLayer = | 2387 bool haveCurrentTimeInstantsLayer = |
2388 (haveCurrentLayer && | 2388 (haveCurrentLayer && |
2389 dynamic_cast<TimeInstantLayer *>(currentLayer)); | 2389 dynamic_cast<TimeInstantLayer *>(currentLayer)); |
2390 bool haveCurrentTimeValueLayer = | 2390 bool haveCurrentTimeValueLayer = |
2391 (haveCurrentLayer && | 2391 (haveCurrentLayer && |
2392 dynamic_cast<TimeValueLayer *>(currentLayer)); | 2392 dynamic_cast<TimeValueLayer *>(currentLayer)); |
2393 | 2393 |
2394 bool alignMode = m_viewManager && m_viewManager->getAlignMode(); | 2394 bool alignMode = m_viewManager && m_viewManager->getAlignMode(); |
2395 emit canChangeSolo(havePlayTarget && !alignMode); | 2395 emit canChangeSolo(havePlayTarget && !alignMode); |
2396 emit canAlign(havePlayTarget && m_document && m_document->canAlign()); | 2396 emit canAlign(havePlayTarget && m_document && m_document->canAlign()); |
2397 | 2397 |
2433 | 2433 |
2434 void | 2434 void |
2435 MainWindow::updateDescriptionLabel() | 2435 MainWindow::updateDescriptionLabel() |
2436 { | 2436 { |
2437 if (!getMainModel()) { | 2437 if (!getMainModel()) { |
2438 m_descriptionLabel->setText(tr("No audio file loaded.")); | 2438 m_descriptionLabel->setText(tr("No audio file loaded.")); |
2439 return; | 2439 return; |
2440 } | 2440 } |
2441 | 2441 |
2442 QString description; | 2442 QString description; |
2443 | 2443 |
2444 //!!!??? | 2444 //!!!??? |
2446 sv_samplerate_t ssr = getMainModel()->getSampleRate(); | 2446 sv_samplerate_t ssr = getMainModel()->getSampleRate(); |
2447 sv_samplerate_t tsr = ssr; | 2447 sv_samplerate_t tsr = ssr; |
2448 if (m_playSource) tsr = m_playSource->getDeviceSampleRate(); | 2448 if (m_playSource) tsr = m_playSource->getDeviceSampleRate(); |
2449 | 2449 |
2450 if (ssr != tsr) { | 2450 if (ssr != tsr) { |
2451 description = tr("%1Hz (resampling to %2Hz)").arg(ssr).arg(tsr); | 2451 description = tr("%1Hz (resampling to %2Hz)").arg(ssr).arg(tsr); |
2452 } else { | 2452 } else { |
2453 description = QString("%1Hz").arg(ssr); | 2453 description = QString("%1Hz").arg(ssr); |
2454 } | 2454 } |
2455 | 2455 |
2456 description = QString("%1 - %2") | 2456 description = QString("%1 - %2") |
2457 .arg(RealTime::frame2RealTime(getMainModel()->getEndFrame(), ssr) | 2457 .arg(RealTime::frame2RealTime(getMainModel()->getEndFrame(), ssr) |
2458 .toText(false).c_str()) | 2458 .toText(false).c_str()) |
2459 .arg(description); | 2459 .arg(description); |
2460 | 2460 |
2461 m_descriptionLabel->setText(description); | 2461 m_descriptionLabel->setText(description); |
2462 } | 2462 } |
2463 | 2463 |
2464 void | 2464 void |
2515 MainWindow::importAudio() | 2515 MainWindow::importAudio() |
2516 { | 2516 { |
2517 QString path = getOpenFileName(FileFinder::AudioFile); | 2517 QString path = getOpenFileName(FileFinder::AudioFile); |
2518 | 2518 |
2519 if (path != "") { | 2519 if (path != "") { |
2520 if (openAudio(path, ReplaceSession) == FileOpenFailed) { | 2520 if (openAudio(path, ReplaceSession) == FileOpenFailed) { |
2521 emit hideSplash(); | 2521 emit hideSplash(); |
2522 QMessageBox::critical(this, tr("Failed to open file"), | 2522 QMessageBox::critical(this, tr("Failed to open file"), |
2523 tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path)); | 2523 tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path)); |
2524 } | 2524 } |
2525 } | 2525 } |
2526 } | 2526 } |
2527 | 2527 |
2528 void | 2528 void |
2529 MainWindow::importMoreAudio() | 2529 MainWindow::importMoreAudio() |
2530 { | 2530 { |
2531 QString path = getOpenFileName(FileFinder::AudioFile); | 2531 QString path = getOpenFileName(FileFinder::AudioFile); |
2532 | 2532 |
2533 if (path != "") { | 2533 if (path != "") { |
2534 if (openAudio(path, CreateAdditionalModel) == FileOpenFailed) { | 2534 if (openAudio(path, CreateAdditionalModel) == FileOpenFailed) { |
2535 emit hideSplash(); | 2535 emit hideSplash(); |
2536 QMessageBox::critical(this, tr("Failed to open file"), | 2536 QMessageBox::critical(this, tr("Failed to open file"), |
2537 tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path)); | 2537 tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path)); |
2538 } | 2538 } |
2539 } | 2539 } |
2540 } | 2540 } |
2541 | 2541 |
2542 void | 2542 void |
2543 MainWindow::replaceMainAudio() | 2543 MainWindow::replaceMainAudio() |
2544 { | 2544 { |
2545 QString path = getOpenFileName(FileFinder::AudioFile); | 2545 QString path = getOpenFileName(FileFinder::AudioFile); |
2546 | 2546 |
2547 if (path != "") { | 2547 if (path != "") { |
2548 if (openAudio(path, ReplaceMainModel) == FileOpenFailed) { | 2548 if (openAudio(path, ReplaceMainModel) == FileOpenFailed) { |
2549 emit hideSplash(); | 2549 emit hideSplash(); |
2550 QMessageBox::critical(this, tr("Failed to open file"), | 2550 QMessageBox::critical(this, tr("Failed to open file"), |
2551 tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path)); | 2551 tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path)); |
2552 } | 2552 } |
2553 } | 2553 } |
2554 } | 2554 } |
2555 | 2555 |
2556 void | 2556 void |
2557 MainWindow::exportAudio() | 2557 MainWindow::exportAudio() |
2647 | 2647 |
2648 MultiSelection *selectionToWrite = 0; | 2648 MultiSelection *selectionToWrite = 0; |
2649 | 2649 |
2650 if (selections.size() == 1) { | 2650 if (selections.size() == 1) { |
2651 | 2651 |
2652 QStringList items; | 2652 QStringList items; |
2653 items << tr("Export the selected region only") | 2653 items << tr("Export the selected region only") |
2654 << tr("Export the whole audio file"); | 2654 << tr("Export the whole audio file"); |
2655 | 2655 |
2656 bool ok = false; | 2656 bool ok = false; |
2657 QString item = ListInputDialog::getItem | 2657 QString item = ListInputDialog::getItem |
2658 (this, tr("Select region to export"), | 2658 (this, tr("Select region to export"), |
2659 tr("Which region from the original audio file do you want to export?"), | 2659 tr("Which region from the original audio file do you want to export?"), |
2660 items, 0, &ok); | 2660 items, 0, &ok); |
2661 | 2661 |
2662 if (!ok || item.isEmpty()) return; | 2662 if (!ok || item.isEmpty()) return; |
2663 | 2663 |
2664 if (item == items[0]) selectionToWrite = &ms; | 2664 if (item == items[0]) selectionToWrite = &ms; |
2665 | 2665 |
2666 } else if (selections.size() > 1) { | 2666 } else if (selections.size() > 1) { |
2667 | 2667 |
2668 if (!asData) { // Multi-file export not supported for data | 2668 if (!asData) { // Multi-file export not supported for data |
2669 | 2669 |
2674 | 2674 |
2675 QString item = ListInputDialog::getItem | 2675 QString item = ListInputDialog::getItem |
2676 (this, tr("Select region to export"), | 2676 (this, tr("Select region to export"), |
2677 tr("Multiple regions of the original audio file are selected.\nWhat do you want to export?"), | 2677 tr("Multiple regions of the original audio file are selected.\nWhat do you want to export?"), |
2678 items, 0, &ok); | 2678 items, 0, &ok); |
2679 | 2679 |
2680 if (!ok || item.isEmpty()) return; | 2680 if (!ok || item.isEmpty()) return; |
2681 | 2681 |
2682 if (item == items[0]) { | 2682 if (item == items[0]) { |
2683 selectionToWrite = &ms; | 2683 selectionToWrite = &ms; |
2684 } else if (item == items[1]) { | 2684 } else if (item == items[1]) { |
2689 selectionToWrite = &ms; | 2689 selectionToWrite = &ms; |
2690 } | 2690 } |
2691 | 2691 |
2692 if (multiple) { // Can only happen when asData false | 2692 if (multiple) { // Can only happen when asData false |
2693 | 2693 |
2694 int n = 1; | 2694 int n = 1; |
2695 QString base = path; | 2695 QString base = path; |
2696 base.replace(".wav", ""); | 2696 base.replace(".wav", ""); |
2697 | 2697 |
2698 for (MultiSelection::SelectionList::iterator i = selections.begin(); | 2698 for (MultiSelection::SelectionList::iterator i = selections.begin(); |
2699 i != selections.end(); ++i) { | 2699 i != selections.end(); ++i) { |
2700 | 2700 |
2701 MultiSelection subms; | 2701 MultiSelection subms; |
2702 subms.setSelection(*i); | 2702 subms.setSelection(*i); |
2703 | 2703 |
2704 QString subpath = QString("%1.%2.wav").arg(base).arg(n); | 2704 QString subpath = QString("%1.%2.wav").arg(base).arg(n); |
2705 ++n; | 2705 ++n; |
2706 | 2706 |
2707 if (QFileInfo(subpath).exists()) { | 2707 if (QFileInfo(subpath).exists()) { |
2708 error = tr("Fragment file %1 already exists, aborting").arg(subpath); | 2708 error = tr("Fragment file %1 already exists, aborting").arg(subpath); |
2709 break; | 2709 break; |
2710 } | 2710 } |
2711 | 2711 |
2712 WavFileWriter subwriter(subpath, | 2712 WavFileWriter subwriter(subpath, |
2713 model->getSampleRate(), | 2713 model->getSampleRate(), |
2714 model->getChannelCount(), | 2714 model->getChannelCount(), |
2715 WavFileWriter::WriteToTemporary); | 2715 WavFileWriter::WriteToTemporary); |
2716 subwriter.writeModel(model, &subms); | 2716 subwriter.writeModel(model, &subms); |
2717 ok = subwriter.isOK(); | 2717 ok = subwriter.isOK(); |
2718 | 2718 |
2719 if (!ok) { | 2719 if (!ok) { |
2720 error = subwriter.getError(); | 2720 error = subwriter.getError(); |
2721 break; | 2721 break; |
2722 } | 2722 } |
2723 } | 2723 } |
2724 } | 2724 } |
2725 } | 2725 } |
2726 | 2726 |
2727 if (!multiple) { | 2727 if (!multiple) { |
2728 if (asData) { | 2728 if (asData) { |
2729 CSVFileWriter writer(path, model, | 2729 CSVFileWriter writer(path, model, |
2753 } else { | 2753 } else { |
2754 emit activity(tr("Export audio to \"%1\"").arg(path)); | 2754 emit activity(tr("Export audio to \"%1\"").arg(path)); |
2755 m_recentFiles.addFile(path); | 2755 m_recentFiles.addFile(path); |
2756 } | 2756 } |
2757 } else { | 2757 } else { |
2758 QMessageBox::critical(this, tr("Failed to write file"), error); | 2758 QMessageBox::critical(this, tr("Failed to write file"), error); |
2759 } | 2759 } |
2760 } | 2760 } |
2761 | 2761 |
2762 void | 2762 void |
2763 MainWindow::importLayer() | 2763 MainWindow::importLayer() |
2764 { | 2764 { |
2765 Pane *pane = m_paneStack->getCurrentPane(); | 2765 Pane *pane = m_paneStack->getCurrentPane(); |
2766 | 2766 |
2767 if (!pane) { | 2767 if (!pane) { |
2768 // shouldn't happen, as the menu action should have been disabled | 2768 // shouldn't happen, as the menu action should have been disabled |
2769 cerr << "WARNING: MainWindow::importLayer: no current pane" << endl; | 2769 cerr << "WARNING: MainWindow::importLayer: no current pane" << endl; |
2770 return; | 2770 return; |
2771 } | 2771 } |
2772 | 2772 |
2773 if (!getMainModel()) { | 2773 if (!getMainModel()) { |
2774 // shouldn't happen, as the menu action should have been disabled | 2774 // shouldn't happen, as the menu action should have been disabled |
2775 cerr << "WARNING: MainWindow::importLayer: No main model -- hence no default sample rate available" << endl; | 2775 cerr << "WARNING: MainWindow::importLayer: No main model -- hence no default sample rate available" << endl; |
2776 return; | 2776 return; |
2777 } | 2777 } |
2778 | 2778 |
2779 QString path = getOpenFileName(FileFinder::LayerFile); | 2779 QString path = getOpenFileName(FileFinder::LayerFile); |
2780 | 2780 |
2781 if (path != "") { | 2781 if (path != "") { |
2950 } | 2950 } |
2951 | 2951 |
2952 bool ok = lid->exec(); | 2952 bool ok = lid->exec(); |
2953 QString item = lid->getCurrentString(); | 2953 QString item = lid->getCurrentString(); |
2954 delete lid; | 2954 delete lid; |
2955 | 2955 |
2956 if (!ok || item.isEmpty()) return; | 2956 if (!ok || item.isEmpty()) return; |
2957 | 2957 |
2958 settings.setValue("lastimageexportregion", deflt); | 2958 settings.setValue("lastimageexportregion", deflt); |
2959 | 2959 |
2960 QImage *image = 0; | 2960 QImage *image = 0; |
3020 } | 3020 } |
3021 | 3021 |
3022 bool ok = lid->exec(); | 3022 bool ok = lid->exec(); |
3023 QString item = lid->getCurrentString(); | 3023 QString item = lid->getCurrentString(); |
3024 delete lid; | 3024 delete lid; |
3025 | 3025 |
3026 if (!ok || item.isEmpty()) return; | 3026 if (!ok || item.isEmpty()) return; |
3027 | 3027 |
3028 settings.setValue("lastsvgexportregion", deflt); | 3028 settings.setValue("lastsvgexportregion", deflt); |
3029 | 3029 |
3030 bool result = false; | 3030 bool result = false; |
3069 | 3069 |
3070 connect(pane, SIGNAL(contextHelpChanged(const QString &)), | 3070 connect(pane, SIGNAL(contextHelpChanged(const QString &)), |
3071 this, SLOT(contextHelpChanged(const QString &))); | 3071 this, SLOT(contextHelpChanged(const QString &))); |
3072 | 3072 |
3073 if (!m_timeRulerLayer) { | 3073 if (!m_timeRulerLayer) { |
3074 m_timeRulerLayer = m_document->createMainModelLayer | 3074 m_timeRulerLayer = m_document->createMainModelLayer |
3075 (LayerFactory::TimeRuler); | 3075 (LayerFactory::TimeRuler); |
3076 } | 3076 } |
3077 | 3077 |
3078 m_document->addLayerToView(pane, m_timeRulerLayer); | 3078 m_document->addLayerToView(pane, m_timeRulerLayer); |
3079 | 3079 |
3080 Layer *waveform = m_document->createMainModelLayer(LayerFactory::Waveform); | 3080 Layer *waveform = m_document->createMainModelLayer(LayerFactory::Waveform); |
3102 { | 3102 { |
3103 if (!checkSaveModified()) return; | 3103 if (!checkSaveModified()) return; |
3104 | 3104 |
3105 while (m_paneStack->getPaneCount() > 0) { | 3105 while (m_paneStack->getPaneCount() > 0) { |
3106 | 3106 |
3107 Pane *pane = m_paneStack->getPane(m_paneStack->getPaneCount() - 1); | 3107 Pane *pane = m_paneStack->getPane(m_paneStack->getPaneCount() - 1); |
3108 | 3108 |
3109 while (pane->getLayerCount() > 0) { | 3109 while (pane->getLayerCount() > 0) { |
3110 m_document->removeLayerFromView | 3110 m_document->removeLayerFromView |
3111 (pane, pane->getLayer(pane->getLayerCount() - 1)); | 3111 (pane, pane->getLayer(pane->getLayerCount() - 1)); |
3112 } | 3112 } |
3113 | 3113 |
3114 m_overview->unregisterView(pane); | 3114 m_overview->unregisterView(pane); |
3115 m_paneStack->deletePane(pane); | 3115 m_paneStack->deletePane(pane); |
3116 } | 3116 } |
3117 | 3117 |
3118 while (m_paneStack->getHiddenPaneCount() > 0) { | 3118 while (m_paneStack->getHiddenPaneCount() > 0) { |
3119 | 3119 |
3120 Pane *pane = m_paneStack->getHiddenPane | 3120 Pane *pane = m_paneStack->getHiddenPane |
3121 (m_paneStack->getHiddenPaneCount() - 1); | 3121 (m_paneStack->getHiddenPaneCount() - 1); |
3122 | 3122 |
3123 while (pane->getLayerCount() > 0) { | 3123 while (pane->getLayerCount() > 0) { |
3124 m_document->removeLayerFromView | 3124 m_document->removeLayerFromView |
3125 (pane, pane->getLayer(pane->getLayerCount() - 1)); | 3125 (pane, pane->getLayer(pane->getLayerCount() - 1)); |
3126 } | 3126 } |
3127 | 3127 |
3128 m_overview->unregisterView(pane); | 3128 m_overview->unregisterView(pane); |
3129 m_paneStack->deletePane(pane); | 3129 m_paneStack->deletePane(pane); |
3130 } | 3130 } |
3131 | 3131 |
3132 delete m_layerTreeDialog.data(); | 3132 delete m_layerTreeDialog.data(); |
3133 delete m_preferencesDialog.data(); | 3133 delete m_preferencesDialog.data(); |
3134 | 3134 |
3212 #if 0 | 3212 #if 0 |
3213 QObject *obj = sender(); | 3213 QObject *obj = sender(); |
3214 QAction *action = dynamic_cast<QAction *>(obj); | 3214 QAction *action = dynamic_cast<QAction *>(obj); |
3215 | 3215 |
3216 if (!action) { | 3216 if (!action) { |
3217 cerr << "WARNING: MainWindow::openRecentFile: sender is not an action" | 3217 cerr << "WARNING: MainWindow::openRecentFile: sender is not an action" |
3218 << endl; | 3218 << endl; |
3219 return; | 3219 return; |
3220 } | 3220 } |
3221 | 3221 |
3222 QString path = action->text(); | 3222 QString path = action->text(); |
3223 #endif | 3223 #endif |
3224 /* End of F. Nicol patch 13 Aug. 2016 */ | 3224 /* End of F. Nicol patch 13 Aug. 2016 */ |
3243 { | 3243 { |
3244 QObject *s = sender(); | 3244 QObject *s = sender(); |
3245 QAction *action = qobject_cast<QAction *>(s); | 3245 QAction *action = qobject_cast<QAction *>(s); |
3246 | 3246 |
3247 if (!action) { | 3247 if (!action) { |
3248 cerr << "WARNING: MainWindow::applyTemplate: sender is not an action" | 3248 cerr << "WARNING: MainWindow::applyTemplate: sender is not an action" |
3249 << endl; | 3249 << endl; |
3250 return; | 3250 return; |
3251 } | 3251 } |
3252 | 3252 |
3253 QString n = action->objectName(); | 3253 QString n = action->objectName(); |
3254 if (n == "") n = action->text(); | 3254 if (n == "") n = action->text(); |
3255 | 3255 |
3401 { | 3401 { |
3402 // cerr << "MainWindow::closeEvent" << endl; | 3402 // cerr << "MainWindow::closeEvent" << endl; |
3403 | 3403 |
3404 if (m_openingAudioFile) { | 3404 if (m_openingAudioFile) { |
3405 // cerr << "Busy - ignoring close event" << endl; | 3405 // cerr << "Busy - ignoring close event" << endl; |
3406 e->ignore(); | 3406 e->ignore(); |
3407 return; | 3407 return; |
3408 } | 3408 } |
3409 | 3409 |
3410 if (!m_abandoning && !checkSaveModified()) { | 3410 if (!m_abandoning && !checkSaveModified()) { |
3411 // cerr << "Close refused by user - ignoring close event" << endl; | 3411 // cerr << "Close refused by user - ignoring close event" << endl; |
3412 e->ignore(); | 3412 e->ignore(); |
3413 return; | 3413 return; |
3414 } | 3414 } |
3415 | 3415 |
3416 QSettings settings; | 3416 QSettings settings; |
3417 settings.beginGroup("MainWindow"); | 3417 settings.beginGroup("MainWindow"); |
3418 settings.setValue("maximised", isMaximized()); | 3418 settings.setValue("maximised", isMaximized()); |
3497 if (!m_documentModified) return true; | 3497 if (!m_documentModified) return true; |
3498 | 3498 |
3499 emit hideSplash(); | 3499 emit hideSplash(); |
3500 | 3500 |
3501 int button = | 3501 int button = |
3502 QMessageBox::warning(this, | 3502 QMessageBox::warning(this, |
3503 tr("Session modified"), | 3503 tr("Session modified"), |
3504 tr("<b>Session modified</b><p>The current session has been modified.<br>Do you want to save it?"), | 3504 tr("<b>Session modified</b><p>The current session has been modified.<br>Do you want to save it?"), |
3505 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, | 3505 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, |
3506 QMessageBox::Yes); | 3506 QMessageBox::Yes); |
3507 | 3507 |
3508 if (button == QMessageBox::Yes) { | 3508 if (button == QMessageBox::Yes) { |
3509 saveSession(); | 3509 saveSession(); |
3510 if (m_documentModified) { // save failed -- don't proceed! | 3510 if (m_documentModified) { // save failed -- don't proceed! |
3511 return false; | 3511 return false; |
3512 } else { | 3512 } else { |
3513 return true; // saved, so it's safe to continue now | 3513 return true; // saved, so it's safe to continue now |
3514 } | 3514 } |
3515 } else if (button == QMessageBox::No) { | 3515 } else if (button == QMessageBox::No) { |
3516 m_documentModified = false; // so we know to abandon it | 3516 m_documentModified = false; // so we know to abandon it |
3517 return true; | 3517 return true; |
3518 } | 3518 } |
3519 | 3519 |
3520 // else cancel | 3520 // else cancel |
3521 return false; | 3521 return false; |
3522 } | 3522 } |
3559 | 3559 |
3560 void | 3560 void |
3561 MainWindow::saveSession() | 3561 MainWindow::saveSession() |
3562 { | 3562 { |
3563 if (m_sessionFile != "") { | 3563 if (m_sessionFile != "") { |
3564 if (!saveSessionFile(m_sessionFile)) { | 3564 if (!saveSessionFile(m_sessionFile)) { |
3565 QMessageBox::critical(this, tr("Failed to save file"), | 3565 QMessageBox::critical(this, tr("Failed to save file"), |
3566 tr("<b>Save failed</b><p>Session file \"%1\" could not be saved.").arg(m_sessionFile)); | 3566 tr("<b>Save failed</b><p>Session file \"%1\" could not be saved.").arg(m_sessionFile)); |
3567 } else { | 3567 } else { |
3568 CommandHistory::getInstance()->documentSaved(); | 3568 CommandHistory::getInstance()->documentSaved(); |
3569 documentRestored(); | 3569 documentRestored(); |
3570 } | 3570 } |
3571 } else { | 3571 } else { |
3572 saveSessionAs(); | 3572 saveSessionAs(); |
3573 } | 3573 } |
3574 } | 3574 } |
3575 | 3575 |
3576 void | 3576 void |
3577 MainWindow::saveSessionAs() | 3577 MainWindow::saveSessionAs() |
3583 QString path = getSaveFileName(FileFinder::SessionFile); | 3583 QString path = getSaveFileName(FileFinder::SessionFile); |
3584 | 3584 |
3585 if (path == "") return; | 3585 if (path == "") return; |
3586 | 3586 |
3587 if (!saveSessionFile(path)) { | 3587 if (!saveSessionFile(path)) { |
3588 QMessageBox::critical(this, tr("Failed to save file"), | 3588 QMessageBox::critical(this, tr("Failed to save file"), |
3589 tr("<b>Save failed</b><p>Session file \"%1\" could not be saved.").arg(path)); | 3589 tr("<b>Save failed</b><p>Session file \"%1\" could not be saved.").arg(path)); |
3590 } else { | 3590 } else { |
3591 setWindowTitle(tr("%1: %2") | 3591 setWindowTitle(tr("%1: %2") |
3592 .arg(QApplication::applicationName()) | 3592 .arg(QApplication::applicationName()) |
3593 .arg(QFileInfo(path).fileName())); | 3593 .arg(QFileInfo(path).fileName())); |
3594 m_sessionFile = path; | 3594 m_sessionFile = path; |
3595 CommandHistory::getInstance()->documentSaved(); | 3595 CommandHistory::getInstance()->documentSaved(); |
3596 documentRestored(); | 3596 documentRestored(); |
3597 m_recentFiles.addFile(path); | 3597 m_recentFiles.addFile(path); |
3598 emit activity(tr("Save session as \"%1\"").arg(path)); | 3598 emit activity(tr("Save session as \"%1\"").arg(path)); |
3599 } | 3599 } |
3600 } | 3600 } |
3601 | 3601 |
3651 QAction *action = dynamic_cast<QAction *>(s); | 3651 QAction *action = dynamic_cast<QAction *>(s); |
3652 | 3652 |
3653 cerr << "addPane: sender is " << s << ", action is " << action << ", name " << action->text() << endl; | 3653 cerr << "addPane: sender is " << s << ", action is " << action << ", name " << action->text() << endl; |
3654 | 3654 |
3655 if (!action) { | 3655 if (!action) { |
3656 cerr << "WARNING: MainWindow::addPane: sender is not an action" | 3656 cerr << "WARNING: MainWindow::addPane: sender is not an action" |
3657 << endl; | 3657 << endl; |
3658 return; | 3658 return; |
3659 } | 3659 } |
3660 | 3660 |
3661 PaneActionMap::iterator i = m_paneActions.find(action); | 3661 PaneActionMap::iterator i = m_paneActions.find(action); |
3662 | 3662 |
3663 if (i == m_paneActions.end()) { | 3663 if (i == m_paneActions.end()) { |
3664 cerr << "WARNING: MainWindow::addPane: unknown action " | 3664 cerr << "WARNING: MainWindow::addPane: unknown action " |
3665 << action->objectName() << endl; | 3665 << action->objectName() << endl; |
3666 cerr << "known actions are:" << endl; | 3666 cerr << "known actions are:" << endl; |
3667 for (PaneActionMap::const_iterator i = m_paneActions.begin(); | 3667 for (PaneActionMap::const_iterator i = m_paneActions.begin(); |
3668 i != m_paneActions.end(); ++i) { | 3668 i != m_paneActions.end(); ++i) { |
3669 cerr << i->first << ", name " << i->first->text() << endl; | 3669 cerr << i->first << ", name " << i->first->text() << endl; |
3670 } | 3670 } |
3671 return; | 3671 return; |
3672 } | 3672 } |
3673 | 3673 |
3674 addPane(i->second, action->text()); | 3674 addPane(i->second, action->text()); |
3675 } | 3675 } |
3676 | 3676 |
3691 } | 3691 } |
3692 | 3692 |
3693 if (configuration.layer != LayerFactory::TimeRuler && | 3693 if (configuration.layer != LayerFactory::TimeRuler && |
3694 configuration.layer != LayerFactory::Spectrum) { | 3694 configuration.layer != LayerFactory::Spectrum) { |
3695 | 3695 |
3696 if (!m_timeRulerLayer) { | 3696 if (!m_timeRulerLayer) { |
3697 // cerr << "no time ruler layer, creating one" << endl; | 3697 // cerr << "no time ruler layer, creating one" << endl; |
3698 m_timeRulerLayer = m_document->createMainModelLayer | 3698 m_timeRulerLayer = m_document->createMainModelLayer |
3699 (LayerFactory::TimeRuler); | 3699 (LayerFactory::TimeRuler); |
3700 } | 3700 } |
3701 | 3701 |
3702 // SVDEBUG << "adding time ruler layer " << m_timeRulerLayer << endl; | 3702 // SVDEBUG << "adding time ruler layer " << m_timeRulerLayer << endl; |
3703 | 3703 |
3704 m_document->addLayerToView(pane, m_timeRulerLayer); | 3704 m_document->addLayerToView(pane, m_timeRulerLayer); |
3705 } | 3705 } |
3706 | 3706 |
3707 Layer *newLayer = m_document->createLayer(configuration.layer); | 3707 Layer *newLayer = m_document->createLayer(configuration.layer); |
3708 | 3708 |
3709 Model *suggestedModel = configuration.sourceModel; | 3709 Model *suggestedModel = configuration.sourceModel; |
3753 { | 3753 { |
3754 QObject *s = sender(); | 3754 QObject *s = sender(); |
3755 QAction *action = dynamic_cast<QAction *>(s); | 3755 QAction *action = dynamic_cast<QAction *>(s); |
3756 | 3756 |
3757 if (!action) { | 3757 if (!action) { |
3758 cerr << "WARNING: MainWindow::addLayer: sender is not an action" | 3758 cerr << "WARNING: MainWindow::addLayer: sender is not an action" |
3759 << endl; | 3759 << endl; |
3760 return; | 3760 return; |
3761 } | 3761 } |
3762 | 3762 |
3763 Pane *pane = m_paneStack->getCurrentPane(); | 3763 Pane *pane = m_paneStack->getCurrentPane(); |
3764 | 3764 |
3765 if (!pane) { | 3765 if (!pane) { |
3766 cerr << "WARNING: MainWindow::addLayer: no current pane" << endl; | 3766 cerr << "WARNING: MainWindow::addLayer: no current pane" << endl; |
3767 return; | 3767 return; |
3768 } | 3768 } |
3769 | 3769 |
3770 ExistingLayerActionMap::iterator ei = m_existingLayerActions.find(action); | 3770 ExistingLayerActionMap::iterator ei = m_existingLayerActions.find(action); |
3771 | 3771 |
3772 if (ei != m_existingLayerActions.end()) { | 3772 if (ei != m_existingLayerActions.end()) { |
3773 Layer *newLayer = ei->second; | 3773 Layer *newLayer = ei->second; |
3774 m_document->addLayerToView(pane, newLayer); | 3774 m_document->addLayerToView(pane, newLayer); |
3775 m_paneStack->setCurrentLayer(pane, newLayer); | 3775 m_paneStack->setCurrentLayer(pane, newLayer); |
3776 return; | 3776 return; |
3777 } | 3777 } |
3778 | 3778 |
3779 ei = m_sliceActions.find(action); | 3779 ei = m_sliceActions.find(action); |
3780 | 3780 |
3781 if (ei != m_sliceActions.end()) { | 3781 if (ei != m_sliceActions.end()) { |
3789 connect(source, SIGNAL(sliceableModelReplaced(const Model *, const Model *)), | 3789 connect(source, SIGNAL(sliceableModelReplaced(const Model *, const Model *)), |
3790 dest, SLOT(sliceableModelReplaced(const Model *, const Model *))); | 3790 dest, SLOT(sliceableModelReplaced(const Model *, const Model *))); |
3791 connect(m_document, SIGNAL(modelAboutToBeDeleted(Model *)), | 3791 connect(m_document, SIGNAL(modelAboutToBeDeleted(Model *)), |
3792 dest, SLOT(modelAboutToBeDeleted(Model *))); | 3792 dest, SLOT(modelAboutToBeDeleted(Model *))); |
3793 } | 3793 } |
3794 m_document->addLayerToView(pane, newLayer); | 3794 m_document->addLayerToView(pane, newLayer); |
3795 m_paneStack->setCurrentLayer(pane, newLayer); | 3795 m_paneStack->setCurrentLayer(pane, newLayer); |
3796 return; | 3796 return; |
3797 } | 3797 } |
3798 | 3798 |
3799 TransformActionMap::iterator i = m_transformActions.find(action); | 3799 TransformActionMap::iterator i = m_transformActions.find(action); |
3800 | 3800 |
3801 if (i == m_transformActions.end()) { | 3801 if (i == m_transformActions.end()) { |
3802 | 3802 |
3803 LayerActionMap::iterator i = m_layerActions.find(action); | 3803 LayerActionMap::iterator i = m_layerActions.find(action); |
3804 | 3804 |
3805 if (i == m_layerActions.end()) { | 3805 if (i == m_layerActions.end()) { |
3806 cerr << "WARNING: MainWindow::addLayer: unknown action " | 3806 cerr << "WARNING: MainWindow::addLayer: unknown action " |
3807 << action->objectName() << endl; | 3807 << action->objectName() << endl; |
3808 return; | 3808 return; |
3809 } | 3809 } |
3810 | 3810 |
3811 LayerFactory::LayerType type = i->second.layer; | 3811 LayerFactory::LayerType type = i->second.layer; |
3812 | 3812 |
3813 LayerFactory::LayerTypeSet emptyTypes = | 3813 LayerFactory::LayerTypeSet emptyTypes = |
3814 LayerFactory::getInstance()->getValidEmptyLayerTypes(); | 3814 LayerFactory::getInstance()->getValidEmptyLayerTypes(); |
3815 | 3815 |
3816 Layer *newLayer = 0; | 3816 Layer *newLayer = 0; |
3817 | 3817 |
3818 if (emptyTypes.find(type) != emptyTypes.end()) { | 3818 if (emptyTypes.find(type) != emptyTypes.end()) { |
3819 | 3819 |
3820 newLayer = m_document->createEmptyLayer(type); | 3820 newLayer = m_document->createEmptyLayer(type); |
3821 if (newLayer) { | 3821 if (newLayer) { |
3822 m_toolActions[ViewManager::DrawMode]->trigger(); | 3822 m_toolActions[ViewManager::DrawMode]->trigger(); |
3823 } | 3823 } |
3824 | 3824 |
3825 } else { | 3825 } else { |
3826 | 3826 |
3827 Model *model = i->second.sourceModel; | 3827 Model *model = i->second.sourceModel; |
3828 | 3828 |
3829 cerr << "model = "<< model << endl; | 3829 cerr << "model = "<< model << endl; |
3830 | 3830 |
3865 if (newLayer) { | 3865 if (newLayer) { |
3866 m_document->addLayerToView(pane, newLayer); | 3866 m_document->addLayerToView(pane, newLayer); |
3867 m_paneStack->setCurrentLayer(pane, newLayer); | 3867 m_paneStack->setCurrentLayer(pane, newLayer); |
3868 } | 3868 } |
3869 | 3869 |
3870 return; | 3870 return; |
3871 } | 3871 } |
3872 | 3872 |
3873 //!!! want to do something like this, but it's not supported in | 3873 //!!! want to do something like this, but it's not supported in |
3874 //ModelTransformerFactory yet | 3874 //ModelTransformerFactory yet |
3875 /* | 3875 /* |
3876 int channel = -1; | 3876 int channel = -1; |
3877 // pick up the default channel from any existing layers on the same pane | 3877 // pick up the default channel from any existing layers on the same pane |
3878 for (int j = 0; j < pane->getLayerCount(); ++j) { | 3878 for (int j = 0; j < pane->getLayerCount(); ++j) { |
3879 int c = LayerFactory::getInstance()->getChannel(pane->getLayer(j)); | 3879 int c = LayerFactory::getInstance()->getChannel(pane->getLayer(j)); |
3880 if (c != -1) { | 3880 if (c != -1) { |
3881 channel = c; | 3881 channel = c; |
3882 break; | 3882 break; |
3883 } | 3883 } |
3884 } | 3884 } |
3885 */ | 3885 */ |
3886 | 3886 |
3887 // We always ask for configuration, even if the plugin isn't | 3887 // We always ask for configuration, even if the plugin isn't |
3888 // supposed to be configurable, because we need to let the user | 3888 // supposed to be configurable, because we need to let the user |
3896 void | 3896 void |
3897 MainWindow::addLayer(QString transformId) | 3897 MainWindow::addLayer(QString transformId) |
3898 { | 3898 { |
3899 Pane *pane = m_paneStack->getCurrentPane(); | 3899 Pane *pane = m_paneStack->getCurrentPane(); |
3900 if (!pane) { | 3900 if (!pane) { |
3901 cerr << "WARNING: MainWindow::addLayer: no current pane" << endl; | 3901 cerr << "WARNING: MainWindow::addLayer: no current pane" << endl; |
3902 return; | 3902 return; |
3903 } | 3903 } |
3904 | 3904 |
3905 Transform transform; | 3905 Transform transform; |
3906 try { | 3906 try { |
3907 transform = TransformFactory::getInstance()-> | 3907 transform = TransformFactory::getInstance()-> |
4014 void | 4014 void |
4015 MainWindow::renameCurrentLayer() | 4015 MainWindow::renameCurrentLayer() |
4016 { | 4016 { |
4017 Pane *pane = m_paneStack->getCurrentPane(); | 4017 Pane *pane = m_paneStack->getCurrentPane(); |
4018 if (pane) { | 4018 if (pane) { |
4019 Layer *layer = pane->getSelectedLayer(); | 4019 Layer *layer = pane->getSelectedLayer(); |
4020 if (layer) { | 4020 if (layer) { |
4021 bool ok = false; | 4021 bool ok = false; |
4022 QString newName = QInputDialog::getText | 4022 QString newName = QInputDialog::getText |
4023 (this, tr("Rename Layer"), | 4023 (this, tr("Rename Layer"), |
4024 tr("New name for this layer:"), | 4024 tr("New name for this layer:"), |
4025 QLineEdit::Normal, layer->objectName(), &ok); | 4025 QLineEdit::Normal, layer->objectName(), &ok); |
4026 if (ok) { | 4026 if (ok) { |
4027 layer->setPresentationName(newName); | 4027 layer->setPresentationName(newName); |
4028 setupExistingLayersMenus(); | 4028 setupExistingLayersMenus(); |
4029 } | 4029 } |
4030 } | 4030 } |
4031 } | 4031 } |
4032 } | 4032 } |
4033 | 4033 |
4034 void | 4034 void |
4035 MainWindow::findTransform() | 4035 MainWindow::findTransform() |
4060 QAction *action = dynamic_cast<QAction *>(sender()); | 4060 QAction *action = dynamic_cast<QAction *>(sender()); |
4061 | 4061 |
4062 if (!m_viewManager) return; | 4062 if (!m_viewManager) return; |
4063 | 4063 |
4064 if (action) { | 4064 if (action) { |
4065 m_viewManager->setAlignMode(action->isChecked()); | 4065 m_viewManager->setAlignMode(action->isChecked()); |
4066 } else { | 4066 } else { |
4067 m_viewManager->setAlignMode(!m_viewManager->getAlignMode()); | 4067 m_viewManager->setAlignMode(!m_viewManager->getAlignMode()); |
4068 } | 4068 } |
4069 | 4069 |
4070 if (m_viewManager->getAlignMode()) { | 4070 if (m_viewManager->getAlignMode()) { |
4071 m_prevSolo = m_soloAction->isChecked(); | 4071 m_prevSolo = m_soloAction->isChecked(); |
4072 if (!m_soloAction->isChecked()) { | 4072 if (!m_soloAction->isChecked()) { |
4088 m_document->setAutoAlignment(false); | 4088 m_document->setAutoAlignment(false); |
4089 } | 4089 } |
4090 | 4090 |
4091 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) { | 4091 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) { |
4092 | 4092 |
4093 Pane *pane = m_paneStack->getPane(i); | 4093 Pane *pane = m_paneStack->getPane(i); |
4094 if (!pane) continue; | 4094 if (!pane) continue; |
4095 | 4095 |
4096 pane->update(); | 4096 pane->update(); |
4097 } | 4097 } |
4098 } | 4098 } |
4099 | 4099 |