diff --git a/src/equalizer/equalizer.ui b/src/equalizer/equalizer.ui index f9d57d192..9dc7c0557 100644 --- a/src/equalizer/equalizer.ui +++ b/src/equalizer/equalizer.ui @@ -21,7 +21,7 @@ - + Preset: @@ -84,7 +84,7 @@ - + 11 @@ -99,7 +99,7 @@ - + Balance @@ -109,7 +109,7 @@ - + 11 @@ -119,7 +119,7 @@ Right - Qt::AlignBottom + Qt::AlignBottom|Qt::AlignRight|Qt::AlignTrailing diff --git a/src/equalizer/equalizerslider.cpp b/src/equalizer/equalizerslider.cpp index b770f1d99..25080dc1b 100644 --- a/src/equalizer/equalizerslider.cpp +++ b/src/equalizer/equalizerslider.cpp @@ -33,15 +33,33 @@ EqualizerSlider::EqualizerSlider(const QString &label, QWidget *parent) ui_(new Ui_EqualizerSlider) { ui_->setupUi(this); - ui_->label->setText(label); + ui_->band->setText(label); + + QFontMetrics fm = ui_->gain->fontMetrics(); + int longestLabelWidth = fm.width(tr("%1 dB").arg(-99.99)); + ui_->gain->setMinimumWidth(longestLabelWidth); + ui_->gain->setText(tr("%1 dB").arg(0)); // Gain [dB] + + ui_->slider->setValue(0); + + connect(ui_->slider, SIGNAL(valueChanged(int)), this, SLOT(OnValueChanged(int))); - connect(ui_->slider, SIGNAL(valueChanged(int)), SIGNAL(ValueChanged(int))); } EqualizerSlider::~EqualizerSlider() { delete ui_; } +void EqualizerSlider::OnValueChanged(int value) { + + // Converting % to dB as per GstEnginePipeline::UpdateEqualizer(): + float gain = (value < 0) ? value * 0.24 : value * 0.12; + + ui_->gain->setText(tr("%1 dB").arg(gain)); // Gain [dB] + emit ValueChanged(value); + +} + int EqualizerSlider::value() const { return ui_->slider->value(); } diff --git a/src/equalizer/equalizerslider.h b/src/equalizer/equalizerslider.h index 60953c61c..0a8500a8b 100644 --- a/src/equalizer/equalizerslider.h +++ b/src/equalizer/equalizerslider.h @@ -44,6 +44,9 @@ class EqualizerSlider : public QWidget { signals: void ValueChanged(int value); + public slots: + void OnValueChanged(int value); + private: Ui_EqualizerSlider *ui_; diff --git a/src/equalizer/equalizerslider.ui b/src/equalizer/equalizerslider.ui index 7ce3cf6a4..5c61c5c3d 100644 --- a/src/equalizer/equalizerslider.ui +++ b/src/equalizer/equalizerslider.ui @@ -6,7 +6,7 @@ 0 0 - 36 + 94 224 @@ -17,7 +17,7 @@ - Form + Equalizer @@ -35,7 +35,7 @@ - + Qt::Horizontal @@ -67,7 +67,7 @@ - + Qt::Horizontal @@ -82,7 +82,29 @@ - + + + true + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + + + + Qt::AlignCenter