| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2010 Ricardo Villalba <rvm@escomposlinux.org>
|
|---|
| 3 |
|
|---|
| 4 | This program is free software; you can redistribute it and/or modify
|
|---|
| 5 | it under the terms of the GNU General Public License as published by
|
|---|
| 6 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 7 | (at your option) any later version.
|
|---|
| 8 |
|
|---|
| 9 | This program is distributed in the hope that it will be useful,
|
|---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 12 | GNU General Public License for more details.
|
|---|
| 13 |
|
|---|
| 14 | You should have received a copy of the GNU General Public License
|
|---|
| 15 | along with this program; if not, write to the Free Software
|
|---|
| 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| 19 | #include "audioequalizer.h"
|
|---|
| 20 | #include "eqslider.h"
|
|---|
| 21 | #include "images.h"
|
|---|
| 22 | #include "preferences.h"
|
|---|
| 23 | #include "global.h"
|
|---|
| 24 | #include <QLayout>
|
|---|
| 25 | #include <QPushButton>
|
|---|
| 26 | #include <QMessageBox>
|
|---|
| 27 |
|
|---|
| 28 | using namespace Global;
|
|---|
| 29 |
|
|---|
| 30 | AudioEqualizer::AudioEqualizer( QWidget* parent, Qt::WindowFlags f)
|
|---|
| 31 | : QWidget(parent, f)
|
|---|
| 32 | {
|
|---|
| 33 | QBoxLayout *bl = new QHBoxLayout; //(0, 4, 2);
|
|---|
| 34 |
|
|---|
| 35 | for (int n = 0; n < 10; n++) {
|
|---|
| 36 | eq[n] = new EqSlider(this);
|
|---|
| 37 | eq[n]->setIcon( QPixmap() );
|
|---|
| 38 | eq[n]->sliderWidget()->setRange(-120, 120);
|
|---|
| 39 | bl->addWidget(eq[n]);
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | reset_button = new QPushButton( "&Reset", this);
|
|---|
| 43 | connect( reset_button, SIGNAL(clicked()), this, SLOT(reset()) );
|
|---|
| 44 |
|
|---|
| 45 | set_default_button = new QPushButton( "&Set as default values", this );
|
|---|
| 46 | connect( set_default_button, SIGNAL(clicked()), this, SLOT(setDefaults()) );
|
|---|
| 47 |
|
|---|
| 48 | apply_button = new QPushButton( "&Apply", this );
|
|---|
| 49 | connect( apply_button, SIGNAL(clicked()), this, SLOT(applyButtonClicked()) );
|
|---|
| 50 |
|
|---|
| 51 | QBoxLayout *button_layout = new QHBoxLayout; //(0, 4, 2);
|
|---|
| 52 | button_layout->addStretch();
|
|---|
| 53 | button_layout->addWidget(apply_button);
|
|---|
| 54 | button_layout->addWidget(reset_button);
|
|---|
| 55 | button_layout->addWidget(set_default_button);
|
|---|
| 56 |
|
|---|
| 57 | QBoxLayout *layout = new QVBoxLayout(this); //, 4, 2);
|
|---|
| 58 | layout->addLayout(bl);
|
|---|
| 59 | layout->addLayout(button_layout);
|
|---|
| 60 |
|
|---|
| 61 | retranslateStrings();
|
|---|
| 62 |
|
|---|
| 63 | adjustSize();
|
|---|
| 64 | //setFixedSize( sizeHint() );
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | AudioEqualizer::~AudioEqualizer() {
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 | void AudioEqualizer::retranslateStrings() {
|
|---|
| 71 | setWindowTitle( tr("Audio Equalizer") );
|
|---|
| 72 | setWindowIcon( Images::icon("logo") );
|
|---|
| 73 |
|
|---|
| 74 | eq[0]->setLabel( tr("31.25 Hz") );
|
|---|
| 75 | eq[1]->setLabel( tr("62.50 Hz") );
|
|---|
| 76 | eq[2]->setLabel( tr("125.0 Hz") );
|
|---|
| 77 | eq[3]->setLabel( tr("250.0 Hz") );
|
|---|
| 78 | eq[4]->setLabel( tr("500.0 Hz") );
|
|---|
| 79 | eq[5]->setLabel( tr("1.000 kHz") );
|
|---|
| 80 | eq[6]->setLabel( tr("2.000 kHz") );
|
|---|
| 81 | eq[7]->setLabel( tr("4.000 kHz") );
|
|---|
| 82 | eq[8]->setLabel( tr("8.000 kHz") );
|
|---|
| 83 | eq[9]->setLabel( tr("16.00 kHz") );
|
|---|
| 84 |
|
|---|
| 85 | apply_button->setText( tr("&Apply") );
|
|---|
| 86 | reset_button->setText( tr("&Reset") );
|
|---|
| 87 | set_default_button->setText( tr("&Set as default values") );
|
|---|
| 88 |
|
|---|
| 89 | // What's this help:
|
|---|
| 90 | set_default_button->setWhatsThis(
|
|---|
| 91 | tr("Use the current values as default values for new videos.") );
|
|---|
| 92 |
|
|---|
| 93 | reset_button->setWhatsThis( tr("Set all controls to zero.") );
|
|---|
| 94 |
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | void AudioEqualizer::reset() {
|
|---|
| 98 | for (int n = 0; n < 10; n++) {
|
|---|
| 99 | eq[n]->setValue(0);
|
|---|
| 100 | }
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | void AudioEqualizer::setDefaults() {
|
|---|
| 104 | AudioEqualizerList l;
|
|---|
| 105 | for (int n = 0; n < 10; n++) {
|
|---|
| 106 | l << eq[n]->value();
|
|---|
| 107 | }
|
|---|
| 108 | pref->initial_audio_equalizer = l;
|
|---|
| 109 |
|
|---|
| 110 | QMessageBox::information(this, tr("Information"),
|
|---|
| 111 | tr("The current values have been stored to be "
|
|---|
| 112 | "used as default.") );
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | void AudioEqualizer::applyButtonClicked() {
|
|---|
| 116 | AudioEqualizerList l;
|
|---|
| 117 | for (int n = 0; n < 10; n++) {
|
|---|
| 118 | l << eq[n]->value();
|
|---|
| 119 | }
|
|---|
| 120 | emit applyClicked( l );
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | void AudioEqualizer::hideEvent( QHideEvent * ) {
|
|---|
| 124 | emit visibilityChanged();
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | void AudioEqualizer::showEvent( QShowEvent * ) {
|
|---|
| 128 | emit visibilityChanged();
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | // Language change stuff
|
|---|
| 132 | void AudioEqualizer::changeEvent(QEvent *e) {
|
|---|
| 133 | if (e->type() == QEvent::LanguageChange) {
|
|---|
| 134 | retranslateStrings();
|
|---|
| 135 | } else {
|
|---|
| 136 | QWidget::changeEvent(e);
|
|---|
| 137 | }
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | #include "moc_audioequalizer.cpp"
|
|---|