Mercurial > hg > sonic-visualiser
comparison 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 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 2456:2508e661e544 | 2457:a94b289f0b93 | 
|---|---|
| 167 | 167 | 
| 168 ColourMapComboBox *colour3DColour = new ColourMapComboBox(true); | 168 ColourMapComboBox *colour3DColour = new ColourMapComboBox(true); | 
| 169 colour3DColour->setCurrentIndex(m_colour3DColour); | 169 colour3DColour->setCurrentIndex(m_colour3DColour); | 
| 170 | 170 | 
| 171 // can't have "add new colour", as it gets saved in the session not in prefs | 171 // can't have "add new colour", as it gets saved in the session not in prefs | 
| 172 ColourComboBox *overviewColour = new ColourComboBox(false); | 172 m_overviewColourCombo = new ColourComboBox(false); | 
| 173 int overviewColourIndex = | 173 int overviewColourIndex = | 
| 174 ColourDatabase::getInstance()->getColourIndex(m_overviewColour); | 174 ColourDatabase::getInstance()->getColourIndex(m_overviewColour); | 
| 175 SVCERR << "index = " << overviewColourIndex << " for colour " << m_overviewColour.name() << endl; | 175 SVCERR << "index = " << overviewColourIndex << " for colour " << m_overviewColour.name() << endl; | 
| 176 if (overviewColourIndex >= 0) { | 176 if (overviewColourIndex >= 0) { | 
| 177 overviewColour->setCurrentIndex(overviewColourIndex); | 177 m_overviewColourCombo->setCurrentIndex(overviewColourIndex); | 
| 178 } | 178 } | 
| 179 | 179 | 
| 180 connect(spectrogramGColour, SIGNAL(colourMapChanged(int)), | 180 connect(spectrogramGColour, SIGNAL(colourMapChanged(int)), | 
| 181 this, SLOT(spectrogramGColourChanged(int))); | 181 this, SLOT(spectrogramGColourChanged(int))); | 
| 182 connect(spectrogramMColour, SIGNAL(colourMapChanged(int)), | 182 connect(spectrogramMColour, SIGNAL(colourMapChanged(int)), | 
| 183 this, SLOT(spectrogramMColourChanged(int))); | 183 this, SLOT(spectrogramMColourChanged(int))); | 
| 184 connect(colour3DColour, SIGNAL(colourMapChanged(int)), | 184 connect(colour3DColour, SIGNAL(colourMapChanged(int)), | 
| 185 this, SLOT(colour3DColourChanged(int))); | 185 this, SLOT(colour3DColourChanged(int))); | 
| 186 connect(overviewColour, SIGNAL(colourChanged(int)), | 186 connect(m_overviewColourCombo, SIGNAL(colourChanged(int)), | 
| 187 this, SLOT(overviewColourChanged(int))); | 187 this, SLOT(overviewColourChanged(int))); | 
| 188 | 188 | 
| 189 m_tuningFrequency = prefs->getTuningFrequency(); | 189 m_tuningFrequency = prefs->getTuningFrequency(); | 
| 190 | 190 | 
| 191 QDoubleSpinBox *frequency = new QDoubleSpinBox; | 191 QDoubleSpinBox *frequency = new QDoubleSpinBox; | 
| 283 m_showSplash = prefs->getShowSplash(); | 283 m_showSplash = prefs->getShowSplash(); | 
| 284 showSplash->setCheckState(m_showSplash ? Qt::Checked : Qt::Unchecked); | 284 showSplash->setCheckState(m_showSplash ? Qt::Checked : Qt::Unchecked); | 
| 285 connect(showSplash, SIGNAL(stateChanged(int)), | 285 connect(showSplash, SIGNAL(stateChanged(int)), | 
| 286 this, SLOT(showSplashChanged(int))); | 286 this, SLOT(showSplashChanged(int))); | 
| 287 | 287 | 
| 288 #ifdef NOT_DEFINED // This no longer works correctly on any platform AFAICS | 288 #ifndef Q_OS_MAC | 
| 289 QComboBox *bgMode = new QComboBox; | 289 QComboBox *bgMode = new QComboBox; | 
| 290 int bg = prefs->getPropertyRangeAndValue("Background Mode", &min, &max, | 290 int bg = prefs->getPropertyRangeAndValue("Background Mode", &min, &max, | 
| 291 &deflt); | 291 &deflt); | 
| 292 m_backgroundMode = bg; | 292 m_backgroundMode = bg; | 
| 293 for (i = min; i <= max; ++i) { | 293 for (i = min; i <= max; ++i) { | 
| 402 subgrid->addWidget(new QLabel(tr("Draw layers at Retina resolution:")), row, 0); | 402 subgrid->addWidget(new QLabel(tr("Draw layers at Retina resolution:")), row, 0); | 
| 403 subgrid->addWidget(retina, row++, 1, 1, 1); | 403 subgrid->addWidget(retina, row++, 1, 1, 1); | 
| 404 } | 404 } | 
| 405 #endif | 405 #endif | 
| 406 | 406 | 
| 407 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel | 407 #ifndef Q_OS_MAC | 
| 408 ("Property Box Layout"))), | |
| 409 row, 0); | |
| 410 subgrid->addWidget(propertyLayout, row++, 1, 1, 2); | |
| 411 | |
| 412 subgrid->addWidget(new QLabel(tr("Default spectrogram colour:")), | |
| 413 row, 0); | |
| 414 subgrid->addWidget(spectrogramGColour, row++, 1, 1, 2); | |
| 415 | |
| 416 subgrid->addWidget(new QLabel(tr("Default melodic spectrogram colour:")), | |
| 417 row, 0); | |
| 418 subgrid->addWidget(spectrogramMColour, row++, 1, 1, 2); | |
| 419 | |
| 420 subgrid->addWidget(new QLabel(tr("Default colour 3D plot colour:")), | |
| 421 row, 0); | |
| 422 subgrid->addWidget(colour3DColour, row++, 1, 1, 2); | |
| 423 | |
| 424 subgrid->addWidget(new QLabel(tr("Overview waveform colour:")), | |
| 425 row, 0); | |
| 426 subgrid->addWidget(overviewColour, row++, 1, 1, 2); | |
| 427 | |
| 428 #ifdef NOT_DEFINED // see earlier | |
| 429 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel | 408 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel | 
| 430 ("Background Mode"))), | 409 ("Background Mode"))), | 
| 431 row, 0); | 410 row, 0); | 
| 432 subgrid->addWidget(bgMode, row++, 1, 1, 2); | 411 subgrid->addWidget(bgMode, row++, 1, 1, 2); | 
| 433 #endif | 412 #endif | 
| 413 | |
| 414 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel | |
| 415 ("Property Box Layout"))), | |
| 416 row, 0); | |
| 417 subgrid->addWidget(propertyLayout, row++, 1, 1, 2); | |
| 418 | |
| 419 subgrid->addWidget(new QLabel(tr("Default spectrogram colour:")), | |
| 420 row, 0); | |
| 421 subgrid->addWidget(spectrogramGColour, row++, 1, 1, 2); | |
| 422 | |
| 423 subgrid->addWidget(new QLabel(tr("Default melodic spectrogram colour:")), | |
| 424 row, 0); | |
| 425 subgrid->addWidget(spectrogramMColour, row++, 1, 1, 2); | |
| 426 | |
| 427 subgrid->addWidget(new QLabel(tr("Default colour 3D plot colour:")), | |
| 428 row, 0); | |
| 429 subgrid->addWidget(colour3DColour, row++, 1, 1, 2); | |
| 430 | |
| 431 subgrid->addWidget(new QLabel(tr("Overview waveform colour:")), | |
| 432 row, 0); | |
| 433 subgrid->addWidget(m_overviewColourCombo, row++, 1, 1, 2); | |
| 434 | 434 | 
| 435 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel | 435 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel | 
| 436 ("View Font Size"))), | 436 ("View Font Size"))), | 
| 437 row, 0); | 437 row, 0); | 
| 438 subgrid->addWidget(fontSize, row++, 1, 1, 2); | 438 subgrid->addWidget(fontSize, row++, 1, 1, 2); | 
| 882 PreferencesDialog::backgroundModeChanged(int mode) | 882 PreferencesDialog::backgroundModeChanged(int mode) | 
| 883 { | 883 { | 
| 884 m_backgroundMode = mode; | 884 m_backgroundMode = mode; | 
| 885 m_applyButton->setEnabled(true); | 885 m_applyButton->setEnabled(true); | 
| 886 m_changesOnRestart = true; | 886 m_changesOnRestart = true; | 
| 887 | |
| 888 // When switching to one of the explicit background choices | |
| 889 // (dark/light), also default the overview colour preference to | |
| 890 // something sensible | |
| 891 | |
| 892 int overviewColour = m_overviewColourCombo->currentIndex(); | |
| 893 int plainColours = 6; // we happen to know there are 6 "light" and 6 "dark" | |
| 894 | |
| 895 if (mode == Preferences::DarkBackground && overviewColour < plainColours) { | |
| 896 overviewColour += plainColours; | |
| 897 } | |
| 898 if (mode == Preferences::LightBackground && overviewColour >= plainColours) { | |
| 899 overviewColour -= plainColours; | |
| 900 } | |
| 901 | |
| 902 m_overviewColourCombo->setCurrentIndex(overviewColour); | |
| 903 overviewColourChanged(overviewColour); | |
| 887 } | 904 } | 
| 888 | 905 | 
| 889 void | 906 void | 
| 890 PreferencesDialog::timeToTextModeChanged(int mode) | 907 PreferencesDialog::timeToTextModeChanged(int mode) | 
| 891 { | 908 { | 
