Mixxx

/home/maxime/Projets/Mixxx/1.10/mixxx/src/dlgprefreplaygain.cpp

Go to the documentation of this file.
00001 
00002 #include <qlineedit.h>
00003 #include <qwidget.h>
00004 #include <qcheckbox.h>
00005 #include <qlabel.h>
00006 #include <qstring.h>
00007 #include <qpushbutton.h>
00008 #include <qlcdnumber.h>
00009 #include <qslider.h>
00010 #include <QtCore>
00011 #include <QMessageBox>
00012 #include "controlobject.h"
00013 
00014 #include "dlgprefreplaygain.h"
00015 
00016 #define CONFIG_KEY "[ReplayGain]"
00017 
00018 
00019 DlgPrefReplayGain::DlgPrefReplayGain(QWidget * parent, ConfigObject<ConfigValue> * _config)
00020         :  QWidget(parent)
00021         , Ui::DlgPrefReplayGainDlg()
00022         , m_COTInitialBoost(ControlObject::getControl(ConfigKey(CONFIG_KEY, "InitialReplayGainBoost")))
00023         , m_COTEnabled(ControlObject::getControl(ConfigKey(CONFIG_KEY, "ReplayGainEnabled")))
00024 {
00025     config = _config;
00026 
00027     setupUi(this);
00028 
00029     //Connections
00030     connect(EnableGain,      SIGNAL(stateChanged(int)), this, SLOT(slotSetRGEnabled()));
00031     connect(EnableAnalyser,  SIGNAL(stateChanged(int)), this, SLOT(slotSetRGAnalyserEnabled()));
00032     connect(SliderBoost,     SIGNAL(valueChanged(int)), this, SLOT(slotUpdateBoost()));
00033     connect(SliderBoost,     SIGNAL(sliderReleased()),  this, SLOT(slotApply()));
00034     connect(PushButtonReset, SIGNAL(clicked(bool)),     this, SLOT(setDefaults()));
00035 
00036     loadSettings();
00037 }
00038 
00039 DlgPrefReplayGain::~DlgPrefReplayGain() {
00040 }
00041 
00042 void DlgPrefReplayGain::loadSettings() {
00043     if(config->getValueString(ConfigKey(CONFIG_KEY,"ReplayGainEnabled"))==QString("")) {
00044         setDefaults();
00045     } else {
00046         int iReplayGainBoost =
00047                 config->getValueString(ConfigKey(CONFIG_KEY, "InitialReplayGainBoost")).toInt();
00048         SliderBoost->setValue(iReplayGainBoost);
00049         lcddB->display(iReplayGainBoost);
00050 
00051         bool gainEnabled =
00052                 config->getValueString(ConfigKey(CONFIG_KEY, "ReplayGainEnabled")).toInt() == 1;
00053         EnableGain->setChecked(gainEnabled);
00054 
00055         bool analyserEnabled =
00056                 config->getValueString(ConfigKey(CONFIG_KEY, "ReplayGainAnalyserEnabled")).toInt();
00057         EnableAnalyser->setChecked(analyserEnabled);
00058     }
00059     slotUpdate();
00060     slotUpdateBoost();
00061 }
00062 
00063 void DlgPrefReplayGain::setDefaults() {
00064     EnableGain->setChecked(true);
00065     // Turn ReplayGain Analyser on by default as it does not give appreciable
00066     // delay on recent hardware (<5 years old).
00067     EnableAnalyser->setChecked(true);
00068     SliderBoost->setValue(6);
00069     lcddB->display(6);
00070     slotUpdate();
00071     slotApply();
00072 }
00073 
00074 void DlgPrefReplayGain::slotSetRGEnabled() {
00075     if (EnableGain->isChecked()) {
00076         config->set(ConfigKey(CONFIG_KEY,"ReplayGainEnabled"), ConfigValue(1));
00077     } else {
00078         config->set(ConfigKey(CONFIG_KEY,"ReplayGainEnabled"), ConfigValue(0));
00079         config->set(ConfigKey(CONFIG_KEY,"ReplayGainAnalyserEnabled"),
00080                     ConfigValue(0));
00081     }
00082 
00083     slotUpdate();
00084     slotApply();
00085 }
00086 
00087 void DlgPrefReplayGain::slotSetRGAnalyserEnabled() {
00088     int enabled = EnableAnalyser->isChecked() ? 1 : 0;
00089     config->set(ConfigKey(CONFIG_KEY,"ReplayGainAnalyserEnabled"),
00090                 ConfigValue(enabled));
00091     slotApply();
00092 }
00093 
00094 void DlgPrefReplayGain::slotUpdateBoost() {
00095     config->set(ConfigKey(CONFIG_KEY, "InitialReplayGainBoost"),
00096                 ConfigValue(SliderBoost->value()));
00097     slotApply();
00098 }
00099 
00100 void DlgPrefReplayGain::slotUpdate() {
00101     if (config->getValueString(ConfigKey(CONFIG_KEY,"ReplayGainEnabled")).toInt()==1)
00102     {
00103         EnableAnalyser->setEnabled(true);
00104         SliderBoost->setEnabled(true);
00105     }
00106     else
00107     {
00108         EnableAnalyser->setChecked(false);
00109         EnableAnalyser->setEnabled(false);
00110         SliderBoost->setValue(0);
00111         SliderBoost->setEnabled(false);
00112         lcddB -> display(0);
00113     }
00114 }
00115 
00116 void DlgPrefReplayGain::slotApply() {
00117     m_COTInitialBoost.slotSet(SliderBoost->value());
00118     int iRGenabled = 0;
00119     int iRGAnalyserEnabled = 0;
00120     if (EnableGain->isChecked()) iRGenabled = 1;
00121     if (EnableAnalyser->isChecked()) iRGAnalyserEnabled = 1;
00122     m_COTEnabled.slotSet(iRGenabled);
00123 }
00124 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines