Merge branch 'master' of ssh://git.xmms.se/xmms2/promoe
This commit is contained in:
commit
b9f8aeadec
13 changed files with 424 additions and 384 deletions
|
@ -2,6 +2,7 @@
|
||||||
#include "TitleBar.h"
|
#include "TitleBar.h"
|
||||||
#include "Equalizer.h"
|
#include "Equalizer.h"
|
||||||
#include "Button.h"
|
#include "Button.h"
|
||||||
|
#include "VolumeSlider.h"
|
||||||
|
|
||||||
EqualizerWindow::EqualizerWindow (QWidget *parent) : QMainWindow (parent)
|
EqualizerWindow::EqualizerWindow (QWidget *parent) : QMainWindow (parent)
|
||||||
{
|
{
|
||||||
|
@ -30,6 +31,27 @@ EqualizerWindow::setEnabled (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
EqualizerWindow::mousePressEvent (QMouseEvent *event)
|
||||||
|
{
|
||||||
|
m_diffx = event->pos().x();
|
||||||
|
m_diffy = event->pos().y();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EqualizerWindow::mouseMoveEvent (QMouseEvent *event)
|
||||||
|
{
|
||||||
|
move(event->globalPos().x() - m_diffx,
|
||||||
|
event->globalPos().y() - m_diffy);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EqualizerWindow::moveEvent (QMoveEvent *event)
|
||||||
|
{
|
||||||
|
QSettings s;
|
||||||
|
s.setValue ("equalizer/pos", pos ());
|
||||||
|
}
|
||||||
|
|
||||||
EqualizerWidget::EqualizerWidget (QWidget *parent) : QWidget (parent)
|
EqualizerWidget::EqualizerWidget (QWidget *parent) : QWidget (parent)
|
||||||
{
|
{
|
||||||
Skin *skin = Skin::getInstance ();
|
Skin *skin = Skin::getInstance ();
|
||||||
|
@ -53,17 +75,22 @@ EqualizerWidget::EqualizerWidget (QWidget *parent) : QWidget (parent)
|
||||||
m_preset->move(217, 18);
|
m_preset->move(217, 18);
|
||||||
|
|
||||||
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,
|
||||||
|
Skin::EQ_WIN_BAR_BTN_0, Skin::EQ_WIN_BAR_BTN_1, -20, 20);
|
||||||
|
m_preamp->move(21, 38);
|
||||||
|
|
||||||
|
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,
|
||||||
|
Skin::EQ_WIN_BAR_BTN_0, Skin::EQ_WIN_BAR_BTN_1, -20, 20);
|
||||||
|
m_bands[i]->move(78+i*18, 38);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EqualizerWidget::~EqualizerWidget (void)
|
EqualizerWidget::~EqualizerWidget (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
EqualizerWidget::mouseMoveEvent (QMouseEvent *event)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EqualizerWidget::setPixmaps (Skin *skin)
|
EqualizerWidget::setPixmaps (Skin *skin)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,7 @@ class Button;
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
class TitleBar;
|
class TitleBar;
|
||||||
class ToggleButton;
|
class ToggleButton;
|
||||||
|
class Slider;
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
@ -23,7 +24,6 @@ class EqualizerWidget : public QWidget
|
||||||
public:
|
public:
|
||||||
EqualizerWidget(QWidget *parent);
|
EqualizerWidget(QWidget *parent);
|
||||||
~EqualizerWidget();
|
~EqualizerWidget();
|
||||||
void mouseMoveEvent(QMouseEvent *);
|
|
||||||
void paintEvent (QPaintEvent *event);
|
void paintEvent (QPaintEvent *event);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -34,6 +34,8 @@ class EqualizerWidget : public QWidget
|
||||||
ToggleButton *m_enable;
|
ToggleButton *m_enable;
|
||||||
ToggleButton *m_auto;
|
ToggleButton *m_auto;
|
||||||
Button *m_preset;
|
Button *m_preset;
|
||||||
|
Slider *m_preamp;
|
||||||
|
Slider *m_bands[10];
|
||||||
};
|
};
|
||||||
|
|
||||||
class EqualizerWindow : public QMainWindow
|
class EqualizerWindow : public QMainWindow
|
||||||
|
@ -42,6 +44,9 @@ class EqualizerWindow : public QMainWindow
|
||||||
public:
|
public:
|
||||||
EqualizerWindow(QWidget *parent);
|
EqualizerWindow(QWidget *parent);
|
||||||
~EqualizerWindow();
|
~EqualizerWindow();
|
||||||
|
void mouseMoveEvent(QMouseEvent *);
|
||||||
|
void mousePressEvent(QMouseEvent *);
|
||||||
|
void moveEvent(QMoveEvent *event);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setEnabled (void);
|
void setEnabled (void);
|
||||||
|
@ -49,6 +54,8 @@ class EqualizerWindow : public QMainWindow
|
||||||
private:
|
private:
|
||||||
MainWindow *m_mw;
|
MainWindow *m_mw;
|
||||||
EqualizerWidget *m_equalizer;
|
EqualizerWidget *m_equalizer;
|
||||||
|
int m_diffx;
|
||||||
|
int m_diffy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include "TimeDisplay.h"
|
#include "TimeDisplay.h"
|
||||||
#include "SmallNumberDisplay.h"
|
#include "SmallNumberDisplay.h"
|
||||||
#include "StereoMono.h"
|
#include "StereoMono.h"
|
||||||
#include "Slider.h"
|
#include "PosBar.h"
|
||||||
#include "PlayStatus.h"
|
#include "PlayStatus.h"
|
||||||
#include "VolumeSlider.h"
|
#include "VolumeSlider.h"
|
||||||
#include "Playlist.h"
|
#include "Playlist.h"
|
||||||
|
@ -51,17 +51,22 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent)
|
||||||
m_clutterbar = new ClutterBar (this);
|
m_clutterbar = new ClutterBar (this);
|
||||||
m_clutterbar->move (10, 22);
|
m_clutterbar->move (10, 22);
|
||||||
|
|
||||||
m_slider = new Slider (this, Skin::POSBAR,
|
m_posbar = new PosBar (this, Skin::POSBAR,
|
||||||
Skin::POSBAR_BTN_0,
|
Skin::POSBAR_BTN_0,
|
||||||
Skin::POSBAR_BTN_1);
|
Skin::POSBAR_BTN_1);
|
||||||
m_slider->move (16, 72);
|
m_posbar->move (16, 72);
|
||||||
|
|
||||||
m_playstatus = new PlayStatus (this);
|
m_playstatus = new PlayStatus (this);
|
||||||
m_playstatus->move (24, 28);
|
m_playstatus->move (24, 28);
|
||||||
|
|
||||||
m_vslider = new VolumeSlider(this);
|
m_vslider = new Slider(this, Skin::VOLUMEBAR_POS_0, Skin::VOLUMEBAR_POS_27,
|
||||||
|
Skin::VOLBAR_BTN_0, Skin::VOLBAR_BTN_1, 0, 100);
|
||||||
m_vslider->move (107, 57);
|
m_vslider->move (107, 57);
|
||||||
|
|
||||||
|
m_bslider = new Slider(this, Skin::BALANCE_POS_0, Skin::BALANCE_POS_27,
|
||||||
|
Skin::BALANCE_BTN_0, Skin::BALANCE_BTN_1, -20, 20);
|
||||||
|
m_bslider->move (177, 57);
|
||||||
|
|
||||||
XMMSHandler &xmmsh = XMMSHandler::getInstance ();
|
XMMSHandler &xmmsh = XMMSHandler::getInstance ();
|
||||||
connect (&xmmsh, SIGNAL(currentSong (const Xmms::PropDict &)),
|
connect (&xmmsh, SIGNAL(currentSong (const Xmms::PropDict &)),
|
||||||
this, SLOT(setMediainfo (const Xmms::PropDict &)));
|
this, SLOT(setMediainfo (const Xmms::PropDict &)));
|
||||||
|
@ -69,6 +74,23 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent)
|
||||||
this, SLOT(setStatus(Xmms::Playback::Status)));
|
this, SLOT(setStatus(Xmms::Playback::Status)));
|
||||||
connect (&xmmsh, SIGNAL(playtimeChanged(uint)),
|
connect (&xmmsh, SIGNAL(playtimeChanged(uint)),
|
||||||
this, SLOT(setPlaytime(uint)));
|
this, SLOT(setPlaytime(uint)));
|
||||||
|
connect (&xmmsh, SIGNAL(getVolume(uint)), this, SLOT(updateVolume(uint)));
|
||||||
|
connect (m_vslider, SIGNAL(valueChanged(int)), this, SLOT(setVolume(int)));
|
||||||
|
xmmsh.volumeGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MainDisplay::updateVolume (uint volume)
|
||||||
|
{
|
||||||
|
m_vslider->setValue((int)volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MainDisplay::setVolume (int volume)
|
||||||
|
{
|
||||||
|
XMMSHandler &xmmsh = XMMSHandler::getInstance();
|
||||||
|
xmmsh.volumeSet((uint)volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -105,8 +127,8 @@ MainDisplay::setStatus (Xmms::Playback::Status status)
|
||||||
{
|
{
|
||||||
if (status == Xmms::Playback::STOPPED) {
|
if (status == Xmms::Playback::STOPPED) {
|
||||||
m_time->setTime(0);
|
m_time->setTime(0);
|
||||||
m_slider->setPos (0);
|
m_posbar->setPos (0);
|
||||||
m_slider->hideBar (true);
|
m_posbar->hideBar (true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +137,7 @@ MainDisplay::setPlaytime (uint time)
|
||||||
{
|
{
|
||||||
uint showtime;
|
uint showtime;
|
||||||
if (m_mw->isTimemodeReverse()) {
|
if (m_mw->isTimemodeReverse()) {
|
||||||
uint maxtime = m_slider->getMax();
|
uint maxtime = m_posbar->getMax();
|
||||||
showtime = -(maxtime - time);
|
showtime = -(maxtime - time);
|
||||||
} else {
|
} else {
|
||||||
showtime = time;
|
showtime = time;
|
||||||
|
@ -123,7 +145,7 @@ MainDisplay::setPlaytime (uint time)
|
||||||
m_time->setTime (showtime);
|
m_time->setTime (showtime);
|
||||||
|
|
||||||
// update slider
|
// update slider
|
||||||
m_slider->setPos (time);
|
m_posbar->setPos (time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -166,10 +188,10 @@ MainDisplay::setMediainfo (const Xmms::PropDict &info)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.contains ("duration")) {
|
if (info.contains ("duration")) {
|
||||||
m_slider->setMax (info.get<int32_t> ("duration"));
|
m_posbar->setMax (info.get<int32_t> ("duration"));
|
||||||
m_slider->hideBar (false);
|
m_posbar->hideBar (false);
|
||||||
} else {
|
} else {
|
||||||
m_slider->hideBar (true);
|
m_posbar->hideBar (true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ class TextScroller;
|
||||||
class TimeDisplay;
|
class TimeDisplay;
|
||||||
class SmallNumberDisplay;
|
class SmallNumberDisplay;
|
||||||
class StereoMono;
|
class StereoMono;
|
||||||
|
class PosBar;
|
||||||
class Slider;
|
class Slider;
|
||||||
class VolumeSlider;
|
|
||||||
class PlayStatus;
|
class PlayStatus;
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
class ClutterBar;
|
class ClutterBar;
|
||||||
|
@ -58,8 +58,9 @@ class MainDisplay : public SkinDisplay
|
||||||
SmallNumberDisplay *m_khz;
|
SmallNumberDisplay *m_khz;
|
||||||
|
|
||||||
StereoMono *m_stereo;
|
StereoMono *m_stereo;
|
||||||
Slider *m_slider;
|
PosBar *m_posbar;
|
||||||
VolumeSlider *m_vslider;
|
Slider *m_vslider;
|
||||||
|
Slider *m_bslider;
|
||||||
|
|
||||||
PlayStatus *m_playstatus;
|
PlayStatus *m_playstatus;
|
||||||
MainWindow *getMW(void) { return m_mw; }
|
MainWindow *getMW(void) { return m_mw; }
|
||||||
|
@ -74,6 +75,8 @@ class MainDisplay : public SkinDisplay
|
||||||
void togglePL(void);
|
void togglePL(void);
|
||||||
void toggleEQ(void);
|
void toggleEQ(void);
|
||||||
void toggleTime(void);
|
void toggleTime(void);
|
||||||
|
void updateVolume (uint volume);
|
||||||
|
void setVolume (int volume);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void SetupPushButtons (void);
|
void SetupPushButtons (void);
|
||||||
|
|
|
@ -123,6 +123,7 @@ MainWindow::toggleEQ (bool UpdateButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.value ("equalizer/hidden").toBool ()) {
|
if (s.value ("equalizer/hidden").toBool ()) {
|
||||||
|
m_equalizer->move (s.value("equalizer/pos").toPoint ());
|
||||||
m_equalizer->show ();
|
m_equalizer->show ();
|
||||||
s.setValue ("equalizer/hidden", false);
|
s.setValue ("equalizer/hidden", false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -174,7 +175,6 @@ main (int argc, char **argv)
|
||||||
settings.setValue ("playlist/pos", QPoint (mw->pos().x(),
|
settings.setValue ("playlist/pos", QPoint (mw->pos().x(),
|
||||||
mw->pos().y()+mw->size().height()));
|
mw->pos().y()+mw->size().height()));
|
||||||
playlistwin->move (settings.value("playlist/pos").toPoint ());
|
playlistwin->move (settings.value("playlist/pos").toPoint ());
|
||||||
playlistwin->move (settings.value("playlist/pos").toPoint ());
|
|
||||||
|
|
||||||
if (!settings.contains ("playlist/hidden"))
|
if (!settings.contains ("playlist/hidden"))
|
||||||
settings.setValue ("playlist/hidden", true);
|
settings.setValue ("playlist/hidden", true);
|
||||||
|
@ -184,6 +184,15 @@ main (int argc, char **argv)
|
||||||
else
|
else
|
||||||
playlistwin->show ();
|
playlistwin->show ();
|
||||||
|
|
||||||
|
|
||||||
|
if (!settings.contains ("equalizer/pos"))
|
||||||
|
settings.setValue ("equalizer/pos", QPoint (mw->pos().x(),
|
||||||
|
mw->pos().y()+mw->size().height()));
|
||||||
|
eqwin->move (settings.value("equalizer/pos").toPoint ());
|
||||||
|
|
||||||
|
if (!settings.contains ("equalizer/hidden"))
|
||||||
|
settings.setValue ("equalizer/hidden", true);
|
||||||
|
|
||||||
if (settings.value("equalizer/hidden").toBool ())
|
if (settings.value("equalizer/hidden").toBool ())
|
||||||
eqwin->hide ();
|
eqwin->hide ();
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
|
||||||
#include "Slider.h"
|
#include "PosBar.h"
|
||||||
#include "Skin.h"
|
#include "Skin.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
||||||
BarButton::BarButton (QWidget *parent, uint normal, uint pressed) : Button (parent, normal, pressed)
|
PosButton::PosButton (QWidget *parent, uint normal, uint pressed) : Button (parent, normal, pressed)
|
||||||
{
|
{
|
||||||
m_slider = dynamic_cast<Slider *>(parent);
|
m_slider = dynamic_cast<PosBar *>(parent);
|
||||||
setMinimumSize (29, 10);
|
setMinimumSize (29, 10);
|
||||||
setMaximumSize (29, 10);
|
setMaximumSize (29, 10);
|
||||||
m_moving = false;
|
m_moving = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BarButton::setPos (uint pos)
|
PosButton::setPos (uint pos)
|
||||||
{
|
{
|
||||||
m_pos = pos;
|
m_pos = pos;
|
||||||
if (!m_moving) {
|
if (!m_moving) {
|
||||||
|
@ -24,13 +24,13 @@ BarButton::setPos (uint pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint
|
uint
|
||||||
BarButton::getPos (void)
|
PosButton::getPos (void)
|
||||||
{
|
{
|
||||||
return m_pos;
|
return m_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BarButton::mousePressEvent (QMouseEvent *event)
|
PosButton::mousePressEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
QPoint p (event->pos ());
|
QPoint p (event->pos ());
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ BarButton::mousePressEvent (QMouseEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BarButton::mouseReleaseEvent (QMouseEvent *event)
|
PosButton::mouseReleaseEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
m_moving = false;
|
m_moving = false;
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ BarButton::mouseReleaseEvent (QMouseEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BarButton::mouseMoveEvent (QMouseEvent *event)
|
PosButton::mouseMoveEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
QPoint p (event->pos ());
|
QPoint p (event->pos ());
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ BarButton::mouseMoveEvent (QMouseEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Slider::Slider (QWidget *parent, uint bg, uint bnormal, uint bpressed, bool vertical) : PixWidget (parent)
|
PosBar::PosBar (QWidget *parent, uint bg, uint bnormal, uint bpressed, bool vertical) : PixWidget (parent)
|
||||||
{
|
{
|
||||||
m_bg = bg;
|
m_bg = bg;
|
||||||
m_vertical = vertical;
|
m_vertical = vertical;
|
||||||
|
@ -87,7 +87,7 @@ Slider::Slider (QWidget *parent, uint bg, uint bnormal, uint bpressed, bool vert
|
||||||
|
|
||||||
m_max = 0;
|
m_max = 0;
|
||||||
|
|
||||||
m_button = new BarButton (this, bnormal, bpressed);
|
m_button = new PosButton (this, bnormal, bpressed);
|
||||||
m_button->move (0, 0);
|
m_button->move (0, 0);
|
||||||
|
|
||||||
if (m_vertical) {
|
if (m_vertical) {
|
||||||
|
@ -101,7 +101,7 @@ Slider::Slider (QWidget *parent, uint bg, uint bnormal, uint bpressed, bool vert
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Slider::setSize (uint x, uint y)
|
PosBar::setSize (uint x, uint y)
|
||||||
{
|
{
|
||||||
setMinimumSize (x, y);
|
setMinimumSize (x, y);
|
||||||
setMaximumSize (x, y);
|
setMaximumSize (x, y);
|
||||||
|
@ -115,7 +115,7 @@ Slider::setSize (uint x, uint y)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint
|
uint
|
||||||
Slider::getPos (void)
|
PosBar::getPos (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (m_vertical) {
|
if (m_vertical) {
|
||||||
|
@ -126,7 +126,7 @@ Slider::getPos (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Slider::hideBar (bool b)
|
PosBar::hideBar (bool b)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (b) {
|
if (b) {
|
||||||
|
@ -139,7 +139,7 @@ Slider::hideBar (bool b)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Slider::setPos (uint p)
|
PosBar::setPos (uint p)
|
||||||
{
|
{
|
||||||
if (!m_max) {
|
if (!m_max) {
|
||||||
return;
|
return;
|
||||||
|
@ -153,13 +153,13 @@ Slider::setPos (uint p)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Slider::requestPos (float value)
|
PosBar::requestPos (float value)
|
||||||
{
|
{
|
||||||
XMMSHandler::getInstance ().setPlaytime (m_max * value);
|
XMMSHandler::getInstance ().setPlaytime (m_max * value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Slider::setPixmaps (Skin *skin)
|
PosBar::setPixmaps (Skin *skin)
|
||||||
{
|
{
|
||||||
m_pixmap = skin->getItem (m_bg);
|
m_pixmap = skin->getItem (m_bg);
|
||||||
}
|
}
|
|
@ -4,12 +4,12 @@
|
||||||
#include "PixWidget.h"
|
#include "PixWidget.h"
|
||||||
#include "Button.h"
|
#include "Button.h"
|
||||||
|
|
||||||
class Slider;
|
class PosBar;
|
||||||
|
|
||||||
class BarButton : public Button
|
class PosButton : public Button
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BarButton (QWidget *, uint, uint);
|
PosButton (QWidget *, uint, uint);
|
||||||
|
|
||||||
void mouseMoveEvent (QMouseEvent *);
|
void mouseMoveEvent (QMouseEvent *);
|
||||||
void mousePressEvent (QMouseEvent *);
|
void mousePressEvent (QMouseEvent *);
|
||||||
|
@ -19,18 +19,18 @@ class BarButton : public Button
|
||||||
uint getPos (void);
|
uint getPos (void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Slider *m_slider;
|
PosBar *m_slider;
|
||||||
bool m_moving;
|
bool m_moving;
|
||||||
uint m_pos;
|
uint m_pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Slider : public PixWidget
|
class PosBar : public PixWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Slider (QWidget *parent, uint bg, uint bnormal, uint bpressed, bool vertical=true);
|
PosBar (QWidget *parent, uint bg, uint bnormal, uint bpressed, bool vertical=true);
|
||||||
~Slider () { }
|
~PosBar () { }
|
||||||
|
|
||||||
void setSize (uint, uint);
|
void setSize (uint, uint);
|
||||||
uint getPos (void);
|
uint getPos (void);
|
||||||
|
@ -50,7 +50,7 @@ class Slider : public PixWidget
|
||||||
int m_bg;
|
int m_bg;
|
||||||
uint m_max;
|
uint m_max;
|
||||||
uint m_pix;
|
uint m_pix;
|
||||||
BarButton *m_button;
|
PosButton *m_button;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
55
Skin.cpp
55
Skin.cpp
|
@ -32,6 +32,16 @@ Skin::BuildEqualizer (void)
|
||||||
|
|
||||||
m_items[EQ_WIN_GRAPH_BG] = img->copy (0, 294, 113, 19);
|
m_items[EQ_WIN_GRAPH_BG] = img->copy (0, 294, 113, 19);
|
||||||
|
|
||||||
|
for (int i = 0; i < 14; i++) {
|
||||||
|
m_items[EQ_WIN_BAR_POS_0+i] = img->copy (13+15*i, 164, 14, 63);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 14; i++) {
|
||||||
|
m_items[EQ_WIN_BAR_POS_14+i] = img->copy (13+15*i, 229, 14, 63);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_items[EQ_WIN_BAR_BTN_1] = img->copy (0, 164, 11, 11);
|
||||||
|
m_items[EQ_WIN_BAR_BTN_0] = img->copy (0, 176, 11, 11);
|
||||||
|
|
||||||
delete img;
|
delete img;
|
||||||
} else {
|
} else {
|
||||||
setSkin(":CleanAMP/");
|
setSkin(":CleanAMP/");
|
||||||
|
@ -481,52 +491,51 @@ Skin::BuildSliders (void)
|
||||||
QPixmap *img;
|
QPixmap *img;
|
||||||
|
|
||||||
img = getPixmap("posbar");
|
img = getPixmap("posbar");
|
||||||
if(img)
|
if (img) {
|
||||||
{
|
|
||||||
m_items[POSBAR] = img->copy (0, 0, 248, 10);
|
m_items[POSBAR] = img->copy (0, 0, 248, 10);
|
||||||
m_items[POSBAR_BTN_0] = img->copy (248, 0, 29, 10);
|
m_items[POSBAR_BTN_0] = img->copy (248, 0, 29, 10);
|
||||||
m_items[POSBAR_BTN_1] = img->copy (278, 0, 29, 10);
|
m_items[POSBAR_BTN_1] = img->copy (278, 0, 29, 10);
|
||||||
|
|
||||||
delete img;
|
delete img;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
setSkin(":CleanAMP/");
|
setSkin(":CleanAMP/");
|
||||||
|
}
|
||||||
|
|
||||||
img = getPixmap("volume");
|
img = getPixmap("volume");
|
||||||
if(img)
|
if (img) {
|
||||||
{
|
for (int i = 0; i <= 27; i++) {
|
||||||
for (int i = VOLUMEBAR_POS_MIN; i <= VOLUMEBAR_POS_MAX; i++) {
|
m_items[VOLUMEBAR_POS_0+i] = img->copy(0, i*15, 68, 13);
|
||||||
m_volume_bar[i] = img->copy(0, i*15, 68, 13);
|
|
||||||
}
|
}
|
||||||
if(img->height() > 420)
|
|
||||||
{
|
if (img->height() > 420) {
|
||||||
m_items[VOLBAR_BTN_1] = img->copy (0, 422, 14, 11);
|
m_items[VOLBAR_BTN_1] = img->copy (0, 422, 14, 11);
|
||||||
m_items[VOLBAR_BTN_0] = img->copy (15, 422, 14, 11);
|
m_items[VOLBAR_BTN_0] = img->copy (15, 422, 14, 11);
|
||||||
m_volbtn = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_volbtn = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete img;
|
delete img;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
setSkin(":CleanAMP/");
|
setSkin(":CleanAMP/");
|
||||||
|
}
|
||||||
|
|
||||||
img = getPixmap("balance");
|
img = getPixmap("balance");
|
||||||
if (!img) {
|
if (!img) {
|
||||||
img = getPixmap("volume");
|
img = getPixmap("volume");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(img)
|
if (img) {
|
||||||
{
|
for (int i = 0; i < 28; i++) {
|
||||||
for (int i = BALANCE_POS_MIN; i <= BALANCE_POS_MAX; i++) {
|
m_items[BALANCE_POS_0+i] = img->copy(9, i*15, 38, 13);
|
||||||
m_balance[i] = img->copy(9, i*15, 38, 13);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (img->height() > 421) {
|
||||||
|
m_items[BALANCE_BTN_0] = img->copy(0, 422, 14, 11);
|
||||||
|
m_items[BALANCE_BTN_1] = img->copy(15, 422, 14, 11);
|
||||||
|
}
|
||||||
|
|
||||||
delete img;
|
delete img;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
setSkin(":CleanAMP/");
|
setSkin(":CleanAMP/");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
155
Skin.h
155
Skin.h
|
@ -20,78 +20,13 @@ class Skin : public QWidget
|
||||||
|
|
||||||
const QPixmap getItem (uint part) const { return m_items[part]; }
|
const QPixmap getItem (uint part) const { return m_items[part]; }
|
||||||
const QPixmap getPls (uint part) const { return m_playlist[part]; }
|
const QPixmap getPls (uint part) const { return m_playlist[part]; }
|
||||||
const QPixmap getVol (uint p) const { return m_volume_bar[p]; }
|
|
||||||
const QPixmap getBal (uint p) const { return m_balance[p]; }
|
|
||||||
const QPixmap getLetter (uint c) const { return m_letterMap[c]; }
|
const QPixmap getLetter (uint c) const { return m_letterMap[c]; }
|
||||||
const QPixmap getNumber (uint c) const { return m_numbers[c]; }
|
const QPixmap getNumber (uint c) const { return m_numbers[c]; }
|
||||||
uint getNumberSize () { return m_numbers.size(); }
|
uint getNumberSize () { return m_numbers.size(); }
|
||||||
const QByteArray getPLeditValue (QByteArray c) const { return m_pledit_txt[c]; }
|
const QByteArray getPLeditValue (QByteArray c) const { return m_pledit_txt[c]; }
|
||||||
const bool getVolBtn(void) const { return m_volbtn; }
|
|
||||||
const bool getBalBtn(void) const { return m_balbtn; }
|
|
||||||
|
|
||||||
enum Volume {
|
|
||||||
VOLUMEBAR_POS_MIN,
|
|
||||||
VOLUMEBAR_POS_1,
|
|
||||||
VOLUMEBAR_POS_2,
|
|
||||||
VOLUMEBAR_POS_3,
|
|
||||||
VOLUMEBAR_POS_4,
|
|
||||||
VOLUMEBAR_POS_5,
|
|
||||||
VOLUMEBAR_POS_6,
|
|
||||||
VOLUMEBAR_POS_7,
|
|
||||||
VOLUMEBAR_POS_8,
|
|
||||||
VOLUMEBAR_POS_9,
|
|
||||||
VOLUMEBAR_POS_10,
|
|
||||||
VOLUMEBAR_POS_11,
|
|
||||||
VOLUMEBAR_POS_12,
|
|
||||||
VOLUMEBAR_POS_13,
|
|
||||||
VOLUMEBAR_POS_14,
|
|
||||||
VOLUMEBAR_POS_15,
|
|
||||||
VOLUMEBAR_POS_16,
|
|
||||||
VOLUMEBAR_POS_17,
|
|
||||||
VOLUMEBAR_POS_18,
|
|
||||||
VOLUMEBAR_POS_19,
|
|
||||||
VOLUMEBAR_POS_20,
|
|
||||||
VOLUMEBAR_POS_21,
|
|
||||||
VOLUMEBAR_POS_22,
|
|
||||||
VOLUMEBAR_POS_23,
|
|
||||||
VOLUMEBAR_POS_24,
|
|
||||||
VOLUMEBAR_POS_25,
|
|
||||||
VOLUMEBAR_POS_26,
|
|
||||||
VOLUMEBAR_POS_MAX
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Balance {
|
|
||||||
BALANCE_POS_MIN,
|
|
||||||
BALANCE_POS_1,
|
|
||||||
BALANCE_POS_2,
|
|
||||||
BALANCE_POS_3,
|
|
||||||
BALANCE_POS_4,
|
|
||||||
BALANCE_POS_5,
|
|
||||||
BALANCE_POS_6,
|
|
||||||
BALANCE_POS_7,
|
|
||||||
BALANCE_POS_8,
|
|
||||||
BALANCE_POS_9,
|
|
||||||
BALANCE_POS_10,
|
|
||||||
BALANCE_POS_11,
|
|
||||||
BALANCE_POS_12,
|
|
||||||
BALANCE_POS_13,
|
|
||||||
BALANCE_POS_14,
|
|
||||||
BALANCE_POS_15,
|
|
||||||
BALANCE_POS_16,
|
|
||||||
BALANCE_POS_17,
|
|
||||||
BALANCE_POS_18,
|
|
||||||
BALANCE_POS_19,
|
|
||||||
BALANCE_POS_20,
|
|
||||||
BALANCE_POS_21,
|
|
||||||
BALANCE_POS_22,
|
|
||||||
BALANCE_POS_23,
|
|
||||||
BALANCE_POS_24,
|
|
||||||
BALANCE_POS_25,
|
|
||||||
BALANCE_POS_26,
|
|
||||||
BALANCE_POS_MAX
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Part {
|
enum Part {
|
||||||
|
NONE,
|
||||||
MAIN_WINDOW,
|
MAIN_WINDOW,
|
||||||
ABOUT_0,
|
ABOUT_0,
|
||||||
ABOUT_1,
|
ABOUT_1,
|
||||||
|
@ -151,6 +86,34 @@ class Skin : public QWidget
|
||||||
POSBAR,
|
POSBAR,
|
||||||
POSBAR_BTN_0,
|
POSBAR_BTN_0,
|
||||||
POSBAR_BTN_1,
|
POSBAR_BTN_1,
|
||||||
|
VOLUMEBAR_POS_0,
|
||||||
|
VOLUMEBAR_POS_1,
|
||||||
|
VOLUMEBAR_POS_2,
|
||||||
|
VOLUMEBAR_POS_3,
|
||||||
|
VOLUMEBAR_POS_4,
|
||||||
|
VOLUMEBAR_POS_5,
|
||||||
|
VOLUMEBAR_POS_6,
|
||||||
|
VOLUMEBAR_POS_7,
|
||||||
|
VOLUMEBAR_POS_8,
|
||||||
|
VOLUMEBAR_POS_9,
|
||||||
|
VOLUMEBAR_POS_10,
|
||||||
|
VOLUMEBAR_POS_11,
|
||||||
|
VOLUMEBAR_POS_12,
|
||||||
|
VOLUMEBAR_POS_13,
|
||||||
|
VOLUMEBAR_POS_14,
|
||||||
|
VOLUMEBAR_POS_15,
|
||||||
|
VOLUMEBAR_POS_16,
|
||||||
|
VOLUMEBAR_POS_17,
|
||||||
|
VOLUMEBAR_POS_18,
|
||||||
|
VOLUMEBAR_POS_19,
|
||||||
|
VOLUMEBAR_POS_20,
|
||||||
|
VOLUMEBAR_POS_21,
|
||||||
|
VOLUMEBAR_POS_22,
|
||||||
|
VOLUMEBAR_POS_23,
|
||||||
|
VOLUMEBAR_POS_24,
|
||||||
|
VOLUMEBAR_POS_25,
|
||||||
|
VOLUMEBAR_POS_26,
|
||||||
|
VOLUMEBAR_POS_27,
|
||||||
VOLBAR_BTN_0,
|
VOLBAR_BTN_0,
|
||||||
VOLBAR_BTN_1,
|
VOLBAR_BTN_1,
|
||||||
CLUTTER_ON,
|
CLUTTER_ON,
|
||||||
|
@ -172,6 +135,66 @@ class Skin : public QWidget
|
||||||
EQ_WIN_PRESET_0,
|
EQ_WIN_PRESET_0,
|
||||||
EQ_WIN_PRESET_1,
|
EQ_WIN_PRESET_1,
|
||||||
EQ_WIN_GRAPH_BG,
|
EQ_WIN_GRAPH_BG,
|
||||||
|
EQ_WIN_BAR_POS_0,
|
||||||
|
EQ_WIN_BAR_POS_1,
|
||||||
|
EQ_WIN_BAR_POS_2,
|
||||||
|
EQ_WIN_BAR_POS_3,
|
||||||
|
EQ_WIN_BAR_POS_4,
|
||||||
|
EQ_WIN_BAR_POS_5,
|
||||||
|
EQ_WIN_BAR_POS_6,
|
||||||
|
EQ_WIN_BAR_POS_7,
|
||||||
|
EQ_WIN_BAR_POS_8,
|
||||||
|
EQ_WIN_BAR_POS_9,
|
||||||
|
EQ_WIN_BAR_POS_10,
|
||||||
|
EQ_WIN_BAR_POS_11,
|
||||||
|
EQ_WIN_BAR_POS_12,
|
||||||
|
EQ_WIN_BAR_POS_13,
|
||||||
|
EQ_WIN_BAR_POS_14,
|
||||||
|
EQ_WIN_BAR_POS_15,
|
||||||
|
EQ_WIN_BAR_POS_16,
|
||||||
|
EQ_WIN_BAR_POS_17,
|
||||||
|
EQ_WIN_BAR_POS_18,
|
||||||
|
EQ_WIN_BAR_POS_19,
|
||||||
|
EQ_WIN_BAR_POS_20,
|
||||||
|
EQ_WIN_BAR_POS_21,
|
||||||
|
EQ_WIN_BAR_POS_22,
|
||||||
|
EQ_WIN_BAR_POS_23,
|
||||||
|
EQ_WIN_BAR_POS_24,
|
||||||
|
EQ_WIN_BAR_POS_25,
|
||||||
|
EQ_WIN_BAR_POS_26,
|
||||||
|
EQ_WIN_BAR_POS_27,
|
||||||
|
EQ_WIN_BAR_BTN_0,
|
||||||
|
EQ_WIN_BAR_BTN_1,
|
||||||
|
BALANCE_POS_0,
|
||||||
|
BALANCE_POS_1,
|
||||||
|
BALANCE_POS_2,
|
||||||
|
BALANCE_POS_3,
|
||||||
|
BALANCE_POS_4,
|
||||||
|
BALANCE_POS_5,
|
||||||
|
BALANCE_POS_6,
|
||||||
|
BALANCE_POS_7,
|
||||||
|
BALANCE_POS_8,
|
||||||
|
BALANCE_POS_9,
|
||||||
|
BALANCE_POS_10,
|
||||||
|
BALANCE_POS_11,
|
||||||
|
BALANCE_POS_12,
|
||||||
|
BALANCE_POS_13,
|
||||||
|
BALANCE_POS_14,
|
||||||
|
BALANCE_POS_15,
|
||||||
|
BALANCE_POS_16,
|
||||||
|
BALANCE_POS_17,
|
||||||
|
BALANCE_POS_18,
|
||||||
|
BALANCE_POS_19,
|
||||||
|
BALANCE_POS_20,
|
||||||
|
BALANCE_POS_21,
|
||||||
|
BALANCE_POS_22,
|
||||||
|
BALANCE_POS_23,
|
||||||
|
BALANCE_POS_24,
|
||||||
|
BALANCE_POS_25,
|
||||||
|
BALANCE_POS_26,
|
||||||
|
BALANCE_POS_27,
|
||||||
|
BALANCE_BTN_0,
|
||||||
|
BALANCE_BTN_1,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PlaylistParts {
|
enum PlaylistParts {
|
||||||
|
|
364
VolumeSlider.cpp
364
VolumeSlider.cpp
|
@ -1,297 +1,227 @@
|
||||||
#include "XMMSHandler.h"
|
#include "XMMSHandler.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include "VolumeSlider.h"
|
#include "VolumeSlider.h"
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
||||||
#include "Skin.h"
|
#include "Skin.h"
|
||||||
|
#include "Button.h"
|
||||||
|
|
||||||
// NOTE!
|
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
|
||||||
// This file has lots of seemingly strange math.
|
|
||||||
// I will document it as we go, but please keep in mind
|
|
||||||
// that all of the coord-space and normalization is pixel-space dependent.
|
|
||||||
|
|
||||||
VolumeSlider::VolumeSlider (QWidget *parent) : PixWidget (parent)
|
Slider::Slider (QWidget *parent, uint name_min, uint name_max,
|
||||||
|
uint name_on, uint name_off, int min, int max) : PixWidget (parent)
|
||||||
{
|
{
|
||||||
XMMSHandler &xmmsh = XMMSHandler::getInstance ();
|
m_name_min = name_min;
|
||||||
|
m_name_max = name_max;
|
||||||
|
m_name_on = name_on;
|
||||||
|
m_name_off = name_off;
|
||||||
|
|
||||||
setMinimumSize (68, 13);
|
m_min = min;
|
||||||
setMaximumSize (68, 13);
|
m_max = max;
|
||||||
m_volume = 0;
|
|
||||||
m_position = 0;
|
|
||||||
m_hasvolbtn = false;
|
|
||||||
m_volbtn = NULL;
|
|
||||||
|
|
||||||
m_pixmap = QPixmap (68, 13);
|
m_button = 0;
|
||||||
|
|
||||||
connect (&xmmsh, SIGNAL(getVolume (uint)),
|
|
||||||
this, SLOT(setVolume (uint)));
|
|
||||||
|
|
||||||
xmmsh.volumeGet ();
|
|
||||||
}
|
|
||||||
|
|
||||||
VolumeSlider::~VolumeSlider ()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
m_value = 0;
|
||||||
|
m_value_index = (uint)((abs(m_min) / (double)(abs(m_min)+abs(m_max))) * (name_max-name_min));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VolumeSlider::setPixmaps (Skin *skin)
|
Slider::setPixmaps (Skin *skin)
|
||||||
{
|
{
|
||||||
m_skin = skin;
|
m_skin = skin;
|
||||||
|
|
||||||
if(m_skin->getVolBtn())
|
m_pixmap_slider = m_skin->getItem(m_name_min+m_value_index);
|
||||||
{
|
m_vertical = (m_pixmap_slider.height() > m_pixmap_slider.width()) ? true : false;
|
||||||
m_hasvolbtn = true;
|
|
||||||
if(m_volbtn)
|
|
||||||
delete m_volbtn;
|
|
||||||
|
|
||||||
m_volbtn = new VolButton (this, Skin::VOLBAR_BTN_0, Skin::VOLBAR_BTN_1);
|
setMinimumSize(m_pixmap_slider.size());
|
||||||
|
setMaximumSize(m_pixmap_slider.size());
|
||||||
|
|
||||||
// If we are out of scope high or low, we clamp the values.
|
resize(m_pixmap_slider.size());
|
||||||
if(m_volume <= 0)
|
|
||||||
m_volbtn->move (0, 1);
|
|
||||||
else if(m_volume >= 27)
|
|
||||||
m_volbtn->move (54, 1);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// If we are not.. we do two things.
|
|
||||||
|
|
||||||
// First, we normalize the difference between the current position
|
if (!skin->getItem(m_name_on).isNull() && !skin->getItem(m_name_off).isNull()) {
|
||||||
// and the maximum position. This will give us the progress ratio.
|
if (m_button) {
|
||||||
float temp = ((float)(m_volume) / (float)(27.0f));
|
delete m_button;
|
||||||
|
|
||||||
// Now, we multiply that by the number of possible positions in our
|
|
||||||
// space. This gives us our relative position according to the progress
|
|
||||||
// ratio.
|
|
||||||
m_volbtn->move ((int)(49 * temp), 1);
|
|
||||||
}
|
}
|
||||||
m_volbtn->setPixmaps (m_skin);
|
|
||||||
m_volbtn->show ();
|
m_button = new SliderButton (this, m_name_on, m_name_off, m_vertical);
|
||||||
}
|
m_button->setPixmaps (m_skin);
|
||||||
else
|
m_button->show ();
|
||||||
{
|
|
||||||
m_hasvolbtn = false;
|
int tmp = (uint)((ceil(abs(m_min) / (double)(abs(m_min)+abs(m_max)))) * (m_name_max-m_name_min));
|
||||||
if(m_volbtn)
|
if (m_vertical) {
|
||||||
{
|
m_button->move(1, height()-m_button->height()-tmp);
|
||||||
delete m_volbtn;
|
} else {
|
||||||
m_volbtn = NULL;
|
m_button->move(tmp, 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (m_button) {
|
||||||
|
delete m_button;
|
||||||
|
m_button = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_volslider = m_skin->getVol (m_volume);
|
update();
|
||||||
|
|
||||||
drawPixmaps ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VolumeSlider::changePixmap ()
|
Slider::changePixmap ()
|
||||||
{
|
{
|
||||||
XMMSHandler::getInstance ().volumeSet (m_volume_base100);
|
m_pixmap_slider = m_skin->getItem (m_name_min+m_value_index);
|
||||||
|
update();
|
||||||
m_volslider = m_skin->getVol (m_volume);
|
|
||||||
drawPixmaps ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VolumeSlider::drawPixmaps ()
|
Slider::paintEvent (QPaintEvent *event)
|
||||||
{
|
{
|
||||||
QPainter paint;
|
QPainter paint;
|
||||||
paint.begin (&m_pixmap);
|
paint.begin (this);
|
||||||
|
paint.drawPixmap (rect(), m_pixmap_slider, m_pixmap_slider.rect ());
|
||||||
paint.drawPixmap (QRect (0, 0, 68, 13),
|
|
||||||
m_volslider,
|
|
||||||
m_pixmap.rect ());
|
|
||||||
paint.end ();
|
paint.end ();
|
||||||
|
|
||||||
update ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VolumeSlider::mousePressEvent (QMouseEvent *event)
|
Slider::mousePressEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
updatePos (event);
|
updatePos (event);
|
||||||
if(m_hasvolbtn)
|
|
||||||
{
|
|
||||||
m_volbtn->mousePressEvent (event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VolumeSlider::mouseMoveEvent (QMouseEvent *event)
|
Slider::mouseMoveEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
updatePos (event);
|
updatePos (event);
|
||||||
if(m_hasvolbtn)
|
|
||||||
{
|
|
||||||
m_volbtn->mouseMoveEvent (event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VolumeSlider::mouseReleaseEvent (QMouseEvent *event)
|
Slider::mouseReleaseEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
updatePos (event);
|
updatePos (event);
|
||||||
if(m_hasvolbtn)
|
|
||||||
{
|
|
||||||
m_volbtn->mouseReleaseEvent (event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VolumeSlider::updatePos (QMouseEvent *event)
|
Slider::updatePos (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
QPoint p (event->pos ());
|
QPoint p (event->pos ());
|
||||||
|
int value;
|
||||||
|
|
||||||
int curx = p.x ();
|
if (m_vertical) {
|
||||||
|
value = CLAMP(p.y(), 0, height());
|
||||||
// Check for scope and clamp.
|
} else {
|
||||||
if(curx <= 0)
|
value = CLAMP(p.x(), 0, width());
|
||||||
{
|
|
||||||
m_volume = 0;
|
|
||||||
m_volume_base100 = 0;
|
|
||||||
}
|
|
||||||
else if(curx >= 68)
|
|
||||||
{
|
|
||||||
m_volume = 27;
|
|
||||||
m_volume_base100 = 100;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Normalize the same way we do above, except this time
|
|
||||||
// we calculate a base-100 value as well.
|
|
||||||
float temp = ((float)(curx - 5) / (float)(width() - 5));
|
|
||||||
m_volume_base100 = (int)(100 * temp);
|
|
||||||
m_volume = (int)(28 * temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
changePixmap ();
|
setPos(value, true);
|
||||||
}
|
if (m_button != 0) {
|
||||||
|
m_button->setPos(value);
|
||||||
void
|
|
||||||
VolumeSlider::setVolume (uint volume_base100)
|
|
||||||
{
|
|
||||||
m_volume_base100 = volume_base100;
|
|
||||||
if(volume_base100 > 100)
|
|
||||||
volume_base100 = 100;
|
|
||||||
|
|
||||||
m_volume = (int)((float)(volume_base100) *.28);
|
|
||||||
if(m_volume > 27)
|
|
||||||
m_volume = 27;
|
|
||||||
|
|
||||||
if(m_hasvolbtn)
|
|
||||||
m_volbtn->setVolume (volume_base100);
|
|
||||||
|
|
||||||
changePixmap ();
|
|
||||||
}
|
|
||||||
|
|
||||||
VolButton::VolButton (QWidget *parent, uint normal, uint pressed) : PixWidget (parent)
|
|
||||||
{
|
|
||||||
m_volslider = dynamic_cast<VolumeSlider *>(parent);
|
|
||||||
setMinimumSize (14, 11);
|
|
||||||
setMaximumSize (14, 11);
|
|
||||||
|
|
||||||
m_normal = normal;
|
|
||||||
m_pressed = pressed;
|
|
||||||
|
|
||||||
m_pixmap = QPixmap (14, 11);
|
|
||||||
}
|
|
||||||
|
|
||||||
VolButton::~VolButton ()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
VolButton::mousePressEvent (QMouseEvent *event)
|
|
||||||
{
|
|
||||||
QPoint p (event->globalPos ());
|
|
||||||
QPoint np = m_volslider->mapFromGlobal (p);
|
|
||||||
|
|
||||||
move (np.x() - 7, 1);
|
|
||||||
|
|
||||||
changePixmap (true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
VolButton::mouseReleaseEvent (QMouseEvent *event)
|
|
||||||
{
|
|
||||||
changePixmap (false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
VolButton::mouseMoveEvent (QMouseEvent *event)
|
|
||||||
{
|
|
||||||
QPoint p = m_volslider->mapFromGlobal (event->globalPos ());
|
|
||||||
int volume = 0;
|
|
||||||
int curx = p.x ();
|
|
||||||
|
|
||||||
// Same deal, clamp then normalize.
|
|
||||||
if(curx < 7)
|
|
||||||
{
|
|
||||||
volume = 0;
|
|
||||||
m_volslider->setVolume (0);
|
|
||||||
}
|
|
||||||
else if(curx > 61)
|
|
||||||
{
|
|
||||||
volume = 54;
|
|
||||||
m_volslider->setVolume (100);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
float temp = ((float)(((float)curx) / (float)(68.0f)));
|
|
||||||
float b100temp = ((float)(((float)curx - 12) / (float)(68.0f - 19)));
|
|
||||||
volume = (int)(68 * temp) - 7;
|
|
||||||
// This is to make sure the volume slider itself reflects our changes.
|
|
||||||
m_volslider->setVolume ((int)(100 * b100temp));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
move (volume, 1);
|
emit valueChanged (m_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VolButton::setVolume (uint volume_base100)
|
Slider::setValue (int value)
|
||||||
{
|
{
|
||||||
int volume = (int)((float)(volume_base100) *.68);
|
double frac;
|
||||||
|
int pos;
|
||||||
|
|
||||||
if(volume < 0)
|
frac = abs(value)/(double)(abs(m_min)+abs(m_max));
|
||||||
volume = 0;
|
if (m_vertical) {
|
||||||
else if(volume > 54)
|
pos = (int)(height() * frac);
|
||||||
volume = 54;
|
} else {
|
||||||
|
pos = (int)(width() * frac);
|
||||||
|
}
|
||||||
|
|
||||||
move (volume,1);
|
setPos(pos, false);
|
||||||
|
if (m_button != 0) {
|
||||||
|
m_button->setPos(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Slider::setPos (int value, bool tell)
|
||||||
|
{
|
||||||
|
double frac;
|
||||||
|
|
||||||
|
if (m_vertical) {
|
||||||
|
frac = (height() - value) / (double) height();
|
||||||
|
} else {
|
||||||
|
frac = value / (double) width();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* calculate m_min <= m_value <= m_max */
|
||||||
|
m_value = (uint)(frac * (abs(m_min) + abs(m_max)) + m_min);
|
||||||
|
|
||||||
|
/* calculate m_name_min <= m_value_index <= m_name_max */
|
||||||
|
m_value_index = (uint) ceil (frac * (m_name_max - m_name_min));
|
||||||
|
|
||||||
|
|
||||||
|
changePixmap();
|
||||||
|
|
||||||
|
if (tell) {
|
||||||
|
emit valueChanged (m_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SliderButton::SliderButton (QWidget *parent, uint normal, uint pressed,
|
||||||
|
bool vertical) : Button (parent, normal, pressed, false)
|
||||||
|
{
|
||||||
|
m_slider = dynamic_cast<Slider *>(parent);
|
||||||
|
m_vertical = vertical;
|
||||||
|
m_diff = 0;
|
||||||
|
m_moving = false;
|
||||||
|
|
||||||
|
if (m_vertical) {
|
||||||
|
move(1, 0);
|
||||||
|
} else {
|
||||||
|
move(0, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
VolButton::setPixmaps (Skin *skin)
|
SliderButton::mousePressEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
m_skin = skin;
|
if (m_vertical) {
|
||||||
|
m_diff = y() - event->pos().y();
|
||||||
m_volbtn = m_skin->getItem (m_normal);
|
} else {
|
||||||
|
m_diff = x() - event->pos().x();
|
||||||
drawPixmaps ();
|
}
|
||||||
|
m_moving = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
VolButton::changePixmap (bool pressed)
|
SliderButton::mouseReleaseEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if(pressed)
|
m_moving = false;
|
||||||
m_volbtn = m_skin->getItem (m_pressed);
|
|
||||||
else
|
|
||||||
m_volbtn = m_skin->getItem (m_normal);
|
|
||||||
|
|
||||||
drawPixmaps ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
VolButton::drawPixmaps ()
|
SliderButton::setPos (uint pos)
|
||||||
{
|
{
|
||||||
QPainter paint;
|
if (m_vertical) {
|
||||||
paint.begin (&m_pixmap);
|
int ypos = MIN(pos, (uint)m_slider->height()-height());
|
||||||
|
move(1, ypos);
|
||||||
paint.drawPixmap (QRect (0, 0, 14, 11),
|
} else {
|
||||||
m_volbtn,
|
int xpos = MIN(pos, (uint)m_slider->width()-width());
|
||||||
m_pixmap.rect ());
|
move(xpos, 1);
|
||||||
paint.end ();
|
}
|
||||||
|
}
|
||||||
update ();
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SliderButton::mouseMoveEvent (QMouseEvent *event)
|
||||||
|
{
|
||||||
|
QPoint p = m_slider->mapFromGlobal (event->globalPos ());
|
||||||
|
int value;
|
||||||
|
if (m_vertical) {
|
||||||
|
value = CLAMP(p.y(), 0, m_slider->height());
|
||||||
|
} else {
|
||||||
|
value = CLAMP(p.x(), 0, m_slider->width());
|
||||||
|
}
|
||||||
|
|
||||||
|
m_slider->setPos(value, true);
|
||||||
|
setPos (value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,67 +1,77 @@
|
||||||
#ifndef __VOLUMESLIDER_H__
|
#ifndef __VOLUMESLIDER_H__
|
||||||
#define __VOLUMESLIDER_H__
|
#define __VOLUMESLIDER_H__
|
||||||
|
|
||||||
#include "PixWidget.h"
|
class Slider;
|
||||||
|
|
||||||
class VolumeSlider;
|
|
||||||
class MainDisplay;
|
class MainDisplay;
|
||||||
class Button;
|
class Button;
|
||||||
|
|
||||||
class VolButton : public PixWidget
|
#include "Button.h"
|
||||||
|
|
||||||
|
class SliderButton : public Button
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VolButton (QWidget *, uint, uint);
|
SliderButton (QWidget *parent, uint normal, uint pressed, bool dir);
|
||||||
~VolButton ();
|
|
||||||
|
|
||||||
void mouseMoveEvent (QMouseEvent *);
|
void mouseMoveEvent (QMouseEvent *);
|
||||||
void mousePressEvent (QMouseEvent *);
|
void mousePressEvent (QMouseEvent *);
|
||||||
void mouseReleaseEvent (QMouseEvent *);
|
void mouseReleaseEvent (QMouseEvent *);
|
||||||
|
void setPos (uint);
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setPixmaps (Skin *skin);
|
//void setValue (uint volume_base100);
|
||||||
void setVolume (uint volume_base100);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void changePixmap (bool pressed);
|
void changePixmap (bool pressed);
|
||||||
void drawPixmaps();
|
Slider *m_slider;
|
||||||
|
bool m_vertical;
|
||||||
VolumeSlider *m_volslider;
|
int m_diff;
|
||||||
Skin *m_skin;
|
bool m_moving;
|
||||||
QPixmap m_volbtn;
|
|
||||||
uint m_normal;
|
|
||||||
uint m_pressed;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class VolumeSlider : public PixWidget
|
class Slider : public PixWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VolumeSlider (QWidget *parent);
|
Slider (QWidget *parent, uint min, uint max, uint on, uint off, int, int);
|
||||||
~VolumeSlider ();
|
|
||||||
|
void paintEvent (QPaintEvent *event);
|
||||||
|
|
||||||
void mouseMoveEvent (QMouseEvent *);
|
void mouseMoveEvent (QMouseEvent *);
|
||||||
void mousePressEvent (QMouseEvent *);
|
void mousePressEvent (QMouseEvent *);
|
||||||
void mouseReleaseEvent (QMouseEvent *);
|
void mouseReleaseEvent (QMouseEvent *);
|
||||||
|
|
||||||
uint getVolume (void) { return m_volume_base100; };
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setPixmaps (Skin *skin);
|
void setPixmaps (Skin *skin);
|
||||||
void setVolume (uint volume_base100);
|
void setPos (int value, bool tell);
|
||||||
|
void setValue (int value);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void valueChanged (int val);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void drawPixmaps ();
|
|
||||||
void updatePos (QMouseEvent *event);
|
void updatePos (QMouseEvent *event);
|
||||||
void changePixmap ();
|
void changePixmap ();
|
||||||
|
|
||||||
QPixmap m_volslider;
|
QPixmap m_pixmap_slider;
|
||||||
VolButton *m_volbtn;
|
SliderButton *m_button;
|
||||||
Skin *m_skin;
|
|
||||||
int m_volume;
|
|
||||||
int m_position;
|
|
||||||
uint m_volume_base100;
|
|
||||||
bool m_hasvolbtn;
|
|
||||||
|
|
||||||
|
Skin *m_skin;
|
||||||
|
|
||||||
|
uint m_value_index;
|
||||||
|
int m_value;
|
||||||
|
|
||||||
|
int m_position;
|
||||||
|
|
||||||
|
uint m_name_min;
|
||||||
|
uint m_name_max;
|
||||||
|
uint m_name_on;
|
||||||
|
uint m_name_off;
|
||||||
|
|
||||||
|
int m_min;
|
||||||
|
int m_max;
|
||||||
|
|
||||||
|
bool m_vertical;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,7 +42,6 @@ class XMMSHandler : public QObject {
|
||||||
void medialibQueryAdd (QString q) { delete m_xmmsc->medialib_add_to_playlist (q.toUtf8 ()); }
|
void medialibQueryAdd (QString q) { delete m_xmmsc->medialib_add_to_playlist (q.toUtf8 ()); }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void volumeSet (uint volume);
|
|
||||||
void volumeGet ();
|
void volumeGet ();
|
||||||
|
|
||||||
//const XMMSClient *getXMMS () { return m_xmmsc; }
|
//const XMMSClient *getXMMS () { return m_xmmsc; }
|
||||||
|
@ -59,6 +58,7 @@ class XMMSHandler : public QObject {
|
||||||
void pause ();
|
void pause ();
|
||||||
void next ();
|
void next ();
|
||||||
void prev ();
|
void prev ();
|
||||||
|
void volumeSet (uint volume);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void settingsSaved ();
|
void settingsSaved ();
|
||||||
|
|
|
@ -12,7 +12,7 @@ SOURCES += XmmsQT4.cpp \
|
||||||
XMMSHandler.cpp \
|
XMMSHandler.cpp \
|
||||||
SmallNumberDisplay.cpp \
|
SmallNumberDisplay.cpp \
|
||||||
StereoMono.cpp \
|
StereoMono.cpp \
|
||||||
Slider.cpp \
|
PosBar.cpp \
|
||||||
PlayStatus.cpp \
|
PlayStatus.cpp \
|
||||||
ShadedDisplay.cpp \
|
ShadedDisplay.cpp \
|
||||||
Playlist.cpp \
|
Playlist.cpp \
|
||||||
|
@ -42,7 +42,7 @@ HEADERS += XmmsQT4.h \
|
||||||
XMMSHandler.h \
|
XMMSHandler.h \
|
||||||
SmallNumberDisplay.h \
|
SmallNumberDisplay.h \
|
||||||
StereoMono.h \
|
StereoMono.h \
|
||||||
Slider.h \
|
PosBar.h \
|
||||||
PlayStatus.h \
|
PlayStatus.h \
|
||||||
ShadedDisplay.h \
|
ShadedDisplay.h \
|
||||||
Playlist.h \
|
Playlist.h \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue