Some cleanups, file moves and changes in PlayStatus

This commit is contained in:
Thomas Frauendorfer 2008-03-22 02:54:19 +01:00
parent a5e35d986e
commit 3f8ba378ad
10 changed files with 55 additions and 33 deletions

View file

@ -134,6 +134,8 @@ MainDisplay::setPixmaps (Skin *skin)
void
MainDisplay::setStatus (Xmms::Playback::Status status)
{
m_playstatus->setStatus (status);
if (status == Xmms::Playback::STOPPED) {
m_time->setTime(0);
m_posbar->setValue (0);

View file

@ -1,12 +1,16 @@
HEADERS += clutterbar.h \
mainwindow.h \
maindisplay.h \
playstatus.h \
posbar.h \
shadeddisplay.h \
stereomono.h
SOURCES += clutterbar.cpp \
mainwindow.cpp \
maindisplay.cpp \
playstatus.cpp \
posbar.cpp \
shadeddisplay.cpp \
stereomono.cpp

View file

@ -0,0 +1,77 @@
/**
* 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 <xmmsclient/xmmsclient++.h>
#include <QPainter>
#include <QPaintEvent>
#include "PlayStatus.h"
#include "Skin.h"
PlayStatus::PlayStatus (QWidget *parent) : QWidget (parent)
{
Skin* skin = Skin::getInstance ();
connect (skin, SIGNAL (skinChanged (Skin *)),
this, SLOT (setPixmaps (Skin *)));
setFixedSize(11, 9);
m_status = Xmms::Playback::STOPPED;
}
void
PlayStatus::setPixmaps (Skin *skin)
{
m_pixmap_play = skin->getItem (Skin::PIC_PLAY);
m_pixmap_pause = skin->getItem (Skin::PIC_PAUSE);
m_pixmap_stop = skin->getItem (Skin::PIC_STOP);
update ();
}
void
PlayStatus::setStatus (Xmms::Playback::Status status)
{
m_status = status;
update ();
}
void
PlayStatus::paintEvent (QPaintEvent *event)
{
QPixmap pixmap;
using Xmms::Playback;
switch (m_status) {
case Playback::STOPPED:
pixmap = m_pixmap_stop;
break;
case Playback::PLAYING:
pixmap = m_pixmap_play;
break;
case Playback::PAUSED:
pixmap = m_pixmap_pause;
break;
default:
qWarning ("Unhandled playback status in PlayStatus");
break;
}
QPainter p;
p.begin (this);
p.drawPixmap (rect (), pixmap, pixmap.rect ());
p.end ();
}

View file

@ -0,0 +1,47 @@
/**
* 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 __PLAYSTATUS_H__
#define __PLAYSTATUS_H__
#include <xmmsclient/xmmsclient++.h>
#include <QWidget>
class Skin;
class PlayStatus : public QWidget
{
Q_OBJECT
public:
PlayStatus (QWidget *parent);
~PlayStatus () { }
public slots:
void setPixmaps (Skin *skin);
void setStatus (Xmms::Playback::Status status);
protected slots:
void paintEvent (QPaintEvent *event);
private:
Xmms::Playback::Status m_status;
QPixmap m_pixmap_stop;
QPixmap m_pixmap_play;
QPixmap m_pixmap_pause;
};
#endif

69
src/mainwindow/posbar.cpp Normal file
View file

@ -0,0 +1,69 @@
/**
* 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 "XMMSHandler.h"
#include "xplayback.h"
#include "PosBar.h"
#include "Skin.h"
#include <QWidget>
PosBar::PosBar (QWidget *parent, uint bg, uint bnormal, uint bpressed)
: PixmapSlider (parent)
{
Skin *skin = Skin::getInstance ();
m_slider_normal = bnormal;
m_slider_pressed = bpressed;
m_bg = bg;
connect (skin, SIGNAL (skinChanged (Skin *)),
this, SLOT (setPixmaps (Skin *)));
setFixedSize (248, 10);
setMinimum (0);
setMaximum (0);
connect (this, SIGNAL (sliderMoved (int)),
this, SLOT (seekMs (int)));
hide ();
}
void
PosBar::seekMs (int value)
{
XMMSHandler::getInstance ().xplayback ()->seekMs (value);
}
void
PosBar::setPixmaps (Skin *skin)
{
QPixmap pixmap = skin->getItem (m_bg);
setBackground (pixmap);
setFixedSize (248, pixmap.height ());
if ( !skin->getItem(m_slider_normal).isNull() &&
!skin->getItem(m_slider_pressed).isNull()) {
setSliders (skin->getItem(m_slider_normal),
skin->getItem(m_slider_pressed));
} else {
setSliders (QPixmap (), QPixmap ());
}
update ();
}

41
src/mainwindow/posbar.h Normal file
View file

@ -0,0 +1,41 @@
/**
* 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 __SLIDER_H__
#define __SLIDER_H__
#include "pixmapslider.h"
class Skin;
class PosBar : public PixmapSlider
{
Q_OBJECT
public:
PosBar (QWidget *parent, uint bg, uint bnormal, uint bpressed);
~PosBar () { }
public slots:
void setPixmaps (Skin *skin);
void seekMs (int);
private:
uint m_slider_normal;
uint m_slider_pressed;
uint m_bg;
};
#endif