OTHER: implement playtime and playback controls in playlistwindow

This commit is contained in:
Thomas Frauendorfer 2008-10-13 03:59:43 +02:00
parent eb96c8b75b
commit ef687a9375
14 changed files with 202 additions and 11 deletions

7
README
View file

@ -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)

View file

@ -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);

View file

@ -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);

View file

@ -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
*/

View file

@ -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

View file

@ -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

View file

@ -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
}

View file

@ -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 <QWidget>
#include <QMap>
class SmallTimeDisplay;
class QPixmap;
typedef QMap<int, QPixmap> 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

View file

@ -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 ();

View file

@ -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;

View file

@ -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);

View file

@ -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 \

View file

@ -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);