diff --git a/MainDisplay.cpp b/MainDisplay.cpp index fabf468..26ff130 100644 --- a/MainDisplay.cpp +++ b/MainDisplay.cpp @@ -22,11 +22,8 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent) m_text = new TextScroller (this, 154, 15, "main"); m_text->move (109, 23); - m_number = new NumberDisplay (this, 33, 11); - m_number->move (37, 26); - - m_number2 = new NumberDisplay (this, 24, 0); - m_number2->move (78, 26); + m_time = new TimeDisplay(this, 0); + connect (m_time, SIGNAL(clicked()), this, SLOT(toggleTime())); m_kbps = new SmallNumberDisplay (this, 15); m_kbps->move (111, 43); @@ -76,8 +73,7 @@ void MainDisplay::setStatus (uint status) { if (status == XMMS_PLAYBACK_STATUS_STOP) { - m_number->setNumber (0, 0); - m_number2->setNumber (0, 0); + m_time->setTime(0); m_slider->setPos (0); m_slider->hideBar (true); } @@ -86,13 +82,14 @@ MainDisplay::setStatus (uint status) void MainDisplay::setPlaytime (uint time) { - uint sec, min; - - sec = (time / 1000) % 60; - min = (time / 1000) / 60; - - m_number->setNumber (min / 10, min % 10); - m_number2->setNumber (sec / 10, sec % 10); + uint showtime; + if (m_mw->isTimemodeReverse()) { + uint maxtime = m_slider->getMax(); + showtime = -(maxtime - time); + } else { + showtime = time; + } + m_time->setTime (showtime); // update slider m_slider->setPos (time); @@ -151,6 +148,11 @@ MainDisplay::togglePL (void) { m_mw->togglePL(false); } +void +MainDisplay::toggleTime (void) +{ + m_mw->setTimemodeReverse (!m_mw->isTimemodeReverse()); +} void MainDisplay::SetupPushButtons (void) diff --git a/MainDisplay.h b/MainDisplay.h index 2d39aa3..c6a4b0c 100644 --- a/MainDisplay.h +++ b/MainDisplay.h @@ -19,6 +19,7 @@ class MainDisplay; #include "Button.h" #include "TextBar.h" #include "NumberDisplay.h" +#include "TimeDisplay.h" #include "SmallNumberDisplay.h" #include "StereoMono.h" #include "Slider.h" @@ -35,8 +36,7 @@ class MainDisplay : public SkinDisplay ToggleButton *GetPls() {return m_pls;}; TextScroller *m_text; - NumberDisplay *m_number; - NumberDisplay *m_number2; + TimeDisplay *m_time; SmallNumberDisplay *m_kbps; SmallNumberDisplay *m_khz; @@ -46,6 +46,7 @@ class MainDisplay : public SkinDisplay VolumeSlider *m_vslider; PlayStatus *m_playstatus; + MainWindow *getMW(void) { return m_mw; } public slots: void setPixmaps(Skin *skin); @@ -53,6 +54,7 @@ class MainDisplay : public SkinDisplay void setPlaytime (uint time); void setMediainfo (const QHash &); void togglePL(void); + void toggleTime(void); protected: void SetupPushButtons (void); diff --git a/MainWindow.h b/MainWindow.h index e3ad267..eb6f496 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -34,6 +34,8 @@ class MainWindow : public QMainWindow void raisePL (void) { m_playlistwin->raise (); } void moveEvent (QMoveEvent *event); void togglePL (bool UpdateButton); + bool isTimemodeReverse(void) { QSettings s; return s.value("MainWindow/timemodereverse").toBool(); } + void setTimemodeReverse(bool b) { QSettings s; return s.setValue("MainWindow/timemodereverse",b); } public slots: void switchDisplay (); diff --git a/NumberDisplay.cpp b/NumberDisplay.cpp index 906b38f..3b1cdff 100644 --- a/NumberDisplay.cpp +++ b/NumberDisplay.cpp @@ -46,3 +46,13 @@ NumberDisplay::setNumber (uint n1, uint n2) NumberDisplay::~NumberDisplay () { } +void +NumberDisplay::mousePressEvent (QMouseEvent *event) +{ +} +void +NumberDisplay::mouseReleaseEvent (QMouseEvent *event) +{ + emit clicked(); +} + diff --git a/NumberDisplay.h b/NumberDisplay.h index 65aa74e..c611932 100644 --- a/NumberDisplay.h +++ b/NumberDisplay.h @@ -14,8 +14,12 @@ class NumberDisplay : public PixWidget 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; diff --git a/Skin.h b/Skin.h index 8f79a53..61132c7 100644 --- a/Skin.h +++ b/Skin.h @@ -24,6 +24,7 @@ class Skin : public QWidget const QPixmap getBal (uint p) const { return m_balance[p]; } const QPixmap getLetter (uint c) const { return m_letterMap[c]; } const QPixmap getNumber (uint c) const { return m_numbers[c]; } + uint getNumberSize () { return m_numbers.size(); } const QByteArray getPLeditValue (QByteArray c) const { return m_pledit_txt[c]; } const bool getVolBtn(void) const { return m_volbtn; } const bool getBalBtn(void) const { return m_balbtn; } diff --git a/Slider.h b/Slider.h index 3d4fe63..005381e 100644 --- a/Slider.h +++ b/Slider.h @@ -38,6 +38,7 @@ class Slider : public PixWidget void requestPos (float value); void setMax (uint max) { m_max = max; } + uint getMax () { return m_max; } void hideBar (bool b); bool getVertical () { return m_vertical; } diff --git a/TimeDisplay.cpp b/TimeDisplay.cpp new file mode 100644 index 0000000..f5f70fb --- /dev/null +++ b/TimeDisplay.cpp @@ -0,0 +1,99 @@ +#include "MainDisplay.h" +#include "TimeDisplay.h" +#include "NumberDisplay.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, 24, 0); + m_number_min->move (37+10, 26); + m_number_sec = new NumberDisplay (parent, 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 (Qt::TexturePattern); + b.setTexture (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(); +} + diff --git a/TimeDisplay.h b/TimeDisplay.h new file mode 100644 index 0000000..6099a19 --- /dev/null +++ b/TimeDisplay.h @@ -0,0 +1,30 @@ +#ifndef __TIMEDISPLAY_H__ +#define __TIMEDISPLAY_H__ + +#include "PixWidget.h" +#include "NumberDisplay.h" + +class TimeDisplay : public PixWidget +{ + Q_OBJECT + public: + TimeDisplay (QWidget *parent, int time); + ~TimeDisplay (); + void setTime (int); + public slots: + void setPixmaps (Skin *skin); + signals: + void clicked(void); + + protected: + void mousePressEvent (QMouseEvent *event); + void mouseReleaseEvent (QMouseEvent *event); + void drawMinus(); + int m_time; + NumberDisplay *m_number_min; + NumberDisplay *m_number_sec; + + uint m_w; +}; + +#endif diff --git a/promoe.pro b/promoe.pro index 834bd43..88276eb 100644 --- a/promoe.pro +++ b/promoe.pro @@ -8,6 +8,7 @@ SOURCES += XmmsQT4.cpp \ Button.cpp \ TextBar.cpp \ NumberDisplay.cpp \ + TimeDisplay.cpp \ XMMSHandler.cpp \ SmallNumberDisplay.cpp \ StereoMono.cpp \ @@ -37,6 +38,7 @@ HEADERS += XmmsQT4.h \ Button.h \ TextBar.h \ NumberDisplay.h \ + TimeDisplay.h \ XMMSHandler.h \ SmallNumberDisplay.h \ StereoMono.h \ @@ -68,7 +70,7 @@ QMAKE_LFLAGS += -L$$[QT_INSTALL_PLUGINS]/imageformats CONFIG += link_pkgconfig ;QMAKE_CXXFLAGS += -g -CONFIG += debug warn_on +;CONFIG += debug warn_on QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-parameter PKGCONFIG += xmms2-client xmms2-client-cpp sigc++-2.0