1
0
mirror of https://github.com/strawberrymusicplayer/strawberry synced 2024-12-18 19:42:53 +01:00

Improve equalizer and fix alignment of label right

This commit is contained in:
Jonas Kvinge 2019-04-22 22:21:44 +02:00
parent 984abc89a8
commit 1e886cb12c
4 changed files with 55 additions and 12 deletions

View File

@ -21,7 +21,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_1">
<widget class="QLabel" name="label_preset">
<property name="text">
<string>Preset:</string>
</property>
@ -84,7 +84,7 @@
<item>
<layout class="QHBoxLayout" name="slider_label_layout">
<item>
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="label_left">
<property name="font">
<font>
<pointsize>11</pointsize>
@ -99,7 +99,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="label_balance">
<property name="text">
<string>Balance</string>
</property>
@ -109,7 +109,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="label_right">
<property name="font">
<font>
<pointsize>11</pointsize>
@ -119,7 +119,7 @@
<string>Right</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom</set>
<set>Qt::AlignBottom|Qt::AlignRight|Qt::AlignTrailing</set>
</property>
</widget>
</item>

View File

@ -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();
}

View File

@ -44,6 +44,9 @@ class EqualizerSlider : public QWidget {
signals:
void ValueChanged(int value);
public slots:
void OnValueChanged(int value);
private:
Ui_EqualizerSlider *ui_;

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>36</width>
<width>94</width>
<height>224</height>
</rect>
</property>
@ -17,7 +17,7 @@
</size>
</property>
<property name="windowTitle">
<string>Form</string>
<string>Equalizer</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
@ -35,7 +35,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_1">
<spacer name="spacer_left">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -67,7 +67,7 @@
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<spacer name="spacer_right">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -82,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>