Mercurial > hg > svapp
comparison framework/MainWindowBase.cpp @ 595:b23bebfdfaba
Untabify
author | Chris Cannam |
---|---|
date | Thu, 01 Mar 2018 18:02:22 +0000 |
parents | 72b4870f0e6b |
children | f03bc1d38cac |
comparison
equal
deleted
inserted
replaced
594:72b4870f0e6b | 595:b23bebfdfaba |
---|---|
122 static int handle_x11_error(Display *dpy, XErrorEvent *err) | 122 static int handle_x11_error(Display *dpy, XErrorEvent *err) |
123 { | 123 { |
124 char errstr[256]; | 124 char errstr[256]; |
125 XGetErrorText(dpy, err->error_code, errstr, 256); | 125 XGetErrorText(dpy, err->error_code, errstr, 256); |
126 if (err->error_code != BadWindow) { | 126 if (err->error_code != BadWindow) { |
127 cerr << "Sonic Visualiser: X Error: " | 127 cerr << "Sonic Visualiser: X Error: " |
128 << errstr << " " << int(err->error_code) | 128 << errstr << " " << int(err->error_code) |
129 << "\nin major opcode: " | 129 << "\nin major opcode: " |
130 << int(err->request_code) << endl; | 130 << int(err->request_code) << endl; |
131 } | 131 } |
132 return 0; | 132 return 0; |
133 } | 133 } |
134 #undef Window | 134 #undef Window |
135 #endif | 135 #endif |
180 #endif | 180 #endif |
181 | 181 |
182 connect(this, SIGNAL(hideSplash()), this, SLOT(emitHideSplash())); | 182 connect(this, SIGNAL(hideSplash()), this, SLOT(emitHideSplash())); |
183 | 183 |
184 connect(CommandHistory::getInstance(), SIGNAL(commandExecuted()), | 184 connect(CommandHistory::getInstance(), SIGNAL(commandExecuted()), |
185 this, SLOT(documentModified())); | 185 this, SLOT(documentModified())); |
186 connect(CommandHistory::getInstance(), SIGNAL(documentRestored()), | 186 connect(CommandHistory::getInstance(), SIGNAL(documentRestored()), |
187 this, SLOT(documentRestored())); | 187 this, SLOT(documentRestored())); |
188 | 188 |
189 SVDEBUG << "MainWindowBase: Creating view manager" << endl; | 189 SVDEBUG << "MainWindowBase: Creating view manager" << endl; |
190 | 190 |
191 m_viewManager = new ViewManager(); | 191 m_viewManager = new ViewManager(); |
192 connect(m_viewManager, SIGNAL(selectionChanged()), | 192 connect(m_viewManager, SIGNAL(selectionChanged()), |
193 this, SLOT(updateMenuStates())); | 193 this, SLOT(updateMenuStates())); |
194 connect(m_viewManager, SIGNAL(inProgressSelectionChanged()), | 194 connect(m_viewManager, SIGNAL(inProgressSelectionChanged()), |
195 this, SLOT(inProgressSelectionChanged())); | 195 this, SLOT(inProgressSelectionChanged())); |
196 | 196 |
197 SVDEBUG << "MainWindowBase: Calculating view font size" << endl; | 197 SVDEBUG << "MainWindowBase: Calculating view font size" << endl; |
198 | 198 |
199 // set a sensible default font size for views -- cannot do this | 199 // set a sensible default font size for views -- cannot do this |
200 // in Preferences, which is in base and not supposed to use QtGui | 200 // in Preferences, which is in base and not supposed to use QtGui |
217 } | 217 } |
218 #endif | 218 #endif |
219 | 219 |
220 m_paneStack = new PaneStack(0, m_viewManager); | 220 m_paneStack = new PaneStack(0, m_viewManager); |
221 connect(m_paneStack, SIGNAL(currentPaneChanged(Pane *)), | 221 connect(m_paneStack, SIGNAL(currentPaneChanged(Pane *)), |
222 this, SLOT(currentPaneChanged(Pane *))); | 222 this, SLOT(currentPaneChanged(Pane *))); |
223 connect(m_paneStack, SIGNAL(currentLayerChanged(Pane *, Layer *)), | 223 connect(m_paneStack, SIGNAL(currentLayerChanged(Pane *, Layer *)), |
224 this, SLOT(currentLayerChanged(Pane *, Layer *))); | 224 this, SLOT(currentLayerChanged(Pane *, Layer *))); |
225 connect(m_paneStack, SIGNAL(rightButtonMenuRequested(Pane *, QPoint)), | 225 connect(m_paneStack, SIGNAL(rightButtonMenuRequested(Pane *, QPoint)), |
226 this, SLOT(rightButtonMenuRequested(Pane *, QPoint))); | 226 this, SLOT(rightButtonMenuRequested(Pane *, QPoint))); |
227 connect(m_paneStack, SIGNAL(contextHelpChanged(const QString &)), | 227 connect(m_paneStack, SIGNAL(contextHelpChanged(const QString &)), |
228 this, SLOT(contextHelpChanged(const QString &))); | 228 this, SLOT(contextHelpChanged(const QString &))); |
229 connect(m_paneStack, SIGNAL(paneAdded(Pane *)), | 229 connect(m_paneStack, SIGNAL(paneAdded(Pane *)), |
262 this, SLOT(audioOverloadPluginDisabled())); | 262 this, SLOT(audioOverloadPluginDisabled())); |
263 connect(m_playSource, SIGNAL(audioTimeStretchMultiChannelDisabled()), | 263 connect(m_playSource, SIGNAL(audioTimeStretchMultiChannelDisabled()), |
264 this, SLOT(audioTimeStretchMultiChannelDisabled())); | 264 this, SLOT(audioTimeStretchMultiChannelDisabled())); |
265 | 265 |
266 connect(m_viewManager, SIGNAL(monitoringLevelsChanged(float, float)), | 266 connect(m_viewManager, SIGNAL(monitoringLevelsChanged(float, float)), |
267 this, SLOT(monitoringLevelsChanged(float, float))); | 267 this, SLOT(monitoringLevelsChanged(float, float))); |
268 | 268 |
269 connect(m_viewManager, SIGNAL(playbackFrameChanged(sv_frame_t)), | 269 connect(m_viewManager, SIGNAL(playbackFrameChanged(sv_frame_t)), |
270 this, SLOT(playbackFrameChanged(sv_frame_t))); | 270 this, SLOT(playbackFrameChanged(sv_frame_t))); |
271 | 271 |
272 connect(m_viewManager, SIGNAL(globalCentreFrameChanged(sv_frame_t)), | 272 connect(m_viewManager, SIGNAL(globalCentreFrameChanged(sv_frame_t)), |
605 (currentPane != 0); | 605 (currentPane != 0); |
606 bool haveCurrentLayer = | 606 bool haveCurrentLayer = |
607 (haveCurrentPane && | 607 (haveCurrentPane && |
608 (currentLayer != 0)); | 608 (currentLayer != 0)); |
609 bool haveMainModel = | 609 bool haveMainModel = |
610 (getMainModel() != 0); | 610 (getMainModel() != 0); |
611 bool havePlayTarget = | 611 bool havePlayTarget = |
612 (m_playTarget != 0 || m_audioIO != 0); | 612 (m_playTarget != 0 || m_audioIO != 0); |
613 bool haveSelection = | 613 bool haveSelection = |
614 (m_viewManager && | 614 (m_viewManager && |
615 !m_viewManager->getSelections().empty()); | 615 !m_viewManager->getSelections().empty()); |
616 bool haveCurrentEditableLayer = | 616 bool haveCurrentEditableLayer = |
617 (haveCurrentLayer && | 617 (haveCurrentLayer && |
618 currentLayer->isLayerEditable()); | 618 currentLayer->isLayerEditable()); |
619 bool haveCurrentTimeInstantsLayer = | 619 bool haveCurrentTimeInstantsLayer = |
620 (haveCurrentLayer && | 620 (haveCurrentLayer && |
621 dynamic_cast<TimeInstantLayer *>(currentLayer)); | 621 dynamic_cast<TimeInstantLayer *>(currentLayer)); |
622 bool haveCurrentDurationLayer = | 622 bool haveCurrentDurationLayer = |
623 (haveCurrentLayer && | 623 (haveCurrentLayer && |
624 (dynamic_cast<NoteLayer *>(currentLayer) || | 624 (dynamic_cast<NoteLayer *>(currentLayer) || |
625 dynamic_cast<FlexiNoteLayer *>(currentLayer) || | 625 dynamic_cast<FlexiNoteLayer *>(currentLayer) || |
626 dynamic_cast<RegionLayer *>(currentLayer))); | 626 dynamic_cast<RegionLayer *>(currentLayer))); |
627 bool haveCurrentColour3DPlot = | 627 bool haveCurrentColour3DPlot = |
628 (haveCurrentLayer && | 628 (haveCurrentLayer && |
629 dynamic_cast<Colour3DPlotLayer *>(currentLayer)); | 629 dynamic_cast<Colour3DPlotLayer *>(currentLayer)); |
630 bool haveClipboardContents = | 630 bool haveClipboardContents = |
691 { | 691 { |
692 // SVDEBUG << "MainWindowBase::documentModified" << endl; | 692 // SVDEBUG << "MainWindowBase::documentModified" << endl; |
693 | 693 |
694 if (!m_documentModified) { | 694 if (!m_documentModified) { |
695 //!!! this in subclass implementation? | 695 //!!! this in subclass implementation? |
696 setWindowTitle(tr("%1 (modified)").arg(windowTitle())); | 696 setWindowTitle(tr("%1 (modified)").arg(windowTitle())); |
697 } | 697 } |
698 | 698 |
699 m_documentModified = true; | 699 m_documentModified = true; |
700 updateMenuStates(); | 700 updateMenuStates(); |
701 } | 701 } |
705 { | 705 { |
706 // SVDEBUG << "MainWindowBase::documentRestored" << endl; | 706 // SVDEBUG << "MainWindowBase::documentRestored" << endl; |
707 | 707 |
708 if (m_documentModified) { | 708 if (m_documentModified) { |
709 //!!! this in subclass implementation? | 709 //!!! this in subclass implementation? |
710 QString wt(windowTitle()); | 710 QString wt(windowTitle()); |
711 wt.replace(tr(" (modified)"), ""); | 711 wt.replace(tr(" (modified)"), ""); |
712 setWindowTitle(wt); | 712 setWindowTitle(wt); |
713 } | 713 } |
714 | 714 |
715 m_documentModified = false; | 715 m_documentModified = false; |
716 updateMenuStates(); | 716 updateMenuStates(); |
717 } | 717 } |
720 MainWindowBase::playLoopToggled() | 720 MainWindowBase::playLoopToggled() |
721 { | 721 { |
722 QAction *action = dynamic_cast<QAction *>(sender()); | 722 QAction *action = dynamic_cast<QAction *>(sender()); |
723 | 723 |
724 if (action) { | 724 if (action) { |
725 m_viewManager->setPlayLoopMode(action->isChecked()); | 725 m_viewManager->setPlayLoopMode(action->isChecked()); |
726 } else { | 726 } else { |
727 m_viewManager->setPlayLoopMode(!m_viewManager->getPlayLoopMode()); | 727 m_viewManager->setPlayLoopMode(!m_viewManager->getPlayLoopMode()); |
728 } | 728 } |
729 } | 729 } |
730 | 730 |
731 void | 731 void |
732 MainWindowBase::playSelectionToggled() | 732 MainWindowBase::playSelectionToggled() |
733 { | 733 { |
734 QAction *action = dynamic_cast<QAction *>(sender()); | 734 QAction *action = dynamic_cast<QAction *>(sender()); |
735 | 735 |
736 if (action) { | 736 if (action) { |
737 m_viewManager->setPlaySelectionMode(action->isChecked()); | 737 m_viewManager->setPlaySelectionMode(action->isChecked()); |
738 } else { | 738 } else { |
739 m_viewManager->setPlaySelectionMode(!m_viewManager->getPlaySelectionMode()); | 739 m_viewManager->setPlaySelectionMode(!m_viewManager->getPlaySelectionMode()); |
740 } | 740 } |
741 } | 741 } |
742 | 742 |
743 void | 743 void |
744 MainWindowBase::playSoloToggled() | 744 MainWindowBase::playSoloToggled() |
745 { | 745 { |
746 QAction *action = dynamic_cast<QAction *>(sender()); | 746 QAction *action = dynamic_cast<QAction *>(sender()); |
747 | 747 |
748 if (action) { | 748 if (action) { |
749 m_viewManager->setPlaySoloMode(action->isChecked()); | 749 m_viewManager->setPlaySoloMode(action->isChecked()); |
750 } else { | 750 } else { |
751 m_viewManager->setPlaySoloMode(!m_viewManager->getPlaySoloMode()); | 751 m_viewManager->setPlaySoloMode(!m_viewManager->getPlaySoloMode()); |
752 } | 752 } |
753 | 753 |
754 if (m_viewManager->getPlaySoloMode()) { | 754 if (m_viewManager->getPlaySoloMode()) { |
755 currentPaneChanged(m_paneStack->getCurrentPane()); | 755 currentPaneChanged(m_paneStack->getCurrentPane()); |
756 } else { | 756 } else { |
845 void | 845 void |
846 MainWindowBase::selectAll() | 846 MainWindowBase::selectAll() |
847 { | 847 { |
848 if (!getMainModel()) return; | 848 if (!getMainModel()) return; |
849 m_viewManager->setSelection(Selection(getMainModel()->getStartFrame(), | 849 m_viewManager->setSelection(Selection(getMainModel()->getStartFrame(), |
850 getMainModel()->getEndFrame())); | 850 getMainModel()->getEndFrame())); |
851 } | 851 } |
852 | 852 |
853 void | 853 void |
854 MainWindowBase::selectToStart() | 854 MainWindowBase::selectToStart() |
855 { | 855 { |
856 if (!getMainModel()) return; | 856 if (!getMainModel()) return; |
857 m_viewManager->setSelection(Selection(getMainModel()->getStartFrame(), | 857 m_viewManager->setSelection(Selection(getMainModel()->getStartFrame(), |
858 m_viewManager->getGlobalCentreFrame())); | 858 m_viewManager->getGlobalCentreFrame())); |
859 } | 859 } |
860 | 860 |
861 void | 861 void |
862 MainWindowBase::selectToEnd() | 862 MainWindowBase::selectToEnd() |
863 { | 863 { |
864 if (!getMainModel()) return; | 864 if (!getMainModel()) return; |
865 m_viewManager->setSelection(Selection(m_viewManager->getGlobalCentreFrame(), | 865 m_viewManager->setSelection(Selection(m_viewManager->getGlobalCentreFrame(), |
866 getMainModel()->getEndFrame())); | 866 getMainModel()->getEndFrame())); |
867 } | 867 } |
868 | 868 |
869 void | 869 void |
870 MainWindowBase::selectVisible() | 870 MainWindowBase::selectVisible() |
871 { | 871 { |
1003 | 1003 |
1004 void | 1004 void |
1005 MainWindowBase::deleteSelected() | 1005 MainWindowBase::deleteSelected() |
1006 { | 1006 { |
1007 if (m_paneStack->getCurrentPane() && | 1007 if (m_paneStack->getCurrentPane() && |
1008 m_paneStack->getCurrentPane()->getSelectedLayer()) { | 1008 m_paneStack->getCurrentPane()->getSelectedLayer()) { |
1009 | 1009 |
1010 Layer *layer = m_paneStack->getCurrentPane()->getSelectedLayer(); | 1010 Layer *layer = m_paneStack->getCurrentPane()->getSelectedLayer(); |
1011 | 1011 |
1012 if (m_viewManager) { | 1012 if (m_viewManager) { |
1013 | 1013 |
1023 for (MultiSelection::SelectionList::iterator i = selections.begin(); | 1023 for (MultiSelection::SelectionList::iterator i = selections.begin(); |
1024 i != selections.end(); ++i) { | 1024 i != selections.end(); ++i) { |
1025 layer->deleteSelection(*i); | 1025 layer->deleteSelection(*i); |
1026 } | 1026 } |
1027 } | 1027 } |
1028 } | 1028 } |
1029 } | 1029 } |
1030 } | 1030 } |
1031 | 1031 |
1032 // FrameTimer method | 1032 // FrameTimer method |
1033 | 1033 |
1457 } | 1457 } |
1458 | 1458 |
1459 ReadOnlyWaveFileModel *newModel = new ReadOnlyWaveFileModel(source, rate); | 1459 ReadOnlyWaveFileModel *newModel = new ReadOnlyWaveFileModel(source, rate); |
1460 | 1460 |
1461 if (!newModel->isOK()) { | 1461 if (!newModel->isOK()) { |
1462 delete newModel; | 1462 delete newModel; |
1463 m_openingAudioFile = false; | 1463 m_openingAudioFile = false; |
1464 if (source.wasCancelled()) { | 1464 if (source.wasCancelled()) { |
1465 return FileOpenCancelled; | 1465 return FileOpenCancelled; |
1466 } else { | 1466 } else { |
1467 return FileOpenFailed; | 1467 return FileOpenFailed; |
1580 } | 1580 } |
1581 PlayParameterRepository::getInstance()->addPlayable(newModel); | 1581 PlayParameterRepository::getInstance()->addPlayable(newModel); |
1582 | 1582 |
1583 SVDEBUG << "SV about to call setMainModel(" << newModel << "): prevMain is " << prevMain << endl; | 1583 SVDEBUG << "SV about to call setMainModel(" << newModel << "): prevMain is " << prevMain << endl; |
1584 | 1584 |
1585 m_document->setMainModel(newModel); | 1585 m_document->setMainModel(newModel); |
1586 | 1586 |
1587 setupMenus(); | 1587 setupMenus(); |
1588 | 1588 |
1589 if (loadedTemplate || (m_sessionFile == "")) { | 1589 if (loadedTemplate || (m_sessionFile == "")) { |
1590 //!!! shouldn't be dealing directly with title from here -- call a method | 1590 //!!! shouldn't be dealing directly with title from here -- call a method |
1591 setWindowTitle(tr("%1: %2") | 1591 setWindowTitle(tr("%1: %2") |
1592 .arg(QApplication::applicationName()) | 1592 .arg(QApplication::applicationName()) |
1593 .arg(source.getLocation())); | 1593 .arg(source.getLocation())); |
1594 CommandHistory::getInstance()->clear(); | 1594 CommandHistory::getInstance()->clear(); |
1595 CommandHistory::getInstance()->documentSaved(); | 1595 CommandHistory::getInstance()->documentSaved(); |
1596 m_documentModified = false; | 1596 m_documentModified = false; |
1597 } else { | 1597 } else { |
1598 setWindowTitle(tr("%1: %2 [%3]") | 1598 setWindowTitle(tr("%1: %2 [%3]") |
1599 .arg(QApplication::applicationName()) | 1599 .arg(QApplication::applicationName()) |
1600 .arg(QFileInfo(m_sessionFile).fileName()) | 1600 .arg(QFileInfo(m_sessionFile).fileName()) |
1601 .arg(source.getLocation())); | 1601 .arg(source.getLocation())); |
1602 if (m_documentModified) { | 1602 if (m_documentModified) { |
1603 m_documentModified = false; | 1603 m_documentModified = false; |
1604 documentModified(); // so as to restore "(modified)" window title | 1604 documentModified(); // so as to restore "(modified)" window title |
1605 } | 1605 } |
1606 } | 1606 } |
1607 | 1607 |
1608 if (!source.isRemote()) m_audioFile = source.getLocalFilename(); | 1608 if (!source.isRemote()) m_audioFile = source.getLocalFilename(); |
1609 | 1609 |
1610 } else if (mode == CreateAdditionalModel) { | 1610 } else if (mode == CreateAdditionalModel) { |
1611 | 1611 |
1612 SVCERR << "Mode is CreateAdditionalModel" << endl; | 1612 SVCERR << "Mode is CreateAdditionalModel" << endl; |
1613 | 1613 |
1614 CommandHistory::getInstance()->startCompoundOperation | 1614 CommandHistory::getInstance()->startCompoundOperation |
1615 (tr("Import \"%1\"").arg(source.getBasename()), true); | 1615 (tr("Import \"%1\"").arg(source.getBasename()), true); |
1616 | 1616 |
1617 m_document->addImportedModel(newModel); | 1617 m_document->addImportedModel(newModel); |
1618 | 1618 |
1619 AddPaneCommand *command = new AddPaneCommand(this); | 1619 AddPaneCommand *command = new AddPaneCommand(this); |
1620 CommandHistory::getInstance()->addCommand(command); | 1620 CommandHistory::getInstance()->addCommand(command); |
1621 | 1621 |
1622 Pane *pane = command->getPane(); | 1622 Pane *pane = command->getPane(); |
1623 | 1623 |
1624 if (m_timeRulerLayer) { | 1624 if (m_timeRulerLayer) { |
1625 SVCERR << "Have time ruler, adding it" << endl; | 1625 SVCERR << "Have time ruler, adding it" << endl; |
1626 m_document->addLayerToView(pane, m_timeRulerLayer); | 1626 m_document->addLayerToView(pane, m_timeRulerLayer); |
1627 } else { | 1627 } else { |
1628 SVCERR << "Do not have time ruler" << endl; | 1628 SVCERR << "Do not have time ruler" << endl; |
1629 } | 1629 } |
1630 | 1630 |
1631 Layer *newLayer = m_document->createImportedLayer(newModel); | 1631 Layer *newLayer = m_document->createImportedLayer(newModel); |
1632 | 1632 |
1633 if (newLayer) { | 1633 if (newLayer) { |
1634 m_document->addLayerToView(pane, newLayer); | 1634 m_document->addLayerToView(pane, newLayer); |
1635 } | 1635 } |
1636 | 1636 |
1637 CommandHistory::getInstance()->endCompoundOperation(); | 1637 CommandHistory::getInstance()->endCompoundOperation(); |
1638 | 1638 |
1639 } else if (mode == ReplaceCurrentPane) { | 1639 } else if (mode == ReplaceCurrentPane) { |
1640 | 1640 |
1641 // We know there is a current pane, otherwise we would have | 1641 // We know there is a current pane, otherwise we would have |
1642 // reset the mode to CreateAdditionalModel above; and we know | 1642 // reset the mode to CreateAdditionalModel above; and we know |
1653 replace = layer; | 1653 replace = layer; |
1654 break; | 1654 break; |
1655 } | 1655 } |
1656 } | 1656 } |
1657 | 1657 |
1658 CommandHistory::getInstance()->startCompoundOperation | 1658 CommandHistory::getInstance()->startCompoundOperation |
1659 (tr("Import \"%1\"").arg(source.getBasename()), true); | 1659 (tr("Import \"%1\"").arg(source.getBasename()), true); |
1660 | 1660 |
1661 m_document->addImportedModel(newModel); | 1661 m_document->addImportedModel(newModel); |
1662 | 1662 |
1663 if (replace) { | 1663 if (replace) { |
1664 m_document->removeLayerFromView(pane, replace); | 1664 m_document->removeLayerFromView(pane, replace); |
1665 } | 1665 } |
1666 | 1666 |
1667 Layer *newLayer = m_document->createImportedLayer(newModel); | 1667 Layer *newLayer = m_document->createImportedLayer(newModel); |
1668 | 1668 |
1669 if (newLayer) { | 1669 if (newLayer) { |
1670 m_document->addLayerToView(pane, newLayer); | 1670 m_document->addLayerToView(pane, newLayer); |
1671 } | 1671 } |
1672 | 1672 |
1673 CommandHistory::getInstance()->endCompoundOperation(); | 1673 CommandHistory::getInstance()->endCompoundOperation(); |
1674 } | 1674 } |
1675 | 1675 |
1676 updateMenuStates(); | 1676 updateMenuStates(); |
1677 m_recentFiles.addFile(source.getLocation()); | 1677 m_recentFiles.addFile(source.getLocation()); |
1678 if (!source.isRemote()) { | 1678 if (!source.isRemote()) { |
1736 SVDEBUG << "MainWindowBase::openLayer(" << source.getLocation() << ")" << endl; | 1736 SVDEBUG << "MainWindowBase::openLayer(" << source.getLocation() << ")" << endl; |
1737 | 1737 |
1738 Pane *pane = m_paneStack->getCurrentPane(); | 1738 Pane *pane = m_paneStack->getCurrentPane(); |
1739 | 1739 |
1740 if (!pane) { | 1740 if (!pane) { |
1741 // shouldn't happen, as the menu action should have been disabled | 1741 // shouldn't happen, as the menu action should have been disabled |
1742 cerr << "WARNING: MainWindowBase::openLayer: no current pane" << endl; | 1742 cerr << "WARNING: MainWindowBase::openLayer: no current pane" << endl; |
1743 return FileOpenWrongMode; | 1743 return FileOpenWrongMode; |
1744 } | 1744 } |
1745 | 1745 |
1746 if (!getMainModel()) { | 1746 if (!getMainModel()) { |
1747 // shouldn't happen, as the menu action should have been disabled | 1747 // shouldn't happen, as the menu action should have been disabled |
1748 cerr << "WARNING: MainWindowBase::openLayer: No main model -- hence no default sample rate available" << endl; | 1748 cerr << "WARNING: MainWindowBase::openLayer: No main model -- hence no default sample rate available" << endl; |
1749 return FileOpenWrongMode; | 1749 return FileOpenWrongMode; |
1750 } | 1750 } |
1751 | 1751 |
1752 if (!source.isAvailable()) return FileOpenFailed; | 1752 if (!source.isAvailable()) return FileOpenFailed; |
1753 source.waitForData(); | 1753 source.waitForData(); |
1754 | 1754 |
1868 SVDEBUG << "MainWindowBase::openImage(" << source.getLocation() << ")" << endl; | 1868 SVDEBUG << "MainWindowBase::openImage(" << source.getLocation() << ")" << endl; |
1869 | 1869 |
1870 Pane *pane = m_paneStack->getCurrentPane(); | 1870 Pane *pane = m_paneStack->getCurrentPane(); |
1871 | 1871 |
1872 if (!pane) { | 1872 if (!pane) { |
1873 // shouldn't happen, as the menu action should have been disabled | 1873 // shouldn't happen, as the menu action should have been disabled |
1874 cerr << "WARNING: MainWindowBase::openImage: no current pane" << endl; | 1874 cerr << "WARNING: MainWindowBase::openImage: no current pane" << endl; |
1875 return FileOpenWrongMode; | 1875 return FileOpenWrongMode; |
1876 } | 1876 } |
1877 | 1877 |
1878 if (!m_document->getMainModel()) { | 1878 if (!m_document->getMainModel()) { |
1879 return FileOpenWrongMode; | 1879 return FileOpenWrongMode; |
1880 } | 1880 } |
2060 | 2060 |
2061 if (ok) { | 2061 if (ok) { |
2062 | 2062 |
2063 emit activity(tr("Import session file \"%1\"").arg(source.getLocation())); | 2063 emit activity(tr("Import session file \"%1\"").arg(source.getLocation())); |
2064 | 2064 |
2065 setWindowTitle(tr("%1: %2") | 2065 setWindowTitle(tr("%1: %2") |
2066 .arg(QApplication::applicationName()) | 2066 .arg(QApplication::applicationName()) |
2067 .arg(source.getLocation())); | 2067 .arg(source.getLocation())); |
2068 | 2068 |
2069 if (!source.isRemote()) m_sessionFile = source.getLocalFilename(); | 2069 if (!source.isRemote()) m_sessionFile = source.getLocalFilename(); |
2070 | 2070 |
2071 setupMenus(); | 2071 setupMenus(); |
2072 findTimeRulerLayer(); | 2072 findTimeRulerLayer(); |
2073 | 2073 |
2074 CommandHistory::getInstance()->clear(); | 2074 CommandHistory::getInstance()->clear(); |
2075 CommandHistory::getInstance()->documentSaved(); | 2075 CommandHistory::getInstance()->documentSaved(); |
2076 m_documentModified = false; | 2076 m_documentModified = false; |
2077 updateMenuStates(); | 2077 updateMenuStates(); |
2078 | 2078 |
2079 m_recentFiles.addFile(source.getLocation()); | 2079 m_recentFiles.addFile(source.getLocation()); |
2080 | 2080 |
2081 if (!source.isRemote()) { | 2081 if (!source.isRemote()) { |
2082 // for file dialog | 2082 // for file dialog |
2085 } | 2085 } |
2086 | 2086 |
2087 emit sessionLoaded(); | 2087 emit sessionLoaded(); |
2088 | 2088 |
2089 } else { | 2089 } else { |
2090 setWindowTitle(QApplication::applicationName()); | 2090 setWindowTitle(QApplication::applicationName()); |
2091 } | 2091 } |
2092 | 2092 |
2093 return ok ? FileOpenSucceeded : FileOpenFailed; | 2093 return ok ? FileOpenSucceeded : FileOpenFailed; |
2094 } | 2094 } |
2095 | 2095 |
2159 | 2159 |
2160 if (ok) { | 2160 if (ok) { |
2161 | 2161 |
2162 emit activity(tr("Open session template \"%1\"").arg(source.getLocation())); | 2162 emit activity(tr("Open session template \"%1\"").arg(source.getLocation())); |
2163 | 2163 |
2164 setupMenus(); | 2164 setupMenus(); |
2165 findTimeRulerLayer(); | 2165 findTimeRulerLayer(); |
2166 | 2166 |
2167 CommandHistory::getInstance()->clear(); | 2167 CommandHistory::getInstance()->clear(); |
2168 CommandHistory::getInstance()->documentSaved(); | 2168 CommandHistory::getInstance()->documentSaved(); |
2169 m_documentModified = false; | 2169 m_documentModified = false; |
2170 updateMenuStates(); | 2170 updateMenuStates(); |
2171 | 2171 |
2172 emit sessionLoaded(); | 2172 emit sessionLoaded(); |
2173 } | 2173 } |
2174 | 2174 |
2175 return ok ? FileOpenSucceeded : FileOpenFailed; | 2175 return ok ? FileOpenSucceeded : FileOpenFailed; |
2528 MainWindowBase::createDocument() | 2528 MainWindowBase::createDocument() |
2529 { | 2529 { |
2530 m_document = new Document; | 2530 m_document = new Document; |
2531 | 2531 |
2532 connect(m_document, SIGNAL(layerAdded(Layer *)), | 2532 connect(m_document, SIGNAL(layerAdded(Layer *)), |
2533 this, SLOT(layerAdded(Layer *))); | 2533 this, SLOT(layerAdded(Layer *))); |
2534 connect(m_document, SIGNAL(layerRemoved(Layer *)), | 2534 connect(m_document, SIGNAL(layerRemoved(Layer *)), |
2535 this, SLOT(layerRemoved(Layer *))); | 2535 this, SLOT(layerRemoved(Layer *))); |
2536 connect(m_document, SIGNAL(layerAboutToBeDeleted(Layer *)), | 2536 connect(m_document, SIGNAL(layerAboutToBeDeleted(Layer *)), |
2537 this, SLOT(layerAboutToBeDeleted(Layer *))); | 2537 this, SLOT(layerAboutToBeDeleted(Layer *))); |
2538 connect(m_document, SIGNAL(layerInAView(Layer *, bool)), | 2538 connect(m_document, SIGNAL(layerInAView(Layer *, bool)), |
2539 this, SLOT(layerInAView(Layer *, bool))); | 2539 this, SLOT(layerInAView(Layer *, bool))); |
2540 | 2540 |
2541 connect(m_document, SIGNAL(modelAdded(Model *)), | 2541 connect(m_document, SIGNAL(modelAdded(Model *)), |
2542 this, SLOT(modelAdded(Model *))); | 2542 this, SLOT(modelAdded(Model *))); |
2543 connect(m_document, SIGNAL(mainModelChanged(WaveFileModel *)), | 2543 connect(m_document, SIGNAL(mainModelChanged(WaveFileModel *)), |
2544 this, SLOT(mainModelChanged(WaveFileModel *))); | 2544 this, SLOT(mainModelChanged(WaveFileModel *))); |
2545 connect(m_document, SIGNAL(modelAboutToBeDeleted(Model *)), | 2545 connect(m_document, SIGNAL(modelAboutToBeDeleted(Model *)), |
2546 this, SLOT(modelAboutToBeDeleted(Model *))); | 2546 this, SLOT(modelAboutToBeDeleted(Model *))); |
2547 | 2547 |
2548 connect(m_document, SIGNAL(modelGenerationFailed(QString, QString)), | 2548 connect(m_document, SIGNAL(modelGenerationFailed(QString, QString)), |
2549 this, SLOT(modelGenerationFailed(QString, QString))); | 2549 this, SLOT(modelGenerationFailed(QString, QString))); |
2550 connect(m_document, SIGNAL(modelRegenerationWarning(QString, QString, QString)), | 2550 connect(m_document, SIGNAL(modelRegenerationWarning(QString, QString, QString)), |
2551 this, SLOT(modelRegenerationWarning(QString, QString, QString))); | 2551 this, SLOT(modelRegenerationWarning(QString, QString, QString))); |
2657 } | 2657 } |
2658 | 2658 |
2659 out << "<display>\n"; | 2659 out << "<display>\n"; |
2660 | 2660 |
2661 out << QString(" <window width=\"%1\" height=\"%2\"/>\n") | 2661 out << QString(" <window width=\"%1\" height=\"%2\"/>\n") |
2662 .arg(width()).arg(height()); | 2662 .arg(width()).arg(height()); |
2663 | 2663 |
2664 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) { | 2664 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) { |
2665 | 2665 |
2666 Pane *pane = m_paneStack->getPane(i); | 2666 Pane *pane = m_paneStack->getPane(i); |
2667 | 2667 |
2668 if (pane) { | 2668 if (pane) { |
2669 pane->toXml(out, indent); | 2669 pane->toXml(out, indent); |
2670 } | 2670 } |
2671 } | 2671 } |
2672 | 2672 |
2673 out << "</display>\n"; | 2673 out << "</display>\n"; |
2674 | 2674 |
2675 m_viewManager->getSelection().toXml(out); | 2675 m_viewManager->getSelection().toXml(out); |
2963 if (action) action->setChecked(false); | 2963 if (action) action->setChecked(false); |
2964 } else { | 2964 } else { |
2965 if (m_audioIO) m_audioIO->resume(); | 2965 if (m_audioIO) m_audioIO->resume(); |
2966 else if (m_playTarget) m_playTarget->resume(); | 2966 else if (m_playTarget) m_playTarget->resume(); |
2967 playbackFrameChanged(m_viewManager->getPlaybackFrame()); | 2967 playbackFrameChanged(m_viewManager->getPlaybackFrame()); |
2968 m_playSource->play(m_viewManager->getPlaybackFrame()); | 2968 m_playSource->play(m_viewManager->getPlaybackFrame()); |
2969 } | 2969 } |
2970 } | 2970 } |
2971 | 2971 |
2972 void | 2972 void |
2973 MainWindowBase::record() | 2973 MainWindowBase::record() |
3080 | 3080 |
3081 m_document->setMainModel(model); | 3081 m_document->setMainModel(model); |
3082 setupMenus(); | 3082 setupMenus(); |
3083 findTimeRulerLayer(); | 3083 findTimeRulerLayer(); |
3084 | 3084 |
3085 if (loadedTemplate || (m_sessionFile == "")) { | 3085 if (loadedTemplate || (m_sessionFile == "")) { |
3086 //!!! shouldn't be dealing directly with title from here -- call a method | 3086 //!!! shouldn't be dealing directly with title from here -- call a method |
3087 setWindowTitle(tr("%1: %2") | 3087 setWindowTitle(tr("%1: %2") |
3088 .arg(QApplication::applicationName()) | 3088 .arg(QApplication::applicationName()) |
3089 .arg(model->getLocation())); | 3089 .arg(model->getLocation())); |
3090 CommandHistory::getInstance()->clear(); | 3090 CommandHistory::getInstance()->clear(); |
3091 CommandHistory::getInstance()->documentSaved(); | 3091 CommandHistory::getInstance()->documentSaved(); |
3092 m_documentModified = false; | 3092 m_documentModified = false; |
3093 } else { | 3093 } else { |
3094 setWindowTitle(tr("%1: %2 [%3]") | 3094 setWindowTitle(tr("%1: %2 [%3]") |
3095 .arg(QApplication::applicationName()) | 3095 .arg(QApplication::applicationName()) |
3096 .arg(QFileInfo(m_sessionFile).fileName()) | 3096 .arg(QFileInfo(m_sessionFile).fileName()) |
3097 .arg(model->getLocation())); | 3097 .arg(model->getLocation())); |
3098 if (m_documentModified) { | 3098 if (m_documentModified) { |
3099 m_documentModified = false; | 3099 m_documentModified = false; |
3100 documentModified(); // so as to restore "(modified)" window title | 3100 documentModified(); // so as to restore "(modified)" window title |
3101 } | 3101 } |
3102 } | 3102 } |
3103 | 3103 |
3104 } else { | 3104 } else { |
3105 | 3105 |
3106 CommandHistory::getInstance()->startCompoundOperation | 3106 CommandHistory::getInstance()->startCompoundOperation |
3107 (tr("Import Recorded Audio"), true); | 3107 (tr("Import Recorded Audio"), true); |
3120 Layer *newLayer = m_document->createImportedLayer(model); | 3120 Layer *newLayer = m_document->createImportedLayer(model); |
3121 | 3121 |
3122 if (newLayer) { | 3122 if (newLayer) { |
3123 m_document->addLayerToView(pane, newLayer); | 3123 m_document->addLayerToView(pane, newLayer); |
3124 } | 3124 } |
3125 | 3125 |
3126 CommandHistory::getInstance()->endCompoundOperation(); | 3126 CommandHistory::getInstance()->endCompoundOperation(); |
3127 } | 3127 } |
3128 | 3128 |
3129 updateMenuStates(); | 3129 updateMenuStates(); |
3130 m_recentFiles.addFile(model->getLocation()); | 3130 m_recentFiles.addFile(model->getLocation()); |
3390 } | 3390 } |
3391 | 3391 |
3392 MainWindowBase::AddPaneCommand::~AddPaneCommand() | 3392 MainWindowBase::AddPaneCommand::~AddPaneCommand() |
3393 { | 3393 { |
3394 if (m_pane && !m_added) { | 3394 if (m_pane && !m_added) { |
3395 m_mw->m_paneStack->deletePane(m_pane); | 3395 m_mw->m_paneStack->deletePane(m_pane); |
3396 } | 3396 } |
3397 } | 3397 } |
3398 | 3398 |
3399 QString | 3399 QString |
3400 MainWindowBase::AddPaneCommand::getName() const | 3400 MainWindowBase::AddPaneCommand::getName() const |
3404 | 3404 |
3405 void | 3405 void |
3406 MainWindowBase::AddPaneCommand::execute() | 3406 MainWindowBase::AddPaneCommand::execute() |
3407 { | 3407 { |
3408 if (!m_pane) { | 3408 if (!m_pane) { |
3409 m_prevCurrentPane = m_mw->m_paneStack->getCurrentPane(); | 3409 m_prevCurrentPane = m_mw->m_paneStack->getCurrentPane(); |
3410 m_pane = m_mw->m_paneStack->addPane(); | 3410 m_pane = m_mw->m_paneStack->addPane(); |
3411 | 3411 |
3412 connect(m_pane, SIGNAL(contextHelpChanged(const QString &)), | 3412 connect(m_pane, SIGNAL(contextHelpChanged(const QString &)), |
3413 m_mw, SLOT(contextHelpChanged(const QString &))); | 3413 m_mw, SLOT(contextHelpChanged(const QString &))); |
3414 } else { | 3414 } else { |
3415 m_mw->m_paneStack->showPane(m_pane); | 3415 m_mw->m_paneStack->showPane(m_pane); |
3416 } | 3416 } |
3417 | 3417 |
3418 m_mw->m_paneStack->setCurrentPane(m_pane); | 3418 m_mw->m_paneStack->setCurrentPane(m_pane); |
3419 m_added = true; | 3419 m_added = true; |
3420 } | 3420 } |
3436 } | 3436 } |
3437 | 3437 |
3438 MainWindowBase::RemovePaneCommand::~RemovePaneCommand() | 3438 MainWindowBase::RemovePaneCommand::~RemovePaneCommand() |
3439 { | 3439 { |
3440 if (m_pane && !m_added) { | 3440 if (m_pane && !m_added) { |
3441 m_mw->m_paneStack->deletePane(m_pane); | 3441 m_mw->m_paneStack->deletePane(m_pane); |
3442 } | 3442 } |
3443 } | 3443 } |
3444 | 3444 |
3445 QString | 3445 QString |
3446 MainWindowBase::RemovePaneCommand::getName() const | 3446 MainWindowBase::RemovePaneCommand::getName() const |
3466 | 3466 |
3467 void | 3467 void |
3468 MainWindowBase::deleteCurrentPane() | 3468 MainWindowBase::deleteCurrentPane() |
3469 { | 3469 { |
3470 CommandHistory::getInstance()->startCompoundOperation | 3470 CommandHistory::getInstance()->startCompoundOperation |
3471 (tr("Delete Pane"), true); | 3471 (tr("Delete Pane"), true); |
3472 | 3472 |
3473 Pane *pane = m_paneStack->getCurrentPane(); | 3473 Pane *pane = m_paneStack->getCurrentPane(); |
3474 if (pane) { | 3474 if (pane) { |
3475 while (pane->getLayerCount() > 0) { | 3475 while (pane->getLayerCount() > 0) { |
3476 Layer *layer = pane->getLayer(0); | 3476 Layer *layer = pane->getLayer(0); |
3477 if (layer) { | 3477 if (layer) { |
3478 m_document->removeLayerFromView(pane, layer); | 3478 m_document->removeLayerFromView(pane, layer); |
3479 } else { | 3479 } else { |
3480 break; | 3480 break; |
3481 } | 3481 } |
3482 } | 3482 } |
3483 | 3483 |
3484 RemovePaneCommand *command = new RemovePaneCommand(this, pane); | 3484 RemovePaneCommand *command = new RemovePaneCommand(this, pane); |
3485 CommandHistory::getInstance()->addCommand(command); | 3485 CommandHistory::getInstance()->addCommand(command); |
3486 } | 3486 } |
3487 | 3487 |
3488 CommandHistory::getInstance()->endCompoundOperation(); | 3488 CommandHistory::getInstance()->endCompoundOperation(); |
3489 | 3489 |
3490 updateMenuStates(); | 3490 updateMenuStates(); |
3493 void | 3493 void |
3494 MainWindowBase::deleteCurrentLayer() | 3494 MainWindowBase::deleteCurrentLayer() |
3495 { | 3495 { |
3496 Pane *pane = m_paneStack->getCurrentPane(); | 3496 Pane *pane = m_paneStack->getCurrentPane(); |
3497 if (pane) { | 3497 if (pane) { |
3498 Layer *layer = pane->getSelectedLayer(); | 3498 Layer *layer = pane->getSelectedLayer(); |
3499 if (layer) { | 3499 if (layer) { |
3500 m_document->removeLayerFromView(pane, layer); | 3500 m_document->removeLayerFromView(pane, layer); |
3501 } | 3501 } |
3502 } | 3502 } |
3503 updateMenuStates(); | 3503 updateMenuStates(); |
3504 } | 3504 } |
3505 | 3505 |
3506 void | 3506 void |
3777 // SVDEBUG << "MainWindowBase::layerAboutToBeDeleted(" << layer << ")" << endl; | 3777 // SVDEBUG << "MainWindowBase::layerAboutToBeDeleted(" << layer << ")" << endl; |
3778 | 3778 |
3779 removeLayerEditDialog(layer); | 3779 removeLayerEditDialog(layer); |
3780 | 3780 |
3781 if (m_timeRulerLayer && (layer == m_timeRulerLayer)) { | 3781 if (m_timeRulerLayer && (layer == m_timeRulerLayer)) { |
3782 // cerr << "(this is the time ruler layer)" << endl; | 3782 // cerr << "(this is the time ruler layer)" << endl; |
3783 m_timeRulerLayer = 0; | 3783 m_timeRulerLayer = 0; |
3784 } | 3784 } |
3785 } | 3785 } |
3786 | 3786 |
3787 void | 3787 void |
3788 MainWindowBase::layerInAView(Layer *layer, bool inAView) | 3788 MainWindowBase::layerInAView(Layer *layer, bool inAView) |
3840 | 3840 |
3841 void | 3841 void |
3842 MainWindowBase::modelAdded(Model *model) | 3842 MainWindowBase::modelAdded(Model *model) |
3843 { | 3843 { |
3844 // SVDEBUG << "MainWindowBase::modelAdded(" << model << ")" << endl; | 3844 // SVDEBUG << "MainWindowBase::modelAdded(" << model << ")" << endl; |
3845 std::cerr << "\nAdding model " << model->getTypeName() << " to playsource " << std::endl; | 3845 std::cerr << "\nAdding model " << model->getTypeName() << " to playsource " << std::endl; |
3846 m_playSource->addModel(model); | 3846 m_playSource->addModel(model); |
3847 } | 3847 } |
3848 | 3848 |
3849 void | 3849 void |
3850 MainWindowBase::mainModelChanged(WaveFileModel *model) | 3850 MainWindowBase::mainModelChanged(WaveFileModel *model) |
3883 << pane << endl; | 3883 << pane << endl; |
3884 return; | 3884 return; |
3885 } | 3885 } |
3886 | 3886 |
3887 CommandHistory::getInstance()->startCompoundOperation | 3887 CommandHistory::getInstance()->startCompoundOperation |
3888 (tr("Delete Pane"), true); | 3888 (tr("Delete Pane"), true); |
3889 | 3889 |
3890 while (pane->getLayerCount() > 0) { | 3890 while (pane->getLayerCount() > 0) { |
3891 Layer *layer = pane->getLayer(0); | 3891 Layer *layer = pane->getLayer(0); |
3892 if (layer) { | 3892 if (layer) { |
3893 m_document->removeLayerFromView(pane, layer); | 3893 m_document->removeLayerFromView(pane, layer); |