diff main/MainWindow.cpp @ 1448:11484141d969 3.0-integration

Add overview colour preference
author Chris Cannam
date Fri, 16 Dec 2016 19:26:21 +0000
parents 387bc365aac1
children e4f223fc9099
line wrap: on
line diff
--- a/main/MainWindow.cpp	Fri Dec 16 19:25:17 2016 +0000
+++ b/main/MainWindow.cpp	Fri Dec 16 19:26:21 2016 +0000
@@ -229,13 +229,7 @@
     m_panLayer->setAggressiveCacheing(true);
     m_overview->addLayer(m_panLayer);
 
-    if (m_viewManager->getGlobalDarkBackground()) {
-        m_panLayer->setBaseColour
-            (ColourDatabase::getInstance()->getColourIndex(tr("Bright Green")));
-    } else {
-        m_panLayer->setBaseColour
-            (ColourDatabase::getInstance()->getColourIndex(tr("Green")));
-    }
+    coloursChanged(); // sets pan layer colour from preferences
 
     m_playSpeed = new AudioDial(frame);
     m_playSpeed->setMinimum(0);
@@ -3502,18 +3496,33 @@
 {
     MainWindowBase::preferenceChanged(name);
 
-    if (name == "Background Mode" && m_viewManager) {
-        if (m_viewManager->getGlobalDarkBackground()) {
-            m_panLayer->setBaseColour
-                (ColourDatabase::getInstance()->getColourIndex(tr("Bright Green")));
-        } else {
-            m_panLayer->setBaseColour
-                (ColourDatabase::getInstance()->getColourIndex(tr("Green")));
-        }      
+    if (name == "Background Mode") {
+        coloursChanged();
     }     
 }
 
 void
+MainWindow::coloursChanged()
+{
+    QSettings settings;
+    settings.beginGroup("Preferences");
+    QString defaultColourName(tr("Green"));
+    if (m_viewManager && m_viewManager->getGlobalDarkBackground()) {
+        defaultColourName = tr("Bright Green");
+    }
+    ColourDatabase *cdb = ColourDatabase::getInstance();
+    QColor colour =
+        ((settings.value("overview-colour", cdb->getColour(defaultColourName)))
+         .value<QColor>());
+    settings.endGroup();
+
+    int index = cdb->getColourIndex(colour);
+    if (index >= 0) {
+        m_panLayer->setBaseColour(index);
+    }
+}
+
+void
 MainWindow::propertyStacksResized(int width)
 {
 //    SVDEBUG << "MainWindow::propertyStacksResized(" << width << ")" << endl;
@@ -4610,6 +4619,8 @@
 
     connect(m_preferencesDialog, SIGNAL(audioDeviceChanged()),
             this, SLOT(recreateAudioIO()));
+    connect(m_preferencesDialog, SIGNAL(coloursChanged()),
+            this, SLOT(coloursChanged()));
     
     // DeleteOnClose is safe here, because m_preferencesDialog is a
     // QPointer that will be zeroed when the dialog is deleted.  We