From b10ef97cfca37b3b59416b63e6fc6e9158dd92ad Mon Sep 17 00:00:00 2001 From: Thomas Frauendorfer Date: Thu, 31 Jan 2008 06:14:51 +0100 Subject: [PATCH] put PlaylistWindow into an on file --- src/main.cpp | 2 +- src/mainwindow/maindisplay.cpp | 2 +- src/mainwindow/mainwindow.cpp | 3 +- src/playlist/playlist.pri | 6 +- src/playlist/playlistshade.cpp | 2 +- src/playlist/playlistview.cpp | 2 +- .../{playlist.cpp => playlistwidget.cpp} | 134 +-------------- src/playlist/{playlist.h => playlistwidget.h} | 39 +---- src/playlist/playlistwindow.cpp | 158 ++++++++++++++++++ src/playlist/playlistwindow.h | 67 ++++++++ 10 files changed, 239 insertions(+), 176 deletions(-) rename src/playlist/{playlist.cpp => playlistwidget.cpp} (84%) rename src/playlist/{playlist.h => playlistwidget.h} (78%) create mode 100644 src/playlist/playlistwindow.cpp create mode 100644 src/playlist/playlistwindow.h diff --git a/src/main.cpp b/src/main.cpp index c476879..1091c92 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,7 +14,7 @@ */ #include "mainwindow.h" -#include "playlist.h" +#include "playlistwindow.h" #include "equalizer.h" #include "Skin.h" //TODO: change to xclient.h sometime later diff --git a/src/mainwindow/maindisplay.cpp b/src/mainwindow/maindisplay.cpp index b63657c..e2e5e84 100644 --- a/src/mainwindow/maindisplay.cpp +++ b/src/mainwindow/maindisplay.cpp @@ -28,7 +28,7 @@ #include "PosBar.h" #include "PlayStatus.h" #include "VolumeSlider.h" -#include "playlist.h" +#include "playlistwindow.h" #include "clutterbar.h" #include diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index 5540901..ada3d28 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -19,10 +19,11 @@ #include "ServerBrowser.h" #endif -#include "playlist.h" +#include "playlistwindow.h" #include "maindisplay.h" #include "shadeddisplay.h" #include "equalizer.h" +#include "Button.h" #include #include diff --git a/src/playlist/playlist.pri b/src/playlist/playlist.pri index ceee4ea..d47083f 100644 --- a/src/playlist/playlist.pri +++ b/src/playlist/playlist.pri @@ -1,9 +1,11 @@ -HEADERS += playlist.h \ +HEADERS += playlistwindow.h \ + playlistwidget.h \ playlistmenu.h \ playlistshade.h \ playlistview.h -SOURCES += playlist.cpp \ +SOURCES += playlistwindow.cpp \ + playlistwidget.cpp \ playlistmenu.cpp \ playlistshade.cpp \ playlistview.cpp diff --git a/src/playlist/playlistshade.cpp b/src/playlist/playlistshade.cpp index 2b40956..19cebb5 100644 --- a/src/playlist/playlistshade.cpp +++ b/src/playlist/playlistshade.cpp @@ -17,7 +17,7 @@ #include #include "playlistshade.h" -#include "playlist.h" +#include "playlistwindow.h" #include diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index 0ebc157..2b02477 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -20,7 +20,7 @@ #include "playlistview.h" #include "playlistmodel.h" -#include "playlist.h" +#include "playlistwidget.h" #include #include diff --git a/src/playlist/playlist.cpp b/src/playlist/playlistwidget.cpp similarity index 84% rename from src/playlist/playlist.cpp rename to src/playlist/playlistwidget.cpp index 6b7c447..2d9b59d 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlistwidget.cpp @@ -16,7 +16,8 @@ #include "mainwindow.h" #include "BrowseDialog.h" -#include "playlist.h" +#include "playlistwindow.h" +#include "playlistwidget.h" #include "playlistview.h" #include "playlistmodel.h" @@ -162,137 +163,6 @@ PlaylistScrollBar::sliderValueFromPosition (int position) } -/* - * PlaylistWindow - */ -PlaylistWindow::PlaylistWindow (QWidget *parent) : QMainWindow (parent) -{ - QSettings s; - m_mw = dynamic_cast(parent); -#ifndef _WIN32 - setWindowIcon (QIcon (":icon.png")); -#endif - - setWindowFlags (Qt::Dialog | Qt::FramelessWindowHint); - setAttribute (Qt::WA_DeleteOnClose); - - s.beginGroup ("playlist"); - if (!s.contains ("size")) { - s.setValue ("size", QSize (275, 350)); - } - resize (s.value("size").toSize ()); - - m_playlist = new PlaylistWidget (this); - setCentralWidget (m_playlist); - m_shaded = new PlaylistShade (this); - - m_shadebtn = new Button (this, Skin::PLS_SHADE_BTN_0, Skin::PLS_SHADE_BTN_1, true); - connect (m_shadebtn, SIGNAL (clicked()), this, SLOT (switchDisplay ())); - m_shadebtn->move(size().width() - 21, 3); - - m_closebtn = new Button (this, Skin::PLS_CLOSE_BTN_0, Skin::PLS_CLOSE_BTN_1, true); - connect (m_closebtn, SIGNAL (clicked()), this, SLOT (togglePL ())); - m_closebtn->move(size().width() - 11, 3); - - if (!s.contains ("shaded")) - s.setValue ("shaded", false); - else - s.setValue ("shaded", !s.value("shaded").toBool ()); - - switchDisplay (); - - s.endGroup (); - - // FIXME: flickering - //setSizeIncrement (25, 29); -} - -void -PlaylistWindow::togglePL (void) -{ - m_mw->togglePL(true); -} - -void -PlaylistWindow::switchDisplay (void) -{ - QSettings s; - - s.beginGroup ("playlist"); - - if (!s.value("shaded").toBool ()) { - m_shaded->hide (); - - m_playlist->show (); - s.setValue ("shaded", true); - m_playlist->resize (s.value("size").toSize ()); - resize (s.value("size").toSize ()); - - } else { - m_playlist->hide (); - - m_shaded->show (); - s.setValue ("shaded", false); - m_shaded->resize (s.value("size").toSize ().width(), 14); - resize (s.value("size").toSize ().width(), 14); - } - - s.endGroup (); - - update (); - -} - -void -PlaylistWindow::resizeEvent (QResizeEvent *event) -{ - QSettings s; - - m_shadebtn->move(size().width() - 21, 3); - m_closebtn->move(size().width() - 11, 3); - - if (s.value("playlist/shaded").toBool ()) { - s.setValue ("playlist/size", size ()); - } -} - -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::moveEvent (QMoveEvent *event) -{ - QSettings s; - s.setValue ("playlist/pos", pos ()); -} - -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 diff --git a/src/playlist/playlist.h b/src/playlist/playlistwidget.h similarity index 78% rename from src/playlist/playlist.h rename to src/playlist/playlistwidget.h index 914fded..001a5a7 100644 --- a/src/playlist/playlist.h +++ b/src/playlist/playlistwidget.h @@ -14,8 +14,8 @@ * GNU General Public License for more details. */ -#ifndef __PLAYLIST_H__ -#define __PLAYLIST_H__ +#ifndef __PLAYLISTWIDGET_H__ +#define __PLAYLISTWIDGET_H__ #include "XMMSHandler.h" @@ -123,39 +123,4 @@ class PlaylistWidget : public QWidget { PlaylistMenu *m_lst; }; - -class PlaylistWindow : public QMainWindow { - Q_OBJECT - - public: - PlaylistWindow (QWidget *parent); - ~PlaylistWindow () {} - - void setActive (bool); - - void mousePressEvent (QMouseEvent *event); - void mouseMoveEvent (QMouseEvent *event); - void enterEvent (QEvent *event); - void leaveEvent (QEvent *event); - void moveEvent (QMoveEvent *event); - void resizeEvent (QResizeEvent *event); - - public slots: - void switchDisplay (void); - void togglePL (void); - - private: - PlaylistWidget *m_playlist; - PlaylistShade *m_shaded; - - int m_diffx; - int m_diffy; - - Button *m_shadebtn; - Button *m_closebtn; - uint getOffset (void); - MainWindow *m_mw; - -}; - #endif diff --git a/src/playlist/playlistwindow.cpp b/src/playlist/playlistwindow.cpp new file mode 100644 index 0000000..e7479b4 --- /dev/null +++ b/src/playlist/playlistwindow.cpp @@ -0,0 +1,158 @@ +/** + * This file is a part of Prome, an XMMS2 Client. + * + * Copyright (C) 2005-2007 XMMS2 Team + * Copyright (C) 2007 Thomas Frauendorfer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "XMMSHandler.h" + +#include "playlistwindow.h" + +#include +#include +#include + +#include "Button.h" +#include "playlistwidget.h" +#include "playlistshade.h" + +#include "mainwindow.h" + +PlaylistWindow::PlaylistWindow (QWidget *parent) : QMainWindow (parent) +{ + QSettings s; + m_mw = dynamic_cast(parent); +#ifndef _WIN32 + setWindowIcon (QIcon (":icon.png")); +#endif + + setWindowFlags (Qt::Dialog | Qt::FramelessWindowHint); + setAttribute (Qt::WA_DeleteOnClose); + + s.beginGroup ("playlist"); + if (!s.contains ("size")) { + s.setValue ("size", QSize (275, 350)); + } + resize (s.value("size").toSize ()); + + m_playlist = new PlaylistWidget (this); + setCentralWidget (m_playlist); + m_shaded = new PlaylistShade (this); + + m_shadebtn = new Button (this, Skin::PLS_SHADE_BTN_0, Skin::PLS_SHADE_BTN_1, true); + connect (m_shadebtn, SIGNAL (clicked()), this, SLOT (switchDisplay ())); + m_shadebtn->move(size().width() - 21, 3); + + m_closebtn = new Button (this, Skin::PLS_CLOSE_BTN_0, Skin::PLS_CLOSE_BTN_1, true); + connect (m_closebtn, SIGNAL (clicked()), this, SLOT (togglePL ())); + m_closebtn->move(size().width() - 11, 3); + + if (!s.contains ("shaded")) + s.setValue ("shaded", false); + else + s.setValue ("shaded", !s.value("shaded").toBool ()); + + switchDisplay (); + + s.endGroup (); + + // FIXME: flickering + //setSizeIncrement (25, 29); +} + +void +PlaylistWindow::togglePL (void) +{ + m_mw->togglePL(true); +} + +void +PlaylistWindow::switchDisplay (void) +{ + QSettings s; + + s.beginGroup ("playlist"); + + if (!s.value("shaded").toBool ()) { + m_shaded->hide (); + + m_playlist->show (); + s.setValue ("shaded", true); + m_playlist->resize (s.value("size").toSize ()); + resize (s.value("size").toSize ()); + + } else { + m_playlist->hide (); + + m_shaded->show (); + s.setValue ("shaded", false); + m_shaded->resize (s.value("size").toSize ().width(), 14); + resize (s.value("size").toSize ().width(), 14); + } + + s.endGroup (); + + update (); + +} + +void +PlaylistWindow::resizeEvent (QResizeEvent *event) +{ + QSettings s; + + m_shadebtn->move(size().width() - 21, 3); + m_closebtn->move(size().width() - 11, 3); + + if (s.value("playlist/shaded").toBool ()) { + s.setValue ("playlist/size", size ()); + } +} + +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::moveEvent (QMoveEvent *event) +{ + QSettings s; + s.setValue ("playlist/pos", pos ()); +} + +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); +} + diff --git a/src/playlist/playlistwindow.h b/src/playlist/playlistwindow.h new file mode 100644 index 0000000..f0a522e --- /dev/null +++ b/src/playlist/playlistwindow.h @@ -0,0 +1,67 @@ +/** + * This file is a part of Prome, an XMMS2 Client. + * + * Copyright (C) 2005-2007 XMMS2 Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef _PLAYLISTWINDOW_ +#define _PLAYLISTWINDOW_ + +// Qt classes + #include + +class QEvent; +class QMouseEvent; +class QMoveEvent; +class QResizeEvent; + +// our own classes +class Button; +class MainWindow; +class PlaylistWidget; +class PlaylistShade; + +class PlaylistWindow : public QMainWindow { + Q_OBJECT + + public: + PlaylistWindow (QWidget *parent); + ~PlaylistWindow () {} + + void setActive (bool); + + void mousePressEvent (QMouseEvent *event); + void mouseMoveEvent (QMouseEvent *event); + void enterEvent (QEvent *event); + void leaveEvent (QEvent *event); + void moveEvent (QMoveEvent *event); + void resizeEvent (QResizeEvent *event); + + public slots: + void switchDisplay (void); + void togglePL (void); + + private: + PlaylistWidget *m_playlist; + PlaylistShade *m_shaded; + + int m_diffx; + int m_diffy; + + Button *m_shadebtn; + Button *m_closebtn; + uint getOffset (void); + MainWindow *m_mw; + +}; + +#endif // _PLAYLISTWINDOW_