From fb264e8d0ec00e506a785baa480ad57972893255 Mon Sep 17 00:00:00 2001 From: Thomas Frauendorfer Date: Sat, 17 May 2008 06:08:05 +0200 Subject: [PATCH] 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 --- TODO | 5 +- src/NumberDisplay.cpp | 79 ------------ src/NumberDisplay.h | 49 -------- src/Skin.cpp | 13 +- src/Skin.h | 6 +- src/TimeDisplay.cpp | 118 ------------------ src/mainwindow/maindisplay.cpp | 14 ++- src/mainwindow/mainwindow.pri | 6 +- src/mainwindow/timedisplay.cpp | 72 +++++++++++ .../timedisplay.h} | 30 +++-- src/src.pri | 4 - 11 files changed, 119 insertions(+), 277 deletions(-) delete mode 100644 src/NumberDisplay.cpp delete mode 100644 src/NumberDisplay.h delete mode 100644 src/TimeDisplay.cpp create mode 100644 src/mainwindow/timedisplay.cpp rename src/{TimeDisplay.h => mainwindow/timedisplay.h} (67%) diff --git a/TODO b/TODO index 8191694..bd5761b 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,9 @@ Todo: +General: + + Feature Requests and Bugs on tracker + + Mainwindow - + Balancebackgrounds are wrong - + enable repeat button + enable random play (will have to wait for a randomplay service client) * Playlist + Make displayed Information configurable diff --git a/src/NumberDisplay.cpp b/src/NumberDisplay.cpp deleted file mode 100644 index 722022c..0000000 --- a/src/NumberDisplay.cpp +++ /dev/null @@ -1,79 +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 "NumberDisplay.h" - -#include "TimeDisplay.h" -#include "Skin.h" - -#include - -NumberDisplay::NumberDisplay (QWidget *parent, TimeDisplay *td,uint w, uint startpx) : PixWidget (parent) -{ - m_td = td; - m_w = w; - m_startpx = startpx; - - m_pixmap = QPixmap (m_w, 13); - - setMinimumSize (m_w, 13); - setMaximumSize (m_w, 13); - - setNumber (0,0); -} - -void -NumberDisplay::setPixmaps (Skin *skin) -{ - QBrush b (skin->getNumber (10)); - - QPainter paint; - paint.begin (&m_pixmap); - paint.fillRect (m_pixmap.rect (), b); - paint.drawPixmap (m_startpx, 0, skin->getNumber (m_n1)); - paint.drawPixmap (m_startpx+12, 0, skin->getNumber (m_n2)); - paint.end(); - - update (); -} - -void -NumberDisplay::setNumber (uint n1, uint n2) -{ - if (m_n1 != n1 || m_n2 != n2) { - Skin *skin = Skin::getInstance (); - - m_n1 = n1; - m_n2 = n2; - - setPixmaps (skin); - } -} - -NumberDisplay::~NumberDisplay () -{ -} -void -NumberDisplay::mousePressEvent (QMouseEvent *event) -{ -} -void -NumberDisplay::mouseReleaseEvent (QMouseEvent *event) -{ -// TimeDisplay *td = dynamic_cast(parent()); - emit clicked(); - m_td->drawMinus (); -} - diff --git a/src/NumberDisplay.h b/src/NumberDisplay.h deleted file mode 100644 index c27a336..0000000 --- a/src/NumberDisplay.h +++ /dev/null @@ -1,49 +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 __NUMBERDISPLAY_H__ -#define __NUMBERDISPLAY_H__ - -class TimeDisplay; - -#include "PixWidget.h" - -class NumberDisplay : public PixWidget -{ - Q_OBJECT - public: - NumberDisplay (QWidget *parent, TimeDisplay *td, uint, uint); - ~NumberDisplay (); - - void setNumber (uint, uint); - - public slots: - void setPixmaps (Skin *skin); - signals: - void clicked(void); - - protected: - void mousePressEvent (QMouseEvent *event); - void mouseReleaseEvent (QMouseEvent *event); - int m_w; - int m_startpx; - - TimeDisplay *m_td; - uint m_n1; - uint m_n2; -}; - - -#endif diff --git a/src/Skin.cpp b/src/Skin.cpp index f39a9fe..788aea5 100644 --- a/src/Skin.cpp +++ b/src/Skin.cpp @@ -725,7 +725,7 @@ Skin::BuildSliders (void) void Skin::BuildNumbers (void) { - uint num = 12; + int num = 12; QPixmap *img = getPixmap("nums_ex"); if (!img) { @@ -735,9 +735,18 @@ Skin::BuildNumbers (void) if(img) { - for (uint i = 0; i < num; i++) { + for (int i = 0; i < num; i++) { m_numbers[i] = img->copy (i*9, 0, 9, qMin (13, img->height ())); } + if (num < 12) { + // We do not yet have a '-' Symbol, so we create one + // from the '2' character and the blank as background + QPixmap pix = m_numbers[10].copy (); + QRect r (3, 6, 3, 1); + QPainter painter (&pix); + painter.drawPixmap (r, m_numbers[2], r); + m_numbers[11] = pix; + } delete img; } else diff --git a/src/Skin.h b/src/Skin.h index 4b6a10a..49f19f4 100644 --- a/src/Skin.h +++ b/src/Skin.h @@ -27,7 +27,8 @@ class QDir; -typedef QList QPixmapList; +typedef QList QPixmapList; +typedef QMap PixmapMap; class Skin : public QObject { @@ -43,6 +44,7 @@ class Skin : public QObject const QIcon getIcon (uint item) const { return m_icons.value(item); }; const QPixmapList getBackgrounds (uint item) const { return m_backgrounds.value(item); }; + const PixmapMap getNumbers () const { return m_numbers; } const QPixmap getItem (uint part) const { return m_items[part]; } const QPixmap getPls (uint part) const { return m_playlist[part]; } @@ -255,9 +257,9 @@ class Skin : public QObject QMap m_icons; QMap m_backgrounds; + QMap m_numbers; QMap m_items; QMap m_letterMap; - QMap m_numbers; QMap m_playlist; QMap m_pledit_txt; diff --git a/src/TimeDisplay.cpp b/src/TimeDisplay.cpp deleted file mode 100644 index f0c0cb7..0000000 --- a/src/TimeDisplay.cpp +++ /dev/null @@ -1,118 +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 "XMMSHandler.h" - -#include "mainwindow.h" -#include "maindisplay.h" -#include "TimeDisplay.h" -#include "NumberDisplay.h" -#include "Skin.h" - -#include - -TimeDisplay::TimeDisplay (QWidget *parent, int time) : PixWidget (parent) -{ - uint w = 12;//+78; - - m_w = w; - - m_pixmap = QPixmap (m_w, 13); - - setMinimumSize (m_w, 13); - setMaximumSize (m_w, 13); - move (37, 26); - - //FIXME: let this be the parent -/* XXX: colon disappear, how make transparent? - m_number_min = new NumberDisplay (this, 24, 0); - m_number_min->move (10, 0); - m_number_sec = new NumberDisplay (this, 24, 0); - m_number_sec->move (78-37, 0); -*/ - - m_number_min = new NumberDisplay (parent, this,24, 0); - m_number_min->move (37+10, 26); - m_number_sec = new NumberDisplay (parent, this,24, 0); - m_number_sec->move (78, 26); - - connect (m_number_min, SIGNAL(clicked()), parent, SLOT(toggleTime())); - connect (m_number_sec, SIGNAL(clicked()), parent, SLOT(toggleTime())); -} -void TimeDisplay::setPixmaps (Skin *skin) -{ - drawMinus(); - m_number_min->setPixmaps (skin); - m_number_sec->setPixmaps (skin); -} -TimeDisplay::~TimeDisplay () -{ -} -void TimeDisplay::setTime (int time) -{ - if (m_time == time) return; - m_time = time; - - uint showtime = abs(time); - uint sec, min; - - sec = (showtime / 1000) % 60; - min = (showtime / 1000) / 60; - - m_number_min->setNumber (min / 10, min % 10); - m_number_sec->setNumber (sec / 10, sec % 10); - - drawMinus (); -} -void -TimeDisplay::drawMinus () -{ - Skin *skin = Skin::getInstance (); - - // Draw background - QBrush b (skin->getNumber (10)); - - QPainter paint; - paint.begin (&m_pixmap); - paint.fillRect (m_pixmap.rect (), b); - MainDisplay *md = dynamic_cast(parent()); - - if (md->getMW()->isTimemodeReverse()) {// draw a minus sign - if (skin->getNumberSize() < 12) { // Skin hasn't got any, draw a line in correct color. - QByteArray a = skin->getPLeditValue("normal"); - QColor c; - c.setNamedColor(a); - QPen pen(c); - paint.setPen(pen); - paint.drawLine (3,6,8,6); - } else { - paint.drawPixmap (0, 0, skin->getNumber (11)); - } - } - paint.end(); - - update (); -} -void -TimeDisplay::mousePressEvent (QMouseEvent *event) -{ -} -void -TimeDisplay::mouseReleaseEvent (QMouseEvent *event) -{ - emit clicked(); - drawMinus (); -} - diff --git a/src/mainwindow/maindisplay.cpp b/src/mainwindow/maindisplay.cpp index 708e846..de89390 100644 --- a/src/mainwindow/maindisplay.cpp +++ b/src/mainwindow/maindisplay.cpp @@ -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); diff --git a/src/mainwindow/mainwindow.pri b/src/mainwindow/mainwindow.pri index 29b741b..ee928da 100644 --- a/src/mainwindow/mainwindow.pri +++ b/src/mainwindow/mainwindow.pri @@ -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 diff --git a/src/mainwindow/timedisplay.cpp b/src/mainwindow/timedisplay.cpp new file mode 100644 index 0000000..03355e6 --- /dev/null +++ b/src/mainwindow/timedisplay.cpp @@ -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 +#include +#include + + +//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(); +} + diff --git a/src/TimeDisplay.h b/src/mainwindow/timedisplay.h similarity index 67% rename from src/TimeDisplay.h rename to src/mainwindow/timedisplay.h index 8548ffe..866d608 100644 --- a/src/TimeDisplay.h +++ b/src/mainwindow/timedisplay.h @@ -16,32 +16,36 @@ #ifndef __TIMEDISPLAY_H__ #define __TIMEDISPLAY_H__ -class TimeDisplay; +#include +#include -#include "PixWidget.h" -#include "NumberDisplay.h" +class QMouseEvent; +class QPaintEvent; +class QPixmap; -class TimeDisplay : public PixWidget +typedef QMap PixmapMap; + +class TimeDisplay : public QWidget { Q_OBJECT public: - TimeDisplay (QWidget *parent, int time); - ~TimeDisplay (); + TimeDisplay (QWidget *parent); + ~TimeDisplay () {}; void setTime (int); - void drawMinus(); + public slots: - void setPixmaps (Skin *skin); + void setPixmaps (const PixmapMap &p) {m_pixmaps = p;} + signals: void clicked(void); protected: - void mousePressEvent (QMouseEvent *event); + void mousePressEvent (QMouseEvent *event) {}; void mouseReleaseEvent (QMouseEvent *event); - int m_time; - NumberDisplay *m_number_min; - NumberDisplay *m_number_sec; + void paintEvent (QPaintEvent *event); - uint m_w; + int m_time; + PixmapMap m_pixmaps; }; #endif diff --git a/src/src.pri b/src/src.pri index e7d6951..14cc0cc 100644 --- a/src/src.pri +++ b/src/src.pri @@ -9,8 +9,6 @@ HEADERS += PixWidget.h \ Display.h \ TitleBar.h \ TextBar.h \ - NumberDisplay.h \ - TimeDisplay.h \ XMMSHandler.h \ SmallNumberDisplay.h \ SkinChooser.h \ @@ -26,8 +24,6 @@ SOURCES += main.cpp \ Display.cpp \ TitleBar.cpp \ TextBar.cpp \ - NumberDisplay.cpp \ - TimeDisplay.cpp \ XMMSHandler.cpp \ SmallNumberDisplay.cpp \ SkinChooser.cpp \