Mercurial > hg > tony
comparison src/MainWindow.cpp @ 128:06f9caf5928d
Initial hack for switching visibility & audibility of layers on and off. This doesn't work well.
author | Chris Cannam |
---|---|
date | Thu, 09 Jan 2014 14:05:20 +0000 |
parents | f2b8cff703ed |
children | eae80729b665 |
comparison
equal
deleted
inserted
replaced
127:5d60f5102baf | 128:06f9caf5928d |
---|---|
69 #include <QDir> | 69 #include <QDir> |
70 #include <QProcess> | 70 #include <QProcess> |
71 #include <QPushButton> | 71 #include <QPushButton> |
72 #include <QSettings> | 72 #include <QSettings> |
73 #include <QScrollArea> | 73 #include <QScrollArea> |
74 #include <QPainter> | |
74 | 75 |
75 #include <iostream> | 76 #include <iostream> |
76 #include <cstdio> | 77 #include <cstdio> |
77 #include <errno.h> | 78 #include <errno.h> |
78 | 79 |
214 layout->setColumnStretch(1, 10); | 215 layout->setColumnStretch(1, 10); |
215 | 216 |
216 frame->setLayout(layout); | 217 frame->setLayout(layout); |
217 | 218 |
218 m_analyser = new Analyser(); | 219 m_analyser = new Analyser(); |
220 connect(m_analyser, SIGNAL(layersChanged()), | |
221 this, SLOT(updateLayerStatuses())); | |
219 | 222 |
220 setupMenus(); | 223 setupMenus(); |
221 setupToolbars(); | 224 setupToolbars(); |
222 setupHelpMenu(); | 225 setupHelpMenu(); |
223 | 226 |
658 m_rightButtonPlaybackMenu->addAction(normalAction); | 661 m_rightButtonPlaybackMenu->addAction(normalAction); |
659 | 662 |
660 toolbar = addToolBar(tr("Playback Controls")); | 663 toolbar = addToolBar(tr("Playback Controls")); |
661 toolbar->addWidget(m_playSpeed); | 664 toolbar->addWidget(m_playSpeed); |
662 toolbar->addWidget(m_fader); | 665 toolbar->addWidget(m_fader); |
666 | |
667 toolbar = addToolBar(tr("Show and Play")); | |
668 | |
669 QAction *cycleWaveformAction = toolbar->addAction(tr("Audio")); | |
670 //!!! shortcut etc | |
671 connect(cycleWaveformAction, SIGNAL(triggered()), this, SLOT(cycleWaveform())); | |
672 | |
673 m_waveformStatus = new QLabel(); | |
674 toolbar->addWidget(m_waveformStatus); | |
675 | |
676 QAction *cyclePitchAction = toolbar->addAction(tr("Pitch")); | |
677 //!!! shortcut etc | |
678 connect(cyclePitchAction, SIGNAL(triggered()), this, SLOT(cyclePitch())); | |
679 | |
680 m_pitchStatus = new QLabel(); | |
681 toolbar->addWidget(m_pitchStatus); | |
682 | |
683 QAction *cycleNotesAction = toolbar->addAction(tr("Notes")); | |
684 //!!! shortcut etc | |
685 connect(cycleNotesAction, SIGNAL(triggered()), this, SLOT(cycleNotes())); | |
686 | |
687 m_notesStatus = new QLabel(); | |
688 toolbar->addWidget(m_notesStatus); | |
689 | |
690 updateLayerStatuses(); | |
663 | 691 |
664 Pane::registerShortcuts(*m_keyReference); | 692 Pane::registerShortcuts(*m_keyReference); |
665 } | 693 } |
666 | 694 |
667 void | 695 void |
737 m_ffwdAction->setStatusTip(tr("Fast forward")); | 765 m_ffwdAction->setStatusTip(tr("Fast forward")); |
738 m_rwdAction->setText(tr("Rewind")); | 766 m_rwdAction->setText(tr("Rewind")); |
739 m_rwdAction->setStatusTip(tr("Rewind")); | 767 m_rwdAction->setStatusTip(tr("Rewind")); |
740 } | 768 } |
741 } | 769 } |
770 } | |
771 | |
772 void | |
773 MainWindow::updateLayerStatuses() | |
774 { | |
775 IconLoader il; | |
776 QPixmap eye = il.loadPixmap("eye"); | |
777 QPixmap speaker = il.loadPixmap("speaker"); | |
778 | |
779 // NB these need to be in the same order as the Analyser::Component enum | |
780 QLabel *statuses[] = { m_waveformStatus, m_pitchStatus, m_notesStatus }; | |
781 | |
782 for (int i = 0; i < sizeof(statuses)/sizeof(statuses[0]); ++i) { | |
783 QPixmap p(40, 16); | |
784 p.fill(QColor(0, 0, 0, 0)); | |
785 QPainter paint(&p); | |
786 if (m_analyser->isVisible((Analyser::Component)i)) { | |
787 paint.drawPixmap(0, 0, eye); | |
788 } | |
789 if (m_analyser->isAudible((Analyser::Component)i)) { | |
790 paint.drawPixmap(20, 0, speaker); | |
791 } | |
792 statuses[i]->setPixmap(p); | |
793 } | |
794 } | |
795 | |
796 void | |
797 MainWindow::cycleWaveform() | |
798 { | |
799 cerr << "cycleWaveform" << endl; | |
800 m_analyser->cycleStatus(Analyser::Audio); | |
801 updateLayerStatuses(); | |
802 } | |
803 | |
804 void | |
805 MainWindow::cyclePitch() | |
806 { | |
807 cerr << "cyclePitch" << endl; | |
808 m_analyser->cycleStatus(Analyser::PitchTrack); | |
809 updateLayerStatuses(); | |
810 } | |
811 | |
812 void | |
813 MainWindow::cycleNotes() | |
814 { | |
815 cerr << "cycleNotes" << endl; | |
816 m_analyser->cycleStatus(Analyser::Notes); | |
817 updateLayerStatuses(); | |
742 } | 818 } |
743 | 819 |
744 void | 820 void |
745 MainWindow::updateDescriptionLabel() | 821 MainWindow::updateDescriptionLabel() |
746 { | 822 { |