Change Sliders to new Slider-class

Use the new PixmapSlider class which is based on Qt's AbstractSlider
class for sliders. This should also fix some offset problems in
PositionSlider which appeared after the introduction of the new Button
class
This commit is contained in:
Thomas Frauendorfer 2008-05-08 04:19:34 +02:00
parent d3e140ad0e
commit 60c17af114
12 changed files with 142 additions and 161 deletions

View file

@ -34,12 +34,12 @@ QT += network
;macx:QTPLUGIN += qjpeg ;macx:QTPLUGIN += qjpeg
QMAKE_LFLAGS += -L$$[QT_INSTALL_PLUGINS]/imageformats QMAKE_LFLAGS += -L$$[QT_INSTALL_PLUGINS]/imageformats
CONFIG += link_pkgconfig
QMAKE_CXXFLAGS += -g QMAKE_CXXFLAGS += -g
;CONFIG += debug warn_on ;CONFIG += debug warn_on
QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-parameter QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-parameter
PKGCONFIG += xmms2-client xmms2-client-cpp
CONFIG += link_pkgconfig
PKGCONFIG += xmms2-client-cpp xmms2-client
;CONFIG += avahi ;CONFIG += avahi

View file

@ -56,9 +56,21 @@ Skin::setSizes ()
<< QSize (46, 15) // BUTTON_MW_SHUFFLE << QSize (46, 15) // BUTTON_MW_SHUFFLE
<< QSize (28, 15) // BUTTON_MW_REPEAT << QSize (28, 15) // BUTTON_MW_REPEAT
<< QSize ( 9, 9) // BUTTON_MW_SHADED_SHADE << QSize ( 9, 9) // BUTTON_MW_SHADED_SHADE
<< QSize () // BUTTON_EQ_CLOSE
<< QSize () // BUTTON_EQ_SHADE
<< QSize (25, 12) // BUTTON_EQ_ACTIVE << QSize (25, 12) // BUTTON_EQ_ACTIVE
<< QSize (33, 12) // BUTTON_EQ_AUTO << QSize (33, 12) // BUTTON_EQ_AUTO
<< QSize (44, 12) // BUTTON_EQ_PRESET << QSize (44, 12) // BUTTON_EQ_PRESET
<< QSize ( 9, 9) // BUTTON_PLS_CLOSE
<< QSize ( 9, 9) // BUTTON_PLS_SHADE
<< QSize () // SLIDER_POSBAR
<< QSize (248, 10) // SLIDER_POSBAR_BGS
<< QSize (14, 11) // SLIDER_VOLUMEBAR
<< QSize (68, 13) // SLIDER_VOLUMEBAR_BGS
<< QSize () // SLIDER_BALANCEBAR
<< QSize (38, 13) // SLIDER_BALANCEBAR_BGS
<< QSize () // SLIDER_EQUALIZER
<< QSize (14, 63) // SLIDER_EQUALIZER_BGS
; ;
} }
@ -71,7 +83,7 @@ Skin::setPositions ()
<< QPoint (264, 3) // BUTTON_MW_CLOSE << QPoint (264, 3) // BUTTON_MW_CLOSE
<< QPoint (254, 3) // BUTTON_MW_SHADE << QPoint (254, 3) // BUTTON_MW_SHADE
<< QPoint ( 16, 88) // BUTTON_MW_PREV << QPoint ( 16, 88) // BUTTON_MW_PREV
<< QPoint ( 39, 88) // BUTTON_MW_PLAY << QPoint ( 39, 88) // BUTTON_MW_PLAY
<< QPoint ( 62, 88) // BUTTON_MW_PAUSE << QPoint ( 62, 88) // BUTTON_MW_PAUSE
<< QPoint ( 85, 88) // BUTTON_MW_STOP << QPoint ( 85, 88) // BUTTON_MW_STOP
<< QPoint (108, 88) // BUTTON_MW_NEXT << QPoint (108, 88) // BUTTON_MW_NEXT
@ -81,9 +93,21 @@ Skin::setPositions ()
<< QPoint (164, 89) // BUTTON_MW_SHUFFLE << QPoint (164, 89) // BUTTON_MW_SHUFFLE
<< QPoint (210, 89) // BUTTON_MW_REPEAT << QPoint (210, 89) // BUTTON_MW_REPEAT
<< QPoint (254, 3) // BUTTON_MW_SHADED_SHADE << QPoint (254, 3) // BUTTON_MW_SHADED_SHADE
<< QPoint () // BUTTON_EQ_CLOSE
<< QPoint () // BUTTON_EQ_SHADE
<< QPoint ( 14, 18) // BUTTON_EQ_ACTIVE << QPoint ( 14, 18) // BUTTON_EQ_ACTIVE
<< QPoint ( 39, 18) // BUTTON_EQ_AUTO << QPoint ( 39, 18) // BUTTON_EQ_AUTO
<< QPoint (217, 18) // BUTTON_EQ_PRESET << QPoint (217, 18) // BUTTON_EQ_PRESET
<< QPoint () // BUTTON_PLS_CLOSE
<< QPoint () // BUTTON_PLS_SHADE
<< QPoint () // SLIDER_POSBAR
<< QPoint ( 16, 72) // SLIDER_POSBAR_BGS
<< QPoint () // SLIDER_VOLUMEBAR
<< QPoint (107, 57) // SLIDER_VOLUMEBAR_BGS
<< QPoint () // SLIDER_BALANCEBAR
<< QPoint (177, 57) // SLIDER_BALANCEBAR_BGS
<< QPoint () // SLIDER_EQUALIZER
<< QPoint () // SLIDER_EQUALITER_BGS
; ;
} }
@ -115,12 +139,14 @@ Skin::BuildEqualizer (void)
icon.addPixmap (img->copy (224, 176, 44, 12), QIcon::Active, QIcon::Off); icon.addPixmap (img->copy (224, 176, 44, 12), QIcon::Active, QIcon::Off);
m_icons[BUTTON_EQ_PRESET] = icon; m_icons[BUTTON_EQ_PRESET] = icon;
QPixmapList list;
for (int i = 0; i < 14; i++) { for (int i = 0; i < 14; i++) {
m_items[EQ_WIN_BAR_POS_0+i] = img->copy (13+15*i, 164, 14, 63); list << img->copy (13+15*i, 164, 14, 63);
} }
for (int i = 0; i < 14; i++) { for (int i = 0; i < 14; i++) {
m_items[EQ_WIN_BAR_POS_14+i] = img->copy (13+15*i, 229, 14, 63); list << img->copy (13+15*i, 229, 14, 63);
} }
m_backgrounds[SLIDER_EQUALIZER_BGS] = list;
m_items[EQ_WIN_BAR_BTN_0] = img->copy (0, 164, 11, 11); m_items[EQ_WIN_BAR_BTN_0] = img->copy (0, 164, 11, 11);
m_items[EQ_WIN_BAR_BTN_1] = img->copy (0, 176, 11, 11); m_items[EQ_WIN_BAR_BTN_1] = img->copy (0, 176, 11, 11);
@ -163,7 +189,7 @@ Skin::BuildPlaylist (void)
m_playlist[PLS_RFILL3_0] = img->copy(44, 42, 7, 29); m_playlist[PLS_RFILL3_0] = img->copy(44, 42, 7, 29);
tmp = m_playlist[PLS_CORNER_UR_0]; tmp = m_playlist[PLS_CORNER_UR_0];
m_playlist[PLS_CLOSE_BTN_0] = tmp.copy(14, 3, 9, 9); m_playlist[PLS_CLOSE_BTN_0] = tmp.copy(14, 3, 9, 9);
m_playlist[PLS_CLOSE_BTN_1] = img->copy(52, 42, 9, 9); m_playlist[PLS_CLOSE_BTN_1] = img->copy(52, 42, 9, 9);
@ -601,6 +627,7 @@ Skin::BuildSliders (void)
img = getPixmap("posbar"); img = getPixmap("posbar");
if (img) { if (img) {
m_sizes[SLIDER_POSBAR_BGS] = QSize (248, qMin (10, img->height ()));
m_items[POSBAR] = img->copy (0, 0, 248, qMin (10, img->height ())); m_items[POSBAR] = img->copy (0, 0, 248, qMin (10, img->height ()));
m_items[POSBAR_BTN_0] = img->copy (248, 0, 29, qMin (10, img->height ())); m_items[POSBAR_BTN_0] = img->copy (248, 0, 29, qMin (10, img->height ()));
m_items[POSBAR_BTN_1] = img->copy (278, 0, 29, qMin (10, img->height ())); m_items[POSBAR_BTN_1] = img->copy (278, 0, 29, qMin (10, img->height ()));
@ -612,9 +639,11 @@ Skin::BuildSliders (void)
img = getPixmap("volume"); img = getPixmap("volume");
if (img) { if (img) {
QPixmapList list;
for (int i = 0; i <= 27; i++) { for (int i = 0; i <= 27; i++) {
m_items[VOLUMEBAR_POS_0+i] = img->copy(0, i*15, 68, 13); list << img->copy(0, i*15, 68, 13);
} }
m_backgrounds[SLIDER_VOLUMEBAR_BGS] = list;
if (img->height() > 421) { if (img->height() > 421) {
m_items[VOLBAR_BTN_1] = img->copy (0, 422, 14, qMin (11, img->height () - 422)); m_items[VOLBAR_BTN_1] = img->copy (0, 422, 14, qMin (11, img->height () - 422));
@ -632,13 +661,21 @@ Skin::BuildSliders (void)
} }
if (img) { if (img) {
for (int i = 0; i < 28; i++) { QPixmapList list;
m_items[BALANCE_POS_0+i] = img->copy(9, i*15, 38, 13); QPixmap p;
list << img->copy (9, 15, 38, 13);
for (int i = 1; i < 28; i++) {
// use p to make use of Qt implicit sharing (I think it will not
// work if appended and prepended Images are copied seperately)
p = img->copy(9, i*15, 38, 13);
list.append (p);
list.prepend (p);
} }
m_backgrounds[SLIDER_BALANCEBAR_BGS] = list;
if (img->height() > 421) { if (img->height() > 421) {
m_items[BALANCE_BTN_0] = img->copy(0, 422, 14, qMin (11, img->height () - 422));//11); m_items[BALANCE_BTN_1] = img->copy(0, 422, 14, qMin (11, img->height () - 422));
m_items[BALANCE_BTN_1] = img->copy(15, 422, 14, qMin (11, img->height () - 422)); //11); m_items[BALANCE_BTN_0] = img->copy(15, 422, 14, qMin (11, img->height () - 422));
} }
delete img; delete img;

View file

@ -37,10 +37,12 @@ class Skin : public QObject
void setSkin (const QString& name); void setSkin (const QString& name);
static QPixmap getPixmap (const QString&, QDir); static QPixmap getPixmap (const QString&, QDir);
const QSize getSize (uint item) const { return m_sizes[item]; }; const QSize getSize (uint item) const { return m_sizes[item]; };
const QPoint getPos (uint item) const { return m_positions[item]; }; const QPoint getPos (uint item) const { return m_positions[item]; };
const QIcon getIcon (uint item) const { return m_icons.value(item); }; const QIcon getIcon (uint item) const { return m_icons.value(item); };
const QPixmapList getBackgrounds (uint item) const
{ return m_backgrounds.value(item); };
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]; }
@ -49,7 +51,7 @@ class Skin : public QObject
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]; }
enum Buttons { enum Part {
/* Mainwindow buttons */ /* Mainwindow buttons */
BUTTON_MW_MENU, BUTTON_MW_MENU,
BUTTON_MW_MINIMIZE, BUTTON_MW_MINIMIZE,
@ -65,16 +67,29 @@ class Skin : public QObject
BUTTON_MW_PLS, BUTTON_MW_PLS,
BUTTON_MW_SHUFFLE, BUTTON_MW_SHUFFLE,
BUTTON_MW_REPEAT, BUTTON_MW_REPEAT,
/* Mainwindow buttons shaded*/ /* Mainwindow buttons shaded */
BUTTON_MW_SHADED_SHADE, BUTTON_MW_SHADED_SHADE,
/* Equalizer buttons */ /* Equalizer buttons */
BUTTON_EQ_CLOSE,
BUTTON_EQ_SHADE,
BUTTON_EQ_ACTIVE, BUTTON_EQ_ACTIVE,
BUTTON_EQ_AUTO, BUTTON_EQ_AUTO,
BUTTON_EQ_PRESET BUTTON_EQ_PRESET,
/* Playlist buttons */ /* Playlist buttons */
}; BUTTON_PLS_CLOSE,
BUTTON_PLS_SHADE,
enum Part { /* Sliders */
SLIDER_POSBAR,
SLIDER_POSBAR_BGS,
SLIDER_VOLUMEBAR,
SLIDER_VOLUMEBAR_BGS,
SLIDER_BALANCEBAR,
SLIDER_BALANCEBAR_BGS,
SLIDER_EQUALIZER,
SLIDER_EQUALIZER_BGS,
// };
//
// enum Part { // Old and not yet sorted enum
NONE, NONE,
MAIN_WINDOW, MAIN_WINDOW,
ABOUT_0, ABOUT_0,
@ -94,39 +109,6 @@ class Skin : public QObject
PIC_PLAY, PIC_PLAY,
PIC_PAUSE, PIC_PAUSE,
PIC_STOP, PIC_STOP,
POSBAR,
POSBAR_BTN_0,
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_1,
CLUTTER_ON, CLUTTER_ON,
CLUTTER_OFF, CLUTTER_OFF,
CLUTTER_O, CLUTTER_O,
@ -136,64 +118,13 @@ class Skin : public QObject
CLUTTER_V, CLUTTER_V,
EQ_WIN_BG, EQ_WIN_BG,
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_0,
EQ_WIN_BAR_BTN_1, EQ_WIN_BAR_BTN_1,
BALANCE_POS_0, POSBAR,
BALANCE_POS_1, POSBAR_BTN_0,
BALANCE_POS_2, POSBAR_BTN_1,
BALANCE_POS_3, VOLBAR_BTN_0,
BALANCE_POS_4, VOLBAR_BTN_1,
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_0,
BALANCE_BTN_1, BALANCE_BTN_1,
}; };
@ -317,21 +248,14 @@ class Skin : public QObject
QList<QSize> m_sizes; QList<QSize> m_sizes;
QMap<uint, QIcon> m_icons; QMap<uint, QIcon> m_icons;
QMap<uint, QPixmapList> m_backgrounds;
QMap<uint, QPixmap> m_items; QMap<uint, QPixmap> m_items;
QMap<uint, QPixmap> m_letterMap; QMap<uint, QPixmap> m_letterMap;
QMap<uint, QPixmap> m_volume_bar;
QMap<uint, QPixmap> m_balance;
QMap<uint, QPixmap> m_numbers; QMap<uint, QPixmap> m_numbers;
QMap<uint, QPixmap> m_playlist; QMap<uint, QPixmap> m_playlist;
QMap<uint, QPixmap> m_equalizer;
QMap<QByteArray, QByteArray> m_pledit_txt; QMap<QByteArray, QByteArray> m_pledit_txt;
QList<QPixmap *> m_buttons;
bool m_volbtn;
bool m_balbtn;
signals: signals:
void skinChanged (Skin *skin); void skinChanged (Skin *skin);

View file

@ -25,7 +25,7 @@ Slider::Slider (QWidget *parent, uint name_min, uint name_max,
connect (skin, SIGNAL (skinChanged (Skin *)), connect (skin, SIGNAL (skinChanged (Skin *)),
this, SLOT (setPixmaps(Skin *))); this, SLOT (setPixmaps(Skin *)));
setSliderOffset (1); setSliderOffset (QPoint (0, 1));
m_name_min = name_min; m_name_min = name_min;
m_name_max = name_max; m_name_max = name_max;

View file

@ -20,20 +20,20 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "pixmapbutton.h" #include "pixmapbutton.h"
#include "pixmapslider.h"
#include "Skin.h" #include "Skin.h"
#include "VolumeSlider.h"
#include <QPainter> #include <QPainter>
EqualizerSlider::EqualizerSlider (QWidget *parent, uint pix_min, uint pix_max, EqualizerSlider::EqualizerSlider (QWidget *parent, int id) :
uint pix_on, uint pix_off, int min, int max, PixmapSlider (parent)
int id) :
Slider (parent, pix_min, pix_max, pix_on,
pix_off, min, max)
{ {
m_id = id; m_id = id;
connect ( this, SIGNAL (sliderMoved (int)), connect ( this, SIGNAL (sliderMoved (int)),
this, SLOT (on_self_slider_moved (int)) ); this, SLOT (on_self_slider_moved (int)) );
setMinimum (-20);
setMaximum (20);
setSliderOffset (QPoint (1, 0));
setInvertedAppearance (true); setInvertedAppearance (true);
setOrientation (Qt::Vertical); setOrientation (Qt::Vertical);
} }
@ -83,20 +83,15 @@ 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 EqualizerSlider(this, -1);
Skin::EQ_WIN_BAR_BTN_0, Skin::EQ_WIN_BAR_BTN_1, m_preamp->resize (skin->getSize (Skin::SLIDER_EQUALIZER_BGS));
-20, 20);
m_preamp->move(21, 38); m_preamp->move(21, 38);
m_preamp->setOrientation (Qt::Vertical);
m_preamp->setInvertedAppearance (true);
connect (m_preamp, SIGNAL (sliderMoved (int)), connect (m_preamp, SIGNAL (sliderMoved (int)),
this, SLOT (updateServerPreamp (int))); this, SLOT (updateServerPreamp (int)));
for (int i=0; i < 10; i++) { for (int i=0; i < 10; i++) {
m_bands[i] = new EqualizerSlider(this, Skin::EQ_WIN_BAR_POS_0, m_bands[i] = new EqualizerSlider(this, i);
Skin::EQ_WIN_BAR_POS_27, m_bands[i]->resize (skin->getSize (Skin::SLIDER_EQUALIZER_BGS));
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 (numberedSliderMoved (int, int)), connect (m_bands[i], SIGNAL (numberedSliderMoved (int, int)),
this, SLOT (updateServerBands (int, int))); this, SLOT (updateServerBands (int, int)));
@ -141,10 +136,24 @@ EqualizerWidget::setPixmaps (Skin *skin)
setMinimumSize (m_pixmap.size ()); setMinimumSize (m_pixmap.size ());
setMaximumSize (m_pixmap.size ()); setMaximumSize (m_pixmap.size ());
/* Updade Buttons */
m_enable->setIcon (skin->getIcon (Skin::BUTTON_EQ_ACTIVE)); m_enable->setIcon (skin->getIcon (Skin::BUTTON_EQ_ACTIVE));
m_auto->setIcon (skin->getIcon (Skin::BUTTON_EQ_AUTO)); m_auto->setIcon (skin->getIcon (Skin::BUTTON_EQ_AUTO));
m_preset->setIcon (skin->getIcon (Skin::BUTTON_EQ_PRESET)); m_preset->setIcon (skin->getIcon (Skin::BUTTON_EQ_PRESET));
/* Update Sliders */
QPixmap normal = skin->getItem (Skin::EQ_WIN_BAR_BTN_0);
QPixmap pressed = skin->getItem (Skin::EQ_WIN_BAR_BTN_1);
QPixmapList bgslist = skin->getBackgrounds (Skin::SLIDER_EQUALIZER_BGS);
m_preamp->setSliders (normal, pressed);
m_preamp->setBackground (bgslist);
for (int i = 0; i < 10; i++) {
m_bands[i]->setSliders (normal, pressed);
m_bands[i]->setBackground (bgslist);
}
update(); update();
} }

View file

@ -22,19 +22,19 @@ class QVariant;
class QPixmap; class QPixmap;
class QPaintEvent; class QPaintEvent;
#include "VolumeSlider.h" #include "pixmapslider.h"
class XConfig; class XConfig;
class Skin; class Skin;
class PixmapButton; class PixmapButton;
//#include <iostream> //#include <iostream>
class EqualizerSlider : public Slider class EqualizerSlider : public PixmapSlider
{ {
Q_OBJECT Q_OBJECT
public: public:
EqualizerSlider (QWidget*, uint, uint, uint, uint, int, int, int); EqualizerSlider (QWidget*, int);
signals: signals:
void numberedSliderMoved (int value, int id); void numberedSliderMoved (int value, int id);
@ -71,7 +71,7 @@ class EqualizerWidget : public QWidget
PixmapButton *m_enable; PixmapButton *m_enable;
PixmapButton *m_auto; PixmapButton *m_auto;
PixmapButton *m_preset; PixmapButton *m_preset;
Slider *m_preamp; PixmapSlider *m_preamp;
EqualizerSlider *m_bands[10]; EqualizerSlider *m_bands[10];
}; };

View file

@ -23,6 +23,7 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "pixmapbutton.h" #include "pixmapbutton.h"
#include "pixmapslider.h"
#include "TitleBar.h" #include "TitleBar.h"
#include "TextBar.h" #include "TextBar.h"
#include "NumberDisplay.h" #include "NumberDisplay.h"
@ -31,7 +32,6 @@
#include "stereomono.h" #include "stereomono.h"
#include "posbar.h" #include "posbar.h"
#include "playstatus.h" #include "playstatus.h"
#include "VolumeSlider.h"
#include "playlistwindow.h" #include "playlistwindow.h"
#include "equalizerwindow.h" #include "equalizerwindow.h"
#include "clutterbar.h" #include "clutterbar.h"
@ -44,6 +44,7 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent)
{ {
XMMSHandler &client = XMMSHandler::getInstance (); XMMSHandler &client = XMMSHandler::getInstance ();
m_xconfig = client.xconfig (); m_xconfig = client.xconfig ();
Skin* skin = Skin::getInstance ();
m_tbar = new TitleBar(this, false); m_tbar = new TitleBar(this, false);
m_tbar->move(0, 0); m_tbar->move(0, 0);
@ -78,25 +79,29 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent)
m_posbar = new PosBar (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_posbar->move (16, 72); m_posbar->move (skin->getPos (Skin::SLIDER_POSBAR_BGS));
m_playstatus = new PlayStatus (this); m_playstatus = new PlayStatus (this);
m_playstatus->move (24, 28); m_playstatus->move (24, 28);
m_vslider = new Slider(this, Skin::VOLUMEBAR_POS_0, Skin::VOLUMEBAR_POS_27, m_vslider = new PixmapSlider(this);
Skin::VOLBAR_BTN_0, Skin::VOLBAR_BTN_1, 0, 100); m_vslider->setMinimum (0);
m_vslider->move (107, 57); m_vslider->setMaximum (100);
m_vslider->setSliderOffset (QPoint (0, 1));
m_vslider->resize (skin->getSize (Skin::SLIDER_VOLUMEBAR_BGS));
m_vslider->move (skin->getPos (Skin::SLIDER_VOLUMEBAR_BGS));
m_bslider = new Slider(this, Skin::BALANCE_POS_0, Skin::BALANCE_POS_27, m_bslider = new PixmapSlider (this);
Skin::BALANCE_BTN_0, Skin::BALANCE_BTN_1, -20, 20); m_bslider->setMinimum (-20);
m_bslider->move (177, 57); m_bslider->setMaximum (20);
m_bslider->setSliderOffset (QPoint (0, 1));
m_bslider->resize (skin->getSize (Skin::SLIDER_BALANCEBAR_BGS));
m_bslider->move (skin->getPos (Skin::SLIDER_BALANCEBAR_BGS));
connect (&client, SIGNAL(currentSong (const Xmms::PropDict &)), connect (&client, SIGNAL(currentSong (const Xmms::PropDict &)),
this, SLOT(setMediainfo (const Xmms::PropDict &))); this, SLOT(setMediainfo (const Xmms::PropDict &)));
connect (&client, SIGNAL(playbackStatusChanged(Xmms::Playback::Status)), connect (&client, SIGNAL(playbackStatusChanged(Xmms::Playback::Status)),
this, SLOT(setStatus(Xmms::Playback::Status))); this, SLOT(setStatus(Xmms::Playback::Status)));
// connect (&xmmsh, SIGNAL(playtimeChanged(uint)),
// this, SLOT(setPlaytime(uint)));
connect (client.cache () , SIGNAL (playtime (uint32_t)), connect (client.cache () , SIGNAL (playtime (uint32_t)),
this, SLOT (setPlaytime (uint32_t))); this, SLOT (setPlaytime (uint32_t)));
connect (&client, SIGNAL(getVolume(uint)), this, SLOT(updateVolume(uint))); connect (&client, SIGNAL(getVolume(uint)), this, SLOT(updateVolume(uint)));
@ -142,6 +147,14 @@ MainDisplay::setPixmaps (Skin *skin)
m_pls->setIcon (skin->getIcon (Skin::BUTTON_MW_PLS)); m_pls->setIcon (skin->getIcon (Skin::BUTTON_MW_PLS));
m_shuffle->setIcon (skin->getIcon (Skin::BUTTON_MW_SHUFFLE)); m_shuffle->setIcon (skin->getIcon (Skin::BUTTON_MW_SHUFFLE));
m_repeat->setIcon (skin->getIcon (Skin::BUTTON_MW_REPEAT)); m_repeat->setIcon (skin->getIcon (Skin::BUTTON_MW_REPEAT));
/* update Sliders */
m_vslider->setBackground (skin->getBackgrounds (Skin::SLIDER_VOLUMEBAR_BGS));
m_vslider->setSliders (skin->getItem (Skin::VOLBAR_BTN_0),
skin->getItem (Skin::VOLBAR_BTN_1));
m_bslider->setBackground (skin->getBackgrounds (Skin::SLIDER_BALANCEBAR_BGS));
m_bslider->setSliders (skin->getItem (Skin::BALANCE_BTN_0),
skin->getItem (Skin::BALANCE_BTN_1));
} }
void void

View file

@ -33,6 +33,7 @@ class MainDisplay;
#include "Display.h" #include "Display.h"
class PixmapButton; class PixmapButton;
class PixmapSlider;
class TextScroller; class TextScroller;
class TimeDisplay; class TimeDisplay;
class SmallNumberDisplay; class SmallNumberDisplay;
@ -59,8 +60,8 @@ class MainDisplay : public SkinDisplay
StereoMono *m_stereo; StereoMono *m_stereo;
PosBar *m_posbar; PosBar *m_posbar;
Slider *m_vslider; PixmapSlider *m_vslider;
Slider *m_bslider; PixmapSlider *m_bslider;
PlayStatus *m_playstatus; PlayStatus *m_playstatus;
MainWindow *getMW(void) { return m_mw; } MainWindow *getMW(void) { return m_mw; }

View file

@ -17,7 +17,6 @@ HEADERS += PixWidget.h \
SkinChooser.h \ SkinChooser.h \
settingsdialog.h \ settingsdialog.h \
basewindow.h \ basewindow.h \
VolumeSlider.h \
FileDialog.h \ FileDialog.h \
BrowseModel.h \ BrowseModel.h \
BrowseDialog.h BrowseDialog.h
@ -36,7 +35,6 @@ SOURCES += main.cpp \
SkinChooser.cpp \ SkinChooser.cpp \
settingsdialog.cpp \ settingsdialog.cpp \
basewindow.cpp \ basewindow.cpp \
VolumeSlider.cpp \
FileDialog.cpp \ FileDialog.cpp \
BrowseModel.cpp \ BrowseModel.cpp \
BrowseDialog.cpp BrowseDialog.cpp

View file

@ -23,12 +23,12 @@ QT += network
;macx:QTPLUGIN += qjpeg ;macx:QTPLUGIN += qjpeg
QMAKE_LFLAGS += -L$$[QT_INSTALL_PLUGINS]/imageformats QMAKE_LFLAGS += -L$$[QT_INSTALL_PLUGINS]/imageformats
CONFIG += link_pkgconfig
QMAKE_CXXFLAGS += -g QMAKE_CXXFLAGS += -g
;CONFIG += debug warn_on ;CONFIG += debug warn_on
QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-parameter QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-parameter
PKGCONFIG += xmms2-client xmms2-client-cpp
CONFIG += link_pkgconfig
PKGCONFIG += xmms2-client-cpp xmms2-client
;CONFIG += avahi ;CONFIG += avahi

View file

@ -25,7 +25,7 @@
PixmapSlider::PixmapSlider (QWidget *parent) : QAbstractSlider (parent) PixmapSlider::PixmapSlider (QWidget *parent) : QAbstractSlider (parent)
{ {
setSliderDown (false); setSliderDown (false);
m_slider_offset = 0; m_slider_offset = QPoint ();
} }
void void
@ -144,11 +144,11 @@ PixmapSlider::paintEvent (QPaintEvent *event)
QPixmap *slider = isSliderDown () ? &m_pressed : &m_normal; QPixmap *slider = isSliderDown () ? &m_pressed : &m_normal;
QRect rect (slider->rect ()); QRect rect (slider->rect ());
if (orientation () == Qt::Vertical) { if (orientation () == Qt::Vertical) {
rect.moveTop (sliderPositionFromValue ()); rect.moveTop (sliderPositionFromValue () + m_slider_offset.y ());
rect.moveLeft (m_slider_offset); rect.moveLeft (m_slider_offset.x ());
} else { } else {
rect.moveLeft (sliderPositionFromValue ()); rect.moveLeft (sliderPositionFromValue () + m_slider_offset.x ());
rect.moveTop (m_slider_offset); rect.moveTop (m_slider_offset.y ());
} }
p.drawPixmap (rect , *slider, slider->rect ()); p.drawPixmap (rect , *slider, slider->rect ());
p.end (); p.end ();

View file

@ -19,6 +19,7 @@
#include <QAbstractSlider> #include <QAbstractSlider>
#include <QList> #include <QList>
#include <QPoint>
class QWidget; class QWidget;
class QPixmap; class QPixmap;
@ -44,6 +45,8 @@ class PixmapSlider : public QAbstractSlider
QPixmap normalSlider () const { return m_normal; } QPixmap normalSlider () const { return m_normal; }
QPixmap pressedSlider () const { return m_pressed; } QPixmap pressedSlider () const { return m_pressed; }
void setSliderOffset (QPoint offset) { m_slider_offset = offset; }
protected slots: protected slots:
void paintEvent (QPaintEvent *event); void paintEvent (QPaintEvent *event);
@ -58,17 +61,13 @@ class PixmapSlider : public QAbstractSlider
int sliderValueFromPosition (int pos); int sliderValueFromPosition (int pos);
int backgroundIndex (); int backgroundIndex ();
// horizontal offset in vertical sliders or
// vertical offset in horizontal sliders
void setSliderOffset (int offset) { m_slider_offset = offset; };
private: private:
QPixmapList m_backgrounds; QPixmapList m_backgrounds;
QPixmap m_normal; QPixmap m_normal;
QPixmap m_pressed; QPixmap m_pressed;
QPoint m_slider_offset;
int m_background_index; int m_background_index;
int m_slider_offset;
}; };
#endif #endif