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

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,115 +0,0 @@
/**
* 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 "timedisplay.h"
#include <QPainter>
#include <QPixmap>
#include <QMap>
TimeDisplay::TimeDisplay (QWidget *parent) : AbstractTimeDisplay (parent)
{
setFixedSize (63, 13);
m_d1_x_pos = 12;
m_d2_x_pos = 24;
m_d3_x_pos = 42;
m_d4_x_pos = 54;
}
SmallTimeDisplay::SmallTimeDisplay (QWidget *parent)
: AbstractTimeDisplay (parent)
{
setFixedSize (28, 6);
m_d1_x_pos = 5;
m_d2_x_pos = 10;
m_d3_x_pos = 18;
m_d4_x_pos = 23;
}
AbstractTimeDisplay::AbstractTimeDisplay (QWidget *parent) : QWidget (parent)
{
m_time = 0;
}
/*
* This method takes the playtime in seconds
*/
void
AbstractTimeDisplay::setTime (int time)
{
// Hack to make display hours and seconds instead of seconds and minutes
// if time (or reversetime) is 100 Minutes or longer
if ((time >= 6000) || (time <= -6000)) {
time /= 60;
}
if (m_time == time) return;
m_time = time;
update ();
}
void
AbstractTimeDisplay::setPixmaps (const PixmapMap &p) {
if (p.size () < 11) {
// This shouldn't happen, if it does then there is a bug in Skin.cpp
qDebug ("TimeDisplay: PixmapMap has not enough elements");
return;
}
m_pixmaps = p;
}
void
AbstractTimeDisplay::mouseReleaseEvent (QMouseEvent *event)
{
emit clicked();
}
void
AbstractTimeDisplay::paintEvent (QPaintEvent *event)
{
QPainter paint;
paint.begin (this);
if (m_time < 0) {
// draw minus
paint.drawPixmap (0, 0, m_pixmaps[11]);
} else {
// draw blank
paint.drawPixmap (0, 0, m_pixmaps[10]);
}
uint showtime = abs(m_time);
if (showtime < 6000) {
// draw minutes
uint min = showtime / 60;
paint.drawPixmap (m_d1_x_pos, 0, m_pixmaps[min/10]);
paint.drawPixmap (m_d2_x_pos, 0, m_pixmaps[min%10]);
// draw seconds
uint sec = showtime % 60;
paint.drawPixmap (m_d3_x_pos, 0, m_pixmaps[sec/10]);
paint.drawPixmap (m_d4_x_pos, 0, m_pixmaps[sec%10]);
} else {
// Just give up and draw '-' if min-variable would become 100 or bigger
paint.drawPixmap (m_d1_x_pos, 0, m_pixmaps[11]);
paint.drawPixmap (m_d2_x_pos, 0, m_pixmaps[11]);
paint.drawPixmap (m_d3_x_pos, 0, m_pixmaps[11]);
paint.drawPixmap (m_d4_x_pos, 0, m_pixmaps[11]);
}
paint.end ();
}

View file

@ -1,72 +0,0 @@
/**
* 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 __TIMEDISPLAY_H__
#define __TIMEDISPLAY_H__
#include <QWidget>
#include <QMap>
class QMouseEvent;
class QPaintEvent;
class QPixmap;
typedef QMap<int, QPixmap> PixmapMap;
// This class is not really abstract, but named so anyway
class AbstractTimeDisplay : public QWidget
{
Q_OBJECT
public:
AbstractTimeDisplay (QWidget *parent);
~AbstractTimeDisplay () {};
void setTime (int);
public slots:
void setPixmaps (const PixmapMap &p);
signals:
void clicked(void);
protected:
void mousePressEvent (QMouseEvent *event) {};
void mouseReleaseEvent (QMouseEvent *event);
void paintEvent (QPaintEvent *event);
// positions for the digits, numbered from left to right
int m_d1_x_pos;
int m_d2_x_pos;
int m_d3_x_pos;
int m_d4_x_pos;
int m_time;
PixmapMap m_pixmaps;
};
class TimeDisplay : public AbstractTimeDisplay
{
Q_OBJECT
public:
TimeDisplay (QWidget *parent);
};
class SmallTimeDisplay : public AbstractTimeDisplay
{
Q_OBJECT
public:
SmallTimeDisplay (QWidget *parent);
};
#endif