2010-04-07 18:26:04 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-04-07 18:26:04 +02:00
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef EQUALIZER_H
|
|
|
|
#define EQUALIZER_H
|
|
|
|
|
|
|
|
#include <QDialog>
|
2010-04-07 19:39:07 +02:00
|
|
|
#include <QMetaType>
|
2010-05-10 23:50:31 +02:00
|
|
|
#include <QMap>
|
2010-04-07 18:26:04 +02:00
|
|
|
|
|
|
|
class EqualizerSlider;
|
2010-05-10 23:50:31 +02:00
|
|
|
class Ui_Equalizer;
|
2010-04-07 18:26:04 +02:00
|
|
|
|
|
|
|
class Equalizer : public QDialog {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
Equalizer(QWidget *parent = 0);
|
2010-05-10 23:50:31 +02:00
|
|
|
~Equalizer();
|
2010-04-07 18:26:04 +02:00
|
|
|
|
|
|
|
static const int kBands = 10;
|
|
|
|
static const char* kGainText[kBands];
|
|
|
|
static const char* kSettingsGroup;
|
|
|
|
|
2010-04-07 19:39:07 +02:00
|
|
|
struct Params {
|
|
|
|
Params();
|
|
|
|
Params(int g0, int g1, int g2, int g3, int g4, int g5, int g6, int g7,
|
|
|
|
int g8, int g9, int pre = 0);
|
|
|
|
|
2010-04-09 02:23:17 +02:00
|
|
|
bool operator ==(const Params& other) const;
|
|
|
|
bool operator !=(const Params& other) const;
|
|
|
|
|
2010-04-07 19:39:07 +02:00
|
|
|
int preamp;
|
|
|
|
int gain[kBands];
|
|
|
|
};
|
|
|
|
|
2010-04-08 17:13:34 +02:00
|
|
|
bool is_enabled() const;
|
2010-04-07 18:26:04 +02:00
|
|
|
int preamp_value() const;
|
|
|
|
QList<int> gain_values() const;
|
2010-04-09 02:23:17 +02:00
|
|
|
Params current_params() const;
|
2013-04-27 05:05:42 +02:00
|
|
|
float stereo_balance() const;
|
2010-04-07 18:26:04 +02:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void EnabledChanged(bool enabled);
|
|
|
|
void ParametersChanged(int preamp, const QList<int>& band_gains);
|
2013-04-27 05:05:42 +02:00
|
|
|
void StereoBalanceChanged(float balance);
|
2010-04-07 18:26:04 +02:00
|
|
|
|
2010-04-09 02:23:17 +02:00
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent *);
|
|
|
|
|
2010-04-07 18:26:04 +02:00
|
|
|
private slots:
|
|
|
|
void ParametersChanged();
|
2010-04-07 19:39:07 +02:00
|
|
|
void PresetChanged(const QString& name);
|
2011-03-23 01:42:35 +01:00
|
|
|
void PresetChanged(int index);
|
2010-04-09 02:23:17 +02:00
|
|
|
void SavePreset();
|
2010-04-07 19:39:07 +02:00
|
|
|
void DelPreset();
|
2010-04-08 17:13:34 +02:00
|
|
|
void Save();
|
2013-04-27 05:05:42 +02:00
|
|
|
void StereoSliderChanged(int value);
|
2010-04-07 18:26:04 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
EqualizerSlider* AddSlider(const QString& label);
|
2010-04-07 19:39:07 +02:00
|
|
|
void LoadDefaultPresets();
|
|
|
|
void AddPreset(const QString& name, const Params& params);
|
2010-04-08 17:13:34 +02:00
|
|
|
void ReloadSettings();
|
2010-04-09 02:23:17 +02:00
|
|
|
QString SaveCurrentPreset();
|
2010-04-07 18:26:04 +02:00
|
|
|
|
|
|
|
private:
|
2010-05-10 23:50:31 +02:00
|
|
|
Ui_Equalizer* ui_;
|
2010-04-07 19:39:07 +02:00
|
|
|
bool loading_;
|
2010-04-07 18:26:04 +02:00
|
|
|
|
2010-04-09 02:23:17 +02:00
|
|
|
QString last_preset_;
|
|
|
|
|
2010-04-07 18:26:04 +02:00
|
|
|
EqualizerSlider* preamp_;
|
|
|
|
EqualizerSlider* gain_[kBands];
|
2010-04-07 19:39:07 +02:00
|
|
|
|
|
|
|
QMap<QString, Params> presets_;
|
2010-04-07 18:26:04 +02:00
|
|
|
};
|
2010-04-07 19:39:07 +02:00
|
|
|
Q_DECLARE_METATYPE(Equalizer::Params);
|
|
|
|
|
|
|
|
QDataStream &operator<<(QDataStream& s, const Equalizer::Params& p);
|
|
|
|
QDataStream &operator>>(QDataStream& s, Equalizer::Params& p);
|
2010-04-07 18:26:04 +02:00
|
|
|
|
|
|
|
#endif // EQUALIZER_H
|