OTHER: Replaced code for current_id handling

Now the current_id changed broadcast is handled in xclientcache, the now
unused code from XMMSHandler has been removed
This commit is contained in:
Thomas Frauendorfer 2008-07-12 06:12:20 +02:00
parent 058e2d0987
commit 20cfdad68d
11 changed files with 82 additions and 111 deletions

View file

@ -126,6 +126,8 @@ TextScroller::setText (QString text)
} else {
drawBitmapFont (text);
}
m_x_off = 0;
m_x2_off = 0;
update ();
}
@ -148,6 +150,7 @@ TextScroller::drawBitmapFont (QString text)
}
} else {
m_pixmap = QPixmap (m_w, m_h);
m_timer->stop ();
}
QByteArray temp2 = temp.toLatin1();
const char *t = temp2.data();
@ -201,6 +204,7 @@ TextScroller::drawQtFont (QString text)
} else {
m_pixmap = QPixmap (m_w, m_h);
m_timer->stop ();
}
QPainter paint;

View file

@ -61,62 +61,18 @@ XMMSHandler::connect_handler (const char *ipcpath, const bool &sync, QWidget *pa
connect(ipcpath, sync, parent);
using Xmms::bind;
m_client->medialib.broadcastEntryChanged () (
bind (&XMMSHandler::medialib_entry_changed, this));
m_client->playback.currentID () (
bind (&XMMSHandler::playback_current_id, this));
m_client->playback.broadcastCurrentID () (
bind (&XMMSHandler::playback_current_id, this));
m_client->playback.broadcastVolumeChanged () (
bind (&XMMSHandler::volume_changed, this));
return true;
}
Xmms::Client *
XMMSHandler::getClient ()
{
return m_client;
}
bool
XMMSHandler::medialib_entry_changed (const unsigned int &id)
{
if (id > 0) {
requestMediainfo (id);
}
return true;
}
void
XMMSHandler::playlistAddURL (const QString &s)
{
m_client->playlist.addUrl (s.toAscii ().constData ()) ();
}
void
XMMSHandler::requestMediainfo (uint id)
{
m_client->medialib.getInfo (id) (
Xmms::bind (&XMMSHandler::medialib_info, this));
}
bool
XMMSHandler::playback_current_id (const unsigned int &id)
{
m_currentid = id;
if (id > 0) {
requestMediainfo (id);
}
return true;
}
void
XMMSHandler::DictToQHash (const std::string &key,
const Xmms::Dict::Variant &value,
@ -176,18 +132,6 @@ XMMSHandler::medialib_select (XMMSResultDictList *res)
}
*/
bool
XMMSHandler::medialib_info (const Xmms::PropDict &propdict)
{
unsigned int id = propdict.get<int32_t>("id");
emit mediainfoChanged (id, propdict);
if (id == m_currentid) {
emit currentSong (propdict);
}
return false;
}
bool
XMMSHandler::volume_error (const std::string &error)
{

View file

@ -36,12 +36,8 @@ class XMMSHandler : public XClient {
bool connect_handler (const char *ipcpath = NULL, const bool &sync = false, QWidget *parent = NULL);
bool playback_current_id (const unsigned int &id);
bool medialib_info (const Xmms::PropDict &propdict);
bool medialib_entry_changed (const unsigned int &id);
bool volume_changed (const Xmms::Dict &levels);
void requestMediainfo (uint id);
void playlistAddURL (const QString& url);
/*
@ -60,7 +56,7 @@ class XMMSHandler : public XClient {
void updateSettings () { emit settingsSaved (); }
Xmms::Client *getClient ();
Xmms::Client *getClient () { return m_client; }
PlaylistModel *getPlaylistModel () {return m_playlist_model; }
@ -69,9 +65,6 @@ class XMMSHandler : public XClient {
signals:
void settingsSaved ();
void mediainfoChanged (uint, const Xmms::PropDict &);
void currentSong (const Xmms::PropDict &);
void playlistChanged (const Xmms::Dict &);
/*
void medialibResponse (uint, const QList<QHash<QString, QString> > &);
*/
@ -91,7 +84,6 @@ class XMMSHandler : public XClient {
XmmsQT4 *m_qt4;
PlaylistModel *m_playlist_model;
unsigned int m_currentid;
bool m_masterchan;
};

View file

@ -104,8 +104,8 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent)
m_bslider->resize (skin->getSize (Skin::SLIDER_BALANCEBAR_BGS));
m_bslider->move (skin->getPos (Skin::SLIDER_BALANCEBAR_BGS));
connect (&client, SIGNAL(currentSong (const Xmms::PropDict &)),
this, SLOT(setMediainfo (const Xmms::PropDict &)));
connect (client.cache (), SIGNAL (activeEntryChanged (QVariantHash)),
this, SLOT (setMediainfo (const QVariantHash)));
connect (client.xplayback (), SIGNAL(playbackStatusChanged(Xmms::Playback::Status)),
this, SLOT(setStatus(Xmms::Playback::Status)));
connect (client.cache () , SIGNAL (playtime (uint32_t)),
@ -221,46 +221,37 @@ MainDisplay::setPlaytime (uint32_t time)
}
void
MainDisplay::setMediainfo (const Xmms::PropDict &info)
MainDisplay::setMediainfo (const QVariantHash info)
{
QString n;
if (info.contains ("title")) {
if (info.contains ("artist")) {
n = QString::fromUtf8 (info.get<std::string> ("artist").c_str ()) + " - ";
n = info["artist"].toString () + " - ";
}
if (info.contains ("album")) {
n += QString::fromUtf8 (info.get<std::string> ("album").c_str ()) + " - ";
n += info["album"].toString () + " - ";
}
n += QString::fromUtf8 (info.get<std::string> ("title").c_str ());
n += info["title"].toString ();
} else if (info.contains ("channel")) {
n = QString::fromUtf8 (info.get<std::string> ("channel").c_str ()) + " - " +
QString::fromUtf8 (info.get<std::string> ("title").c_str ());
n = info["channel"].toString () + " - " + info["title"].toString ();
} else {
n = QString::fromUtf8 (info.get<std::string> ("url").c_str ());
n = info["url"].toString ();
n = n.section ("/", -1);
}
m_text->setText (n);
if (info.contains ("bitrate")) {
m_kbps->setValue (info.get<int32_t> ("bitrate")/1000);
} else {
m_kbps->setValue (0);
}
if (info.contains ("samplerate")) {
m_khz->setValue (info.get<int32_t> ("samplerate")/1000);
} else {
m_khz->setValue(0);
}
m_kbps->setValue (info.value ("bitrate", 0).toInt ()/1000);
m_khz->setValue (info.value ("samplerate", 0).toInt ()/1000);
if (info.contains ("channels") &&
info.get<int32_t> ("channels") > 1) {
info["channels"].toInt () > 1) {
m_stereo->setStereoMono (1, 0);
} else {
m_stereo->setStereoMono (0, 1);
}
if (info.contains ("duration")) {
m_posbar->setMaximum (info.get<int32_t> ("duration"));
m_posbar->setMaximum (info["duration"].toInt ());
m_posbar->show ();
} else {
m_posbar->setMaximum (0);

View file

@ -29,9 +29,13 @@ class MainDisplay;
#include <QHash>
#include <QBrush>
#include <QPalette>
#include <QHash>
#include <QVariant>
#include "Display.h"
typedef QHash<QString, QVariant> QVariantHash;
class PixmapButton;
class PixmapNumberDisplay;
class PixmapSlider;
@ -67,7 +71,8 @@ class MainDisplay : public SkinDisplay
void setPixmaps(Skin *skin);
void setStatus (Xmms::Playback::Status status);
void setPlaytime (uint32_t time);
void setMediainfo (const Xmms::PropDict &);
// void setMediainfo (const Xmms::PropDict &);
void setMediainfo (const QVariantHash);
void updateVolume (uint volume);
void setVolume (int volume);

View file

@ -79,8 +79,8 @@ ShadedDisplay::ShadedDisplay (QWidget *parent) : SkinDisplay (parent)
this, SLOT(setStatus(Xmms::Playback::Status)));
connect (client.cache (), SIGNAL (playtime (uint32_t)),
this, SLOT ( setPlaytime(uint32_t)));
connect (&client, SIGNAL(currentSong (const Xmms::PropDict &)),
this, SLOT(setMediainfo (const Xmms::PropDict &)));
connect (client.cache (), SIGNAL (activeEntryChanged (QVariantHash)),
this, SLOT (setMediainfo (QVariantHash)));
}
void
@ -90,22 +90,20 @@ ShadedDisplay::setPixmaps (Skin *skin)
}
void
ShadedDisplay::setMediainfo (const Xmms::PropDict &info)
ShadedDisplay::setMediainfo (QVariantHash info)
{
QString n;
if (info.contains ("artist") && info.contains ("album") &&
info.contains ("title")) {
n = QString::fromUtf8 (info.get<std::string> ("artist").c_str ())
+ " - " +
QString::fromUtf8 (info.get<std::string> ("album").c_str ())
+ " - " +
QString::fromUtf8 (info.get<std::string> ("title").c_str ());
n = info["artist"].toString () + " - "
+ info["album"].toString () + " - "
+ info["title"].toString ();
} else {
n = QString::fromUtf8 (info.get<std::string> ("url").c_str ());
n = info["url"].toString ();
}
if (info.contains ("duration")) {
m_duration = (info.get<int32_t> ("duration"));
m_duration = info["duration"].toInt ();
} else {
m_duration = 0;
}

View file

@ -20,6 +20,10 @@ class ShadedDisplay;
#include <xmmsclient/xmmsclient++.h>
#include "Display.h"
#include <QHash>
#include <QVariant>
typedef QHash<QString, QVariant> QVariantHash;
class MainWindow;
class Skin;
@ -53,7 +57,7 @@ class ShadedDisplay : public SkinDisplay
public slots:
void setStatus (Xmms::Playback::Status status);
void setPlaytime (uint32_t time);
void setMediainfo (const Xmms::PropDict &info);
void setMediainfo (QVariantHash info);
void setPixmaps (Skin *skin);
};

