diff --git a/lib/xclient.cpp b/lib/xclient.cpp index e6ec102..b754d13 100644 --- a/lib/xclient.cpp +++ b/lib/xclient.cpp @@ -137,7 +137,10 @@ try_again: } } - m_isconnected = true; + // useing normal disconnect callback, if that causes problems, + // an own method schould be created + setDisconnectCallback (boost::bind (&XClient::disconnect, this)); + m_isconnected = true; emit gotConnection (this); return true; diff --git a/lib/xclient.h b/lib/xclient.h index 9ef784f..99a15f2 100644 --- a/lib/xclient.h +++ b/lib/xclient.h @@ -36,7 +36,6 @@ class XClient : public QObject { public: XClient (QObject *, const std::string &); - void disconnect (); bool connect (const char *path = NULL, const bool &sync = false, QWidget* parent = NULL); static void propDictToQHash (const std::string &key, @@ -92,6 +91,9 @@ class XClient : public QObject { void gotConnection (XClient *); void disconnected (XClient *); + public slots: + void disconnect (); + protected: Xmms::Client *m_client; diff --git a/src/mainwindow/maindisplay.cpp b/src/mainwindow/maindisplay.cpp index c414b33..9fd315b 100644 --- a/src/mainwindow/maindisplay.cpp +++ b/src/mainwindow/maindisplay.cpp @@ -39,6 +39,7 @@ #include #include #include +#include MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent) { @@ -110,8 +111,21 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent) client.volumeGet(); setupServerConfig (); + + //TODO: move to better place + connect (&client, SIGNAL(disconnected(XClient *)), this, SLOT(handleDisconnected ())); } +void +MainDisplay::handleDisconnected () +{ + QMessageBox::critical( this, "xmms2 daemon disconnecte", + "The xmms2 deamon has disconnected\n" + "This could be because the server crashed\n" + "or because another client has shut down the sever.", + "Quit Promoe"); + qApp->quit (); +} void MainDisplay::updateVolume (uint volume) diff --git a/src/mainwindow/maindisplay.h b/src/mainwindow/maindisplay.h index 7f3e358..7388bad 100644 --- a/src/mainwindow/maindisplay.h +++ b/src/mainwindow/maindisplay.h @@ -77,7 +77,7 @@ class MainDisplay : public SkinDisplay protected slots: void serverConfigChanged (QString key, QString value); void setRepeatAllEnabled (bool enabled); - + void handleDisconnected (); protected: void SetupPushButtons (void); void SetupToggleButtons (void);