From 46a0fd1b29eab0b04151696bb9bb84f6f937b4f7 Mon Sep 17 00:00:00 2001 From: Tobias Rundstrom Date: Mon, 20 Feb 2006 16:21:35 -0300 Subject: [PATCH] Added PlayStatus widget. --- MainDisplay.cpp | 3 +++ MainDisplay.h | 3 +++ PlayStatus.cpp | 35 +++++++++++++++++++++++++++++++++++ PlayStatus.h | 27 +++++++++++++++++++++++++++ TextBar.cpp | 2 +- XMMSHandler.cpp | 11 +++++++++++ XMMSHandler.h | 1 + promoe.pro | 10 +++++----- 8 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 PlayStatus.cpp create mode 100644 PlayStatus.h diff --git a/MainDisplay.cpp b/MainDisplay.cpp index c5db859..8be3e2f 100644 --- a/MainDisplay.cpp +++ b/MainDisplay.cpp @@ -40,6 +40,9 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent) Skin::POSBAR_BTN_1); m_slider->move (16, 72); + m_playstatus = new PlayStatus (this); + m_playstatus->move (24, 28); + } void diff --git a/MainDisplay.h b/MainDisplay.h index f54b4f9..56abc6f 100644 --- a/MainDisplay.h +++ b/MainDisplay.h @@ -22,6 +22,7 @@ class MainDisplay; #include "SmallNumberDisplay.h" #include "StereoMono.h" #include "Slider.h" +#include "PlayStatus.h" using namespace std; @@ -42,6 +43,8 @@ class MainDisplay : public SkinDisplay StereoMono *m_stereo; Slider *m_slider; + PlayStatus *m_playstatus; + public slots: void setPixmaps(Skin *skin); protected: diff --git a/PlayStatus.cpp b/PlayStatus.cpp new file mode 100644 index 0000000..53f83c6 --- /dev/null +++ b/PlayStatus.cpp @@ -0,0 +1,35 @@ +#include "PlayStatus.h" + +PlayStatus::PlayStatus (QWidget *parent) : PixWidget (parent) +{ + setMinimumSize(11, 9); + setMaximumSize(11, 9); + + m_status = XMMS_PLAYBACK_STATUS_STOP; +} + +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); + + setStatus (m_status); +} + +void +PlayStatus::setStatus (int status) +{ + + if (status == XMMS_PLAYBACK_STATUS_STOP) { + m_pixmap = m_pixmap_stop; + } else if (status == XMMS_PLAYBACK_STATUS_PLAY) { + m_pixmap = m_pixmap_play; + } else if (status == XMMS_PLAYBACK_STATUS_PAUSE) { + m_pixmap = m_pixmap_pause; + } + + update (); +} + diff --git a/PlayStatus.h b/PlayStatus.h new file mode 100644 index 0000000..8e58ae8 --- /dev/null +++ b/PlayStatus.h @@ -0,0 +1,27 @@ +#ifndef __PLAYSTATUS_H__ +#define __PLAYSTATUS_H__ + +#include +#include "PixWidget.h" + +class PlayStatus : public PixWidget +{ + public: + PlayStatus (QWidget *parent); + ~PlayStatus () { } + + void setStatus (int); + + public slots: + void setPixmaps (Skin *skin); + + private: + int m_status; + + QPixmap m_pixmap_stop; + QPixmap m_pixmap_play; + QPixmap m_pixmap_pause; + +}; + +#endif diff --git a/TextBar.cpp b/TextBar.cpp index 6a8179e..c3a152b 100644 --- a/TextBar.cpp +++ b/TextBar.cpp @@ -110,7 +110,7 @@ void TextScroller::drawQtFont (const QString &text) { QFont font(m_skin->getPLeditValue ("font")); - font.setPointSize (6); + font.setPixelSize (9); QFontMetrics fM(font); QRect rect = fM.boundingRect (text); diff --git a/XMMSHandler.cpp b/XMMSHandler.cpp index 74ec78a..3a2584f 100644 --- a/XMMSHandler.cpp +++ b/XMMSHandler.cpp @@ -25,6 +25,17 @@ XMMSHandler::XMMSHandler (MainWindow *mw) : sigc::trackable () r = m_xmmsc->broadcast_playback_current_id (); r->connect (sigc::mem_fun (this, &XMMSHandler::playback_current_id)); + + r = m_xmmsc->broadcast_playback_status (); + r->connect (sigc::mem_fun (this, &XMMSHandler::playback_status)); +} + +void +XMMSHandler::playback_status (XMMSResult *res) +{ + uint i; + res->getValue (&i); + m_mw->getMD ()->m_playstatus->setStatus (i); } void diff --git a/XMMSHandler.h b/XMMSHandler.h index 82b1a1f..fc09516 100644 --- a/XMMSHandler.h +++ b/XMMSHandler.h @@ -18,6 +18,7 @@ class XMMSHandler : public QObject, public sigc::trackable { void playback_playtime (XMMSResult *res); void playback_current_id (XMMSResult *res); void medialib_info (XMMSResult *res); + void playback_status (XMMSResult *res); const XMMSClient *getXMMS () { return m_xmmsc; } diff --git a/promoe.pro b/promoe.pro index 94cdf73..e7ad340 100644 --- a/promoe.pro +++ b/promoe.pro @@ -11,7 +11,8 @@ SOURCES += XmmsQT4.cpp \ XMMSHandler.cpp \ SmallNumberDisplay.cpp \ StereoMono.cpp \ - Slider.cpp + Slider.cpp \ + PlayStatus.cpp HEADERS += XmmsQT4.h \ PixWidget.h \ @@ -26,9 +27,8 @@ HEADERS += XmmsQT4.h \ XMMSHandler.h \ SmallNumberDisplay.h \ StereoMono.h \ - Slider.h + Slider.h \ + PlayStatus.h CONFIG += link_pkgconfig -CONFIG += debug -QMAKE_CFLAGS_WARN_OFF += -Wno-unused-parameter -PKGCONFIG += xmms2-client-cpp sigc++-2.0 +PKGCONFIG += xmms2-client xmms2-client-cpp sigc++-2.0