Shaded mode for playlist.
This commit is contained in:
parent
c8d095a6f5
commit
07977b89f5
4 changed files with 130 additions and 52 deletions
126
Playlist.cpp
126
Playlist.cpp
|
@ -39,7 +39,7 @@ dragButton::mouseMoveEvent (QMouseEvent *event)
|
||||||
pw->size().height()+(event->pos().y()-m_diffy));
|
pw->size().height()+(event->pos().y()-m_diffy));
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaylistScroller::PlaylistScroller (PlaylistWindow *parent) : QWidget (parent)
|
PlaylistScroller::PlaylistScroller (PlaylistWidget *parent) : QWidget (parent)
|
||||||
{
|
{
|
||||||
Skin *skin = Skin::getInstance ();
|
Skin *skin = Skin::getInstance ();
|
||||||
|
|
||||||
|
@ -79,13 +79,85 @@ PlaylistScroller::paintEvent (QPaintEvent *event)
|
||||||
|
|
||||||
PlaylistWindow::PlaylistWindow (QWidget *parent) : QMainWindow (parent)
|
PlaylistWindow::PlaylistWindow (QWidget *parent) : QMainWindow (parent)
|
||||||
{
|
{
|
||||||
Skin *skin = Skin::getInstance ();
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
setWindowIcon (QIcon (":icon.png"));
|
setWindowIcon (QIcon (":icon.png"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
setWindowFlags (Qt::FramelessWindowHint);
|
setWindowFlags (Qt::FramelessWindowHint);
|
||||||
|
|
||||||
|
resize (275, 300);
|
||||||
|
|
||||||
|
m_playlist = new PlaylistWidget (this);
|
||||||
|
setCentralWidget (m_playlist);
|
||||||
|
m_shaded = new PlaylistShade (this);
|
||||||
|
m_shaded->hide ();
|
||||||
|
|
||||||
|
m_isshaded = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistWindow::switchDisplay (void)
|
||||||
|
{
|
||||||
|
if (m_isshaded) {
|
||||||
|
m_shaded->hide ();
|
||||||
|
|
||||||
|
m_playlist->show ();
|
||||||
|
m_playlist->resize (m_pl_size);
|
||||||
|
resize (m_pl_size);
|
||||||
|
|
||||||
|
m_isshaded = false;
|
||||||
|
} else {
|
||||||
|
m_pl_size = m_playlist->size ();
|
||||||
|
m_playlist->hide ();
|
||||||
|
|
||||||
|
m_shaded->show ();
|
||||||
|
m_shaded->resize (size().width(), 14);
|
||||||
|
|
||||||
|
resize (size().width(), 14);
|
||||||
|
|
||||||
|
m_isshaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
update ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistWindow::mousePressEvent (QMouseEvent *event)
|
||||||
|
{
|
||||||
|
m_diffx = event->pos ().x ();
|
||||||
|
m_diffy = event->pos ().y ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistWindow::mouseMoveEvent (QMouseEvent *event)
|
||||||
|
{
|
||||||
|
move (event->globalPos().x() - m_diffx,
|
||||||
|
event->globalPos().y() - m_diffy);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistWindow::enterEvent (QEvent *event)
|
||||||
|
{
|
||||||
|
m_playlist->setActive (true);
|
||||||
|
m_shaded->setActive (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistWindow::leaveEvent (QEvent *event)
|
||||||
|
{
|
||||||
|
m_playlist->setActive (false);
|
||||||
|
m_shaded->setActive (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PlaylistWidget::PlaylistWidget (QWidget *parent) : QWidget (parent)
|
||||||
|
{
|
||||||
|
Skin *skin = Skin::getInstance ();
|
||||||
|
|
||||||
connect (skin, SIGNAL (skinChanged (Skin *)),
|
connect (skin, SIGNAL (skinChanged (Skin *)),
|
||||||
this, SLOT (setPixmaps(Skin *)));
|
this, SLOT (setPixmaps(Skin *)));
|
||||||
|
|
||||||
|
@ -107,7 +179,7 @@ PlaylistWindow::PlaylistWindow (QWidget *parent) : QMainWindow (parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistWindow::doScroll (int pos)
|
PlaylistWidget::doScroll (int pos)
|
||||||
{
|
{
|
||||||
int npos = ((float)pos) / (float)(m_scroller->getMax()) * float(m_list->height() - m_view->height());
|
int npos = ((float)pos) / (float)(m_scroller->getMax()) * float(m_list->height() - m_view->height());
|
||||||
|
|
||||||
|
@ -121,49 +193,21 @@ PlaylistWindow::doScroll (int pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistWindow::resizeEvent (QResizeEvent *event)
|
PlaylistWidget::resizeEvent (QResizeEvent *event)
|
||||||
{
|
{
|
||||||
m_view->resize (size().width()-30, size().height()-20-38);
|
m_view->resize (size().width()-30, size().height()-20-38);
|
||||||
m_list->setSize (m_view->size().width(), m_view->size().height());
|
m_list->setSize (m_view->size().width(), m_view->size().height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistWindow::mousePressEvent (QMouseEvent *event)
|
PlaylistWidget::setPixmaps (Skin *skin)
|
||||||
{
|
|
||||||
m_diffx = event->pos ().x ();
|
|
||||||
m_diffy = event->pos ().y ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
PlaylistWindow::mouseMoveEvent (QMouseEvent *event)
|
|
||||||
{
|
|
||||||
move (event->globalPos().x() - m_diffx,
|
|
||||||
event->globalPos().y() - m_diffy);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
PlaylistWindow::setPixmaps (Skin *skin)
|
|
||||||
{
|
{
|
||||||
setActive (m_active);
|
setActive (m_active);
|
||||||
resize (size().width(), size().height());
|
resize (size().width(), size().height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistWindow::enterEvent (QEvent *event)
|
PlaylistWidget::setActive (bool active)
|
||||||
{
|
|
||||||
setActive (true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PlaylistWindow::leaveEvent (QEvent *event)
|
|
||||||
{
|
|
||||||
setActive (false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
PlaylistWindow::setActive (bool active)
|
|
||||||
{
|
{
|
||||||
Skin *skin = Skin::getInstance ();
|
Skin *skin = Skin::getInstance ();
|
||||||
|
|
||||||
|
@ -198,7 +242,17 @@ PlaylistWindow::setActive (bool active)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistWindow::paintEvent (QPaintEvent *event)
|
PlaylistWidget::mouseDoubleClickEvent (QMouseEvent *event)
|
||||||
|
{
|
||||||
|
PlaylistWindow *pw = dynamic_cast<PlaylistWindow *>(window ());
|
||||||
|
if (event->pos().y() < 14) {
|
||||||
|
pw->switchDisplay ();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistWidget::paintEvent (QPaintEvent *event)
|
||||||
{
|
{
|
||||||
QPainter paint;
|
QPainter paint;
|
||||||
|
|
||||||
|
|
47
Playlist.h
47
Playlist.h
|
@ -5,10 +5,11 @@
|
||||||
#include "PlaylistList.h"
|
#include "PlaylistList.h"
|
||||||
#include "PixWidget.h"
|
#include "PixWidget.h"
|
||||||
#include "Button.h"
|
#include "Button.h"
|
||||||
|
#include "PlaylistShade.h"
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
|
|
||||||
class PlaylistWindow;
|
class PlaylistWidget;
|
||||||
class PlaylistScroller;
|
class PlaylistScroller;
|
||||||
|
|
||||||
class dragButton : public Button {
|
class dragButton : public Button {
|
||||||
|
@ -31,7 +32,7 @@ class PlaylistScrollButton : public Button {
|
||||||
class PlaylistScroller : public QWidget{
|
class PlaylistScroller : public QWidget{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
PlaylistScroller (PlaylistWindow *arent);
|
PlaylistScroller (PlaylistWidget *arent);
|
||||||
~PlaylistScroller () {}
|
~PlaylistScroller () {}
|
||||||
void doScroll (int p) { emit scrolled(p); }
|
void doScroll (int p) { emit scrolled(p); }
|
||||||
|
|
||||||
|
@ -55,14 +56,15 @@ class PlaylistView : public QWidget {
|
||||||
~PlaylistView () {}
|
~PlaylistView () {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PlaylistWindow : public QMainWindow {
|
class PlaylistWidget : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PlaylistWindow (QWidget *parent);
|
PlaylistWidget (QWidget *parent);
|
||||||
~PlaylistWindow () {}
|
~PlaylistWidget () {}
|
||||||
|
|
||||||
void setActive (bool);
|
void setActive (bool);
|
||||||
|
void switchDisplay (void);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setPixmaps (Skin *skin);
|
void setPixmaps (Skin *skin);
|
||||||
|
@ -71,10 +73,7 @@ class PlaylistWindow : public QMainWindow {
|
||||||
private:
|
private:
|
||||||
void resizeEvent (QResizeEvent *event);
|
void resizeEvent (QResizeEvent *event);
|
||||||
void paintEvent (QPaintEvent *event);
|
void paintEvent (QPaintEvent *event);
|
||||||
void enterEvent (QEvent *event);
|
void mouseDoubleClickEvent (QMouseEvent *event);
|
||||||
void leaveEvent (QEvent *event);
|
|
||||||
void mousePressEvent (QMouseEvent *event);
|
|
||||||
void mouseMoveEvent (QMouseEvent *event);
|
|
||||||
|
|
||||||
QPixmap m_corner1;
|
QPixmap m_corner1;
|
||||||
QPixmap m_corner2;
|
QPixmap m_corner2;
|
||||||
|
@ -91,8 +90,6 @@ class PlaylistWindow : public QMainWindow {
|
||||||
|
|
||||||
bool m_active;
|
bool m_active;
|
||||||
|
|
||||||
int m_diffx;
|
|
||||||
int m_diffy;
|
|
||||||
|
|
||||||
PlaylistView *m_view;
|
PlaylistView *m_view;
|
||||||
PlaylistList *m_list;
|
PlaylistList *m_list;
|
||||||
|
@ -100,4 +97,32 @@ class PlaylistWindow : public QMainWindow {
|
||||||
dragButton *m_drag;
|
dragButton *m_drag;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class PlaylistWindow : public QMainWindow {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
PlaylistWindow (QWidget *parent);
|
||||||
|
~PlaylistWindow () {}
|
||||||
|
|
||||||
|
void setActive (bool);
|
||||||
|
void switchDisplay (void);
|
||||||
|
|
||||||
|
void mousePressEvent (QMouseEvent *event);
|
||||||
|
void mouseMoveEvent (QMouseEvent *event);
|
||||||
|
void enterEvent (QEvent *event);
|
||||||
|
void leaveEvent (QEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_isshaded;
|
||||||
|
|
||||||
|
PlaylistWidget *m_playlist;
|
||||||
|
PlaylistShade *m_shaded;
|
||||||
|
|
||||||
|
int m_diffx;
|
||||||
|
int m_diffy;
|
||||||
|
|
||||||
|
QSize m_pl_size;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -361,9 +361,6 @@ PlaylistList::dropEvent (QDropEvent *event)
|
||||||
m_selected->append (m_drag_id);
|
m_selected->append (m_drag_id);
|
||||||
m_bar = -2;
|
m_bar = -2;
|
||||||
update ();
|
update ();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -16,7 +16,8 @@ SOURCES += XmmsQT4.cpp \
|
||||||
ShadedDisplay.cpp \
|
ShadedDisplay.cpp \
|
||||||
Playlist.cpp \
|
Playlist.cpp \
|
||||||
PlaylistList.cpp \
|
PlaylistList.cpp \
|
||||||
SkinChooser.cpp
|
SkinChooser.cpp \
|
||||||
|
PlaylistShade.cpp
|
||||||
|
|
||||||
HEADERS += XmmsQT4.h \
|
HEADERS += XmmsQT4.h \
|
||||||
PixWidget.h \
|
PixWidget.h \
|
||||||
|
@ -36,7 +37,8 @@ HEADERS += XmmsQT4.h \
|
||||||
ShadedDisplay.h \
|
ShadedDisplay.h \
|
||||||
Playlist.h \
|
Playlist.h \
|
||||||
PlaylistList.h \
|
PlaylistList.h \
|
||||||
SkinChooser.h
|
SkinChooser.h \
|
||||||
|
PlaylistShade.h
|
||||||
|
|
||||||
|
|
||||||
RESOURCES = promoe.qrc
|
RESOURCES = promoe.qrc
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue