mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-11 09:24:50 +01:00
Add gain label to equalizerSlider
This commit is contained in:
parent
9056963225
commit
ec89bd3ea2
@ -21,9 +21,25 @@
|
||||
EqualizerSlider::EqualizerSlider(const QString& label, QWidget* parent)
|
||||
: QWidget(parent), ui_(new Ui_EqualizerSlider) {
|
||||
ui_->setupUi(this);
|
||||
ui_->label->setText(label);
|
||||
ui_->band->setText(label); // Band [Hz]
|
||||
|
||||
connect(ui_->slider, SIGNAL(valueChanged(int)), SIGNAL(ValueChanged(int)));
|
||||
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)));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
EqualizerSlider::~EqualizerSlider() { delete ui_; }
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define EQUALISERSLIDER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QFontMetrics>
|
||||
|
||||
class Ui_EqualizerSlider;
|
||||
|
||||
@ -33,6 +34,9 @@ class EqualizerSlider : public QWidget {
|
||||
int value() const;
|
||||
void set_value(int value);
|
||||
|
||||
public slots:
|
||||
void onValueChanged(int value);
|
||||
|
||||
signals:
|
||||
void ValueChanged(int value);
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>33</width>
|
||||
<width>34</width>
|
||||
<height>224</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -20,7 +20,16 @@
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
@ -73,7 +82,29 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel" name="band">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="gain">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
|
Loading…
Reference in New Issue
Block a user