OTHER: get rid of XMMSHandler and update classes using it

This commit is contained in:
Thomas Frauendorfer 2008-11-04 19:50:28 +01:00
parent 786b745d55
commit 982660510a
33 changed files with 145 additions and 266 deletions

View file

@ -30,6 +30,7 @@
#include "xconfig.h" #include "xconfig.h"
#include "xmmsqt4.h" #include "xmmsqt4.h"
#include "debug.h" #include "debug.h"
#include "playlistmodel.h"
#include "sourcepref.h" #include "sourcepref.h"
@ -71,6 +72,7 @@ XClient::XClient (QObject *parent, const std::string &name) : QObject (parent),
m_config = new XConfig (this); m_config = new XConfig (this);
m_playback = new XPlayback (this); m_playback = new XPlayback (this);
m_collection = new XCollection (this); m_collection = new XCollection (this);
m_active_playlist = new PlaylistModel(this, this, "_active");
m_name = name; m_name = name;
} }

View file

@ -30,6 +30,7 @@ class XClientCache;
class XConfig; class XConfig;
class XPlayback; class XPlayback;
class XCollection; class XCollection;
class PlaylistModel;
#define SOURCEPREF_HACK #define SOURCEPREF_HACK
@ -72,6 +73,10 @@ class XClient : public QObject {
return m_collection; return m_collection;
} }
PlaylistModel *active_playlist () const {
return m_active_playlist;
}
const Xmms::Client *sync () const { const Xmms::Client *sync () const {
return &m_sync; return &m_sync;
}; };
@ -93,6 +98,9 @@ class XClient : public QObject {
const Xmms::Config* config () { if (m_client && m_client->isConnected ()) return &m_client->config; else return NULL; } const Xmms::Config* config () { if (m_client && m_client->isConnected ()) return &m_client->config; else return NULL; }
const Xmms::Stats* stats () { if (m_client && m_client->isConnected ()) return &m_client->stats; else return NULL; } const Xmms::Stats* stats () { if (m_client && m_client->isConnected ()) return &m_client->stats; else return NULL; }
// TODO: remove as soon as it's no longer neede
Xmms::Client *getClient () {return m_client;}
signals: signals:
void gotConnection (XClient *); void gotConnection (XClient *);
void disconnected (XClient *); void disconnected (XClient *);
@ -111,6 +119,7 @@ class XClient : public QObject {
XConfig *m_config; XConfig *m_config;
XPlayback *m_playback; XPlayback *m_playback;
XCollection *m_collection; XCollection *m_collection;
PlaylistModel *m_active_playlist;
bool m_isconnected; bool m_isconnected;
Xmms::Client m_sync; Xmms::Client m_sync;

View file

@ -210,6 +210,19 @@ XCollection::addIdlist (QString name) {
return true; return true;
} }
bool
XCollection::playlistAddUrl (QString url, QString plsname)
{
if (plsname == "") {
plsname = d->m_activePlaylist;
}
m_client->playlist ()->addUrl (url.toStdString (),
plsname.toStdString ());
return true;
}
bool bool
XCollection::playlistAddUrl (QUrl url, QString plsname) XCollection::playlistAddUrl (QUrl url, QString plsname)
{ {

View file

@ -40,6 +40,7 @@ class XCollection : public QObject
// idlist spesific // idlist spesific
bool setActivePlaylist (QString name); bool setActivePlaylist (QString name);
bool addIdlist (QString name); bool addIdlist (QString name);
bool playlistAddUrl (QString url, QString plsname = "");
bool playlistAddUrl (QUrl url, QString plsname = ""); bool playlistAddUrl (QUrl url, QString plsname = "");
bool playlistClear (QString name = ""); bool playlistClear (QString name = "");
bool addPlsFile (QUrl url); bool addPlsFile (QUrl url);

View file

@ -49,6 +49,8 @@ class XPlayback : public QObject {
void seekMs (uint milliseconds); void seekMs (uint milliseconds);
void seekMsRel (int milliseconds); void seekMsRel (int milliseconds);
// Helper to directly connect sliders to this class
void seekMs (int milliseconds) {seekMs ((uint) milliseconds);};
void setVolume (int new_volume); void setVolume (int new_volume);
void setBalance (int new_balance); void setBalance (int new_balance);

View file

@ -13,9 +13,12 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include "XMMSHandler.h"
#include "BrowseModel.h" #include "BrowseModel.h"
#include "BrowseDialog.h" #include "BrowseDialog.h"
#include "xclient.h"
#include "xcollection.h"
#include "application.h"
#include <QDialog> #include <QDialog>
#include <QSettings> #include <QSettings>
@ -169,12 +172,12 @@ BrowseDialog::navigateToPrevious ()
void void
BrowseDialog::setPath (const QModelIndex &index) BrowseDialog::setPath (const QModelIndex &index)
{ {
XMMSHandler &handler = XMMSHandler::getInstance (); XClient *client = App->client ();
BrowseModelItem *item = m_model->itemByIndex (index); BrowseModelItem *item = m_model->itemByIndex (index);
if (item->isDir ()) { if (item->isDir ()) {
m_model->setPath (index); m_model->setPath (index);
} else { } else {
handler.playlistAddURL (item->data("path")); client->xcollection ()->playlistAddUrl (item->data("path"));
} }
} }

View file

@ -13,9 +13,11 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include "XMMSHandler.h" #include "xclient.h"
#include "BrowseModel.h" #include "BrowseModel.h"
#include "application.h"
#include <QAbstractTableModel> #include <QAbstractTableModel>
#include <QString> #include <QString>
#include <QIcon> #include <QIcon>
@ -36,7 +38,7 @@ BrowseModel::BrowseModel (QWidget *parent) : QAbstractTableModel ()
{ {
m_columns.append ("Name"); m_columns.append ("Name");
m_style = parent->style (); m_style = parent->style ();
m_client = XMMSHandler::getInstance ().getClient (); m_client = App->client ()->getClient ();
m_filter_dot = true; m_filter_dot = true;
//list_root (); //list_root ();
} }

View file

@ -63,9 +63,9 @@ ServerBrowserList::connectServer (QListWidgetItem *it)
{ {
ServerBrowserWindow *sw = dynamic_cast<ServerBrowserWindow*> (window ()); ServerBrowserWindow *sw = dynamic_cast<ServerBrowserWindow*> (window ());
XMMSHandler *xmmsh = XMMSHandler::getInstance (); XClient *client = App->client ();
ServerItem *item = dynamic_cast<ServerItem*> (it); ServerItem *item = dynamic_cast<ServerItem*> (it);
if (xmmsh->connect (item->path ().toAscii())) { if (client->connect (item->path ().toAscii())) {
sw->close (); sw->close ();
} }
} }

View file

@ -16,7 +16,7 @@
#ifndef __SERVER_BROWSER_H__ #ifndef __SERVER_BROWSER_H__
#define __SERVER_BROWSER_H__ #define __SERVER_BROWSER_H__
#include "XMMSHandler.h" #include "xclient.h"
#include <QWidget> #include <QWidget>
#include <QListWidget> #include <QListWidget>

View file

@ -1,73 +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 <xmmsclient/xmmsclient++.h>
#include "xmmsqt4.h"
#include "XMMSHandler.h"
#include "playlistmodel.h"
#include <cstdlib>
#include <string>
#include <iostream>
#include <QErrorMessage>
#include <QHash>
XMMSHandler &XMMSHandler::getInstance ()
{
static XMMSHandler singleton(NULL, "Promoe_Main");
return singleton;
}
XMMSHandler::XMMSHandler (QObject *parent, const std::string &name) : XClient (parent, name)
{
connect_handler();
}
bool
XMMSHandler::connect_handler (const char *ipcpath, const bool &sync, QWidget *parent)
{
//TODO must be moved elsewere later
m_playlist_model = new PlaylistModel(NULL, this, "_active");
connect(ipcpath, sync, parent);
return true;
}
void
XMMSHandler::playlistAddURL (const QString &s)
{
m_client->playlist.addUrl (s.toAscii ().constData ()) ();
}
void
XMMSHandler::DictToQHash (const std::string &key,
const Xmms::Dict::Variant &value,
QHash<QString, QString> &hash)
{
if (value.type () == typeid (int32_t)) {
hash.insert (QString::fromLatin1 (key.c_str ()),
QString::number (boost::get< int32_t > (value)));
} else if (value.type () == typeid (uint32_t)) {
hash.insert (QString::fromLatin1 (key.c_str ()),
QString::number (boost::get< uint32_t > (value)));
} else if (value.type () == typeid (std::string)) {
hash.insert (QString::fromLatin1 (key.c_str ()),
QString::fromUtf8 (boost::get< std::string > (value).c_str ()));
}
}

View file

@ -1,61 +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 __XMMS_HANDLER_H__
#define __XMMS_HANDLER_H__
#include <xmmsclient/xmmsclient++.h>
#include "xclient.h"
#include "xmmsqt4.h"
#include <QObject>
#include <QHash>
class PlaylistModel;
class XMMSHandler : public XClient {
Q_OBJECT
public:
static XMMSHandler &getInstance ();
XMMSHandler (QObject *parent, const std::string &name);
~XMMSHandler () {};
bool connect_handler (const char *ipcpath = NULL, const bool &sync = false, QWidget *parent = NULL);
void playlistAddURL (const QString& url);
/*
void medialib_select (XMMSResultDictList *res);
*/
/*
uint medialibQuery (QString);
void medialibQueryAdd (QString q) { delete m_xmmsc->medialib_add_to_playlist (q.toUtf8 ()); }
*/
Xmms::Client *getClient () { return m_client; }
PlaylistModel *getPlaylistModel () {return m_playlist_model; }
private:
void DictToQHash (const std::string &key,
const Xmms::Dict::Variant &value,
QHash<QString, QString> &hash);
PlaylistModel *m_playlist_model;
};
#endif

View file

@ -13,7 +13,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include "XMMSHandler.h" #include "xclient.h"
#include "application.h" #include "application.h"
@ -35,12 +35,11 @@ Application::Application (int &argc, char **argv) : QApplication (argc, argv)
setOrganizationDomain("xmms.org"); setOrganizationDomain("xmms.org");
setApplicationName("Promoe"); setApplicationName("Promoe");
//TODO: Change to XClient sometime later m_xmms2_client = new XClient (this, "Promoe");
XMMSHandler &client = XMMSHandler::getInstance ();
connect (this, SIGNAL (aboutToQuit ()), connect (this, SIGNAL (aboutToQuit ()),
this, SLOT (cleanupHandler ())); this, SLOT (cleanupHandler ()));
connect (&client, SIGNAL(disconnected(XClient *)), connect (m_xmms2_client, SIGNAL(disconnected(XClient *)),
this, SLOT(handleDisconnected ())); this, SLOT(handleDisconnected ()));
QSettings settings; QSettings settings;
@ -65,6 +64,8 @@ Application::Application (int &argc, char **argv) : QApplication (argc, argv)
mw->getEQ ()->setVisible (settings.value ("equalizer/visible", false).toBool ()); mw->getEQ ()->setVisible (settings.value ("equalizer/visible", false).toBool ());
mw->getPL ()->setVisible (settings.value ("playlist/visible", false).toBool ()); mw->getPL ()->setVisible (settings.value ("playlist/visible", false).toBool ());
m_xmms2_client->connect ();
#ifdef HAVE_SERVERBROWSER #ifdef HAVE_SERVERBROWSER
ServerBrowserWindow *browser = new ServerBrowserWindow (mw); ServerBrowserWindow *browser = new ServerBrowserWindow (mw);
browser->show (); browser->show ();
@ -82,7 +83,7 @@ Application::cleanupHandler ()
s.setValue("MainWindow/timemodereverse",m_timemode_reverse); s.setValue("MainWindow/timemodereverse",m_timemode_reverse);
if (s.value ("promoe/quitonclose", false).toBool ()) if (s.value ("promoe/quitonclose", false).toBool ())
XMMSHandler::getInstance ().shutdownServer (); m_xmms2_client->shutdownServer ();
} }
void void

View file

@ -15,6 +15,8 @@
#include <QApplication> #include <QApplication>
class XClient;
class Application; class Application;
#if defined(qApp) #if defined(qApp)
#undef qApp #undef qApp
@ -32,11 +34,15 @@ class Application : public QApplication
public: public:
Application (int &argc, char **argv); Application (int &argc, char **argv);
XClient *client () const {return m_xmms2_client;}
public slots: public slots:
void cleanupHandler (); void cleanupHandler ();
void handleDisconnected (); void handleDisconnected ();
private:
XClient *m_xmms2_client;
// TODO: Search some better place for those methods // TODO: Search some better place for those methods
public: public:
bool isTimemodeReverse(void) {return m_timemode_reverse;} bool isTimemodeReverse(void) {return m_timemode_reverse;}

View file

@ -14,9 +14,8 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
// FIXME: because somewhere something with the includes is wrong, this line // Needed for XMMS_COLLECTION_CHANGED_* defines
// is needed #include <xmmsc/xmmsc_idnumbers.h>
#include "XMMSHandler.h"
#include <QRegExp> #include <QRegExp>
#include <QStringList> #include <QStringList>

View file

@ -13,11 +13,12 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include "XMMSHandler.h" #include "xclient.h"
#include "xconfig.h" #include "xconfig.h"
#include "equalizerwidget.h" #include "equalizerwidget.h"
#include "application.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "pixmapbutton.h" #include "pixmapbutton.h"
#include "pixmapslider.h" #include "pixmapslider.h"
@ -52,8 +53,8 @@ EqualizerSlider::on_self_slider_moved (int value)
EqualizerWidget::EqualizerWidget (QWidget *parent) : QWidget (parent) EqualizerWidget::EqualizerWidget (QWidget *parent) : QWidget (parent)
{ {
Skin *skin = Skin::getInstance (); Skin *skin = Skin::getInstance ();
XMMSHandler &client = XMMSHandler::getInstance (); const XClient *client = App->client ();
m_xconfig = client.xconfig (); m_xconfig = client->xconfig ();
connect (skin, SIGNAL(skinChanged(Skin *)), connect (skin, SIGNAL(skinChanged(Skin *)),
this, SLOT(setPixmaps(Skin *))); this, SLOT(setPixmaps(Skin *)));

View file

@ -13,8 +13,6 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include "XMMSHandler.h"
#include "equalizerwindow.h" #include "equalizerwindow.h"
#include "QWidget" #include "QWidget"

View file

@ -13,8 +13,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <xmmsclient/xmmsclient++.h> #include "xclient.h"
#include "XMMSHandler.h"
#include "xclientcache.h" #include "xclientcache.h"
#include "xplayback.h" #include "xplayback.h"
#include "xconfig.h" #include "xconfig.h"
@ -43,8 +42,8 @@
MainDisplay::MainDisplay (MainWindow *parent) : SkinDisplay(parent) MainDisplay::MainDisplay (MainWindow *parent) : SkinDisplay(parent)
{ {
XMMSHandler &client = XMMSHandler::getInstance (); const XClient *client = App->client ();
m_xconfig = client.xconfig (); m_xconfig = client->xconfig ();
Skin* skin = Skin::getInstance (); Skin* skin = Skin::getInstance ();
connect (skin, SIGNAL (skinChanged (Skin *)), connect (skin, SIGNAL (skinChanged (Skin *)),
@ -56,7 +55,7 @@ MainDisplay::MainDisplay (MainWindow *parent) : SkinDisplay(parent)
m_mw = parent; m_mw = parent;
SetupPushButtons (); SetupPushButtons (client);
SetupToggleButtons (); SetupToggleButtons ();
m_text = new TextScroller (this, 154, 12, "main"); m_text = new TextScroller (this, 154, 12, "main");
@ -90,6 +89,8 @@ MainDisplay::MainDisplay (MainWindow *parent) : SkinDisplay(parent)
Skin::POSBAR_BTN_0, Skin::POSBAR_BTN_0,
Skin::POSBAR_BTN_1); Skin::POSBAR_BTN_1);
m_posbar->move (skin->getPos (Skin::SLIDER_POSBAR_BGS)); m_posbar->move (skin->getPos (Skin::SLIDER_POSBAR_BGS));
connect (m_posbar, SIGNAL (sliderMoved (int)),
client->xplayback (), SLOT (seekMs (int)));
m_playstatus = new PlayStatus (this); m_playstatus = new PlayStatus (this);
m_playstatus->move (24, 28); m_playstatus->move (24, 28);
@ -100,10 +101,10 @@ MainDisplay::MainDisplay (MainWindow *parent) : SkinDisplay(parent)
m_vslider->setSliderOffset (QPoint (0, 1)); m_vslider->setSliderOffset (QPoint (0, 1));
m_vslider->resize (skin->getSize (Skin::SLIDER_VOLUMEBAR_BGS)); m_vslider->resize (skin->getSize (Skin::SLIDER_VOLUMEBAR_BGS));
m_vslider->move (skin->getPos (Skin::SLIDER_VOLUMEBAR_BGS)); m_vslider->move (skin->getPos (Skin::SLIDER_VOLUMEBAR_BGS));
connect (client.xplayback (), SIGNAL (volumeChanged (int)), connect (client->xplayback (), SIGNAL (volumeChanged (int)),
m_vslider, SLOT (setValue (int))); m_vslider, SLOT (setValue (int)));
connect (m_vslider, SIGNAL (sliderMoved (int)), connect (m_vslider, SIGNAL (sliderMoved (int)),
client.xplayback (), SLOT (setVolume (int))); client->xplayback (), SLOT (setVolume (int)));
m_bslider = new PixmapSlider (this); m_bslider = new PixmapSlider (this);
m_bslider->setMinimum (-MAX_BALANCE); m_bslider->setMinimum (-MAX_BALANCE);
@ -111,16 +112,16 @@ MainDisplay::MainDisplay (MainWindow *parent) : SkinDisplay(parent)
m_bslider->setSliderOffset (QPoint (0, 1)); m_bslider->setSliderOffset (QPoint (0, 1));
m_bslider->resize (skin->getSize (Skin::SLIDER_BALANCEBAR_BGS)); m_bslider->resize (skin->getSize (Skin::SLIDER_BALANCEBAR_BGS));
m_bslider->move (skin->getPos (Skin::SLIDER_BALANCEBAR_BGS)); m_bslider->move (skin->getPos (Skin::SLIDER_BALANCEBAR_BGS));
connect (client.xplayback (), SIGNAL (balanceChanged (int)), connect (client->xplayback (), SIGNAL (balanceChanged (int)),
m_bslider, SLOT (setValue (int))); m_bslider, SLOT (setValue (int)));
connect (m_bslider, SIGNAL (sliderMoved (int)), connect (m_bslider, SIGNAL (sliderMoved (int)),
client.xplayback (), SLOT (setBalance (int))); client->xplayback (), SLOT (setBalance (int)));
connect (client.cache (), SIGNAL (activeEntryChanged (QVariantHash)), connect (client->cache (), SIGNAL (activeEntryChanged (QVariantHash)),
this, SLOT (setMediainfo (const QVariantHash))); this, SLOT (setMediainfo (const QVariantHash)));
connect (client.xplayback (), SIGNAL(playbackStatusChanged(Xmms::Playback::Status)), connect (client->xplayback (), SIGNAL(playbackStatusChanged(Xmms::Playback::Status)),
this, SLOT(setStatus(Xmms::Playback::Status))); this, SLOT(setStatus(Xmms::Playback::Status)));
connect (client.cache () , SIGNAL (playtime (uint32_t)), connect (client->cache () , SIGNAL (playtime (uint32_t)),
this, SLOT (setPlaytime (uint32_t))); this, SLOT (setPlaytime (uint32_t)));
setupServerConfig (); setupServerConfig ();
@ -183,6 +184,9 @@ MainDisplay::setStatus (Xmms::Playback::Status status)
m_posbar->setValue (0); m_posbar->setValue (0);
m_posbar->hide (); m_posbar->hide ();
m_stereo->setStereoMono (false, false); m_stereo->setStereoMono (false, false);
//FIXME: workaround, fix by hiding timedisplay in playlist
emit displayTime (0);
} else if (status == Xmms::Playback::PLAYING) { } else if (status == Xmms::Playback::PLAYING) {
m_time->show (); m_time->show ();
m_kbps->show (); m_kbps->show ();
@ -204,7 +208,6 @@ MainDisplay::setPlaytime (uint32_t time)
showtime = time/1000; showtime = time/1000;
} }
emit displayTime (showtime); emit displayTime (showtime);
// m_time->setTime (showtime);
// update slider // update slider
m_posbar->setValue (time); m_posbar->setValue (time);
@ -292,37 +295,36 @@ MainDisplay::SetupToggleButtons (void)
} }
void void
MainDisplay::SetupPushButtons (void) MainDisplay::SetupPushButtons (const XClient* client)
{ {
XMMSHandler &client = XMMSHandler::getInstance ();
Skin *skin = Skin::getInstance (); Skin *skin = Skin::getInstance ();
/* Normal buttons */ /* Normal buttons */
m_prev = new PixmapButton (this); m_prev = new PixmapButton (this);
m_prev->resize (skin->getSize (Skin::BUTTON_MW_PREV)); m_prev->resize (skin->getSize (Skin::BUTTON_MW_PREV));
m_prev->move (skin->getPos (Skin::BUTTON_MW_PREV)); m_prev->move (skin->getPos (Skin::BUTTON_MW_PREV));
connect (m_prev, SIGNAL(clicked()), client.xplayback (), SLOT(prev ())); connect (m_prev, SIGNAL(clicked()), client->xplayback (), SLOT(prev ()));
m_play = new PixmapButton (this); m_play = new PixmapButton (this);
m_play->resize (skin->getSize (Skin::BUTTON_MW_PLAY)); m_play->resize (skin->getSize (Skin::BUTTON_MW_PLAY));
m_play->move (skin->getPos (Skin::BUTTON_MW_PLAY)); m_play->move (skin->getPos (Skin::BUTTON_MW_PLAY));
connect (m_play, SIGNAL(clicked()), client.xplayback (), SLOT(play ())); connect (m_play, SIGNAL(clicked()), client->xplayback (), SLOT(play ()));
m_pause = new PixmapButton (this); m_pause = new PixmapButton (this);
m_pause->resize (skin->getSize (Skin::BUTTON_MW_PAUSE)); m_pause->resize (skin->getSize (Skin::BUTTON_MW_PAUSE));
m_pause->move (skin->getPos (Skin::BUTTON_MW_PAUSE)); m_pause->move (skin->getPos (Skin::BUTTON_MW_PAUSE));
connect (m_pause, SIGNAL(clicked()), connect (m_pause, SIGNAL(clicked()),
client.xplayback (), SLOT(toggle_pause ())); client->xplayback (), SLOT(toggle_pause ()));
m_stop = new PixmapButton (this); m_stop = new PixmapButton (this);
m_stop->resize (skin->getSize (Skin::BUTTON_MW_STOP)); m_stop->resize (skin->getSize (Skin::BUTTON_MW_STOP));
m_stop->move (skin->getPos (Skin::BUTTON_MW_STOP)); m_stop->move (skin->getPos (Skin::BUTTON_MW_STOP));
connect (m_stop, SIGNAL(clicked()), client.xplayback (), SLOT(stop ())); connect (m_stop, SIGNAL(clicked()), client->xplayback (), SLOT(stop ()));
m_next = new PixmapButton (this); m_next = new PixmapButton (this);
m_next->resize (skin->getSize (Skin::BUTTON_MW_NEXT)); m_next->resize (skin->getSize (Skin::BUTTON_MW_NEXT));
m_next->move (skin->getPos (Skin::BUTTON_MW_NEXT)); m_next->move (skin->getPos (Skin::BUTTON_MW_NEXT));
connect (m_next, SIGNAL(clicked()), client.xplayback (), SLOT(next ())); connect (m_next, SIGNAL(clicked()), client->xplayback (), SLOT(next ()));
m_eject = new PixmapButton (this); m_eject = new PixmapButton (this);
m_eject->resize (skin->getSize (Skin::BUTTON_MW_EJECT)); m_eject->resize (skin->getSize (Skin::BUTTON_MW_EJECT));

View file

@ -19,9 +19,6 @@
class MainDisplay; class MainDisplay;
#include <xmmsclient/xmmsclient++.h> #include <xmmsclient/xmmsclient++.h>
#include "XMMSHandler.h"
#include <iostream>
#include <QPixmap> #include <QPixmap>
#include <QPainter> #include <QPainter>
@ -49,6 +46,7 @@ class PlayStatus;
class MainWindow; class MainWindow;
class ClutterBar; class ClutterBar;
class XConfig; class XConfig;
class XClient;
class MainDisplay : public SkinDisplay class MainDisplay : public SkinDisplay
{ {
@ -85,7 +83,7 @@ class MainDisplay : public SkinDisplay
void setRepeatAllEnabled (bool enabled); void setRepeatAllEnabled (bool enabled);
protected: protected:
void SetupPushButtons (void); void SetupPushButtons (const XClient *);
void SetupToggleButtons (void); void SetupToggleButtons (void);
PixmapButton *m_prev; PixmapButton *m_prev;

View file

@ -13,7 +13,8 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include "XMMSHandler.h" // TODO: Try to get includes right without this
#include <xmmsclient/xmmsclient++.h>
#include "mainwindow.h" #include "mainwindow.h"
@ -21,6 +22,7 @@
#include "ServerBrowser.h" #include "ServerBrowser.h"
#endif #endif
#include "application.h"
#include "playlistwindow.h" #include "playlistwindow.h"
#include "maindisplay.h" #include "maindisplay.h"
#include "shadeddisplay.h" #include "shadeddisplay.h"

View file

@ -13,14 +13,11 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <xmmsclient/xmmsclient++.h>
#include <QPainter>
#include <QPaintEvent>
#include "playstatus.h" #include "playstatus.h"
#include "Skin.h" #include "Skin.h"
#include <QPainter>
PlayStatus::PlayStatus (QWidget *parent) : QWidget (parent) PlayStatus::PlayStatus (QWidget *parent) : QWidget (parent)
{ {
Skin* skin = Skin::getInstance (); Skin* skin = Skin::getInstance ();

View file

@ -19,6 +19,8 @@
#include <xmmsclient/xmmsclient++.h> #include <xmmsclient/xmmsclient++.h>
#include <QWidget> #include <QWidget>
class QPaintEvent;
class Skin; class Skin;
class PlayStatus : public QWidget class PlayStatus : public QWidget

View file

@ -13,9 +13,6 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include "XMMSHandler.h"
#include "xplayback.h"
#include "posbar.h" #include "posbar.h"
#include "Skin.h" #include "Skin.h"
@ -37,18 +34,9 @@ PosBar::PosBar (QWidget *parent, uint bg, uint bnormal, uint bpressed)
setMinimum (0); setMinimum (0);
setMaximum (0); setMaximum (0);
connect (this, SIGNAL (sliderMoved (int)),
this, SLOT (seekMs (int)));
hide (); hide ();
} }
void
PosBar::seekMs (int value)
{
XMMSHandler::getInstance ().xplayback ()->seekMs (value);
}
void void
PosBar::setPixmaps (Skin *skin) PosBar::setPixmaps (Skin *skin)
{ {

View file

@ -30,7 +30,6 @@ class PosBar : public PixmapSlider
public slots: public slots:
void setPixmaps (Skin *skin); void setPixmaps (Skin *skin);
void seekMs (int);
private: private:
uint m_slider_normal; uint m_slider_normal;

View file

@ -13,8 +13,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <xmmsclient/xmmsclient++.h> #include "xclient.h"
#include "XMMSHandler.h"
#include "xclientcache.h" #include "xclientcache.h"
#include "xplayback.h" #include "xplayback.h"
@ -35,7 +34,7 @@ ShadedDisplay::ShadedDisplay (QWidget *parent) : SkinDisplay (parent)
connect (skin, SIGNAL (skinChanged (Skin *)), connect (skin, SIGNAL (skinChanged (Skin *)),
this, SLOT (setPixmaps(Skin *))); this, SLOT (setPixmaps(Skin *)));
XMMSHandler &client = XMMSHandler::getInstance (); const XClient *client = App->client ();
setFixedSize (275, 14); setFixedSize (275, 14);
@ -54,39 +53,39 @@ ShadedDisplay::ShadedDisplay (QWidget *parent) : SkinDisplay (parent)
m_prev = new PixmapButton (this); m_prev = new PixmapButton (this);
m_prev->move(169, 4); m_prev->move(169, 4);
m_prev->resize (8, 7); m_prev->resize (8, 7);
connect (m_prev, SIGNAL(clicked()), client.xplayback (), SLOT(prev ())); connect (m_prev, SIGNAL(clicked()), client->xplayback (), SLOT(prev ()));
m_play = new PixmapButton (this); m_play = new PixmapButton (this);
m_play->move(177, 4); m_play->move(177, 4);
m_play->resize (10, 7); m_play->resize (10, 7);
connect (m_play, SIGNAL(clicked()), client.xplayback (), SLOT(play ())); connect (m_play, SIGNAL(clicked()), client->xplayback (), SLOT(play ()));
m_pause = new PixmapButton (this); m_pause = new PixmapButton (this);
m_pause->move(187, 4); m_pause->move(187, 4);
m_pause->resize (10, 7); m_pause->resize (10, 7);
connect (m_pause, SIGNAL(clicked()), connect (m_pause, SIGNAL(clicked()),
client.xplayback (), SLOT(toggle_pause ())); client->xplayback (), SLOT(toggle_pause ()));
m_stop = new PixmapButton (this); m_stop = new PixmapButton (this);
m_stop->move(197, 4); m_stop->move(197, 4);
m_stop->resize (9, 7); m_stop->resize (9, 7);
connect (m_stop, SIGNAL(clicked()), client.xplayback (), SLOT(stop ())); connect (m_stop, SIGNAL(clicked()), client->xplayback (), SLOT(stop ()));
m_next = new PixmapButton (this); m_next = new PixmapButton (this);
m_next->move(206, 4); m_next->move(206, 4);
m_next->resize (8, 7); m_next->resize (8, 7);
connect (m_next, SIGNAL(clicked()), client.xplayback (), SLOT(next ())); connect (m_next, SIGNAL(clicked()), client->xplayback (), SLOT(next ()));
m_eject = new PixmapButton (this); m_eject = new PixmapButton (this);
m_eject->move(216, 4); m_eject->move(216, 4);
m_eject->resize (9, 7); m_eject->resize (9, 7);
connect (m_eject, SIGNAL(clicked()), this, SLOT(fileOpen())); connect (m_eject, SIGNAL(clicked()), this, SLOT(fileOpen()));
connect (client.xplayback (), SIGNAL(playbackStatusChanged(Xmms::Playback::Status)), connect (client->xplayback (), SIGNAL(playbackStatusChanged(Xmms::Playback::Status)),
this, SLOT(setStatus(Xmms::Playback::Status))); this, SLOT(setStatus(Xmms::Playback::Status)));
connect (client.cache (), SIGNAL (playtime (uint32_t)), connect (client->cache (), SIGNAL (playtime (uint32_t)),
this, SLOT ( setPlaytime(uint32_t))); this, SLOT ( setPlaytime(uint32_t)));
connect (client.cache (), SIGNAL (activeEntryChanged (QVariantHash)), connect (client->cache (), SIGNAL (activeEntryChanged (QVariantHash)),
this, SLOT (setMediainfo (QVariantHash))); this, SLOT (setMediainfo (QVariantHash)));
} }
@ -121,8 +120,7 @@ void
ShadedDisplay::setStatus (Xmms::Playback::Status status) ShadedDisplay::setStatus (Xmms::Playback::Status status)
{ {
if (status == Xmms::Playback::STOPPED) { if (status == Xmms::Playback::STOPPED) {
//m_number->setNumber (0, 2); m_time->setTime (0);
//nm_number2->setNumber (0, 2);
} }
} }

View file

@ -13,9 +13,10 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include "XMMSHandler.h" #include "xclient.h"
#include "xcollection.h" #include "xcollection.h"
#include "application.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "skindisplay.h" #include "skindisplay.h"
#include "Skin.h" #include "Skin.h"
@ -48,13 +49,13 @@ SkinDisplay::fileOpen (void)
files = fd.getFiles (); files = fd.getFiles ();
XMMSHandler &xmmsh = XMMSHandler::getInstance(); const XClient *client = App->client ();
if (files.count() > 0) { // if (files.count() > 0) {
xmmsh.xcollection ()->playlistClear (); // xmmsh.xcollection ()->playlistClear ();
} // }
for (int i = 0; i < files.count(); i++) { for (int i = 0; i < files.count(); i++) {
xmmsh.playlistAddURL ("file://" + files.value(i)); client->xcollection ()->playlistAddUrl ("file://" + files.value(i));
} }
} }

View file

@ -13,8 +13,6 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include "XMMSHandler.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "titlebar.h" #include "titlebar.h"
#include "skindisplay.h" #include "skindisplay.h"

View file

@ -13,14 +13,14 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include "XMMSHandler.h" #include "xclient.h"
#include <xmmsclient/xmmsclient++.h>
#include "xclientcache.h" #include "xclientcache.h"
#include "application.h" #include "application.h"
#include "playlistshade.h" #include "playlistshade.h"
#include "playlistwindow.h" #include "playlistwindow.h"
#include "pixmapbutton.h" #include "pixmapbutton.h"
#include "Skin.h"
#include <QSettings> #include <QSettings>
#include <QPainter> #include <QPainter>
@ -29,7 +29,7 @@
PlaylistShade::PlaylistShade (PlaylistWindow *parent) : QWidget (parent) PlaylistShade::PlaylistShade (PlaylistWindow *parent) : QWidget (parent)
{ {
QSettings s; QSettings s;
XMMSHandler &xmmsh = XMMSHandler::getInstance (); const XClient *client = App->client ();
if (!s.contains ("playlist/shadedsize")) if (!s.contains ("playlist/shadedsize"))
s.setValue ("playlist/shadedsize", 8); s.setValue ("playlist/shadedsize", 8);
@ -47,7 +47,7 @@ PlaylistShade::PlaylistShade (PlaylistWindow *parent) : QWidget (parent)
connect (m_unshadebtn, SIGNAL (clicked ()), connect (m_unshadebtn, SIGNAL (clicked ()),
parent, SLOT (switchDisplay ())); parent, SLOT (switchDisplay ()));
connect (xmmsh.cache (), SIGNAL (activeEntryChanged (QVariantHash)), connect (client->cache (), SIGNAL (activeEntryChanged (QVariantHash)),
this, SLOT (setMediainfo (QVariantHash))); this, SLOT (setMediainfo (QVariantHash)));
connect (App, SIGNAL(settingsChanged ()), connect (App, SIGNAL(settingsChanged ()),

View file

@ -16,15 +16,14 @@
#ifndef __PLAYLISTSHADE_H__ #ifndef __PLAYLISTSHADE_H__
#define __PLAYLISTSHADE_H__ #define __PLAYLISTSHADE_H__
#include <xmmsclient/xmmsclient++.h>
#include "Skin.h"
#include <QWidget> #include <QWidget>
#include <QHash> #include <QHash>
#include <QVariant> #include <QVariant>
typedef QHash<QString, QVariant> QVariantHash; typedef QHash<QString, QVariant> QVariantHash;
class Skin;
class QResizeEvent; class QResizeEvent;
class PixmapButton; class PixmapButton;
class PlaylistWindow; class PlaylistWindow;

View file

@ -13,9 +13,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
// FIXME should not need those two #include "xclient.h"
#include <xmmsclient/xmmsclient++.h>
#include "XMMSHandler.h"
#include "xplayback.h" #include "xplayback.h"
#include "application.h" #include "application.h"
@ -136,12 +134,12 @@ PlaylistView::PlaylistView (QWidget *parent) : QListView (parent)
m_font = NULL; m_font = NULL;
m_fontmetrics = NULL; m_fontmetrics = NULL;
XMMSHandler &xmmsh = XMMSHandler::getInstance (); const XClient *client = App->client ();
connect (App, SIGNAL (settingsChanged ()), connect (App, SIGNAL (settingsChanged ()),
this, SLOT (settingsChanged ())); this, SLOT (settingsChanged ()));
connect (xmmsh.xplayback (), SIGNAL(playbackStatusChanged(Xmms::Playback::Status)), connect (client->xplayback (), SIGNAL(playbackStatusChanged(Xmms::Playback::Status)),
this, SLOT(handleStatus(Xmms::Playback::Status))); this, SLOT(handleStatus(Xmms::Playback::Status)));
} }
@ -278,18 +276,18 @@ PlaylistView::mouseDoubleClickEvent (QMouseEvent *event)
return; return;
} }
XMMSHandler &xmmsh = XMMSHandler::getInstance (); const XClient *client = App->client ();
xmmsh.xplayback ()->setPos (index.row()); client->xplayback ()->setPos (index.row());
if (m_status == XMMS_PLAYBACK_STATUS_STOP || if (m_status == XMMS_PLAYBACK_STATUS_STOP ||
m_status == XMMS_PLAYBACK_STATUS_PAUSE) { m_status == XMMS_PLAYBACK_STATUS_PAUSE) {
xmmsh.xplayback ()->play (); client->xplayback ()->play ();
} }
} }
void void
PlaylistView::showEntryInfo (void) PlaylistView::showEntryInfo (void)
{ {
XMMSHandler &client = XMMSHandler::getInstance (); const XClient *client = App->client ();
QModelIndex current = selectionModel ()->currentIndex (); QModelIndex current = selectionModel ()->currentIndex ();
if (current.isValid ()) { if (current.isValid ()) {
uint32_t id = model ()->data (current, PlaylistModel::MedialibIdRole) uint32_t id = model ()->data (current, PlaylistModel::MedialibIdRole)
@ -297,7 +295,7 @@ PlaylistView::showEntryInfo (void)
// If no infodialog exists, create one, else set the selected Item as // If no infodialog exists, create one, else set the selected Item as
// displayed item // displayed item
if (!m_entry_info) { if (!m_entry_info) {
m_entry_info = new EntryInfo (this, client.cache (), id); m_entry_info = new EntryInfo (this, client->cache (), id);
} else { } else {
m_entry_info->raise (); m_entry_info->raise ();
m_entry_info->setId (id); m_entry_info->setId (id);

View file

@ -13,7 +13,10 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include "XMMSHandler.h" #include "xclient.h"
#include "playlistmodel.h"
#include "xcollection.h"
#include "xplayback.h"
#include "application.h" #include "application.h"
#include "mainwindow.h" #include "mainwindow.h"
@ -23,10 +26,6 @@
#include "playlistview.h" #include "playlistview.h"
#include "playlistcontrols.h" #include "playlistcontrols.h"
#include "playlistmodel.h"
#include "xcollection.h"
#include "xplayback.h"
#include "pixmapbutton.h" #include "pixmapbutton.h"
#include "playlistshade.h" #include "playlistshade.h"
#include "playlistmenu.h" #include "playlistmenu.h"
@ -196,7 +195,7 @@ PlaylistWidget::PlaylistWidget (PlaylistWindow *parent) : QWidget (parent)
m_view->move (10, 20); m_view->move (10, 20);
// m_view->resize (size().width()-30, size().height()-20-38); // m_view->resize (size().width()-30, size().height()-20-38);
// TODO: creation of Playlistmodel should be done elsewhere // TODO: creation of Playlistmodel should be done elsewhere
m_view->setModel (XMMSHandler::getInstance().getPlaylistModel()); m_view->setModel (App->client ()->active_playlist ());
/* /*
* This is a hack to make PlaylistScrollBar work with PlaylistView. * This is a hack to make PlaylistScrollBar work with PlaylistView.
@ -219,20 +218,20 @@ PlaylistWidget::PlaylistWidget (PlaylistWindow *parent) : QWidget (parent)
addButtons (); addButtons ();
XMMSHandler &client = XMMSHandler::getInstance (); const XClient *client = App->client ();
m_controls = new PlaylistControls (this); m_controls = new PlaylistControls (this);
// connect buttons // connect buttons
connect (m_controls, SIGNAL (prev ()), connect (m_controls, SIGNAL (prev ()),
client.xplayback (), SLOT (prev ())); client->xplayback (), SLOT (prev ()));
connect (m_controls, SIGNAL (play ()), connect (m_controls, SIGNAL (play ()),
client.xplayback (), SLOT (play ())); client->xplayback (), SLOT (play ()));
connect (m_controls, SIGNAL (pause ()), connect (m_controls, SIGNAL (pause ()),
client.xplayback (), SLOT (pause ())); client->xplayback (), SLOT (pause ()));
connect (m_controls, SIGNAL (stop ()), connect (m_controls, SIGNAL (stop ()),
client.xplayback (), SLOT (stop ())); client->xplayback (), SLOT (stop ()));
connect (m_controls, SIGNAL (next ()), connect (m_controls, SIGNAL (next ()),
client.xplayback (), SLOT (next ())); client->xplayback (), SLOT (next ()));
// TODO: eject // TODO: eject
connect (m_controls, SIGNAL (toggleTime ()), connect (m_controls, SIGNAL (toggleTime ()),
App, SLOT (toggleTime())); App, SLOT (toggleTime()));
@ -269,7 +268,7 @@ PlaylistWidget::addButtons ()
b = new PlaylistMenuButton (m_del, Skin::PLS_DEL_ALL_0, b = new PlaylistMenuButton (m_del, Skin::PLS_DEL_ALL_0,
Skin::PLS_DEL_ALL_1); Skin::PLS_DEL_ALL_1);
connect (b, SIGNAL (activated ()), connect (b, SIGNAL (activated ()),
XMMSHandler::getInstance().xcollection (), App->client ()->xcollection (),
SLOT (playlistClear ())); SLOT (playlistClear ()));
b = new PlaylistMenuButton (m_del, Skin::PLS_DEL_CRP_0, b = new PlaylistMenuButton (m_del, Skin::PLS_DEL_CRP_0,
Skin::PLS_DEL_CRP_1); Skin::PLS_DEL_CRP_1);
@ -324,8 +323,8 @@ PlaylistWidget::addButtons ()
void void
PlaylistWidget::menuAddUrl () PlaylistWidget::menuAddUrl ()
{ {
XMMSHandler &client = XMMSHandler::getInstance (); const XClient *client = App->client ();
UrlOpen *tmp = new UrlOpen (this, client.xcollection ()); UrlOpen *tmp = new UrlOpen (this, client->xcollection ());
tmp->show (); tmp->show ();
} }
@ -343,7 +342,7 @@ PlaylistWidget::diveDir (const QString &dir)
diveDir (fileInfo.filePath ()); diveDir (fileInfo.filePath ());
} else { } else {
QString fname = fileInfo.filePath(); QString fname = fileInfo.filePath();
XMMSHandler::getInstance ().playlistAddURL ("file://" + fname); App->client ()->xcollection ()->playlistAddUrl ("file://" + fname);
} }
} }
} }
@ -374,7 +373,7 @@ PlaylistWidget::menuAddFile ()
BrowseDialog bd (window ()); BrowseDialog bd (window ());
files = bd.getFiles (); files = bd.getFiles ();
for (int i = 0; i < files.count(); i++) { for (int i = 0; i < files.count(); i++) {
XMMSHandler::getInstance ().playlistAddURL (files.value (i)); App->client ()->xcollection ()->playlistAddUrl (files.value (i));
} }
} else { } else {
FileDialog fd (this, "playlist_add_files"); FileDialog fd (this, "playlist_add_files");
@ -382,7 +381,7 @@ PlaylistWidget::menuAddFile ()
files = fd.getFiles (); files = fd.getFiles ();
for (int i = 0; i < files.count(); i++) { for (int i = 0; i < files.count(); i++) {
XMMSHandler::getInstance ().playlistAddURL ("file://" + files.value(i)); App->client ()->xcollection ()->playlistAddUrl ("file://" + files.value(i));
} }
} }
@ -397,9 +396,9 @@ PlaylistWidget::menuAddPls ()
files = fd.getFiles (); files = fd.getFiles ();
if (files.count () > 0) { if (files.count () > 0) {
XMMSHandler::getInstance ().xcollection ()->playlistClear (); App->client ()->xcollection ()->playlistClear ();
QString file = files[0]; QString file = files[0];
XMMSHandler::getInstance ().xcollection ()->addPlsFile (QUrl (file)); App->client ()->xcollection ()->addPlsFile (QUrl (file));
} }
} }
@ -590,8 +589,8 @@ PlaylistWidget::paintEvent (QPaintEvent *event)
void void
PlaylistWidget::openPlaylistChooser () PlaylistWidget::openPlaylistChooser ()
{ {
XMMSHandler &client = XMMSHandler::getInstance (); const XClient *client = App->client ();
PlaylistChooser *tmp = new PlaylistChooser (this, client.xcollection ()); PlaylistChooser *tmp = new PlaylistChooser (this, client->xcollection ());
tmp->show (); tmp->show ();
} }

View file

@ -16,8 +16,6 @@
#ifndef __PLAYLISTWIDGET_H__ #ifndef __PLAYLISTWIDGET_H__
#define __PLAYLISTWIDGET_H__ #define __PLAYLISTWIDGET_H__
#include "XMMSHandler.h"
#include <QScrollBar> #include <QScrollBar>
#include <QSizeGrip> #include <QSizeGrip>
#include <QWidget> #include <QWidget>

View file

@ -13,13 +13,12 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include "XMMSHandler.h"
#include "playlistwindow.h" #include "playlistwindow.h"
#include <QMoveEvent> #include <QMoveEvent>
#include <QResizeEvent> #include <QResizeEvent>
#include <QPoint> #include <QPoint>
#include <QIcon>
#include "playlistwidget.h" #include "playlistwidget.h"
#include "playlistshade.h" #include "playlistshade.h"

View file

@ -7,7 +7,6 @@ include($$PWD/dialogs/dialogs.pri)
HEADERS += application.h \ HEADERS += application.h \
Skin.h \ Skin.h \
timedisplay.h \ timedisplay.h \
XMMSHandler.h \
SkinChooser.h \ SkinChooser.h \
settingsdialog.h \ settingsdialog.h \
basewindow.h \ basewindow.h \
@ -18,7 +17,6 @@ HEADERS += application.h \
SOURCES += application.cpp \ SOURCES += application.cpp \
timedisplay.cpp \ timedisplay.cpp \
Skin.cpp \ Skin.cpp \
XMMSHandler.cpp \
SkinChooser.cpp \ SkinChooser.cpp \
settingsdialog.cpp \ settingsdialog.cpp \
basewindow.cpp \ basewindow.cpp \