View file

@ -15,6 +15,7 @@
#include "XMMSHandler.h"
#include <xmmsclient/xmmsclient++.h>
#include "xclientcache.h"
#include "playlistshade.h"
#include "playlistwindow.h"
@ -45,8 +46,8 @@ PlaylistShade::PlaylistShade (PlaylistWindow *parent) : QWidget (parent)
connect (m_unshadebtn, SIGNAL (clicked ()),
parent, SLOT (switchDisplay ()));
connect (&xmmsh, SIGNAL(currentSong (const Xmms::PropDict &)),
this, SLOT(setMediainfo (const Xmms::PropDict &)));
connect (xmmsh.cache (), SIGNAL (activeEntryChanged (QVariantHash)),
this, SLOT (setMediainfo (QVariantHash)));
connect (&xmmsh, SIGNAL(settingsSaved ()),
this, SLOT(settingsSaved ()));
@ -65,18 +66,16 @@ PlaylistShade::settingsSaved ()
}
void
PlaylistShade::setMediainfo (const Xmms::PropDict &info)
PlaylistShade::setMediainfo (QVariantHash info)
{
QString n;
if (info.contains ("artist") && info.contains ("album") &&
info.contains ("title")) {
n = QString::fromUtf8 (info.get<std::string> ("artist").c_str ())
+ " - " +
QString::fromUtf8 (info.get<std::string> ("album").c_str ())
+ " - " +
QString::fromUtf8 (info.get<std::string> ("title").c_str ());
n = info["artist"].toString () + " - "
+ info["album"].toString () + " - "
+ info["title"].toString ();
} else {
n = QString::fromUtf8 (info.get<std::string> ("url").c_str ());
n = info["url"].toString ();
}
m_text = (n);

View file

@ -21,6 +21,9 @@
#include <QWidget>
#include <QHash>
#include <QVariant>
typedef QHash<QString, QVariant> QVariantHash;
class QResizeEvent;
class PixmapButton;
@ -39,7 +42,7 @@ class PlaylistShade : public QWidget {
public slots:
void setPixmaps (Skin *skin);
void setMediainfo (const Xmms::PropDict &info);
void setMediainfo (QVariantHash);
void settingsSaved ();
void resizeEvent (QResizeEvent *);