changeset 1096:11ef2f95ea15 3.0-integration

Add default spectrogram colours to prefs
author Chris Cannam
date Wed, 20 Jan 2016 11:43:16 +0000
parents 88f3978cb0df
children df73c834764c
files .hgsubstate main/PreferencesDialog.cpp main/PreferencesDialog.h
diffstat 3 files changed, 49 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/.hgsubstate	Tue Jan 19 17:28:26 2016 +0000
+++ b/.hgsubstate	Wed Jan 20 11:43:16 2016 +0000
@@ -6,4 +6,4 @@
 55ece8862b6d3a54aad271a53f9c1615e5d3bcf8 sv-dependency-builds
 14a81e881b1ae7ade2520611c902a20971d9898d svapp
 afed8be790321ebc805b2620bcddb91405886c8d svcore
-6a8084c72e7a8fd663089269f6af2b250aea0835 svgui
+9c890b7dfa836bf6999df4601ae8974a6888284b svgui
--- a/main/PreferencesDialog.cpp	Tue Jan 19 17:28:26 2016 +0000
+++ b/main/PreferencesDialog.cpp	Wed Jan 20 11:43:16 2016 +0000
@@ -40,6 +40,7 @@
 #include "widgets/IconLoader.h"
 #include "base/Preferences.h"
 #include "base/ResourceFinder.h"
+#include "layer/ColourMapper.h"
 
 //#include "audioio/AudioTargetFactory.h"
 
@@ -123,6 +124,25 @@
     connect(propertyLayout, SIGNAL(currentIndexChanged(int)),
             this, SLOT(propertyLayoutChanged(int)));
 
+    QSettings settings;
+    settings.beginGroup("Preferences");
+    m_spectrogramGColour = (settings.value("spectrogram-colour",
+                                           int(ColourMapper::Green)).toInt());
+    m_spectrogramMColour = (settings.value("spectrogram-melodic-colour",
+                                           int(ColourMapper::Sunset)).toInt());
+    settings.endGroup();
+    QComboBox *spectrogramGColour = new QComboBox;
+    QComboBox *spectrogramMColour = new QComboBox;
+    for (i = 0; i < ColourMapper::getColourMapCount(); ++i) {
+        spectrogramGColour->addItem(ColourMapper::getColourMapName(i));
+        spectrogramMColour->addItem(ColourMapper::getColourMapName(i));
+        if (i == m_spectrogramGColour) spectrogramGColour->setCurrentIndex(i);
+        if (i == m_spectrogramMColour) spectrogramMColour->setCurrentIndex(i);
+    }
+    connect(spectrogramGColour, SIGNAL(currentIndexChanged(int)),
+            this, SLOT(spectrogramGColourChanged(int)));
+    connect(spectrogramMColour, SIGNAL(currentIndexChanged(int)),
+            this, SLOT(spectrogramMColourChanged(int)));
 
     m_tuningFrequency = prefs->getTuningFrequency();
 
@@ -150,8 +170,6 @@
     connect(octaveSystem, SIGNAL(currentIndexChanged(int)),
             this, SLOT(octaveSystemChanged(int)));
 
-    QSettings settings;
-
     /*!!! restore
     QComboBox *audioDevice = new QComboBox;
     std::vector<QString> devices =
@@ -377,6 +395,14 @@
                        row, 0);
     subgrid->addWidget(propertyLayout, row++, 1, 1, 2);
 
+    subgrid->addWidget(new QLabel(tr("Default spectrogram color:")),
+                       row, 0);
+    subgrid->addWidget(spectrogramGColour, row++, 1, 1, 2);
+
+    subgrid->addWidget(new QLabel(tr("Default melodic spectrogram color:")),
+                       row, 0);
+    subgrid->addWidget(spectrogramMColour, row++, 1, 1, 2);
+
 #ifdef NOT_DEFINED // see earlier
     subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
                                                 ("Background Mode"))),
@@ -538,6 +564,20 @@
 }
 
 void
+PreferencesDialog::spectrogramGColourChanged(int colour)
+{
+    m_spectrogramGColour = colour;
+    m_applyButton->setEnabled(true);
+}
+
+void
+PreferencesDialog::spectrogramMColourChanged(int colour)
+{
+    m_spectrogramMColour = colour;
+    m_applyButton->setEnabled(true);
+}
+
+void
 PreferencesDialog::propertyLayoutChanged(int layout)
 {
     m_propertyLayout = layout;
@@ -710,6 +750,8 @@
 #ifdef Q_OS_MAC
     settings.setValue("scaledHiDpi", m_retina);
 #endif
+    settings.setValue("spectrogram-colour", m_spectrogramGColour);
+    settings.setValue("spectrogram-melodic-colour", m_spectrogramMColour);
     settings.endGroup();
 
     settings.beginGroup("MainWindow");
--- a/main/PreferencesDialog.h	Tue Jan 19 17:28:26 2016 +0000
+++ b/main/PreferencesDialog.h	Wed Jan 20 11:43:16 2016 +0000
@@ -49,6 +49,8 @@
     void windowTypeChanged(WindowType type);
     void spectrogramSmoothingChanged(int state);
     void spectrogramXSmoothingChanged(int state);
+    void spectrogramGColourChanged(int state);
+    void spectrogramMColourChanged(int state);
     void propertyLayoutChanged(int layout);
     void tuningFrequencyChanged(double freq);
     void audioDeviceChanged(int device);
@@ -90,6 +92,8 @@
     WindowType m_windowType;
     int m_spectrogramSmoothing;
     int m_spectrogramXSmoothing;
+    int m_spectrogramGColour;
+    int m_spectrogramMColour;
     int m_propertyLayout;
     double m_tuningFrequency;
     int m_audioDevice;