Mercurial > hg > sonic-visualiser
diff main/PreferencesDialog.cpp @ 2457:a94b289f0b93 background-mode
Re-enable background mode switching, and make some fixes to it
author | Chris Cannam |
---|---|
date | Fri, 17 Jan 2020 13:51:22 +0000 |
parents | 0b15f3b16776 |
children | 2197ba438a3f |
line wrap: on
line diff
--- a/main/PreferencesDialog.cpp Wed Jan 15 14:04:39 2020 +0000 +++ b/main/PreferencesDialog.cpp Fri Jan 17 13:51:22 2020 +0000 @@ -169,12 +169,12 @@ colour3DColour->setCurrentIndex(m_colour3DColour); // can't have "add new colour", as it gets saved in the session not in prefs - ColourComboBox *overviewColour = new ColourComboBox(false); + m_overviewColourCombo = new ColourComboBox(false); int overviewColourIndex = ColourDatabase::getInstance()->getColourIndex(m_overviewColour); SVCERR << "index = " << overviewColourIndex << " for colour " << m_overviewColour.name() << endl; if (overviewColourIndex >= 0) { - overviewColour->setCurrentIndex(overviewColourIndex); + m_overviewColourCombo->setCurrentIndex(overviewColourIndex); } connect(spectrogramGColour, SIGNAL(colourMapChanged(int)), @@ -183,7 +183,7 @@ this, SLOT(spectrogramMColourChanged(int))); connect(colour3DColour, SIGNAL(colourMapChanged(int)), this, SLOT(colour3DColourChanged(int))); - connect(overviewColour, SIGNAL(colourChanged(int)), + connect(m_overviewColourCombo, SIGNAL(colourChanged(int)), this, SLOT(overviewColourChanged(int))); m_tuningFrequency = prefs->getTuningFrequency(); @@ -285,7 +285,7 @@ connect(showSplash, SIGNAL(stateChanged(int)), this, SLOT(showSplashChanged(int))); -#ifdef NOT_DEFINED // This no longer works correctly on any platform AFAICS +#ifndef Q_OS_MAC QComboBox *bgMode = new QComboBox; int bg = prefs->getPropertyRangeAndValue("Background Mode", &min, &max, &deflt); @@ -404,6 +404,13 @@ } #endif +#ifndef Q_OS_MAC + subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel + ("Background Mode"))), + row, 0); + subgrid->addWidget(bgMode, row++, 1, 1, 2); +#endif + subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel ("Property Box Layout"))), row, 0); @@ -423,14 +430,7 @@ subgrid->addWidget(new QLabel(tr("Overview waveform colour:")), row, 0); - subgrid->addWidget(overviewColour, row++, 1, 1, 2); - -#ifdef NOT_DEFINED // see earlier - subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel - ("Background Mode"))), - row, 0); - subgrid->addWidget(bgMode, row++, 1, 1, 2); -#endif + subgrid->addWidget(m_overviewColourCombo, row++, 1, 1, 2); subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel ("View Font Size"))), @@ -884,6 +884,23 @@ m_backgroundMode = mode; m_applyButton->setEnabled(true); m_changesOnRestart = true; + + // When switching to one of the explicit background choices + // (dark/light), also default the overview colour preference to + // something sensible + + int overviewColour = m_overviewColourCombo->currentIndex(); + int plainColours = 6; // we happen to know there are 6 "light" and 6 "dark" + + if (mode == Preferences::DarkBackground && overviewColour < plainColours) { + overviewColour += plainColours; + } + if (mode == Preferences::LightBackground && overviewColour >= plainColours) { + overviewColour -= plainColours; + } + + m_overviewColourCombo->setCurrentIndex(overviewColour); + overviewColourChanged(overviewColour); } void