Playlist "works"
This commit is contained in:
parent
4c0bffeb6f
commit
65c1011b8a
14 changed files with 710 additions and 19 deletions
20
Button.cpp
20
Button.cpp
|
@ -8,13 +8,14 @@ Button::Button (QWidget *parent) : PixWidget (parent)
|
||||||
m_name_pressed = 0;
|
m_name_pressed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Button::Button (QWidget *parent, uint normal, uint pressed) : PixWidget (parent)
|
Button::Button (QWidget *parent, uint normal, uint pressed, bool pls) : PixWidget (parent)
|
||||||
{
|
{
|
||||||
m_name_normal = normal;
|
m_name_normal = normal;
|
||||||
m_name_pressed = pressed;
|
m_name_pressed = pressed;
|
||||||
m_diffx = 0;
|
m_diffx = 0;
|
||||||
m_diffy = 0;
|
m_diffy = 0;
|
||||||
m_nodrag = false;
|
m_nodrag = false;
|
||||||
|
m_pls = pls;
|
||||||
}
|
}
|
||||||
|
|
||||||
Button::~Button ()
|
Button::~Button ()
|
||||||
|
@ -28,8 +29,13 @@ Button::setPixmaps(Skin *skin)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_pls) {
|
||||||
|
m_pixmap_normal = skin->getPls (m_name_normal);
|
||||||
|
m_pixmap_pressed = skin->getPls (m_name_pressed);
|
||||||
|
} else {
|
||||||
m_pixmap_normal = skin->getItem (m_name_normal);
|
m_pixmap_normal = skin->getItem (m_name_normal);
|
||||||
m_pixmap_pressed = skin->getItem (m_name_pressed);
|
m_pixmap_pressed = skin->getItem (m_name_pressed);
|
||||||
|
}
|
||||||
m_pixmap = m_pixmap_normal;
|
m_pixmap = m_pixmap_normal;
|
||||||
|
|
||||||
if (!m_pixmap_normal || m_pixmap_normal.isNull()) {
|
if (!m_pixmap_normal || m_pixmap_normal.isNull()) {
|
||||||
|
@ -49,7 +55,12 @@ void
|
||||||
Button::mousePressEvent (QMouseEvent *event)
|
Button::mousePressEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
MainWindow *mw = dynamic_cast<MainWindow *>(window ());
|
MainWindow *mw = dynamic_cast<MainWindow *>(window ());
|
||||||
|
if (mw) {
|
||||||
mw->setNoDrag (true);
|
mw->setNoDrag (true);
|
||||||
|
} else {
|
||||||
|
PlaylistWindow *pw = dynamic_cast<PlaylistWindow *>(window ());
|
||||||
|
pw->setNoDrag (true);
|
||||||
|
}
|
||||||
|
|
||||||
m_pixmap = m_pixmap_pressed;
|
m_pixmap = m_pixmap_pressed;
|
||||||
|
|
||||||
|
@ -65,7 +76,12 @@ void
|
||||||
Button::mouseReleaseEvent (QMouseEvent *event)
|
Button::mouseReleaseEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
MainWindow *mw = dynamic_cast<MainWindow *>(window ());
|
MainWindow *mw = dynamic_cast<MainWindow *>(window ());
|
||||||
mw->setNoDrag (false);
|
if (mw) {
|
||||||
|
mw->setNoDrag (true);
|
||||||
|
} else {
|
||||||
|
PlaylistWindow *pw = dynamic_cast<PlaylistWindow *>(window ());
|
||||||
|
pw->setNoDrag (true);
|
||||||
|
}
|
||||||
m_pixmap = m_pixmap_normal;
|
m_pixmap = m_pixmap_normal;
|
||||||
m_nodrag = false;
|
m_nodrag = false;
|
||||||
update();
|
update();
|
||||||
|
|
3
Button.h
3
Button.h
|
@ -9,7 +9,7 @@ class Button : public PixWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Button (QWidget *parent, uint btn1, uint btn2);
|
Button (QWidget *parent, uint btn1, uint btn2, bool pls=false);
|
||||||
Button (QWidget *parent);
|
Button (QWidget *parent);
|
||||||
~Button ();
|
~Button ();
|
||||||
bool noDrag (void) { return m_nodrag; }
|
bool noDrag (void) { return m_nodrag; }
|
||||||
|
@ -34,6 +34,7 @@ class Button : public PixWidget
|
||||||
QPixmap m_pixmap_pressed;
|
QPixmap m_pixmap_pressed;
|
||||||
|
|
||||||
bool m_nodrag;
|
bool m_nodrag;
|
||||||
|
bool m_pls;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ToggleButton : public Button
|
class ToggleButton : public Button
|
||||||
|
|
|
@ -36,13 +36,6 @@ MainWindow::MainWindow (QWidget *parent) : QMainWindow (parent)
|
||||||
*/
|
*/
|
||||||
m_isshaded = false;
|
m_isshaded = false;
|
||||||
|
|
||||||
/*
|
|
||||||
* Now that everything is initialized
|
|
||||||
* open the skin and send the
|
|
||||||
* SkinChanged signal that will cause
|
|
||||||
* all widgets to get their pixmaps
|
|
||||||
*/
|
|
||||||
skin->setSkin ("./CleanAMP/");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +85,16 @@ int main (int argc, char **argv)
|
||||||
MainWindow *mw = new MainWindow (NULL);
|
MainWindow *mw = new MainWindow (NULL);
|
||||||
mw->show ();
|
mw->show ();
|
||||||
|
|
||||||
|
QMainWindow *playlistwin = new PlaylistWindow (NULL, mw->getSkin ());
|
||||||
|
playlistwin->show ();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now that everything is initialized
|
||||||
|
* open the skin and send the
|
||||||
|
* SkinChanged signal that will cause
|
||||||
|
* all widgets to get their pixmaps
|
||||||
|
*/
|
||||||
|
mw->getSkin ()->setSkin ("./CleanAMP/");
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ class MainWindow;
|
||||||
#include "XmmsQT4.h"
|
#include "XmmsQT4.h"
|
||||||
#include "MainDisplay.h"
|
#include "MainDisplay.h"
|
||||||
#include "ShadedDisplay.h"
|
#include "ShadedDisplay.h"
|
||||||
|
#include "Playlist.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ class MainWindow : public QMainWindow
|
||||||
XMMSHandler *m_handler;
|
XMMSHandler *m_handler;
|
||||||
MainDisplay *m_display;
|
MainDisplay *m_display;
|
||||||
ShadedDisplay *m_shaded;
|
ShadedDisplay *m_shaded;
|
||||||
|
PlaylistWindow *m_playlistwin;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,19 @@
|
||||||
|
|
||||||
PixWidget::PixWidget (QWidget *parent) : QWidget (parent)
|
PixWidget::PixWidget (QWidget *parent) : QWidget (parent)
|
||||||
{
|
{
|
||||||
|
Skin *s;
|
||||||
MainWindow *mw = dynamic_cast<MainWindow *>(window ());
|
MainWindow *mw = dynamic_cast<MainWindow *>(window ());
|
||||||
if (!mw) {
|
if (!mw) {
|
||||||
qDebug ("******** DANGER! NO MAINWINDOW FOUND");
|
PlaylistWindow *pl = dynamic_cast<PlaylistWindow*>(window ());
|
||||||
|
if (!pl) {
|
||||||
|
qDebug ("What are you?!");
|
||||||
|
}
|
||||||
|
s = pl->getSkin ();
|
||||||
|
} else {
|
||||||
|
s = mw->getSkin ();
|
||||||
}
|
}
|
||||||
m_pixmap = QPixmap(0,0);
|
m_pixmap = QPixmap(0,0);
|
||||||
connect (mw->getSkin(), SIGNAL (skinChanged (Skin *)), this, SLOT (setPixmaps(Skin *)));
|
connect (s, SIGNAL (skinChanged (Skin *)), this, SLOT (setPixmaps(Skin *)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
272
Playlist.cpp
Normal file
272
Playlist.cpp
Normal file
|
@ -0,0 +1,272 @@
|
||||||
|
|
||||||
|
#include "Playlist.h"
|
||||||
|
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QPaintEvent>
|
||||||
|
#include <QRect>
|
||||||
|
|
||||||
|
PlaylistScrollButton::PlaylistScrollButton (PlaylistScroller *parent, uint normal, uint pressed) : Button (parent, normal, pressed, true)
|
||||||
|
{
|
||||||
|
m_slider = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistScrollButton::mouseMoveEvent (QMouseEvent *event)
|
||||||
|
{
|
||||||
|
QPoint p (event->pos ());
|
||||||
|
|
||||||
|
int npos = pos().y()+p.y()-m_diffy;
|
||||||
|
if (npos >= 0 && npos + rect().height() <= m_slider->rect().height()) {
|
||||||
|
move (0, npos);
|
||||||
|
} else if (npos < 0) {
|
||||||
|
move (0, 0);
|
||||||
|
npos = 0;
|
||||||
|
} else if (npos + rect().height() > m_slider->rect().height()) {
|
||||||
|
move (0, m_slider->rect().height()-rect().height());
|
||||||
|
npos = m_slider->rect().height()-rect().height();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_slider->doScroll (npos);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlaylistScroller::PlaylistScroller (PlaylistWindow *parent) : QWidget (parent)
|
||||||
|
{
|
||||||
|
m_pixmap = QPixmap(0,0);
|
||||||
|
connect (parent->getSkin(), SIGNAL (skinChanged (Skin *)), this, SLOT (setPixmaps(Skin *)));
|
||||||
|
m_button = new PlaylistScrollButton (this, Skin::PLS_SCROLL_0, Skin::PLS_SCROLL_1);
|
||||||
|
m_button->move (0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
PlaylistScroller::getMax (void)
|
||||||
|
{
|
||||||
|
return rect().height()-m_button->rect().height();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistScroller::setPixmaps (Skin *skin)
|
||||||
|
{
|
||||||
|
m_pixmap = skin->getPls (Skin::PLS_RFILL2_0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistScroller::paintEvent (QPaintEvent *event)
|
||||||
|
{
|
||||||
|
if (m_pixmap.isNull ()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPainter (paint);
|
||||||
|
paint.begin (this);
|
||||||
|
paint.drawPixmap (rect (), m_pixmap, m_pixmap.rect ());
|
||||||
|
paint.end ();
|
||||||
|
}
|
||||||
|
|
||||||
|
PlaylistWindow::PlaylistWindow (QWidget *parent, Skin *skin) : QMainWindow (parent)
|
||||||
|
{
|
||||||
|
m_skin = skin;
|
||||||
|
m_noDrag = false;
|
||||||
|
|
||||||
|
setWindowFlags (Qt::FramelessWindowHint);
|
||||||
|
connect (m_skin, SIGNAL (skinChanged (Skin *)), this, SLOT (setPixmaps(Skin *)));
|
||||||
|
|
||||||
|
setActive (underMouse ());
|
||||||
|
|
||||||
|
m_view = new PlaylistView (this);
|
||||||
|
m_view->move (10, 20);
|
||||||
|
m_view->resize (size().width()-30, size().height()-20-38);
|
||||||
|
|
||||||
|
m_list = new PlaylistList (m_view);
|
||||||
|
|
||||||
|
m_scroller = new PlaylistScroller (this);
|
||||||
|
connect (m_scroller, SIGNAL(scrolled(int)), this, SLOT(doScroll (int)));
|
||||||
|
|
||||||
|
setMinimumSize (275, 116);
|
||||||
|
resize (275, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistWindow::doScroll (int pos)
|
||||||
|
{
|
||||||
|
int npos = ((float)pos) / (float)(m_scroller->getMax()) * float(m_list->height() - m_view->height());
|
||||||
|
m_list->setOffset (npos);
|
||||||
|
m_list->scroll (0, npos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistWindow::resizeEvent (QResizeEvent *event)
|
||||||
|
{
|
||||||
|
m_view->resize (size().width()-30, size().height()-20-38);
|
||||||
|
m_list->resize (m_view->size().width(), m_view->size().height());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistWindow::mousePressEvent (QMouseEvent *event)
|
||||||
|
{
|
||||||
|
m_diffx = event->pos ().x ();
|
||||||
|
m_diffy = event->pos ().y ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistWindow::mouseMoveEvent (QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (m_noDrag)
|
||||||
|
return;
|
||||||
|
|
||||||
|
move (event->globalPos().x() - m_diffx,
|
||||||
|
event->globalPos().y() - m_diffy);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistWindow::setPixmaps (Skin *skin)
|
||||||
|
{
|
||||||
|
m_skin = skin;
|
||||||
|
setActive (m_active);
|
||||||
|
resize (size().width(), size().height());
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistWindow::enterEvent (QEvent *event)
|
||||||
|
{
|
||||||
|
setActive (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistWindow::leaveEvent (QEvent *event)
|
||||||
|
{
|
||||||
|
setActive (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistWindow::setActive (bool active)
|
||||||
|
{
|
||||||
|
m_active = active;
|
||||||
|
|
||||||
|
if (!m_skin) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_corner3 = m_skin->getPls (Skin::PLS_LCBAR);
|
||||||
|
m_corner4 = m_skin->getPls (Skin::PLS_RCBAR);
|
||||||
|
|
||||||
|
if (active) {
|
||||||
|
m_corner1 = m_skin->getPls (Skin::PLS_CORNER_UL_0);
|
||||||
|
m_corner2 = m_skin->getPls (Skin::PLS_CORNER_UR_0);
|
||||||
|
m_titlebar = m_skin->getPls (Skin::PLS_TBAR_0);
|
||||||
|
m_tfill = m_skin->getPls (Skin::PLS_TFILL_0);
|
||||||
|
m_bfill = m_skin->getPls (Skin::PLS_BFILL_0);
|
||||||
|
m_lfill = m_skin->getPls (Skin::PLS_LFILL_0);
|
||||||
|
m_rfill = m_skin->getPls (Skin::PLS_RFILL_0);
|
||||||
|
m_rfill2 = m_skin->getPls (Skin::PLS_RFILL2_0);
|
||||||
|
m_rfill3 = m_skin->getPls (Skin::PLS_RFILL3_0);
|
||||||
|
} else {
|
||||||
|
m_corner1 = m_skin->getPls (Skin::PLS_CORNER_UL_1);
|
||||||
|
m_corner2 = m_skin->getPls (Skin::PLS_CORNER_UR_1);
|
||||||
|
m_titlebar = m_skin->getPls (Skin::PLS_TBAR_1);
|
||||||
|
m_tfill = m_skin->getPls (Skin::PLS_TFILL_1);
|
||||||
|
m_bfill = m_skin->getPls (Skin::PLS_BFILL_1);
|
||||||
|
m_lfill = m_skin->getPls (Skin::PLS_LFILL_1);
|
||||||
|
m_rfill = m_skin->getPls (Skin::PLS_RFILL_1);
|
||||||
|
m_rfill2 = m_skin->getPls (Skin::PLS_RFILL2_1);
|
||||||
|
m_rfill3 = m_skin->getPls (Skin::PLS_RFILL3_1);
|
||||||
|
}
|
||||||
|
|
||||||
|
update ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistWindow::paintEvent (QPaintEvent *event)
|
||||||
|
{
|
||||||
|
QPainter paint;
|
||||||
|
|
||||||
|
paint.begin (this);
|
||||||
|
paint.drawPixmap (QRect (0, 0,
|
||||||
|
m_corner1.size ().width (),
|
||||||
|
m_corner1.size ().height ()),
|
||||||
|
m_corner1,
|
||||||
|
m_corner1.rect ());
|
||||||
|
|
||||||
|
paint.drawPixmap (QRect (size().width()-m_corner2.width(),
|
||||||
|
0, m_corner2.width(),
|
||||||
|
m_corner2.height()),
|
||||||
|
m_corner2,
|
||||||
|
m_corner2.rect());
|
||||||
|
|
||||||
|
paint.drawPixmap (QRect (0, size().height()-m_corner3.height(),
|
||||||
|
m_corner3.width(),
|
||||||
|
m_corner3.height()),
|
||||||
|
m_corner3,
|
||||||
|
m_corner3.rect());
|
||||||
|
|
||||||
|
paint.drawPixmap (QRect (size().width()-m_corner4.width(),
|
||||||
|
size().height()-m_corner4.height(),
|
||||||
|
m_corner4.width(),
|
||||||
|
m_corner4.height()),
|
||||||
|
m_corner4,
|
||||||
|
m_corner4.rect());
|
||||||
|
|
||||||
|
int midx = (size().width()/2) - (m_titlebar.width()/2);
|
||||||
|
paint.drawPixmap (QRect(midx, 0, m_titlebar.width(), m_titlebar.height()),
|
||||||
|
m_titlebar, m_titlebar.rect());
|
||||||
|
|
||||||
|
/* left fill */
|
||||||
|
paint.drawPixmap (QRect(m_corner1.width(),
|
||||||
|
0, midx - m_corner1.width(),
|
||||||
|
m_tfill.height()),
|
||||||
|
m_tfill,
|
||||||
|
m_tfill.rect());
|
||||||
|
|
||||||
|
int midx2 = midx + m_titlebar.width();
|
||||||
|
|
||||||
|
paint.drawPixmap (QRect (midx2, 0, size().width()-midx2-m_corner2.width(),
|
||||||
|
m_tfill.height()),
|
||||||
|
m_tfill,
|
||||||
|
m_tfill.rect());
|
||||||
|
|
||||||
|
int bsize = m_corner3.width()+m_corner4.width();
|
||||||
|
|
||||||
|
if (size().width() > bsize) {
|
||||||
|
int pad_to = size().width() - bsize;
|
||||||
|
paint.drawPixmap (QRect (m_corner3.width(),
|
||||||
|
size().height()-m_bfill.height(),
|
||||||
|
pad_to,
|
||||||
|
m_bfill.height()),
|
||||||
|
m_bfill,
|
||||||
|
m_bfill.rect());
|
||||||
|
}
|
||||||
|
|
||||||
|
paint.drawPixmap (QRect (0, m_corner1.height(), m_lfill.width(),
|
||||||
|
size().height()-m_corner3.height()-m_corner1.height()),
|
||||||
|
m_lfill,
|
||||||
|
m_lfill.rect());
|
||||||
|
paint.drawPixmap (QRect (size().width()-m_rfill3.width(),
|
||||||
|
m_corner2.height(),
|
||||||
|
m_rfill3.width(),
|
||||||
|
size().height()-m_corner2.height()-m_corner3.height()),
|
||||||
|
m_rfill3,
|
||||||
|
m_rfill3.rect());
|
||||||
|
|
||||||
|
int x = size().width();
|
||||||
|
x -= m_rfill3.width();
|
||||||
|
x -= m_rfill2.width();
|
||||||
|
x -= m_rfill.width();
|
||||||
|
|
||||||
|
paint.drawPixmap (QRect (x, m_corner2.height(),
|
||||||
|
m_rfill.width(),
|
||||||
|
size().height()-m_corner2.height()-m_corner3.height()),
|
||||||
|
m_rfill,
|
||||||
|
m_rfill.rect());
|
||||||
|
|
||||||
|
paint.end ();
|
||||||
|
|
||||||
|
m_scroller->move (size().width()-m_rfill3.width()-m_rfill2.width(),
|
||||||
|
m_corner2.height());
|
||||||
|
m_scroller->resize (m_rfill2.width(),
|
||||||
|
size().height()-m_corner2.height()-m_corner4.height());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
99
Playlist.h
Normal file
99
Playlist.h
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
#ifndef __PLAYLIST_H__
|
||||||
|
#define __PLAYLIST_H__
|
||||||
|
|
||||||
|
#include "Skin.h"
|
||||||
|
#include "PlaylistList.h"
|
||||||
|
#include "PixWidget.h"
|
||||||
|
#include "Button.h"
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QFont>
|
||||||
|
|
||||||
|
class PlaylistWindow;
|
||||||
|
class PlaylistScroller;
|
||||||
|
|
||||||
|
class PlaylistScrollButton : public Button {
|
||||||
|
public:
|
||||||
|
PlaylistScrollButton (PlaylistScroller *parent, uint normal, uint pressed);
|
||||||
|
~PlaylistScrollButton () {}
|
||||||
|
private:
|
||||||
|
PlaylistScroller *m_slider;
|
||||||
|
void mouseMoveEvent (QMouseEvent *event);
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlaylistScroller : public QWidget{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
PlaylistScroller (PlaylistWindow *arent);
|
||||||
|
~PlaylistScroller () {}
|
||||||
|
void doScroll (int p) { emit scrolled(p); }
|
||||||
|
|
||||||
|
int getMax (void);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setPixmaps (Skin *skin);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void scrolled (int);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void paintEvent (QPaintEvent *event);
|
||||||
|
QPixmap m_pixmap;
|
||||||
|
PlaylistScrollButton *m_button;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlaylistView : public QWidget {
|
||||||
|
public:
|
||||||
|
PlaylistView (QWidget *parent) : QWidget (parent) {}
|
||||||
|
~PlaylistView () {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlaylistWindow : public QMainWindow {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
PlaylistWindow (QWidget *parent, Skin *skin);
|
||||||
|
~PlaylistWindow () {}
|
||||||
|
|
||||||
|
void setActive (bool);
|
||||||
|
Skin *getSkin (void) { return m_skin; }
|
||||||
|
void setNoDrag (bool b) { m_noDrag = b; }
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setPixmaps (Skin *skin);
|
||||||
|
void doScroll (int);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void resizeEvent (QResizeEvent *event);
|
||||||
|
void paintEvent (QPaintEvent *event);
|
||||||
|
void enterEvent (QEvent *event);
|
||||||
|
void leaveEvent (QEvent *event);
|
||||||
|
void mousePressEvent (QMouseEvent *event);
|
||||||
|
void mouseMoveEvent (QMouseEvent *event);
|
||||||
|
|
||||||
|
QPixmap m_corner1;
|
||||||
|
QPixmap m_corner2;
|
||||||
|
QPixmap m_corner3;
|
||||||
|
QPixmap m_corner4;
|
||||||
|
|
||||||
|
QPixmap m_titlebar;
|
||||||
|
QPixmap m_tfill;
|
||||||
|
QPixmap m_bfill;
|
||||||
|
QPixmap m_lfill;
|
||||||
|
QPixmap m_rfill;
|
||||||
|
QPixmap m_rfill2;
|
||||||
|
QPixmap m_rfill3;
|
||||||
|
|
||||||
|
bool m_active;
|
||||||
|
bool m_noDrag;
|
||||||
|
|
||||||
|
Skin *m_skin;
|
||||||
|
|
||||||
|
int m_diffx;
|
||||||
|
int m_diffy;
|
||||||
|
|
||||||
|
PlaylistView *m_view;
|
||||||
|
PlaylistList *m_list;
|
||||||
|
PlaylistScroller *m_scroller;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
124
PlaylistList.cpp
Normal file
124
PlaylistList.cpp
Normal file
|
@ -0,0 +1,124 @@
|
||||||
|
#include "PlaylistList.h"
|
||||||
|
#include "Playlist.h"
|
||||||
|
|
||||||
|
#include <QPaintEvent>
|
||||||
|
|
||||||
|
PlaylistItem::PlaylistItem (PlaylistList *pl, uint id)
|
||||||
|
{
|
||||||
|
m_pl = pl;
|
||||||
|
m_id = id;
|
||||||
|
pl->addItem (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
PlaylistItem::text (void)
|
||||||
|
{
|
||||||
|
return QString::fromUtf8 ("Entry entry entry");
|
||||||
|
}
|
||||||
|
|
||||||
|
PlaylistList::PlaylistList (QWidget *parent) : QWidget (parent)
|
||||||
|
{
|
||||||
|
PlaylistWindow *pl = dynamic_cast<PlaylistWindow*>(window ());
|
||||||
|
connect (pl->getSkin (), SIGNAL (skinChanged (Skin *)), this, SLOT (setPixmaps(Skin *)));
|
||||||
|
m_font = NULL;
|
||||||
|
m_fontmetrics = NULL;
|
||||||
|
m_items = new QList<PlaylistItem *>;
|
||||||
|
m_offset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistList::paintEvent (QPaintEvent *event)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
QPainter paint;
|
||||||
|
paint.begin (this);
|
||||||
|
paint.setFont (*m_font);
|
||||||
|
paint.setClipping (false);
|
||||||
|
|
||||||
|
int cy = event->rect().y () + m_offset;
|
||||||
|
int ch = event->rect().height();
|
||||||
|
int sitem = cy / getFontH();
|
||||||
|
int eitem = (cy + ch) / getFontH();
|
||||||
|
|
||||||
|
if (eitem > m_items->count())
|
||||||
|
eitem = m_items->count();
|
||||||
|
|
||||||
|
for (i = sitem; i < eitem; i++) {
|
||||||
|
QRect r (3, getFontH()*(i-sitem), size().width(), getFontH());
|
||||||
|
if (event->region().contains (r)) {
|
||||||
|
QString q;
|
||||||
|
q.sprintf ("%d. ", i+1);
|
||||||
|
q += m_items->value(i)->text ();
|
||||||
|
paint.eraseRect (r);
|
||||||
|
paint.drawText (r, q);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getFontH()*(i-sitem) < size().height()) {
|
||||||
|
paint.eraseRect (QRect (0, getFontH()*(i-sitem), size().width(),
|
||||||
|
size().height()-getFontH()*(i-sitem)));
|
||||||
|
}
|
||||||
|
|
||||||
|
paint.end ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistList::addItem (PlaylistItem *i)
|
||||||
|
{
|
||||||
|
m_items->append (i);
|
||||||
|
if (m_items->count()*getFontH () > size().height()) {
|
||||||
|
resize (size().width(), m_items->count ()*getFontH ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
PlaylistList::getFontH (void)
|
||||||
|
{
|
||||||
|
if (!m_fontmetrics) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return m_fontmetrics->height();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistList::setPixmaps (Skin *skin)
|
||||||
|
{
|
||||||
|
QPalette pal;
|
||||||
|
QColor c;
|
||||||
|
c.setNamedColor (skin->getPLeditValue ("normalbg"));
|
||||||
|
QBrush b (c);
|
||||||
|
pal.setBrush (QPalette::Window, b);
|
||||||
|
setPalette (pal);
|
||||||
|
|
||||||
|
if (m_font) {
|
||||||
|
delete m_font;
|
||||||
|
}
|
||||||
|
m_font = new QFont (skin->getPLeditValue ("font"));
|
||||||
|
m_font->setPixelSize (10);
|
||||||
|
|
||||||
|
if (m_fontmetrics) {
|
||||||
|
delete m_fontmetrics;
|
||||||
|
}
|
||||||
|
m_fontmetrics = new QFontMetrics (*m_font);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistList::setSize (int width, int height)
|
||||||
|
{
|
||||||
|
int nx, ny;
|
||||||
|
if (width > size().width()) {
|
||||||
|
nx = width;
|
||||||
|
} else {
|
||||||
|
nx = size().width();
|
||||||
|
}
|
||||||
|
if (height > size().height()) {
|
||||||
|
ny = height;
|
||||||
|
} else {
|
||||||
|
ny = size().height();
|
||||||
|
}
|
||||||
|
resize (ny, nx);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
46
PlaylistList.h
Normal file
46
PlaylistList.h
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#ifndef __PLAYLISTLIST_H__
|
||||||
|
#define __PLAYLISTLIST_H__
|
||||||
|
|
||||||
|
#include "Skin.h"
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class PlaylistItem;
|
||||||
|
|
||||||
|
class PlaylistList : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
PlaylistList (QWidget *parent);
|
||||||
|
~PlaylistList () {}
|
||||||
|
|
||||||
|
void setSize (int, int);
|
||||||
|
void addItem (PlaylistItem *i);
|
||||||
|
void setOffset (int i) { m_offset = i; }
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setPixmaps (Skin *skin);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void paintEvent (QPaintEvent *event);
|
||||||
|
QList<PlaylistItem*> *m_items;
|
||||||
|
QFont *m_font;
|
||||||
|
QFontMetrics *m_fontmetrics;
|
||||||
|
|
||||||
|
int getFontH (void);
|
||||||
|
int m_offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlaylistItem {
|
||||||
|
public:
|
||||||
|
PlaylistItem (PlaylistList *pl, uint);
|
||||||
|
~PlaylistItem () {}
|
||||||
|
|
||||||
|
QString text (void);
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint m_id;
|
||||||
|
PlaylistList *m_pl;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
58
Skin.cpp
58
Skin.cpp
|
@ -9,6 +9,7 @@ Skin::Skin (void)
|
||||||
m_pledit_txt = new QHash<QByteArray, QByteArray>;
|
m_pledit_txt = new QHash<QByteArray, QByteArray>;
|
||||||
m_numbers = new QHash<uint, QPixmap>;
|
m_numbers = new QHash<uint, QPixmap>;
|
||||||
m_letterMap = new QHash<uint, QPixmap>;
|
m_letterMap = new QHash<uint, QPixmap>;
|
||||||
|
m_playlist = new QHash<uint, QPixmap>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,6 +17,60 @@ Skin::~Skin ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Skin::BuildPlaylist (void)
|
||||||
|
{
|
||||||
|
QPixmap tmp;
|
||||||
|
|
||||||
|
QPixmap *img = getPixmap ("pledit.bmp");
|
||||||
|
qDebug ("%d %d", img->size().width(), img->size().height());
|
||||||
|
|
||||||
|
m_playlist->insert (PLS_CORNER_UL_0, img->copy(0, 0, 25, 20));
|
||||||
|
m_playlist->insert (PLS_CORNER_UL_1, img->copy(0, 21, 25, 20));
|
||||||
|
|
||||||
|
m_playlist->insert (PLS_TBAR_0, img->copy (26, 0, 100, 20));
|
||||||
|
m_playlist->insert (PLS_TBAR_1, img->copy (26, 21, 100, 20));
|
||||||
|
|
||||||
|
m_playlist->insert (PLS_CORNER_UR_0, img->copy(153, 0, 25, 20));
|
||||||
|
m_playlist->insert (PLS_CORNER_UR_1, img->copy(153, 21, 25, 20));
|
||||||
|
|
||||||
|
m_playlist->insert (PLS_TFILL_0, img->copy(127, 0, 25, 20));
|
||||||
|
m_playlist->insert (PLS_TFILL_1, img->copy(127, 21, 25, 20));
|
||||||
|
|
||||||
|
m_playlist->insert (PLS_BFILL_0, img->copy(179, 0, 25, 38));
|
||||||
|
|
||||||
|
m_playlist->insert (PLS_VISMINI_0, img->copy(205, 0, 75, 38));
|
||||||
|
|
||||||
|
m_playlist->insert (PLS_LFILL_0, img->copy(0, 42, 12, 29));
|
||||||
|
|
||||||
|
m_playlist->insert (PLS_RFILL_0, img->copy(31, 42, 5, 29));
|
||||||
|
m_playlist->insert (PLS_RFILL2_0, img->copy(36, 42, 8, 29));
|
||||||
|
m_playlist->insert (PLS_RFILL3_0, img->copy(44, 42, 7, 29));
|
||||||
|
|
||||||
|
tmp = m_playlist->value (PLS_CORNER_UR_0);
|
||||||
|
|
||||||
|
m_playlist->insert (PLS_CLOSE_BTN_0, tmp.copy(14, 3, 9, 9));
|
||||||
|
m_playlist->insert (PLS_CLOSE_BTN_1, img->copy(52, 42, 9, 9));
|
||||||
|
|
||||||
|
m_playlist->insert (PLS_SHADE_BTN_0, tmp.copy(14, 3, 9, 9));
|
||||||
|
m_playlist->insert (PLS_SHADE_BTN_1, img->copy(52, 42, 9, 9));
|
||||||
|
|
||||||
|
m_playlist->insert (PLS_MAX_BTN_0, img->copy(150, 42, 9, 9));
|
||||||
|
|
||||||
|
m_playlist->insert (PLS_SCROLL_0, img->copy(52, 53, 8, 18));
|
||||||
|
m_playlist->insert (PLS_SCROLL_1, img->copy(61, 53, 8, 18));
|
||||||
|
|
||||||
|
m_playlist->insert (PLS_WS_LE_0, img->copy(72, 42, 25, 14));
|
||||||
|
m_playlist->insert (PLS_WS_RE_0, img->copy(99, 42, 50, 14));
|
||||||
|
m_playlist->insert (PLS_WS_RE_1, img->copy(99, 57, 50, 14));
|
||||||
|
m_playlist->insert (PLS_WS_MID_0, img->copy(72, 57, 25, 14));
|
||||||
|
|
||||||
|
m_playlist->insert (PLS_LCBAR, img->copy(0, 72, 125, 38));
|
||||||
|
m_playlist->insert (PLS_RCBAR, img->copy(126, 72, 150, 38));
|
||||||
|
|
||||||
|
delete img;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Skin::setSkin (QString name)
|
Skin::setSkin (QString name)
|
||||||
|
@ -39,6 +94,9 @@ Skin::setSkin (QString name)
|
||||||
m_numbers->clear();
|
m_numbers->clear();
|
||||||
BuildNumbers();
|
BuildNumbers();
|
||||||
|
|
||||||
|
m_playlist->clear ();
|
||||||
|
BuildPlaylist ();
|
||||||
|
|
||||||
emit skinChanged(this);
|
emit skinChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
41
Skin.h
41
Skin.h
|
@ -21,6 +21,7 @@ class Skin : public QWidget
|
||||||
void setSkin (QString name);
|
void setSkin (QString name);
|
||||||
|
|
||||||
const QPixmap getItem (uint part) const { return m_items->value(part); }
|
const QPixmap getItem (uint part) const { return m_items->value(part); }
|
||||||
|
const QPixmap getPls (uint part) const { return m_playlist->value(part); }
|
||||||
const QPixmap getVol (uint p) const { return m_volume_bar->value(p); }
|
const QPixmap getVol (uint p) const { return m_volume_bar->value(p); }
|
||||||
const QPixmap getBal (uint p) const { return m_balance->value(p); }
|
const QPixmap getBal (uint p) const { return m_balance->value(p); }
|
||||||
const QPixmap getLetter (uint c) const { return m_letterMap->value(c); }
|
const QPixmap getLetter (uint c) const { return m_letterMap->value(c); }
|
||||||
|
@ -150,6 +151,44 @@ class Skin : public QWidget
|
||||||
POSBAR_BTN_0,
|
POSBAR_BTN_0,
|
||||||
POSBAR_BTN_1,
|
POSBAR_BTN_1,
|
||||||
};
|
};
|
||||||
|
enum PlaylistParts {
|
||||||
|
PLS_CORNER_UL_0,
|
||||||
|
PLS_CORNER_UL_1,
|
||||||
|
PLS_CORNER_UR_0,
|
||||||
|
PLS_CORNER_UR_1,
|
||||||
|
PLS_TBAR_0,
|
||||||
|
PLS_TBAR_1,
|
||||||
|
PLS_TFILL_0,
|
||||||
|
PLS_TFILL_1,
|
||||||
|
PLS_BFILL_0,
|
||||||
|
PLS_BFILL_1 = PLS_BFILL_0,
|
||||||
|
PLS_VISMINI_0,
|
||||||
|
PLS_VISMINI_1 = PLS_VISMINI_0,
|
||||||
|
PLS_LFILL_0,
|
||||||
|
PLS_LFILL_1 = PLS_LFILL_0,
|
||||||
|
PLS_RFILL_0,
|
||||||
|
PLS_RFILL_1 = PLS_RFILL_0,
|
||||||
|
PLS_RFILL2_0,
|
||||||
|
PLS_RFILL2_1 = PLS_RFILL2_0,
|
||||||
|
PLS_RFILL3_0,
|
||||||
|
PLS_RFILL3_1 = PLS_RFILL3_0,
|
||||||
|
PLS_CLOSE_BTN_0,
|
||||||
|
PLS_CLOSE_BTN_1,
|
||||||
|
PLS_SHADE_BTN_0,
|
||||||
|
PLS_SHADE_BTN_1,
|
||||||
|
PLS_MAX_BTN_0,
|
||||||
|
PLS_MAX_BTN_1,
|
||||||
|
PLS_SCROLL_0,
|
||||||
|
PLS_SCROLL_1,
|
||||||
|
PLS_WS_LE_0,
|
||||||
|
PLS_WS_LE_1 = PLS_WS_LE_0,
|
||||||
|
PLS_WS_RE_0,
|
||||||
|
PLS_WS_RE_1,
|
||||||
|
PLS_WS_MID_0,
|
||||||
|
PLS_WS_MID_1 = PLS_WS_MID_0,
|
||||||
|
PLS_LCBAR,
|
||||||
|
PLS_RCBAR
|
||||||
|
};
|
||||||
private:
|
private:
|
||||||
QPixmap *Skin::getPixmap (string file);
|
QPixmap *Skin::getPixmap (string file);
|
||||||
void Parse (string file);
|
void Parse (string file);
|
||||||
|
@ -160,6 +199,7 @@ class Skin : public QWidget
|
||||||
void BuildSliders (void);
|
void BuildSliders (void);
|
||||||
void BuildOther (void);
|
void BuildOther (void);
|
||||||
void BuildNumbers (void);
|
void BuildNumbers (void);
|
||||||
|
void BuildPlaylist (void);
|
||||||
void ParsePLEdit (void);
|
void ParsePLEdit (void);
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,6 +211,7 @@ class Skin : public QWidget
|
||||||
QHash<uint, QPixmap> *m_volume_bar;
|
QHash<uint, QPixmap> *m_volume_bar;
|
||||||
QHash<uint, QPixmap> *m_balance;
|
QHash<uint, QPixmap> *m_balance;
|
||||||
QHash<uint, QPixmap> *m_numbers;
|
QHash<uint, QPixmap> *m_numbers;
|
||||||
|
QHash<uint, QPixmap> *m_playlist;
|
||||||
|
|
||||||
QHash<QByteArray, QByteArray> *m_pledit_txt;
|
QHash<QByteArray, QByteArray> *m_pledit_txt;
|
||||||
QList<QPixmap *> m_buttons;
|
QList<QPixmap *> m_buttons;
|
||||||
|
|
|
@ -31,6 +31,22 @@ XMMSHandler::XMMSHandler (MainWindow *mw) : sigc::trackable ()
|
||||||
|
|
||||||
r = m_xmmsc->broadcast_playback_status ();
|
r = m_xmmsc->broadcast_playback_status ();
|
||||||
r->connect (sigc::mem_fun (this, &XMMSHandler::playback_status));
|
r->connect (sigc::mem_fun (this, &XMMSHandler::playback_status));
|
||||||
|
|
||||||
|
XMMSResultValueListUint *l = m_xmmsc->playlist_list ();
|
||||||
|
l->connect (sigc::mem_fun (this, &XMMSHandler::playlist_list));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
XMMSHandler::playlist_list (XMMSResultValueListUint *res)
|
||||||
|
{
|
||||||
|
qDebug ("korv!");
|
||||||
|
|
||||||
|
for (;res->listValid(); res->listNext()) {
|
||||||
|
uint i;
|
||||||
|
qDebug ("%u", res->getValue(&i));
|
||||||
|
}
|
||||||
|
|
||||||
|
delete res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -19,6 +19,7 @@ class XMMSHandler : public QObject, public sigc::trackable {
|
||||||
void playback_current_id (XMMSResultValueUint *res);
|
void playback_current_id (XMMSResultValueUint *res);
|
||||||
void medialib_info (XMMSResultDict *res);
|
void medialib_info (XMMSResultDict *res);
|
||||||
void playback_status (XMMSResultValueUint *res);
|
void playback_status (XMMSResultValueUint *res);
|
||||||
|
void playlist_list (XMMSResultValueListUint *res);
|
||||||
|
|
||||||
const XMMSClient *getXMMS () { return m_xmmsc; }
|
const XMMSClient *getXMMS () { return m_xmmsc; }
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,9 @@ SOURCES += XmmsQT4.cpp \
|
||||||
StereoMono.cpp \
|
StereoMono.cpp \
|
||||||
Slider.cpp \
|
Slider.cpp \
|
||||||
PlayStatus.cpp \
|
PlayStatus.cpp \
|
||||||
ShadedDisplay.cpp
|
ShadedDisplay.cpp \
|
||||||
|
Playlist.cpp \
|
||||||
|
PlaylistList.cpp
|
||||||
|
|
||||||
HEADERS += XmmsQT4.h \
|
HEADERS += XmmsQT4.h \
|
||||||
PixWidget.h \
|
PixWidget.h \
|
||||||
|
@ -30,7 +32,10 @@ HEADERS += XmmsQT4.h \
|
||||||
StereoMono.h \
|
StereoMono.h \
|
||||||
Slider.h \
|
Slider.h \
|
||||||
PlayStatus.h \
|
PlayStatus.h \
|
||||||
ShadedDisplay.h
|
ShadedDisplay.h \
|
||||||
|
Playlist.h \
|
||||||
|
PlaylistList.h
|
||||||
|
|
||||||
CONFIG += link_pkgconfig
|
CONFIG += link_pkgconfig
|
||||||
|
CONFIG += debug
|
||||||
PKGCONFIG += xmms2-client xmms2-client-cpp sigc++-2.0
|
PKGCONFIG += xmms2-client xmms2-client-cpp sigc++-2.0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue