From ef687a9375a16305d1e70016b1ad5e64992bcd2a Mon Sep 17 00:00:00 2001 From: Thomas Frauendorfer Date: Mon, 13 Oct 2008 03:59:43 +0200 Subject: [PATCH] OTHER: implement playtime and playback controls in playlistwindow --- README | 7 ++- src/mainwindow/maindisplay.cpp | 4 +- src/mainwindow/maindisplay.h | 4 ++ src/mainwindow/mainwindow.cpp | 6 ++ src/mainwindow/mainwindow.pri | 2 - src/playlist/playlist.pri | 2 + src/playlist/playlistcontrols.cpp | 86 ++++++++++++++++++++++++++++ src/playlist/playlistcontrols.h | 59 +++++++++++++++++++ src/playlist/playlistwidget.cpp | 30 +++++++++- src/playlist/playlistwidget.h | 2 + src/playlist/playlistwindow.h | 5 ++ src/src.pri | 4 +- src/{mainwindow => }/timedisplay.cpp | 0 src/{mainwindow => }/timedisplay.h | 2 +- 14 files changed, 202 insertions(+), 11 deletions(-) create mode 100644 src/playlist/playlistcontrols.cpp create mode 100644 src/playlist/playlistcontrols.h rename src/{mainwindow => }/timedisplay.cpp (100%) rename src/{mainwindow => }/timedisplay.h (100%) diff --git a/README b/README index 92ec636..8922111 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ Required dependencys: * QT4.2.x http://www.trolltech.no/ * XMMS2 http://xmms2.xmms.org/ - * XMMS2 C++ bindings (make sure to have boost_signals when compiling xmms2) + * XMMS2 C++ bindings (make sure you have boost_signals when compiling xmms2) - promoe works with 0.4DrK and 0.5DrL Optional dependencys: @@ -37,7 +37,8 @@ Patches: 'http://bugs.xmms2.xmms.se/' at project 'Client - Promoe'. Either append the patch to the bug it fixes or supply a link to your own - git repository + git repository (github.com is a good place for your own public git + repository) - To discuss a patch of wanted feature , you can also try to reach the + To discuss a patch or feature request, you can also try to reach the developer at xmms2's irc channel #xmms2 on freenode (irc.freenode.net) diff --git a/src/mainwindow/maindisplay.cpp b/src/mainwindow/maindisplay.cpp index 147fc33..677f042 100644 --- a/src/mainwindow/maindisplay.cpp +++ b/src/mainwindow/maindisplay.cpp @@ -62,6 +62,7 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent) m_time = new TimeDisplay(this); m_time->move (36, 26); connect (m_time, SIGNAL(clicked()), m_mw, SLOT(toggleTime())); + connect (this, SIGNAL (displayTime (int)), m_time, SLOT (setTime (int))); m_kbps = new PixmapNumberDisplay (this); m_kbps->resize (15, 6); @@ -205,7 +206,8 @@ MainDisplay::setPlaytime (uint32_t time) } else { showtime = time/1000; } - m_time->setTime (showtime); + emit displayTime (showtime); +// m_time->setTime (showtime); // update slider m_posbar->setValue (time); diff --git a/src/mainwindow/maindisplay.h b/src/mainwindow/maindisplay.h index 095c5f7..a6f883a 100644 --- a/src/mainwindow/maindisplay.h +++ b/src/mainwindow/maindisplay.h @@ -67,6 +67,10 @@ class MainDisplay : public SkinDisplay PlayStatus *m_playstatus; MainWindow *getMW(void) { return m_mw; } + signals: + //used to set time in timedisplays + void displayTime (int time); + public slots: void setPixmaps(Skin *skin); void setStatus (Xmms::Playback::Status status); diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index fc08e16..04eea0a 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -79,6 +79,12 @@ MainWindow::MainWindow (QWidget *parent) : BaseWindow (parent) setCentralWidget (m_display); m_display->show (); + //connects for timedisplay in playlistwindow + connect (m_display, SIGNAL (displayTime (int)), + m_playlistwin, SIGNAL (setDisplayTime (int))); + connect (m_playlistwin, SIGNAL (toggleTime()), + this, SLOT (toggleTime ())); + /* * MainDisplay's shaded mode */ diff --git a/src/mainwindow/mainwindow.pri b/src/mainwindow/mainwindow.pri index d62239b..b711871 100644 --- a/src/mainwindow/mainwindow.pri +++ b/src/mainwindow/mainwindow.pri @@ -7,7 +7,6 @@ HEADERS += clutterbar.h \ skindisplay.h \ stereomono.h \ textbar.h \ - timedisplay.h \ titlebar.h SOURCES += clutterbar.cpp \ @@ -19,7 +18,6 @@ SOURCES += clutterbar.cpp \ skindisplay.cpp \ stereomono.cpp \ textbar.cpp \ - timedisplay.cpp \ titlebar.cpp INCLUDEPATH += $$PWD diff --git a/src/playlist/playlist.pri b/src/playlist/playlist.pri index d47083f..0c519de 100644 --- a/src/playlist/playlist.pri +++ b/src/playlist/playlist.pri @@ -1,11 +1,13 @@ HEADERS += playlistwindow.h \ playlistwidget.h \ + playlistcontrols.h \ playlistmenu.h \ playlistshade.h \ playlistview.h SOURCES += playlistwindow.cpp \ playlistwidget.cpp \ + playlistcontrols.cpp \ playlistmenu.cpp \ playlistshade.cpp \ playlistview.cpp diff --git a/src/playlist/playlistcontrols.cpp b/src/playlist/playlistcontrols.cpp new file mode 100644 index 0000000..9e3426c --- /dev/null +++ b/src/playlist/playlistcontrols.cpp @@ -0,0 +1,86 @@ +/** + * This file is a part of Promoe, an XMMS2 Client. + * + * Copyright (C) 2005-2008 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. + */ + +#include "playlistcontrols.h" +#include "pixmapbutton.h" +#include "timedisplay.h" + +PlaylistControls::PlaylistControls (QWidget *parent) : QWidget (parent) +{ + setFixedSize (100, 38); + + /* + * Buttons + */ + PixmapButton *button; + //prev button + button = new PixmapButton (this); + button->resize (9, 8); + button->move (6, 23); + connect (button, SIGNAL (clicked ()), this, SIGNAL (prev ())); + //play button + button = new PixmapButton (this); + button->resize (9, 8); + button->move (15, 23); + connect (button, SIGNAL (clicked ()), this, SIGNAL (play ())); + //pause button + button = new PixmapButton (this); + button->resize (9, 8); + button->move (24, 23); + connect (button, SIGNAL (clicked ()), this, SIGNAL (pause ())); + //stop button + button = new PixmapButton (this); + button->resize (9, 8); + button->move (33, 23); + connect (button, SIGNAL (clicked ()), this, SIGNAL (stop ())); + //next button + button = new PixmapButton (this); + button->resize (9, 8); + button->move (42, 23); + connect (button, SIGNAL (clicked ()), this, SIGNAL (next ())); + //eject button + button = new PixmapButton (this); + button->resize (9, 8); + button->move (52, 23); + connect (button, SIGNAL (clicked ()), this, SIGNAL (eject ())); + + m_timedisplay = new SmallTimeDisplay (this); + m_timedisplay->move (69, 23); +// m_timedisplay->hide (); + connect (m_timedisplay, SIGNAL (clicked ()), + this, SIGNAL (toggleTime ())); + connect (this, SIGNAL (setDisplayTime (int)), + m_timedisplay, SLOT (setTime (int))); + + //TODO: playtimes +} + +void +PlaylistControls::setNumbers (const PixmapMap &p) +{ + m_timedisplay->setPixmaps (p); +} + +void +PlaylistControls::setSelectedLength (int lenght) +{ + //TODO +} + +void +PlaylistControls::setPlaylistLength (int lenght) +{ + //TODO +} diff --git a/src/playlist/playlistcontrols.h b/src/playlist/playlistcontrols.h new file mode 100644 index 0000000..a379b30 --- /dev/null +++ b/src/playlist/playlistcontrols.h @@ -0,0 +1,59 @@ +/** + * This file is a part of Promoe, an XMMS2 Client. + * + * Copyright (C) 2005-2008 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 __PLAYLISTCONTROLS_H__ +#define __PLAYLISTCONTROLS_H__ + +#include +#include + +class SmallTimeDisplay; +class QPixmap; + +typedef QMap PixmapMap; + +class PlaylistControls : public QWidget { + Q_OBJECT + + public: + PlaylistControls (QWidget *parent); + + void setNumbers (const PixmapMap &p); + + public slots: + void setSelectedLength (int); + void setPlaylistLength (int); + + signals: + // emitted when buttons are clicked + void prev (); + void play (); + void pause (); + void stop (); + void next (); + void eject (); + + void toggleTime (); + //connected to internal timedisplay + void setDisplayTime (int); + + private: + int m_playlist_length; + int m_selected_length; + + SmallTimeDisplay *m_timedisplay; +}; + +#endif diff --git a/src/playlist/playlistwidget.cpp b/src/playlist/playlistwidget.cpp index 8df7aa4..c53d247 100644 --- a/src/playlist/playlistwidget.cpp +++ b/src/playlist/playlistwidget.cpp @@ -20,9 +20,11 @@ #include "playlistwindow.h" #include "playlistwidget.h" #include "playlistview.h" +#include "playlistcontrols.h" #include "playlistmodel.h" #include "xcollection.h" +#include "xplayback.h" #include "pixmapbutton.h" #include "playlistshade.h" @@ -201,13 +203,10 @@ PlaylistWidget::PlaylistWidget (PlaylistWindow *parent) : QWidget (parent) * It is necessery because of limitations and at least one Bug in the * QT library (as of Version 4.3) * TODO: This might break in a future Qt version. Try to find a better solution - * FIXME: scrollbar is only visible if playlist was closed on startup or - * after resizing the playlist */ m_scrollBar = new PlaylistScrollBar (this); m_view->setVerticalScrollBar (m_scrollBar); m_scrollBar->setParent(this); - m_scrollBar->setVisible (true); m_scrollBar->show(); /* Workarounds for another QT bug (at least in my opinion) */ connect (m_scrollBar, SIGNAL(actionTriggered (int)), @@ -220,6 +219,26 @@ PlaylistWidget::PlaylistWidget (PlaylistWindow *parent) : QWidget (parent) addButtons (); + XMMSHandler &client = XMMSHandler::getInstance (); + + m_controls = new PlaylistControls (this); + // connect buttons + connect (m_controls, SIGNAL (prev ()), + client.xplayback (), SLOT (prev ())); + connect (m_controls, SIGNAL (play ()), + client.xplayback (), SLOT (play ())); + connect (m_controls, SIGNAL (pause ()), + client.xplayback (), SLOT (pause ())); + connect (m_controls, SIGNAL (stop ()), + client.xplayback (), SLOT (stop ())); + connect (m_controls, SIGNAL (next ()), + client.xplayback (), SLOT (next ())); + // TODO: eject + connect (m_controls, SIGNAL (toggleTime ()), + parent, SIGNAL (toggleTime())); + connect (parent, SIGNAL (setDisplayTime (int)), + m_controls, SIGNAL (setDisplayTime (int))); + setMinimumSize (275, 116); // resize (275, 300); } @@ -418,6 +437,9 @@ PlaylistWidget::resizeEvent (QResizeEvent *event) m_sel->move (69, height() - m_sel->height() - 12); m_msc->move (98, height() - m_msc->height() - 12); m_lst->move (width()-22-25, height() - m_lst->height() - 12); + + + m_controls->move (width ()-150, height()-38); } void @@ -426,6 +448,8 @@ PlaylistWidget::setPixmaps (Skin *skin) m_closebtn->setIcon (skin->getIcon (Skin::BUTTON_PLS_CLOSE)); m_shadebtn->setIcon (skin->getIcon (Skin::BUTTON_PLS_SHADE)); + m_controls->setNumbers (skin->getSmallNumbers ()); + setActive (m_active); update (); diff --git a/src/playlist/playlistwidget.h b/src/playlist/playlistwidget.h index a30c756..aa1e2cc 100644 --- a/src/playlist/playlistwidget.h +++ b/src/playlist/playlistwidget.h @@ -25,6 +25,7 @@ class PlaylistWidget; class PlaylistWindow; class PlaylistScroller; +class PlaylistControls; class Skin; class PlaylistView; @@ -118,6 +119,7 @@ class PlaylistWidget : public QWidget { PlaylistView *m_view; QScrollBar *m_scrollBar; PlaylistSizeGrip *m_sizegrip; + PlaylistControls *m_controls; PlaylistMenu *m_add; PlaylistMenu *m_del; diff --git a/src/playlist/playlistwindow.h b/src/playlist/playlistwindow.h index 14624a5..c53cff2 100644 --- a/src/playlist/playlistwindow.h +++ b/src/playlist/playlistwindow.h @@ -43,6 +43,11 @@ class PlaylistWindow : public BaseWindow { signals: void visibilityChanged(bool visible); + // connected to + void toggleTime (); // toggle the playtime + // setTime is used to set playtime in playlistcontrols + void setDisplayTime (int seconds); + public slots: void switchDisplay (void); diff --git a/src/src.pri b/src/src.pri index fe70a3e..30ff03e 100644 --- a/src/src.pri +++ b/src/src.pri @@ -5,7 +5,8 @@ include($$PWD/equalizer/equalizer.pri) include($$PWD/dialogs/dialogs.pri) HEADERS += Skin.h \ - XMMSHandler.h \ + timedisplay.h \ + XMMSHandler.h \ SkinChooser.h \ settingsdialog.h \ basewindow.h \ @@ -14,6 +15,7 @@ HEADERS += Skin.h \ BrowseDialog.h SOURCES += main.cpp \ + timedisplay.cpp \ Skin.cpp \ XMMSHandler.cpp \ SkinChooser.cpp \ diff --git a/src/mainwindow/timedisplay.cpp b/src/timedisplay.cpp similarity index 100% rename from src/mainwindow/timedisplay.cpp rename to src/timedisplay.cpp diff --git a/src/mainwindow/timedisplay.h b/src/timedisplay.h similarity index 100% rename from src/mainwindow/timedisplay.h rename to src/timedisplay.h index 7940ec5..44f9ecf 100644 --- a/src/mainwindow/timedisplay.h +++ b/src/timedisplay.h @@ -32,10 +32,10 @@ class AbstractTimeDisplay : public QWidget public: AbstractTimeDisplay (QWidget *parent); ~AbstractTimeDisplay () {}; - void setTime (int); public slots: void setPixmaps (const PixmapMap &p); + void setTime (int); signals: void clicked(void);