comparison main/PreferencesDialog.cpp @ 1448:11484141d969 3.0-integration

Add overview colour preference
author Chris Cannam
date Fri, 16 Dec 2016 19:26:21 +0000
parents 8e4e598a8c25
children 9a3684f1393b
comparison
equal deleted inserted replaced
1447:68abc2ea47aa 1448:11484141d969
37 #include <set> 37 #include <set>
38 38
39 #include "widgets/WindowTypeSelector.h" 39 #include "widgets/WindowTypeSelector.h"
40 #include "widgets/IconLoader.h" 40 #include "widgets/IconLoader.h"
41 #include "widgets/ColourMapComboBox.h" 41 #include "widgets/ColourMapComboBox.h"
42 #include "widgets/ColourComboBox.h"
42 #include "base/Preferences.h" 43 #include "base/Preferences.h"
43 #include "base/ResourceFinder.h" 44 #include "base/ResourceFinder.h"
44 #include "layer/ColourMapper.h" 45 #include "layer/ColourMapper.h"
46 #include "layer/ColourDatabase.h"
45 47
46 #include "bqaudioio/AudioFactory.h" 48 #include "bqaudioio/AudioFactory.h"
47 49
48 #include "version.h" 50 #include "version.h"
49 51
53 QDialog(parent), 55 QDialog(parent),
54 m_audioImplementation(0), 56 m_audioImplementation(0),
55 m_audioPlaybackDevice(0), 57 m_audioPlaybackDevice(0),
56 m_audioRecordDevice(0), 58 m_audioRecordDevice(0),
57 m_audioDeviceChanged(false), 59 m_audioDeviceChanged(false),
60 m_coloursChanged(false),
58 m_changesOnRestart(false) 61 m_changesOnRestart(false)
59 { 62 {
60 setWindowTitle(tr("Sonic Visualiser: Application Preferences")); 63 setWindowTitle(tr("Sonic Visualiser: Application Preferences"));
61 64
62 Preferences *prefs = Preferences::getInstance(); 65 Preferences *prefs = Preferences::getInstance();
143 int(ColourMapper::Green)).toInt()); 146 int(ColourMapper::Green)).toInt());
144 m_spectrogramMColour = (settings.value("spectrogram-melodic-colour", 147 m_spectrogramMColour = (settings.value("spectrogram-melodic-colour",
145 int(ColourMapper::Sunset)).toInt()); 148 int(ColourMapper::Sunset)).toInt());
146 m_colour3DColour = (settings.value("colour-3d-plot-colour", 149 m_colour3DColour = (settings.value("colour-3d-plot-colour",
147 int(ColourMapper::Green)).toInt()); 150 int(ColourMapper::Green)).toInt());
151 m_overviewColour =
152 (settings.value("overview-colour",
153 ColourDatabase::getInstance()->getColour(tr("Green"))))
154 .value<QColor>();
148 settings.endGroup(); 155 settings.endGroup();
149 156
150 ColourMapComboBox *spectrogramGColour = new ColourMapComboBox(true); 157 ColourMapComboBox *spectrogramGColour = new ColourMapComboBox(true);
151 spectrogramGColour->setCurrentIndex(m_spectrogramGColour); 158 spectrogramGColour->setCurrentIndex(m_spectrogramGColour);
152 159
153 ColourMapComboBox *spectrogramMColour = new ColourMapComboBox(true); 160 ColourMapComboBox *spectrogramMColour = new ColourMapComboBox(true);
154 spectrogramMColour->setCurrentIndex(m_spectrogramMColour); 161 spectrogramMColour->setCurrentIndex(m_spectrogramMColour);
155 162
156 ColourMapComboBox *colour3DColour = new ColourMapComboBox(true); 163 ColourMapComboBox *colour3DColour = new ColourMapComboBox(true);
157 colour3DColour->setCurrentIndex(m_colour3DColour); 164 colour3DColour->setCurrentIndex(m_colour3DColour);
165
166 // can't have "add new colour", as it gets saved in the session not in prefs
167 ColourComboBox *overviewColour = new ColourComboBox(false);
168 int overviewColourIndex =
169 ColourDatabase::getInstance()->getColourIndex(m_overviewColour);
170 if (overviewColourIndex >= 0) {
171 overviewColour->setCurrentIndex(overviewColourIndex);
172 }
158 173
159 connect(spectrogramGColour, SIGNAL(colourMapChanged(int)), 174 connect(spectrogramGColour, SIGNAL(colourMapChanged(int)),
160 this, SLOT(spectrogramGColourChanged(int))); 175 this, SLOT(spectrogramGColourChanged(int)));
161 connect(spectrogramMColour, SIGNAL(colourMapChanged(int)), 176 connect(spectrogramMColour, SIGNAL(colourMapChanged(int)),
162 this, SLOT(spectrogramMColourChanged(int))); 177 this, SLOT(spectrogramMColourChanged(int)));
163 connect(colour3DColour, SIGNAL(colourMapChanged(int)), 178 connect(colour3DColour, SIGNAL(colourMapChanged(int)),
164 this, SLOT(colour3DColourChanged(int))); 179 this, SLOT(colour3DColourChanged(int)));
180 connect(overviewColour, SIGNAL(colourChanged(int)),
181 this, SLOT(overviewColourChanged(int)));
165 182
166 m_tuningFrequency = prefs->getTuningFrequency(); 183 m_tuningFrequency = prefs->getTuningFrequency();
167 184
168 QDoubleSpinBox *frequency = new QDoubleSpinBox; 185 QDoubleSpinBox *frequency = new QDoubleSpinBox;
169 frequency->setMinimum(100.0); 186 frequency->setMinimum(100.0);
387 404
388 subgrid->addWidget(new QLabel(tr("Default colour 3D plot colour:")), 405 subgrid->addWidget(new QLabel(tr("Default colour 3D plot colour:")),
389 row, 0); 406 row, 0);
390 subgrid->addWidget(colour3DColour, row++, 1, 1, 2); 407 subgrid->addWidget(colour3DColour, row++, 1, 1, 2);
391 408
409 subgrid->addWidget(new QLabel(tr("Overview waveform colour:")),
410 row, 0);
411 subgrid->addWidget(overviewColour, row++, 1, 1, 2);
412
392 #ifdef NOT_DEFINED // see earlier 413 #ifdef NOT_DEFINED // see earlier
393 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel 414 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
394 ("Background Mode"))), 415 ("Background Mode"))),
395 row, 0); 416 row, 0);
396 subgrid->addWidget(bgMode, row++, 1, 1, 2); 417 subgrid->addWidget(bgMode, row++, 1, 1, 2);
673 694
674 void 695 void
675 PreferencesDialog::spectrogramGColourChanged(int colour) 696 PreferencesDialog::spectrogramGColourChanged(int colour)
676 { 697 {
677 m_spectrogramGColour = colour; 698 m_spectrogramGColour = colour;
699 m_coloursChanged = true;
678 m_applyButton->setEnabled(true); 700 m_applyButton->setEnabled(true);
679 } 701 }
680 702
681 void 703 void
682 PreferencesDialog::spectrogramMColourChanged(int colour) 704 PreferencesDialog::spectrogramMColourChanged(int colour)
683 { 705 {
684 m_spectrogramMColour = colour; 706 m_spectrogramMColour = colour;
707 m_coloursChanged = true;
685 m_applyButton->setEnabled(true); 708 m_applyButton->setEnabled(true);
686 } 709 }
687 710
688 void 711 void
689 PreferencesDialog::colour3DColourChanged(int colour) 712 PreferencesDialog::colour3DColourChanged(int colour)
690 { 713 {
691 m_colour3DColour = colour; 714 m_colour3DColour = colour;
715 m_coloursChanged = true;
716 m_applyButton->setEnabled(true);
717 }
718
719 void
720 PreferencesDialog::overviewColourChanged(int colour)
721 {
722 m_overviewColour = ColourDatabase::getInstance()->getColour(colour);
723 m_coloursChanged = true;
692 m_applyButton->setEnabled(true); 724 m_applyButton->setEnabled(true);
693 } 725 }
694 726
695 void 727 void
696 PreferencesDialog::propertyLayoutChanged(int layout) 728 PreferencesDialog::propertyLayoutChanged(int layout)
930 settings.setValue("scaledHiDpi", m_retina); 962 settings.setValue("scaledHiDpi", m_retina);
931 #endif 963 #endif
932 settings.setValue("spectrogram-colour", m_spectrogramGColour); 964 settings.setValue("spectrogram-colour", m_spectrogramGColour);
933 settings.setValue("spectrogram-melodic-colour", m_spectrogramMColour); 965 settings.setValue("spectrogram-melodic-colour", m_spectrogramMColour);
934 settings.setValue("colour-3d-plot-colour", m_colour3DColour); 966 settings.setValue("colour-3d-plot-colour", m_colour3DColour);
967 settings.setValue("overview-colour", m_overviewColour);
935 settings.endGroup(); 968 settings.endGroup();
936 969
937 settings.beginGroup("MainWindow"); 970 settings.beginGroup("MainWindow");
938 settings.setValue("sessiontemplate", m_currentTemplate); 971 settings.setValue("sessiontemplate", m_currentTemplate);
939 settings.endGroup(); 972 settings.endGroup();
947 } 980 }
948 981
949 if (m_audioDeviceChanged) { 982 if (m_audioDeviceChanged) {
950 emit audioDeviceChanged(); 983 emit audioDeviceChanged();
951 m_audioDeviceChanged = false; 984 m_audioDeviceChanged = false;
985 }
986
987 if (m_coloursChanged) {
988 emit coloursChanged();
989 m_coloursChanged = false;
952 } 990 }
953 } 991 }
954 992
955 void 993 void
956 PreferencesDialog::cancelClicked() 994 PreferencesDialog::cancelClicked()