implement equalizer widget. access to legacy equalizer is now possible
This commit is contained in:
parent
47d8e323ab
commit
ac44b4efc6
6 changed files with 168 additions and 21 deletions
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
XSettings::XSettings (QObject *parent, XClient *client) : QObject (parent)
|
XSettings::XSettings (QObject *parent, XClient *client) : QObject (parent)
|
||||||
{
|
{
|
||||||
|
m_ready = false;
|
||||||
|
|
||||||
connect (client, SIGNAL (gotConnection (XClient *)),
|
connect (client, SIGNAL (gotConnection (XClient *)),
|
||||||
this, SLOT (on_connect (XClient *)));
|
this, SLOT (on_connect (XClient *)));
|
||||||
|
|
||||||
|
@ -53,6 +55,10 @@ XSettings::value_set (QString key, QString val)
|
||||||
if (!m_client->isConnected ()) {
|
if (!m_client->isConnected ()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Only send change, if the value really changed;
|
||||||
|
if (val == value_get (key))
|
||||||
|
return true;
|
||||||
|
|
||||||
m_client->config ()->valueSet (key.toStdString (), val.toStdString ());
|
m_client->config ()->valueSet (key.toStdString (), val.toStdString ());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -38,7 +38,7 @@ class XSettings : public QObject
|
||||||
bool isReady (void) {return m_ready;}
|
bool isReady (void) {return m_ready;}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void configChanged(QString key, QString value);
|
void configChanged (QString key, QString value);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void on_connect (XClient *);
|
void on_connect (XClient *);
|
||||||
|
|
16
src/Skin.cpp
16
src/Skin.cpp
|
@ -32,15 +32,15 @@ Skin::BuildEqualizer (void)
|
||||||
QPixmap *img = getPixmap ("eqmain");
|
QPixmap *img = getPixmap ("eqmain");
|
||||||
if (img) {
|
if (img) {
|
||||||
m_items[EQ_WIN_BG] = img->copy (0, 0, 275, 116);
|
m_items[EQ_WIN_BG] = img->copy (0, 0, 275, 116);
|
||||||
m_items[EQ_WIN_ON_0] = img->copy (10, 119, 25, 12);
|
m_items[EQ_WIN_OFF_0] = img->copy (10, 119, 25, 12);
|
||||||
m_items[EQ_WIN_ON_1] = img->copy (128, 119, 25, 12);
|
m_items[EQ_WIN_OFF_1] = img->copy (128, 119, 25, 12);
|
||||||
m_items[EQ_WIN_OFF_1] = img->copy (187, 119, 25, 12);
|
m_items[EQ_WIN_ON_1] = img->copy (187, 119, 25, 12);
|
||||||
m_items[EQ_WIN_OFF_0] = img->copy (69, 119, 25, 12);
|
m_items[EQ_WIN_ON_0] = img->copy (69, 119, 25, 12);
|
||||||
|
|
||||||
m_items[EQ_WIN_AUTO_ON_0] = img->copy (35, 119, 33, 12);
|
m_items[EQ_WIN_AUTO_OFF_0] = img->copy (35, 119, 33, 12);
|
||||||
m_items[EQ_WIN_AUTO_ON_1] = img->copy (153, 119, 33, 12);
|
m_items[EQ_WIN_AUTO_OFF_1] = img->copy (153, 119, 33, 12);
|
||||||
m_items[EQ_WIN_AUTO_OFF_1] = img->copy (212, 119, 33, 12);
|
m_items[EQ_WIN_AUTO_ON_1] = img->copy (212, 119, 33, 12);
|
||||||
m_items[EQ_WIN_AUTO_OFF_0] = img->copy (94, 119, 33, 12);
|
m_items[EQ_WIN_AUTO_ON_0] = img->copy (94, 119, 33, 12);
|
||||||
|
|
||||||
m_items[EQ_WIN_PRESET_0] = img->copy (224, 164, 44, 12);
|
m_items[EQ_WIN_PRESET_0] = img->copy (224, 164, 44, 12);
|
||||||
m_items[EQ_WIN_PRESET_1] = img->copy (224, 176, 44, 12);
|
m_items[EQ_WIN_PRESET_1] = img->copy (224, 176, 44, 12);
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "XMMSHandler.h"
|
#include "XMMSHandler.h"
|
||||||
|
#include "xsettings.h"
|
||||||
|
|
||||||
#include "equalizerwidget.h"
|
#include "equalizerwidget.h"
|
||||||
|
|
||||||
|
@ -21,9 +22,34 @@
|
||||||
#include "Button.h"
|
#include "Button.h"
|
||||||
#include "VolumeSlider.h"
|
#include "VolumeSlider.h"
|
||||||
|
|
||||||
|
|
||||||
|
EqualizerSlider::EqualizerSlider (QWidget *parent, uint pix_min, uint pix_max,
|
||||||
|
uint pix_on, uint pix_off, int min, int max,
|
||||||
|
int id) :
|
||||||
|
Slider (parent, pix_min, pix_max, pix_on,
|
||||||
|
pix_off, min, max)
|
||||||
|
{
|
||||||
|
m_id = id;
|
||||||
|
connect ( this, SIGNAL (valueChanged (int)),
|
||||||
|
this, SLOT (on_self_value_changed (int)) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EqualizerSlider::on_self_value_changed (int value)
|
||||||
|
{
|
||||||
|
emit numberedValueChanged (value, m_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* EqualizerWidget
|
||||||
|
*/
|
||||||
|
|
||||||
EqualizerWidget::EqualizerWidget (QWidget *parent) : QWidget (parent)
|
EqualizerWidget::EqualizerWidget (QWidget *parent) : QWidget (parent)
|
||||||
{
|
{
|
||||||
Skin *skin = Skin::getInstance ();
|
Skin *skin = Skin::getInstance ();
|
||||||
|
XMMSHandler &client = XMMSHandler::getInstance ();
|
||||||
|
m_xsettings = client.settings ();
|
||||||
|
|
||||||
connect (skin, SIGNAL(skinChanged(Skin *)),
|
connect (skin, SIGNAL(skinChanged(Skin *)),
|
||||||
this, SLOT(setPixmaps(Skin *)));
|
this, SLOT(setPixmaps(Skin *)));
|
||||||
|
@ -31,9 +57,11 @@ EqualizerWidget::EqualizerWidget (QWidget *parent) : QWidget (parent)
|
||||||
m_enable = new ToggleButton(this, Skin::EQ_WIN_ON_0, Skin::EQ_WIN_ON_1,
|
m_enable = new ToggleButton(this, Skin::EQ_WIN_ON_0, Skin::EQ_WIN_ON_1,
|
||||||
Skin::EQ_WIN_OFF_0, Skin::EQ_WIN_OFF_1);
|
Skin::EQ_WIN_OFF_0, Skin::EQ_WIN_OFF_1);
|
||||||
m_enable->move(14, 18);
|
m_enable->move(14, 18);
|
||||||
m_enable->setEnabled(false); // FIXME: needs to be implemented
|
// must use signal clicked here, as this button also becomes unchecked if
|
||||||
|
// use_legacy is deactivated
|
||||||
|
connect(m_enable, SIGNAL (clicked (bool)),
|
||||||
|
this, SLOT (setEqualizerEnabled (bool)));
|
||||||
|
|
||||||
connect(m_enable, SIGNAL(clicked()), parent, SLOT(setEnabled()));
|
|
||||||
|
|
||||||
m_auto = new ToggleButton(this, Skin::EQ_WIN_AUTO_ON_0, Skin::EQ_WIN_AUTO_ON_1,
|
m_auto = new ToggleButton(this, Skin::EQ_WIN_AUTO_ON_0, Skin::EQ_WIN_AUTO_ON_1,
|
||||||
Skin::EQ_WIN_AUTO_OFF_0, Skin::EQ_WIN_AUTO_OFF_1);
|
Skin::EQ_WIN_AUTO_OFF_0, Skin::EQ_WIN_AUTO_OFF_1);
|
||||||
|
@ -49,13 +77,43 @@ EqualizerWidget::EqualizerWidget (QWidget *parent) : QWidget (parent)
|
||||||
connect(m_preset, SIGNAL(clicked()), parent, SLOT(setEnabled()));
|
connect(m_preset, SIGNAL(clicked()), parent, SLOT(setEnabled()));
|
||||||
|
|
||||||
m_preamp = new Slider(this, Skin::EQ_WIN_BAR_POS_0, Skin::EQ_WIN_BAR_POS_27,
|
m_preamp = new Slider(this, Skin::EQ_WIN_BAR_POS_0, Skin::EQ_WIN_BAR_POS_27,
|
||||||
Skin::EQ_WIN_BAR_BTN_0, Skin::EQ_WIN_BAR_BTN_1, -20, 20);
|
Skin::EQ_WIN_BAR_BTN_0, Skin::EQ_WIN_BAR_BTN_1,
|
||||||
|
-20, 20);
|
||||||
m_preamp->move(21, 38);
|
m_preamp->move(21, 38);
|
||||||
|
connect (m_preamp, SIGNAL (valueChanged (int)),
|
||||||
|
this, SLOT (updateServerPreamp (int)));
|
||||||
|
|
||||||
for (int i=0; i < 10; i++) {
|
for (int i=0; i < 10; i++) {
|
||||||
m_bands[i] = new Slider(this, Skin::EQ_WIN_BAR_POS_0, Skin::EQ_WIN_BAR_POS_27,
|
m_bands[i] = new EqualizerSlider(this, Skin::EQ_WIN_BAR_POS_0,
|
||||||
Skin::EQ_WIN_BAR_BTN_0, Skin::EQ_WIN_BAR_BTN_1, -20, 20);
|
Skin::EQ_WIN_BAR_POS_27,
|
||||||
|
Skin::EQ_WIN_BAR_BTN_0,
|
||||||
|
Skin::EQ_WIN_BAR_BTN_1, -20, 20, i);
|
||||||
m_bands[i]->move(78+i*18, 38);
|
m_bands[i]->move(78+i*18, 38);
|
||||||
|
connect (m_bands[i], SIGNAL (numberedValueChanged (int, int)),
|
||||||
|
this, SLOT (updateServerBands (int, int)));
|
||||||
|
}
|
||||||
|
|
||||||
|
connect (m_xsettings, SIGNAL (configChanged (QString, QString)),
|
||||||
|
this, SLOT (serverConfigChanged (QString, QString)));
|
||||||
|
|
||||||
|
// if the settings from the server were already loaded, we will only
|
||||||
|
// receive configChanged signals for values that really change
|
||||||
|
// so we must request the existing values manually
|
||||||
|
if (m_xsettings->isReady()) {
|
||||||
|
QString key;
|
||||||
|
QString value;
|
||||||
|
// set enabled checkbox
|
||||||
|
key = QString ("equalizer.enabled");
|
||||||
|
value = m_xsettings->value_get (key);
|
||||||
|
serverConfigChanged (key, value);
|
||||||
|
// set preamp
|
||||||
|
|
||||||
|
// Set band-sliders
|
||||||
|
for (int i=0; i < 10; i++) {
|
||||||
|
key = QString ("equalizer.legacy%1").arg(i);
|
||||||
|
value = m_xsettings->value_get (key);
|
||||||
|
serverConfigChanged (key, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,3 +150,57 @@ EqualizerWidget::paintEvent (QPaintEvent *event)
|
||||||
|
|
||||||
paint.end();
|
paint.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These methods handle server configuration updates and
|
||||||
|
* update the serverconfiguraten if we change something
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
EqualizerWidget::serverConfigChanged (QString key, QString value)
|
||||||
|
{
|
||||||
|
// qDebug (key.toAscii ());
|
||||||
|
// qDebug (value.toAscii ());
|
||||||
|
|
||||||
|
// FIXME: also test on use_legacy
|
||||||
|
if (key.startsWith ("equalizer.enabled")) {
|
||||||
|
if (value != "0") {
|
||||||
|
m_enable->setChecked (true);
|
||||||
|
} else {
|
||||||
|
m_enable->setChecked (false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (key == "equalizer.preamp") {
|
||||||
|
// FIXME: value can be of type floas
|
||||||
|
// '-20' should not be necessary. seems to be a bug in slider
|
||||||
|
m_preamp->setValue (value.toInt () -20);
|
||||||
|
}
|
||||||
|
if (key.startsWith ("equalizer.legacy")) {
|
||||||
|
int i = key.right (1).toInt ();
|
||||||
|
// FIXME: value can be float
|
||||||
|
// '-20' should not be necessary. seems to be a bug in slider
|
||||||
|
m_bands[i]->setValue (value.toInt () -20 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EqualizerWidget::setEqualizerEnabled (bool enabled) {
|
||||||
|
if (enabled) {
|
||||||
|
m_xsettings->value_set ("equalizer.enabled", "1");
|
||||||
|
m_xsettings->value_set ("equalizer.use_legacy", "1");
|
||||||
|
} else {
|
||||||
|
m_xsettings->value_set ("equalizer.enabled", "0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EqualizerWidget::updateServerPreamp (int value)
|
||||||
|
{
|
||||||
|
m_xsettings->value_set ("equalizer.preamp", QString::number (value));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EqualizerWidget::updateServerBands (int value, int id)
|
||||||
|
{
|
||||||
|
QString key = QString ("equalizer.legacy%1").arg (id);
|
||||||
|
m_xsettings->value_set (key, QString::number (value));
|
||||||
|
}
|
||||||
|
|
|
@ -17,19 +17,40 @@
|
||||||
#define __EQUALIZERWIDGET_H__
|
#define __EQUALIZERWIDGET_H__
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
class QString;
|
||||||
|
class QVariant;
|
||||||
class QPixmap;
|
class QPixmap;
|
||||||
class QPaintEvent;
|
class QPaintEvent;
|
||||||
|
|
||||||
|
#include "VolumeSlider.h"
|
||||||
|
class XSettings;
|
||||||
class Skin;
|
class Skin;
|
||||||
class Button;
|
class Button;
|
||||||
class ToggleButton;
|
class ToggleButton;
|
||||||
class Slider;
|
|
||||||
|
|
||||||
//#include <iostream>
|
//#include <iostream>
|
||||||
|
|
||||||
|
class EqualizerSlider : public Slider
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
EqualizerSlider (QWidget*, uint, uint, uint, uint, int, int, int);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void numberedValueChanged (int value, int id);
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void on_self_value_changed (int value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_id;
|
||||||
|
};
|
||||||
|
|
||||||
class EqualizerWidget : public QWidget
|
class EqualizerWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EqualizerWidget(QWidget *parent);
|
EqualizerWidget(QWidget *parent);
|
||||||
~EqualizerWidget();
|
~EqualizerWidget();
|
||||||
|
@ -38,14 +59,21 @@ class EqualizerWidget : public QWidget
|
||||||
public slots:
|
public slots:
|
||||||
void setPixmaps(Skin *skin);
|
void setPixmaps(Skin *skin);
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void serverConfigChanged (QString key, QString value);
|
||||||
|
void setEqualizerEnabled (bool enabled);
|
||||||
|
void updateServerPreamp (int value);
|
||||||
|
void updateServerBands (int value, int id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
XSettings *m_xsettings;
|
||||||
QPixmap m_pixmap;
|
QPixmap m_pixmap;
|
||||||
QPixmap m_graph;
|
QPixmap m_graph;
|
||||||
ToggleButton *m_enable;
|
ToggleButton *m_enable;
|
||||||
ToggleButton *m_auto;
|
ToggleButton *m_auto;
|
||||||
Button *m_preset;
|
Button *m_preset;
|
||||||
Slider *m_preamp;
|
Slider *m_preamp;
|
||||||
Slider *m_bands[10];
|
EqualizerSlider *m_bands[10];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -217,6 +217,7 @@ MainDisplay::SetupToggleButtons (void)
|
||||||
{
|
{
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
|
||||||
|
|
||||||
m_eq = new ToggleButton (this, Skin::EQ_ON_0, Skin::EQ_ON_1,
|
m_eq = new ToggleButton (this, Skin::EQ_ON_0, Skin::EQ_ON_1,
|
||||||
Skin::EQ_OFF_0, Skin::EQ_OFF_1);
|
Skin::EQ_OFF_0, Skin::EQ_OFF_1);
|
||||||
m_eq->move(219, 58);
|
m_eq->move(219, 58);
|
||||||
|
@ -225,7 +226,7 @@ MainDisplay::SetupToggleButtons (void)
|
||||||
m_mw->getEQ (), SLOT (setVisible (bool)));
|
m_mw->getEQ (), SLOT (setVisible (bool)));
|
||||||
connect (m_mw->getEQ (), SIGNAL (visibilityChanged (bool)),
|
connect (m_mw->getEQ (), SIGNAL (visibilityChanged (bool)),
|
||||||
m_eq, SLOT (setChecked (bool)));
|
m_eq, SLOT (setChecked (bool)));
|
||||||
m_eq->setEnabled(false); // FIXME: Disabled for now, equalizer doesn't work yet
|
|
||||||
|
|
||||||
m_pls = new ToggleButton (this, Skin::PLS_ON_0, Skin::PLS_ON_1,
|
m_pls = new ToggleButton (this, Skin::PLS_ON_0, Skin::PLS_ON_1,
|
||||||
Skin::PLS_OFF_0, Skin::PLS_OFF_1);
|
Skin::PLS_OFF_0, Skin::PLS_OFF_1);
|
||||||
|
@ -245,7 +246,7 @@ MainDisplay::SetupToggleButtons (void)
|
||||||
m_repeat = new ToggleButton (this, Skin::REPEAT_ON_0, Skin::REPEAT_ON_1,
|
m_repeat = new ToggleButton (this, Skin::REPEAT_ON_0, Skin::REPEAT_ON_1,
|
||||||
Skin::REPEAT_OFF_0, Skin::REPEAT_OFF_1);
|
Skin::REPEAT_OFF_0, Skin::REPEAT_OFF_1);
|
||||||
m_repeat->move(210, 89);
|
m_repeat->move(210, 89);
|
||||||
// m_repeat->setEnabled(false); // FIXME: Disabled button for now, not yet implemented
|
m_repeat->setEnabled(false); // FIXME: Disabled button for now, not yet implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue