# HG changeset patch # User Chris Cannam # Date 1418127424 0 # Node ID 09b2940f483afafb4775b8c8bc4fd08a71fcaa5f # Parent 1f2dc7fcad922ddc2eb51fae126fdcb2badd2463 Update units when prefs change diff -r 1f2dc7fcad92 -r 09b2940f483a widgets/UnitConverter.cpp --- a/widgets/UnitConverter.cpp Tue Dec 09 11:49:27 2014 +0000 +++ b/widgets/UnitConverter.cpp Tue Dec 09 12:17:04 2014 +0000 @@ -114,13 +114,8 @@ ++row; - grid->addWidget - (new QLabel(tr("With concert A tuning frequency at %1 Hz, and " - "middle C residing in octave %2.\n" - "(These can be changed in the application preferences.)") - .arg(Preferences::getInstance()->getTuningFrequency()) - .arg(Preferences::getInstance()->getOctaveOfMiddleC())), - row, 0, 1, 9); + m_pitchPrefsLabel = new QLabel; + grid->addWidget(m_pitchPrefsLabel, row, 0, 1, 9); ++row; @@ -130,8 +125,20 @@ row, 0, 1, 9); ++row; + + frame = new QFrame; + tabs->addTab(frame, tr("Tempo")); + + grid = new QGridLayout; + frame->setLayout(grid); + connect(Preferences::getInstance(), + SIGNAL(propertyChanged(PropertyContainer::PropertyName)), + this, SLOT(preferenceChanged(PropertyContainer::PropertyName))); + updatePitchesFromFreq(); + updatePitchPrefsLabel(); + updateTempiFromSamples(); } UnitConverter::~UnitConverter() @@ -139,6 +146,24 @@ } void +UnitConverter::preferenceChanged(PropertyContainer::PropertyName) +{ + updatePitchesFromFreq(); + updatePitchPrefsLabel(); +} + +void +UnitConverter::updatePitchPrefsLabel() +{ + m_pitchPrefsLabel->setText + (tr("With concert-A tuning frequency at %1 Hz, and " + "middle C residing in octave %2.\n" + "(These can be changed in the application preferences.)") + .arg(Preferences::getInstance()->getTuningFrequency()) + .arg(Preferences::getInstance()->getOctaveOfMiddleC())); +} + +void UnitConverter::freqChanged(double freq) { cerr << "freqChanged: " << freq << endl; @@ -217,6 +242,9 @@ m_octave->blockSignals(false); } - +void +UnitConverter::updateTempiFromSamples() +{ +} diff -r 1f2dc7fcad92 -r 09b2940f483a widgets/UnitConverter.h --- a/widgets/UnitConverter.h Tue Dec 09 11:49:27 2014 +0000 +++ b/widgets/UnitConverter.h Tue Dec 09 12:17:04 2014 +0000 @@ -17,9 +17,12 @@ #include +#include "base/PropertyContainer.h" + class QSpinBox; class QDoubleSpinBox; class QComboBox; +class QLabel; class UnitConverter : public QDialog { @@ -37,6 +40,7 @@ void centsChanged(double); void pianoChanged(int); + void preferenceChanged(PropertyContainer::PropertyName); private: QDoubleSpinBox *m_freq; @@ -45,8 +49,13 @@ QSpinBox *m_octave; QDoubleSpinBox *m_cents; QSpinBox *m_piano; + QLabel *m_pitchPrefsLabel; + void updatePitchesFromFreq(); + void updatePitchPrefsLabel(); - void updatePitchesFromFreq(); + QDoubleSpinBox *m_samples; + + void updateTempiFromSamples(); }; #endif