OTHER: Rewrote TimeDisplay

Positions and sizes of the numbers are now correct
NumberDisplay now unused -> removed
renamed file to lowercase and moved to subdir mainwindow
This commit is contained in:
Thomas Frauendorfer 2008-05-17 06:08:05 +02:00
parent bece172e92
commit fb264e8d0e
11 changed files with 119 additions and 277 deletions

View file

@ -26,8 +26,7 @@
#include "pixmapslider.h"
#include "TitleBar.h"
#include "TextBar.h"
#include "NumberDisplay.h"
#include "TimeDisplay.h"
#include "timedisplay.h"
#include "Skin.h"
#include "SmallNumberDisplay.h"
#include "stereomono.h"
@ -59,8 +58,8 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent)
m_text = new TextScroller (this, 154, 10, "main");
m_text->move (112, 25);
m_time = new TimeDisplay(this, 0);
// m_time->move (36, 26);
m_time = new TimeDisplay(this);
m_time->move (36, 26);
connect (m_time, SIGNAL(clicked()), this, SLOT(toggleTime()));
m_kbps = new SmallNumberDisplay (this, 15);
@ -157,6 +156,9 @@ MainDisplay::setPixmaps (Skin *skin)
m_bslider->setBackground (skin->getBackgrounds (Skin::SLIDER_BALANCEBAR_BGS));
m_bslider->setSliders (skin->getItem (Skin::BALANCE_BTN_0),
skin->getItem (Skin::BALANCE_BTN_1));
/* update some other widgets */
m_time->setPixmaps (skin->getNumbers ());
}
void
@ -178,9 +180,9 @@ MainDisplay::setPlaytime (uint32_t time)
uint32_t showtime;
if (m_mw->isTimemodeReverse()) {
uint maxtime = m_posbar->maximum ();
showtime = -(maxtime - time);
showtime = (time/1000 - maxtime/1000);
} else {
showtime = time;
showtime = time/1000;
}
m_time->setTime (showtime);

View file

@ -4,7 +4,8 @@ HEADERS += clutterbar.h \
playstatus.h \
posbar.h \
shadeddisplay.h \
stereomono.h
stereomono.h \
timedisplay.h
SOURCES += clutterbar.cpp \
mainwindow.cpp \
@ -12,7 +13,8 @@ SOURCES += clutterbar.cpp \
playstatus.cpp \
posbar.cpp \
shadeddisplay.cpp \
stereomono.cpp
stereomono.cpp \
timedisplay.cpp
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD

View file

@ -0,0 +1,72 @@
/**
* 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) : PixWidget (parent)
TimeDisplay::TimeDisplay (QWidget *parent) : QWidget (parent)
{
setFixedSize (63, 13);
}
void TimeDisplay::setTime (int time)
{
if (m_time == time) return;
m_time = time;
update ();
}
void
TimeDisplay::paintEvent (QPaintEvent *event)
{
if (m_pixmaps.size () < 11) {
qDebug ("too small");
return;
}
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);
// draw minutes
uint min = showtime / 60;
paint.drawPixmap (12, 0, m_pixmaps[min/10]);
paint.drawPixmap (24, 0, m_pixmaps[min%10]);
// draw seconds
uint sec = showtime % 60;
paint.drawPixmap (42, 0, m_pixmaps[sec/10]);
paint.drawPixmap (54, 0, m_pixmaps[sec%10]);
paint.end ();
}
void
TimeDisplay::mouseReleaseEvent (QMouseEvent *event)
{
emit clicked();
}

View file

@ -0,0 +1,51 @@
/**
* 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;
class TimeDisplay : public QWidget
{
Q_OBJECT
public:
TimeDisplay (QWidget *parent);
~TimeDisplay () {};
void setTime (int);
public slots:
void setPixmaps (const PixmapMap &p) {m_pixmaps = p;}
signals:
void clicked(void);
protected:
void mousePressEvent (QMouseEvent *event) {};
void mouseReleaseEvent (QMouseEvent *event);
void paintEvent (QPaintEvent *event);
int m_time;
PixmapMap m_pixmaps;
};
#endif