diff --git a/Playlist.cpp b/Playlist.cpp index f62476f..9598cef 100644 --- a/Playlist.cpp +++ b/Playlist.cpp @@ -39,7 +39,7 @@ dragButton::mouseMoveEvent (QMouseEvent *event) pw->size().height()+(event->pos().y()-m_diffy)); } -PlaylistScroller::PlaylistScroller (PlaylistWindow *parent) : QWidget (parent) +PlaylistScroller::PlaylistScroller (PlaylistWidget *parent) : QWidget (parent) { Skin *skin = Skin::getInstance (); @@ -79,13 +79,85 @@ PlaylistScroller::paintEvent (QPaintEvent *event) PlaylistWindow::PlaylistWindow (QWidget *parent) : QMainWindow (parent) { - Skin *skin = Skin::getInstance (); - #ifndef _WIN32 setWindowIcon (QIcon (":icon.png")); #endif 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 *)), this, SLOT (setPixmaps(Skin *))); @@ -107,7 +179,7 @@ PlaylistWindow::PlaylistWindow (QWidget *parent) : QMainWindow (parent) } void -PlaylistWindow::doScroll (int pos) +PlaylistWidget::doScroll (int pos) { int npos = ((float)pos) / (float)(m_scroller->getMax()) * float(m_list->height() - m_view->height()); @@ -121,49 +193,21 @@ PlaylistWindow::doScroll (int pos) } void -PlaylistWindow::resizeEvent (QResizeEvent *event) +PlaylistWidget::resizeEvent (QResizeEvent *event) { m_view->resize (size().width()-30, size().height()-20-38); m_list->setSize (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) -{ - move (event->globalPos().x() - m_diffx, - event->globalPos().y() - m_diffy); - -} - -void -PlaylistWindow::setPixmaps (Skin *skin) +PlaylistWidget::setPixmaps (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) +PlaylistWidget::setActive (bool active) { Skin *skin = Skin::getInstance (); @@ -198,7 +242,17 @@ PlaylistWindow::setActive (bool active) } void -PlaylistWindow::paintEvent (QPaintEvent *event) +PlaylistWidget::mouseDoubleClickEvent (QMouseEvent *event) +{ + PlaylistWindow *pw = dynamic_cast(window ()); + if (event->pos().y() < 14) { + pw->switchDisplay (); + } + +} + +void +PlaylistWidget::paintEvent (QPaintEvent *event) { QPainter paint; diff --git a/Playlist.h b/Playlist.h index 2d5b8cd..ed3230d 100644 --- a/Playlist.h +++ b/Playlist.h @@ -5,10 +5,11 @@ #include "PlaylistList.h" #include "PixWidget.h" #include "Button.h" +#include "PlaylistShade.h" #include #include -class PlaylistWindow; +class PlaylistWidget; class PlaylistScroller; class dragButton : public Button { @@ -31,7 +32,7 @@ class PlaylistScrollButton : public Button { class PlaylistScroller : public QWidget{ Q_OBJECT public: - PlaylistScroller (PlaylistWindow *arent); + PlaylistScroller (PlaylistWidget *arent); ~PlaylistScroller () {} void doScroll (int p) { emit scrolled(p); } @@ -55,14 +56,15 @@ class PlaylistView : public QWidget { ~PlaylistView () {} }; -class PlaylistWindow : public QMainWindow { +class PlaylistWidget : public QWidget { Q_OBJECT public: - PlaylistWindow (QWidget *parent); - ~PlaylistWindow () {} + PlaylistWidget (QWidget *parent); + ~PlaylistWidget () {} void setActive (bool); + void switchDisplay (void); public slots: void setPixmaps (Skin *skin); @@ -71,10 +73,7 @@ class PlaylistWindow : public QMainWindow { 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); + void mouseDoubleClickEvent (QMouseEvent *event); QPixmap m_corner1; QPixmap m_corner2; @@ -91,8 +90,6 @@ class PlaylistWindow : public QMainWindow { bool m_active; - int m_diffx; - int m_diffy; PlaylistView *m_view; PlaylistList *m_list; @@ -100,4 +97,32 @@ class PlaylistWindow : public QMainWindow { 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 diff --git a/PlaylistList.cpp b/PlaylistList.cpp index 4b2ec09..9d3b17b 100644 --- a/PlaylistList.cpp +++ b/PlaylistList.cpp @@ -361,9 +361,6 @@ PlaylistList::dropEvent (QDropEvent *event) m_selected->append (m_drag_id); m_bar = -2; update (); - - - } void diff --git a/promoe.pro b/promoe.pro index 99842a6..890dbdf 100644 --- a/promoe.pro +++ b/promoe.pro @@ -16,7 +16,8 @@ SOURCES += XmmsQT4.cpp \ ShadedDisplay.cpp \ Playlist.cpp \ PlaylistList.cpp \ - SkinChooser.cpp + SkinChooser.cpp \ + PlaylistShade.cpp HEADERS += XmmsQT4.h \ PixWidget.h \ @@ -36,7 +37,8 @@ HEADERS += XmmsQT4.h \ ShadedDisplay.h \ Playlist.h \ PlaylistList.h \ - SkinChooser.h + SkinChooser.h \ + PlaylistShade.h RESOURCES = promoe.qrc