comparison main/MainWindow.cpp @ 67:0229bec2d2dc

* Tidy up panes menu
author Chris Cannam
date Fri, 20 Oct 2006 20:14:20 +0000
parents cf27fc7feb7a
children 76cc2c424268
comparison
equal deleted inserted replaced
66:cf27fc7feb7a 67:0229bec2d2dc
677 677
678 std::vector<Model *> models; 678 std::vector<Model *> models;
679 if (m_document) models = m_document->getTransformInputModels(); //!!! not well named for this! 679 if (m_document) models = m_document->getTransformInputModels(); //!!! not well named for this!
680 bool plural = (models.size() > 1); 680 bool plural = (models.size() > 1);
681 if (models.empty()) { 681 if (models.empty()) {
682 if (m_document) { 682 models.push_back(getMainModel()); // probably 0
683 models.push_back(m_document->getMainModel()); // probably 0
684 } else {
685 models.push_back(0);
686 }
687 } 683 }
688 684
689 for (unsigned int i = 0; 685 for (unsigned int i = 0;
690 i < sizeof(backgroundTypes)/sizeof(backgroundTypes[0]); ++i) { 686 i < sizeof(backgroundTypes)/sizeof(backgroundTypes[0]); ++i) {
691 687
714 } 710 }
715 mono = false; 711 mono = false;
716 break; 712 break;
717 713
718 case LayerFactory::Spectrogram: 714 case LayerFactory::Spectrogram:
715 icon = QIcon(":/icons/spectrogram.png");
719 mainText = tr("Add &Spectrogram"); 716 mainText = tr("Add &Spectrogram");
720 if (menuType == 0) { 717 if (menuType == 0) {
721 shortcutText = tr("Alt+S"); 718 shortcutText = tr("Alt+S");
722 tipText = tr("Add a new pane showing a dB spectrogram"); 719 tipText = tr("Add a new pane showing a dB spectrogram");
723 } else { 720 } else {
724 tipText = tr("Add a new layer showing a dB spectrogram"); 721 tipText = tr("Add a new layer showing a dB spectrogram");
725 } 722 }
726 break; 723 break;
727 724
728 case LayerFactory::MelodicRangeSpectrogram: 725 case LayerFactory::MelodicRangeSpectrogram:
726 icon = QIcon(":/icons/spectrogram.png");
729 mainText = tr("Add &Melodic Range Spectrogram"); 727 mainText = tr("Add &Melodic Range Spectrogram");
730 if (menuType == 0) { 728 if (menuType == 0) {
731 shortcutText = tr("Alt+M"); 729 shortcutText = tr("Alt+M");
732 tipText = tr("Add a new pane showing a spectrogram set up for a pitch overview"); 730 tipText = tr("Add a new pane showing a spectrogram set up for a pitch overview");
733 } else { 731 } else {
734 tipText = tr("Add a new layer showing a spectrogram set up for a pitch overview"); 732 tipText = tr("Add a new layer showing a spectrogram set up for a pitch overview");
735 } 733 }
736 break; 734 break;
737 735
738 case LayerFactory::PeakFrequencySpectrogram: 736 case LayerFactory::PeakFrequencySpectrogram:
737 icon = QIcon(":/icons/spectrogram.png");
739 mainText = tr("Add &Peak Frequency Spectrogram"); 738 mainText = tr("Add &Peak Frequency Spectrogram");
740 if (menuType == 0) { 739 if (menuType == 0) {
741 shortcutText = tr("Alt+P"); 740 shortcutText = tr("Alt+P");
742 tipText = tr("Add a new pane showing a spectrogram set up for tracking frequencies"); 741 tipText = tr("Add a new pane showing a spectrogram set up for tracking frequencies");
743 } else { 742 } else {
744 tipText = tr("Add a new layer showing a spectrogram set up for tracking frequencies"); 743 tipText = tr("Add a new layer showing a spectrogram set up for tracking frequencies");
745 } 744 }
746 break; 745 break;
747 746
748 case LayerFactory::Spectrum: 747 case LayerFactory::Spectrum:
748 icon = QIcon(":/icons/spectrum.png");
749 mainText = tr("Add Spectr&um"); 749 mainText = tr("Add Spectr&um");
750 if (menuType == 0) { 750 if (menuType == 0) {
751 shortcutText = tr("Alt+U"); 751 shortcutText = tr("Alt+U");
752 tipText = tr("Add a new pane showing a frequency spectrum"); 752 tipText = tr("Add a new pane showing a frequency spectrum");
753 } else { 753 } else {
793 else continue; 793 else continue;
794 } 794 }
795 795
796 if (isOnly && (!plural || menuType == 1)) { 796 if (isOnly && (!plural || menuType == 1)) {
797 797
798 action = new QAction(icon, mainText, this); 798 if (type != LayerFactory::Waveform) {
799 action = new QAction(mainText, this);
800 } else {
801 action = new QAction(icon, mainText, this);
802 }
803
799 action->setShortcut(shortcutText); 804 action->setShortcut(shortcutText);
800 action->setStatusTip(tipText); 805 action->setStatusTip(tipText);
801 if (menuType == 0) { 806 if (menuType == 0) {
802 connect(action, SIGNAL(triggered()), 807 connect(action, SIGNAL(triggered()),
803 this, SLOT(addPane())); 808 this, SLOT(addPane()));
815 820
816 } else { 821 } else {
817 822
818 if (!submenu) { 823 if (!submenu) {
819 submenu = menu->addMenu(mainText); 824 submenu = menu->addMenu(mainText);
825 } else if (isDefault) {
826 submenu->addSeparator();
820 } 827 }
821 828
822 QString actionText; 829 QString actionText;
823 if (c == 0) { 830 if (c == 0) {
824 if (mono) { 831 if (mono) {
833 if (model) { 840 if (model) {
834 actionText = tr("%1: %2") 841 actionText = tr("%1: %2")
835 .arg(model->objectName()) 842 .arg(model->objectName())
836 .arg(actionText); 843 .arg(actionText);
837 } 844 }
838 845
839 action = new QAction(icon, actionText, this); 846 if (isDefault) {
840 if (isDefault) action->setShortcut(shortcutText); 847 action = new QAction(icon, actionText, this);
848 if (!model || model == getMainModel()) {
849 action->setShortcut(shortcutText);
850 }
851 } else {
852 action = new QAction(actionText, this);
853 }
854
841 action->setStatusTip(tipText); 855 action->setStatusTip(tipText);
842 856
843 if (menuType == 0) { 857 if (menuType == 0) {
844 connect(action, SIGNAL(triggered()), 858 connect(action, SIGNAL(triggered()),
845 this, SLOT(addPane())); 859 this, SLOT(addPane()));