comparison main/MainWindow.cpp @ 7:c3ef80114040

* Add zoom thumbwheels to Pane. Implement horizontal thumbwheel, and vertical depending on layer type (supported for waveform and spectrogram, though wrong for log-scale spectrogram at the moment). * Add bare bones of a spectrum layer. * Add window icon * Add shortcut for "insert time instant" on laptops without keypad enter (";") * Delete FFT processing thread when it exits (at least, next time we're asked for something interesting) * Get audio file extensions from the file readers, and thus from libsndfile for the wave file reader -- leads to rather a wide combo box in file dialog though * Better refresh order for spectrogram (redraw centre section first)
author Chris Cannam
date Fri, 04 Aug 2006 17:01:37 +0000
parents 0a687ed1b50f
children 92cb01225e7a
comparison
equal deleted inserted replaced
6:d4487202d0e8 7:c3ef80114040
72 #include <QStatusBar> 72 #include <QStatusBar>
73 #include <QTreeView> 73 #include <QTreeView>
74 #include <QFile> 74 #include <QFile>
75 #include <QTextStream> 75 #include <QTextStream>
76 #include <QProcess> 76 #include <QProcess>
77 #include <QShortcut>
77 #include <QSettings> 78 #include <QSettings>
78 79
79 #include <iostream> 80 #include <iostream>
80 #include <cstdio> 81 #include <cstdio>
81 #include <errno.h> 82 #include <errno.h>
177 SLOT(preferenceChanged(PropertyContainer::PropertyName))); 178 SLOT(preferenceChanged(PropertyContainer::PropertyName)));
178 179
179 setupMenus(); 180 setupMenus();
180 setupToolbars(); 181 setupToolbars();
181 182
182 // statusBar()->addWidget(m_descriptionLabel); 183 statusBar()->addWidget(m_descriptionLabel);
183 184
184 newSession(); 185 newSession();
185 } 186 }
186 187
187 MainWindow::~MainWindow() 188 MainWindow::~MainWindow()
402 action = new QAction(tr("&Insert Instant at Playback Position"), this); 403 action = new QAction(tr("&Insert Instant at Playback Position"), this);
403 action->setShortcut(tr("Enter")); 404 action->setShortcut(tr("Enter"));
404 connect(action, SIGNAL(triggered()), this, SLOT(insertInstant())); 405 connect(action, SIGNAL(triggered()), this, SLOT(insertInstant()));
405 connect(this, SIGNAL(canInsertInstant(bool)), action, SLOT(setEnabled(bool))); 406 connect(this, SIGNAL(canInsertInstant(bool)), action, SLOT(setEnabled(bool)));
406 menu->addAction(action); 407 menu->addAction(action);
408
409 // Laptop shortcut (no keypad Enter key)
410 connect(new QShortcut(tr(";"), this), SIGNAL(activated()),
411 this, SLOT(insertInstant()));
407 412
408 menu = menuBar()->addMenu(tr("&View")); 413 menu = menuBar()->addMenu(tr("&View"));
409 414
410 QActionGroup *overlayGroup = new QActionGroup(this); 415 QActionGroup *overlayGroup = new QActionGroup(this);
411 416
428 menu->addAction(action); 433 menu->addAction(action);
429 434
430 action = new QAction(tr("&All Text Overlays"), this); 435 action = new QAction(tr("&All Text Overlays"), this);
431 action->setShortcut(tr("8")); 436 action->setShortcut(tr("8"));
432 action->setStatusTip(tr("Show texts for frame times, layer names etc")); 437 action->setStatusTip(tr("Show texts for frame times, layer names etc"));
433 connect(action, SIGNAL(triggered()), this, SLOT(showAllOverlays())); 438 connect(action, SIGNAL(triggered()), this, SLOT(showAllTextOverlays()));
434 action->setCheckable(true); 439 action->setCheckable(true);
435 action->setChecked(false); 440 action->setChecked(false);
436 overlayGroup->addAction(action); 441 overlayGroup->addAction(action);
437 menu->addAction(action); 442 menu->addAction(action);
438 443
491 496
492 action = new QAction(tr("Zoom to &Fit"), this); 497 action = new QAction(tr("Zoom to &Fit"), this);
493 action->setStatusTip(tr("Zoom to show the whole file")); 498 action->setStatusTip(tr("Zoom to show the whole file"));
494 connect(action, SIGNAL(triggered()), this, SLOT(zoomToFit())); 499 connect(action, SIGNAL(triggered()), this, SLOT(zoomToFit()));
495 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool))); 500 connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
501 menu->addAction(action);
502
503 action = new QAction(tr("Show &Zoom Wheels"), this);
504 action->setShortcut(tr("Z"));
505 action->setStatusTip(tr("Show thumbwheels for zooming horizontally and vertically"));
506 connect(action, SIGNAL(triggered()), this, SLOT(toggleZoomWheels()));
507 action->setCheckable(true);
508 action->setChecked(m_viewManager->getZoomWheelsEnabled());
496 menu->addAction(action); 509 menu->addAction(action);
497 510
498 /*!!! This one doesn't work properly yet 511 /*!!! This one doesn't work properly yet
499 512
500 menu->addSeparator(); 513 menu->addSeparator();
610 623
611 LayerFactory::LayerType backgroundTypes[] = { 624 LayerFactory::LayerType backgroundTypes[] = {
612 LayerFactory::Waveform, 625 LayerFactory::Waveform,
613 LayerFactory::Spectrogram, 626 LayerFactory::Spectrogram,
614 LayerFactory::MelodicRangeSpectrogram, 627 LayerFactory::MelodicRangeSpectrogram,
615 LayerFactory::PeakFrequencySpectrogram 628 LayerFactory::PeakFrequencySpectrogram,
629 LayerFactory::Spectrum
616 }; 630 };
617 631
618 for (unsigned int i = 0; 632 for (unsigned int i = 0;
619 i < sizeof(backgroundTypes)/sizeof(backgroundTypes[0]); ++i) { 633 i < sizeof(backgroundTypes)/sizeof(backgroundTypes[0]); ++i) {
620 634
683 } else { 697 } else {
684 tipText = tr("Add a new layer showing a spectrogram set up for tracking frequencies"); 698 tipText = tr("Add a new layer showing a spectrogram set up for tracking frequencies");
685 } 699 }
686 break; 700 break;
687 701
702 case LayerFactory::Spectrum:
703 mainText = tr("Add Spectr&um");
704 if (menuType == 0) {
705 shortcutText = tr("Alt+U");
706 tipText = tr("Add a new pane showing a frequency spectrum");
707 } else {
708 tipText = tr("Add a new layer showing a frequency spectrum");
709 }
710 break;
711
688 default: break; 712 default: break;
689 } 713 }
690 714
691 if (isOnly) { 715 if (isOnly) {
692 716
2380 { 2404 {
2381 m_viewManager->setOverlayMode(ViewManager::BasicOverlays); 2405 m_viewManager->setOverlayMode(ViewManager::BasicOverlays);
2382 } 2406 }
2383 2407
2384 void 2408 void
2385 MainWindow::showAllOverlays() 2409 MainWindow::showAllTextOverlays()
2386 { 2410 {
2387 m_viewManager->setOverlayMode(ViewManager::AllOverlays); 2411 m_viewManager->setOverlayMode(ViewManager::AllOverlays);
2412 }
2413
2414 void
2415 MainWindow::toggleZoomWheels()
2416 {
2417 if (m_viewManager->getZoomWheelsEnabled()) {
2418 m_viewManager->setZoomWheelsEnabled(false);
2419 } else {
2420 m_viewManager->setZoomWheelsEnabled(true);
2421 }
2388 } 2422 }
2389 2423
2390 void 2424 void
2391 MainWindow::play() 2425 MainWindow::play()
2392 { 2426 {
2490 2524
2491 AddPaneCommand *command = new AddPaneCommand(this); 2525 AddPaneCommand *command = new AddPaneCommand(this);
2492 CommandHistory::getInstance()->addCommand(command); 2526 CommandHistory::getInstance()->addCommand(command);
2493 2527
2494 Pane *pane = command->getPane(); 2528 Pane *pane = command->getPane();
2529
2530 if (i->second.layer == LayerFactory::Spectrum) {
2531 pane->setPlaybackFollow(View::PlaybackScrollContinuous);
2532 }
2495 2533
2496 if (i->second.layer != LayerFactory::TimeRuler) { 2534 if (i->second.layer != LayerFactory::TimeRuler) {
2497 if (!m_timeRulerLayer) { 2535 if (!m_timeRulerLayer) {
2498 // std::cerr << "no time ruler layer, creating one" << std::endl; 2536 // std::cerr << "no time ruler layer, creating one" << std::endl;
2499 m_timeRulerLayer = m_document->createMainModelLayer 2537 m_timeRulerLayer = m_document->createMainModelLayer