diff --git a/lib/xclient.cpp b/lib/xclient.cpp index 4e08384..a4aee6a 100644 --- a/lib/xclient.cpp +++ b/lib/xclient.cpp @@ -30,6 +30,7 @@ #include "xconfig.h" #include "xmmsqt4.h" #include "debug.h" +#include "playlistmodel.h" #include "sourcepref.h" @@ -71,6 +72,7 @@ XClient::XClient (QObject *parent, const std::string &name) : QObject (parent), m_config = new XConfig (this); m_playback = new XPlayback (this); m_collection = new XCollection (this); + m_active_playlist = new PlaylistModel(this, this, "_active"); m_name = name; } diff --git a/lib/xclient.h b/lib/xclient.h index ff16727..d0fcfc7 100644 --- a/lib/xclient.h +++ b/lib/xclient.h @@ -30,6 +30,7 @@ class XClientCache; class XConfig; class XPlayback; class XCollection; +class PlaylistModel; #define SOURCEPREF_HACK @@ -72,6 +73,10 @@ class XClient : public QObject { return m_collection; } + PlaylistModel *active_playlist () const { + return m_active_playlist; + } + const Xmms::Client *sync () const { 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::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: void gotConnection (XClient *); void disconnected (XClient *); @@ -111,7 +119,8 @@ class XClient : public QObject { XConfig *m_config; XPlayback *m_playback; XCollection *m_collection; - bool m_isconnected; + PlaylistModel *m_active_playlist; + bool m_isconnected; Xmms::Client m_sync; }; diff --git a/lib/xcollection.cpp b/lib/xcollection.cpp index c15b6ae..a197ed8 100644 --- a/lib/xcollection.cpp +++ b/lib/xcollection.cpp @@ -210,6 +210,19 @@ XCollection::addIdlist (QString name) { 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 XCollection::playlistAddUrl (QUrl url, QString plsname) { diff --git a/lib/xcollection.h b/lib/xcollection.h index 5070065..cecee6f 100644 --- a/lib/xcollection.h +++ b/lib/xcollection.h @@ -40,6 +40,7 @@ class XCollection : public QObject // idlist spesific bool setActivePlaylist (QString name); bool addIdlist (QString name); + bool playlistAddUrl (QString url, QString plsname = ""); bool playlistAddUrl (QUrl url, QString plsname = ""); bool playlistClear (QString name = ""); bool addPlsFile (QUrl url); diff --git a/lib/xplayback.h b/lib/xplayback.h index 279b1ae..c2b40e2 100644 --- a/lib/xplayback.h +++ b/lib/xplayback.h @@ -49,6 +49,8 @@ class XPlayback : public QObject { void seekMs (uint 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 setBalance (int new_balance); diff --git a/src/BrowseDialog.cpp b/src/BrowseDialog.cpp index 1bfc087..66e4795 100644 --- a/src/BrowseDialog.cpp +++ b/src/BrowseDialog.cpp @@ -13,9 +13,12 @@ * GNU General Public License for more details. */ -#include "XMMSHandler.h" #include "BrowseModel.h" #include "BrowseDialog.h" +#include "xclient.h" +#include "xcollection.h" + +#include "application.h" #include #include @@ -169,12 +172,12 @@ BrowseDialog::navigateToPrevious () void BrowseDialog::setPath (const QModelIndex &index) { - XMMSHandler &handler = XMMSHandler::getInstance (); + XClient *client = App->client (); BrowseModelItem *item = m_model->itemByIndex (index); if (item->isDir ()) { m_model->setPath (index); } else { - handler.playlistAddURL (item->data("path")); + client->xcollection ()->playlistAddUrl (item->data("path")); } } diff --git a/src/BrowseModel.cpp b/src/BrowseModel.cpp index a7eec4c..caf3b2d 100644 --- a/src/BrowseModel.cpp +++ b/src/BrowseModel.cpp @@ -13,9 +13,11 @@ * GNU General Public License for more details. */ -#include "XMMSHandler.h" +#include "xclient.h" #include "BrowseModel.h" +#include "application.h" + #include #include #include @@ -36,7 +38,7 @@ BrowseModel::BrowseModel (QWidget *parent) : QAbstractTableModel () { m_columns.append ("Name"); m_style = parent->style (); - m_client = XMMSHandler::getInstance ().getClient (); + m_client = App->client ()->getClient (); m_filter_dot = true; //list_root (); } diff --git a/src/ServerBrowser.cpp b/src/ServerBrowser.cpp index 463cacd..bbf15de 100644 --- a/src/ServerBrowser.cpp +++ b/src/ServerBrowser.cpp @@ -63,9 +63,9 @@ ServerBrowserList::connectServer (QListWidgetItem *it) { ServerBrowserWindow *sw = dynamic_cast (window ()); - XMMSHandler *xmmsh = XMMSHandler::getInstance (); + XClient *client = App->client (); ServerItem *item = dynamic_cast (it); - if (xmmsh->connect (item->path ().toAscii())) { + if (client->connect (item->path ().toAscii())) { sw->close (); } } diff --git a/src/ServerBrowser.h b/src/ServerBrowser.h index cc89444..665b3a4 100644 --- a/src/ServerBrowser.h +++ b/src/ServerBrowser.h @@ -16,7 +16,7 @@ #ifndef __SERVER_BROWSER_H__ #define __SERVER_BROWSER_H__ -#include "XMMSHandler.h" +#include "xclient.h" #include #include diff --git a/src/XMMSHandler.cpp b/src/XMMSHandler.cpp deleted file mode 100644 index 2483e31..0000000 --- a/src/XMMSHandler.cpp +++ /dev/null @@ -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 - -#include "xmmsqt4.h" -#include "XMMSHandler.h" -#include "playlistmodel.h" - -#include -#include -#include - -#include -#include - -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 &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 ())); - } -} - diff --git a/src/XMMSHandler.h b/src/XMMSHandler.h deleted file mode 100644 index 93fafd0..0000000 --- a/src/XMMSHandler.h +++ /dev/null @@ -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 - -#include "xclient.h" -#include "xmmsqt4.h" - -#include -#include - -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 &hash); - PlaylistModel *m_playlist_model; -}; - -#endif - diff --git a/src/application.cpp b/src/application.cpp index c31ef37..1f68016 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -13,7 +13,7 @@ * GNU General Public License for more details. */ -#include "XMMSHandler.h" +#include "xclient.h" #include "application.h" @@ -35,12 +35,11 @@ Application::Application (int &argc, char **argv) : QApplication (argc, argv) setOrganizationDomain("xmms.org"); setApplicationName("Promoe"); - //TODO: Change to XClient sometime later - XMMSHandler &client = XMMSHandler::getInstance (); + m_xmms2_client = new XClient (this, "Promoe"); connect (this, SIGNAL (aboutToQuit ()), this, SLOT (cleanupHandler ())); - connect (&client, SIGNAL(disconnected(XClient *)), + connect (m_xmms2_client, SIGNAL(disconnected(XClient *)), this, SLOT(handleDisconnected ())); 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->getPL ()->setVisible (settings.value ("playlist/visible", false).toBool ()); + m_xmms2_client->connect (); + #ifdef HAVE_SERVERBROWSER ServerBrowserWindow *browser = new ServerBrowserWindow (mw); browser->show (); @@ -82,7 +83,7 @@ Application::cleanupHandler () s.setValue("MainWindow/timemodereverse",m_timemode_reverse); if (s.value ("promoe/quitonclose", false).toBool ()) - XMMSHandler::getInstance ().shutdownServer (); + m_xmms2_client->shutdownServer (); } void diff --git a/src/application.h b/src/application.h index 9677f95..374c1ca 100644 --- a/src/application.h +++ b/src/application.h @@ -15,6 +15,8 @@ #include +class XClient; + class Application; #if defined(qApp) #undef qApp @@ -32,11 +34,15 @@ class Application : public QApplication public: Application (int &argc, char **argv); + XClient *client () const {return m_xmms2_client;} public slots: void cleanupHandler (); void handleDisconnected (); + private: + XClient *m_xmms2_client; + // TODO: Search some better place for those methods public: bool isTimemodeReverse(void) {return m_timemode_reverse;} diff --git a/src/dialogs/playlistchooser.cpp b/src/dialogs/playlistchooser.cpp index e73da74..a2625d9 100644 --- a/src/dialogs/playlistchooser.cpp +++ b/src/dialogs/playlistchooser.cpp @@ -14,9 +14,8 @@ * GNU General Public License for more details. */ -// FIXME: because somewhere something with the includes is wrong, this line -// is needed -#include "XMMSHandler.h" +// Needed for XMMS_COLLECTION_CHANGED_* defines +#include #include #include diff --git a/src/equalizer/equalizerwidget.cpp b/src/equalizer/equalizerwidget.cpp index 0176358..42c57fd 100644 --- a/src/equalizer/equalizerwidget.cpp +++ b/src/equalizer/equalizerwidget.cpp @@ -13,11 +13,12 @@ * GNU General Public License for more details. */ -#include "XMMSHandler.h" +#include "xclient.h" #include "xconfig.h" #include "equalizerwidget.h" +#include "application.h" #include "mainwindow.h" #include "pixmapbutton.h" #include "pixmapslider.h" @@ -52,8 +53,8 @@ EqualizerSlider::on_self_slider_moved (int value) EqualizerWidget::EqualizerWidget (QWidget *parent) : QWidget (parent) { Skin *skin = Skin::getInstance (); - XMMSHandler &client = XMMSHandler::getInstance (); - m_xconfig = client.xconfig (); + const XClient *client = App->client (); + m_xconfig = client->xconfig (); connect (skin, SIGNAL(skinChanged(Skin *)), this, SLOT(setPixmaps(Skin *))); diff --git a/src/equalizer/equalizerwindow.cpp b/src/equalizer/equalizerwindow.cpp index f0fff2a..0c1d0b9 100644 --- a/src/equalizer/equalizerwindow.cpp +++ b/src/equalizer/equalizerwindow.cpp @@ -13,8 +13,6 @@ * GNU General Public License for more details. */ -#include "XMMSHandler.h" - #include "equalizerwindow.h" #include "QWidget" diff --git a/src/mainwindow/maindisplay.cpp b/src/mainwindow/maindisplay.cpp index 6c598ae..006f70f 100644 --- a/src/mainwindow/maindisplay.cpp +++ b/src/mainwindow/maindisplay.cpp @@ -13,8 +13,7 @@ * GNU General Public License for more details. */ -#include -#include "XMMSHandler.h" +#include "xclient.h" #include "xclientcache.h" #include "xplayback.h" #include "xconfig.h" @@ -43,8 +42,8 @@ MainDisplay::MainDisplay (MainWindow *parent) : SkinDisplay(parent) { - XMMSHandler &client = XMMSHandler::getInstance (); - m_xconfig = client.xconfig (); + const XClient *client = App->client (); + m_xconfig = client->xconfig (); Skin* skin = Skin::getInstance (); connect (skin, SIGNAL (skinChanged (Skin *)), @@ -56,7 +55,7 @@ MainDisplay::MainDisplay (MainWindow *parent) : SkinDisplay(parent) m_mw = parent; - SetupPushButtons (); + SetupPushButtons (client); SetupToggleButtons (); 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_1); 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->move (24, 28); @@ -100,10 +101,10 @@ MainDisplay::MainDisplay (MainWindow *parent) : SkinDisplay(parent) m_vslider->setSliderOffset (QPoint (0, 1)); m_vslider->resize (skin->getSize (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))); connect (m_vslider, SIGNAL (sliderMoved (int)), - client.xplayback (), SLOT (setVolume (int))); + client->xplayback (), SLOT (setVolume (int))); m_bslider = new PixmapSlider (this); m_bslider->setMinimum (-MAX_BALANCE); @@ -111,16 +112,16 @@ MainDisplay::MainDisplay (MainWindow *parent) : SkinDisplay(parent) m_bslider->setSliderOffset (QPoint (0, 1)); m_bslider->resize (skin->getSize (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))); 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))); - connect (client.xplayback (), SIGNAL(playbackStatusChanged(Xmms::Playback::Status)), + connect (client->xplayback (), SIGNAL(playbackStatusChanged(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))); setupServerConfig (); @@ -183,6 +184,9 @@ MainDisplay::setStatus (Xmms::Playback::Status status) m_posbar->setValue (0); m_posbar->hide (); m_stereo->setStereoMono (false, false); + + //FIXME: workaround, fix by hiding timedisplay in playlist + emit displayTime (0); } else if (status == Xmms::Playback::PLAYING) { m_time->show (); m_kbps->show (); @@ -204,7 +208,6 @@ MainDisplay::setPlaytime (uint32_t time) showtime = time/1000; } emit displayTime (showtime); -// m_time->setTime (showtime); // update slider m_posbar->setValue (time); @@ -292,37 +295,36 @@ MainDisplay::SetupToggleButtons (void) } void -MainDisplay::SetupPushButtons (void) +MainDisplay::SetupPushButtons (const XClient* client) { - XMMSHandler &client = XMMSHandler::getInstance (); Skin *skin = Skin::getInstance (); /* Normal buttons */ m_prev = new PixmapButton (this); m_prev->resize (skin->getSize (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->resize (skin->getSize (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->resize (skin->getSize (Skin::BUTTON_MW_PAUSE)); m_pause->move (skin->getPos (Skin::BUTTON_MW_PAUSE)); connect (m_pause, SIGNAL(clicked()), - client.xplayback (), SLOT(toggle_pause ())); + client->xplayback (), SLOT(toggle_pause ())); m_stop = new PixmapButton (this); m_stop->resize (skin->getSize (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->resize (skin->getSize (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->resize (skin->getSize (Skin::BUTTON_MW_EJECT)); diff --git a/src/mainwindow/maindisplay.h b/src/mainwindow/maindisplay.h index a81dbd9..6f87ac0 100644 --- a/src/mainwindow/maindisplay.h +++ b/src/mainwindow/maindisplay.h @@ -19,9 +19,6 @@ class MainDisplay; #include -#include "XMMSHandler.h" - -#include #include #include @@ -49,6 +46,7 @@ class PlayStatus; class MainWindow; class ClutterBar; class XConfig; +class XClient; class MainDisplay : public SkinDisplay { @@ -85,7 +83,7 @@ class MainDisplay : public SkinDisplay void setRepeatAllEnabled (bool enabled); protected: - void SetupPushButtons (void); + void SetupPushButtons (const XClient *); void SetupToggleButtons (void); PixmapButton *m_prev; diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index ea7d830..b0fcb6e 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -13,7 +13,8 @@ * GNU General Public License for more details. */ -#include "XMMSHandler.h" +// TODO: Try to get includes right without this +#include #include "mainwindow.h" @@ -21,6 +22,7 @@ #include "ServerBrowser.h" #endif +#include "application.h" #include "playlistwindow.h" #include "maindisplay.h" #include "shadeddisplay.h" diff --git a/src/mainwindow/playstatus.cpp b/src/mainwindow/playstatus.cpp index 13185ae..e6e3da5 100644 --- a/src/mainwindow/playstatus.cpp +++ b/src/mainwindow/playstatus.cpp @@ -13,14 +13,11 @@ * GNU General Public License for more details. */ -#include - -#include -#include - #include "playstatus.h" #include "Skin.h" +#include + PlayStatus::PlayStatus (QWidget *parent) : QWidget (parent) { Skin* skin = Skin::getInstance (); diff --git a/src/mainwindow/playstatus.h b/src/mainwindow/playstatus.h index c847cdb..19cb10b 100644 --- a/src/mainwindow/playstatus.h +++ b/src/mainwindow/playstatus.h @@ -19,6 +19,8 @@ #include #include +class QPaintEvent; + class Skin; class PlayStatus : public QWidget diff --git a/src/mainwindow/posbar.cpp b/src/mainwindow/posbar.cpp index e447d91..adba8a0 100644 --- a/src/mainwindow/posbar.cpp +++ b/src/mainwindow/posbar.cpp @@ -13,9 +13,6 @@ * GNU General Public License for more details. */ -#include "XMMSHandler.h" -#include "xplayback.h" - #include "posbar.h" #include "Skin.h" @@ -37,18 +34,9 @@ PosBar::PosBar (QWidget *parent, uint bg, uint bnormal, uint bpressed) setMinimum (0); setMaximum (0); - connect (this, SIGNAL (sliderMoved (int)), - this, SLOT (seekMs (int))); - hide (); } -void -PosBar::seekMs (int value) -{ - XMMSHandler::getInstance ().xplayback ()->seekMs (value); -} - void PosBar::setPixmaps (Skin *skin) { diff --git a/src/mainwindow/posbar.h b/src/mainwindow/posbar.h index ef4d3d5..fa4d07a 100644 --- a/src/mainwindow/posbar.h +++ b/src/mainwindow/posbar.h @@ -30,7 +30,6 @@ class PosBar : public PixmapSlider public slots: void setPixmaps (Skin *skin); - void seekMs (int); private: uint m_slider_normal; diff --git a/src/mainwindow/shadeddisplay.cpp b/src/mainwindow/shadeddisplay.cpp index 30a0414..83e35bd 100644 --- a/src/mainwindow/shadeddisplay.cpp +++ b/src/mainwindow/shadeddisplay.cpp @@ -13,8 +13,7 @@ * GNU General Public License for more details. */ -#include -#include "XMMSHandler.h" +#include "xclient.h" #include "xclientcache.h" #include "xplayback.h" @@ -35,7 +34,7 @@ ShadedDisplay::ShadedDisplay (QWidget *parent) : SkinDisplay (parent) connect (skin, SIGNAL (skinChanged (Skin *)), this, SLOT (setPixmaps(Skin *))); - XMMSHandler &client = XMMSHandler::getInstance (); + const XClient *client = App->client (); setFixedSize (275, 14); @@ -54,39 +53,39 @@ ShadedDisplay::ShadedDisplay (QWidget *parent) : SkinDisplay (parent) m_prev = new PixmapButton (this); m_prev->move(169, 4); 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->move(177, 4); 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->move(187, 4); m_pause->resize (10, 7); connect (m_pause, SIGNAL(clicked()), - client.xplayback (), SLOT(toggle_pause ())); + client->xplayback (), SLOT(toggle_pause ())); m_stop = new PixmapButton (this); m_stop->move(197, 4); 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->move(206, 4); 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->move(216, 4); m_eject->resize (9, 7); 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))); - connect (client.cache (), SIGNAL (playtime (uint32_t)), + connect (client->cache (), SIGNAL (playtime (uint32_t)), this, SLOT ( setPlaytime(uint32_t))); - connect (client.cache (), SIGNAL (activeEntryChanged (QVariantHash)), + connect (client->cache (), SIGNAL (activeEntryChanged (QVariantHash)), this, SLOT (setMediainfo (QVariantHash))); } @@ -121,8 +120,7 @@ void ShadedDisplay::setStatus (Xmms::Playback::Status status) { if (status == Xmms::Playback::STOPPED) { - //m_number->setNumber (0, 2); - //nm_number2->setNumber (0, 2); + m_time->setTime (0); } } diff --git a/src/mainwindow/skindisplay.cpp b/src/mainwindow/skindisplay.cpp index 5e2174e..e824f70 100644 --- a/src/mainwindow/skindisplay.cpp +++ b/src/mainwindow/skindisplay.cpp @@ -13,9 +13,10 @@ * GNU General Public License for more details. */ -#include "XMMSHandler.h" +#include "xclient.h" #include "xcollection.h" +#include "application.h" #include "mainwindow.h" #include "skindisplay.h" #include "Skin.h" @@ -48,13 +49,13 @@ SkinDisplay::fileOpen (void) files = fd.getFiles (); - XMMSHandler &xmmsh = XMMSHandler::getInstance(); - if (files.count() > 0) { - xmmsh.xcollection ()->playlistClear (); - } + const XClient *client = App->client (); +// if (files.count() > 0) { +// xmmsh.xcollection ()->playlistClear (); +// } for (int i = 0; i < files.count(); i++) { - xmmsh.playlistAddURL ("file://" + files.value(i)); + client->xcollection ()->playlistAddUrl ("file://" + files.value(i)); } } diff --git a/src/mainwindow/titlebar.cpp b/src/mainwindow/titlebar.cpp index 02ca59a..90ab062 100644 --- a/src/mainwindow/titlebar.cpp +++ b/src/mainwindow/titlebar.cpp @@ -13,8 +13,6 @@ * GNU General Public License for more details. */ -#include "XMMSHandler.h" - #include "mainwindow.h" #include "titlebar.h" #include "skindisplay.h" diff --git a/src/playlist/playlistshade.cpp b/src/playlist/playlistshade.cpp index 5b6776b..f446262 100644 --- a/src/playlist/playlistshade.cpp +++ b/src/playlist/playlistshade.cpp @@ -13,14 +13,14 @@ * GNU General Public License for more details. */ -#include "XMMSHandler.h" -#include +#include "xclient.h" #include "xclientcache.h" #include "application.h" #include "playlistshade.h" #include "playlistwindow.h" #include "pixmapbutton.h" +#include "Skin.h" #include #include @@ -29,7 +29,7 @@ PlaylistShade::PlaylistShade (PlaylistWindow *parent) : QWidget (parent) { QSettings s; - XMMSHandler &xmmsh = XMMSHandler::getInstance (); + const XClient *client = App->client (); if (!s.contains ("playlist/shadedsize")) s.setValue ("playlist/shadedsize", 8); @@ -47,7 +47,7 @@ PlaylistShade::PlaylistShade (PlaylistWindow *parent) : QWidget (parent) connect (m_unshadebtn, SIGNAL (clicked ()), parent, SLOT (switchDisplay ())); - connect (xmmsh.cache (), SIGNAL (activeEntryChanged (QVariantHash)), + connect (client->cache (), SIGNAL (activeEntryChanged (QVariantHash)), this, SLOT (setMediainfo (QVariantHash))); connect (App, SIGNAL(settingsChanged ()), diff --git a/src/playlist/playlistshade.h b/src/playlist/playlistshade.h index 0b4e7cf..72b5b30 100644 --- a/src/playlist/playlistshade.h +++ b/src/playlist/playlistshade.h @@ -16,15 +16,14 @@ #ifndef __PLAYLISTSHADE_H__ #define __PLAYLISTSHADE_H__ -#include -#include "Skin.h" - #include #include #include typedef QHash QVariantHash; +class Skin; + class QResizeEvent; class PixmapButton; class PlaylistWindow; diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index f30278e..c017de9 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -13,9 +13,7 @@ * GNU General Public License for more details. */ -// FIXME should not need those two -#include -#include "XMMSHandler.h" +#include "xclient.h" #include "xplayback.h" #include "application.h" @@ -136,12 +134,12 @@ PlaylistView::PlaylistView (QWidget *parent) : QListView (parent) m_font = NULL; m_fontmetrics = NULL; - XMMSHandler &xmmsh = XMMSHandler::getInstance (); + const XClient *client = App->client (); connect (App, SIGNAL (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))); } @@ -278,18 +276,18 @@ PlaylistView::mouseDoubleClickEvent (QMouseEvent *event) return; } - XMMSHandler &xmmsh = XMMSHandler::getInstance (); - xmmsh.xplayback ()->setPos (index.row()); + const XClient *client = App->client (); + client->xplayback ()->setPos (index.row()); if (m_status == XMMS_PLAYBACK_STATUS_STOP || m_status == XMMS_PLAYBACK_STATUS_PAUSE) { - xmmsh.xplayback ()->play (); + client->xplayback ()->play (); } } void PlaylistView::showEntryInfo (void) { - XMMSHandler &client = XMMSHandler::getInstance (); + const XClient *client = App->client (); QModelIndex current = selectionModel ()->currentIndex (); if (current.isValid ()) { 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 // displayed item if (!m_entry_info) { - m_entry_info = new EntryInfo (this, client.cache (), id); + m_entry_info = new EntryInfo (this, client->cache (), id); } else { m_entry_info->raise (); m_entry_info->setId (id); diff --git a/src/playlist/playlistwidget.cpp b/src/playlist/playlistwidget.cpp index 237fa9c..61cca99 100644 --- a/src/playlist/playlistwidget.cpp +++ b/src/playlist/playlistwidget.cpp @@ -13,7 +13,10 @@ * 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 "mainwindow.h" @@ -23,10 +26,6 @@ #include "playlistview.h" #include "playlistcontrols.h" -#include "playlistmodel.h" -#include "xcollection.h" -#include "xplayback.h" - #include "pixmapbutton.h" #include "playlistshade.h" #include "playlistmenu.h" @@ -196,7 +195,7 @@ PlaylistWidget::PlaylistWidget (PlaylistWindow *parent) : QWidget (parent) m_view->move (10, 20); // m_view->resize (size().width()-30, size().height()-20-38); // 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. @@ -219,20 +218,20 @@ PlaylistWidget::PlaylistWidget (PlaylistWindow *parent) : QWidget (parent) addButtons (); - XMMSHandler &client = XMMSHandler::getInstance (); + const XClient *client = App->client (); m_controls = new PlaylistControls (this); // connect buttons connect (m_controls, SIGNAL (prev ()), - client.xplayback (), SLOT (prev ())); + client->xplayback (), SLOT (prev ())); connect (m_controls, SIGNAL (play ()), - client.xplayback (), SLOT (play ())); + client->xplayback (), SLOT (play ())); connect (m_controls, SIGNAL (pause ()), - client.xplayback (), SLOT (pause ())); + client->xplayback (), SLOT (pause ())); connect (m_controls, SIGNAL (stop ()), - client.xplayback (), SLOT (stop ())); + client->xplayback (), SLOT (stop ())); connect (m_controls, SIGNAL (next ()), - client.xplayback (), SLOT (next ())); + client->xplayback (), SLOT (next ())); // TODO: eject connect (m_controls, SIGNAL (toggleTime ()), App, SLOT (toggleTime())); @@ -269,7 +268,7 @@ PlaylistWidget::addButtons () b = new PlaylistMenuButton (m_del, Skin::PLS_DEL_ALL_0, Skin::PLS_DEL_ALL_1); connect (b, SIGNAL (activated ()), - XMMSHandler::getInstance().xcollection (), + App->client ()->xcollection (), SLOT (playlistClear ())); b = new PlaylistMenuButton (m_del, Skin::PLS_DEL_CRP_0, Skin::PLS_DEL_CRP_1); @@ -324,8 +323,8 @@ PlaylistWidget::addButtons () void PlaylistWidget::menuAddUrl () { - XMMSHandler &client = XMMSHandler::getInstance (); - UrlOpen *tmp = new UrlOpen (this, client.xcollection ()); + const XClient *client = App->client (); + UrlOpen *tmp = new UrlOpen (this, client->xcollection ()); tmp->show (); } @@ -343,7 +342,7 @@ PlaylistWidget::diveDir (const QString &dir) diveDir (fileInfo.filePath ()); } else { QString fname = fileInfo.filePath(); - XMMSHandler::getInstance ().playlistAddURL ("file://" + fname); + App->client ()->xcollection ()->playlistAddUrl ("file://" + fname); } } } @@ -374,7 +373,7 @@ PlaylistWidget::menuAddFile () BrowseDialog bd (window ()); files = bd.getFiles (); for (int i = 0; i < files.count(); i++) { - XMMSHandler::getInstance ().playlistAddURL (files.value (i)); + App->client ()->xcollection ()->playlistAddUrl (files.value (i)); } } else { FileDialog fd (this, "playlist_add_files"); @@ -382,7 +381,7 @@ PlaylistWidget::menuAddFile () files = fd.getFiles (); 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 (); if (files.count () > 0) { - XMMSHandler::getInstance ().xcollection ()->playlistClear (); + App->client ()->xcollection ()->playlistClear (); 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 PlaylistWidget::openPlaylistChooser () { - XMMSHandler &client = XMMSHandler::getInstance (); - PlaylistChooser *tmp = new PlaylistChooser (this, client.xcollection ()); + const XClient *client = App->client (); + PlaylistChooser *tmp = new PlaylistChooser (this, client->xcollection ()); tmp->show (); } diff --git a/src/playlist/playlistwidget.h b/src/playlist/playlistwidget.h index aa1e2cc..05d4005 100644 --- a/src/playlist/playlistwidget.h +++ b/src/playlist/playlistwidget.h @@ -16,8 +16,6 @@ #ifndef __PLAYLISTWIDGET_H__ #define __PLAYLISTWIDGET_H__ -#include "XMMSHandler.h" - #include #include #include @@ -35,7 +33,7 @@ class PixmapButton; class PlaylistSizeGrip : public QSizeGrip { Q_OBJECT - + public: PlaylistSizeGrip (QWidget *parent) : QSizeGrip (parent) {} ~PlaylistSizeGrip () {} diff --git a/src/playlist/playlistwindow.cpp b/src/playlist/playlistwindow.cpp index c491df0..7cfdff1 100644 --- a/src/playlist/playlistwindow.cpp +++ b/src/playlist/playlistwindow.cpp @@ -13,13 +13,12 @@ * GNU General Public License for more details. */ -#include "XMMSHandler.h" - #include "playlistwindow.h" #include #include #include +#include #include "playlistwidget.h" #include "playlistshade.h" diff --git a/src/src.pri b/src/src.pri index 01af089..17569dc 100644 --- a/src/src.pri +++ b/src/src.pri @@ -7,7 +7,6 @@ include($$PWD/dialogs/dialogs.pri) HEADERS += application.h \ Skin.h \ timedisplay.h \ - XMMSHandler.h \ SkinChooser.h \ settingsdialog.h \ basewindow.h \ @@ -18,7 +17,6 @@ HEADERS += application.h \ SOURCES += application.cpp \ timedisplay.cpp \ Skin.cpp \ - XMMSHandler.cpp \ SkinChooser.cpp \ settingsdialog.cpp \ basewindow.cpp \