Mercurial > hg > sonic-visualiser
changeset 1448:11484141d969 3.0-integration
Add overview colour preference
author | Chris Cannam |
---|---|
date | Fri, 16 Dec 2016 19:26:21 +0000 |
parents | 68abc2ea47aa |
children | 29327c53202a |
files | main/MainWindow.cpp main/MainWindow.h main/PreferencesDialog.cpp main/PreferencesDialog.h |
diffstat | 4 files changed, 71 insertions(+), 15 deletions(-) [+] |
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
--- a/main/MainWindow.h Fri Dec 16 19:25:17 2016 +0000 +++ b/main/MainWindow.h Fri Dec 16 19:26:21 2016 +0000 @@ -41,6 +41,8 @@ public slots: virtual void preferenceChanged(PropertyContainer::PropertyName); + virtual void coloursChanged(); + virtual bool commitData(bool mayAskUser); void goFullScreen();
--- a/main/PreferencesDialog.cpp Fri Dec 16 19:25:17 2016 +0000 +++ b/main/PreferencesDialog.cpp Fri Dec 16 19:26:21 2016 +0000 @@ -39,9 +39,11 @@ #include "widgets/WindowTypeSelector.h" #include "widgets/IconLoader.h" #include "widgets/ColourMapComboBox.h" +#include "widgets/ColourComboBox.h" #include "base/Preferences.h" #include "base/ResourceFinder.h" #include "layer/ColourMapper.h" +#include "layer/ColourDatabase.h" #include "bqaudioio/AudioFactory.h" @@ -55,6 +57,7 @@ m_audioPlaybackDevice(0), m_audioRecordDevice(0), m_audioDeviceChanged(false), + m_coloursChanged(false), m_changesOnRestart(false) { setWindowTitle(tr("Sonic Visualiser: Application Preferences")); @@ -145,6 +148,10 @@ int(ColourMapper::Sunset)).toInt()); m_colour3DColour = (settings.value("colour-3d-plot-colour", int(ColourMapper::Green)).toInt()); + m_overviewColour = + (settings.value("overview-colour", + ColourDatabase::getInstance()->getColour(tr("Green")))) + .value<QColor>(); settings.endGroup(); ColourMapComboBox *spectrogramGColour = new ColourMapComboBox(true); @@ -156,12 +163,22 @@ ColourMapComboBox *colour3DColour = new ColourMapComboBox(true); 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); + int overviewColourIndex = + ColourDatabase::getInstance()->getColourIndex(m_overviewColour); + if (overviewColourIndex >= 0) { + overviewColour->setCurrentIndex(overviewColourIndex); + } + connect(spectrogramGColour, SIGNAL(colourMapChanged(int)), this, SLOT(spectrogramGColourChanged(int))); connect(spectrogramMColour, SIGNAL(colourMapChanged(int)), this, SLOT(spectrogramMColourChanged(int))); connect(colour3DColour, SIGNAL(colourMapChanged(int)), this, SLOT(colour3DColourChanged(int))); + connect(overviewColour, SIGNAL(colourChanged(int)), + this, SLOT(overviewColourChanged(int))); m_tuningFrequency = prefs->getTuningFrequency(); @@ -389,6 +406,10 @@ row, 0); subgrid->addWidget(colour3DColour, row++, 1, 1, 2); + 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"))), @@ -675,6 +696,7 @@ PreferencesDialog::spectrogramGColourChanged(int colour) { m_spectrogramGColour = colour; + m_coloursChanged = true; m_applyButton->setEnabled(true); } @@ -682,6 +704,7 @@ PreferencesDialog::spectrogramMColourChanged(int colour) { m_spectrogramMColour = colour; + m_coloursChanged = true; m_applyButton->setEnabled(true); } @@ -689,6 +712,15 @@ PreferencesDialog::colour3DColourChanged(int colour) { m_colour3DColour = colour; + m_coloursChanged = true; + m_applyButton->setEnabled(true); +} + +void +PreferencesDialog::overviewColourChanged(int colour) +{ + m_overviewColour = ColourDatabase::getInstance()->getColour(colour); + m_coloursChanged = true; m_applyButton->setEnabled(true); } @@ -932,6 +964,7 @@ settings.setValue("spectrogram-colour", m_spectrogramGColour); settings.setValue("spectrogram-melodic-colour", m_spectrogramMColour); settings.setValue("colour-3d-plot-colour", m_colour3DColour); + settings.setValue("overview-colour", m_overviewColour); settings.endGroup(); settings.beginGroup("MainWindow"); @@ -950,6 +983,11 @@ emit audioDeviceChanged(); m_audioDeviceChanged = false; } + + if (m_coloursChanged) { + emit coloursChanged(); + m_coloursChanged = false; + } } void
--- a/main/PreferencesDialog.h Fri Dec 16 19:25:17 2016 +0000 +++ b/main/PreferencesDialog.h Fri Dec 16 19:26:21 2016 +0000 @@ -18,6 +18,7 @@ #include <QDialog> #include <QMap> +#include <QColor> #include "base/Window.h" @@ -46,6 +47,7 @@ signals: void audioDeviceChanged(); + void coloursChanged(); public slots: void applicationClosing(bool quickly); @@ -57,6 +59,7 @@ void spectrogramGColourChanged(int state); void spectrogramMColourChanged(int state); void colour3DColourChanged(int state); + void overviewColourChanged(int state); void propertyLayoutChanged(int layout); void tuningFrequencyChanged(double freq); void audioImplementationChanged(int impl); @@ -108,6 +111,7 @@ int m_spectrogramGColour; int m_spectrogramMColour; int m_colour3DColour; + QColor m_overviewColour; int m_propertyLayout; double m_tuningFrequency; int m_audioImplementation; @@ -127,6 +131,7 @@ bool m_showSplash; bool m_audioDeviceChanged; + bool m_coloursChanged; bool m_changesOnRestart; };