OTHER: Make 'Quit server on close' option work
This commit is contained in:
parent
ef687a9375
commit
5e8d83ca8e
8 changed files with 102 additions and 37 deletions
|
@ -31,19 +31,6 @@
|
||||||
#include "xmmsqt4.h"
|
#include "xmmsqt4.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
/*
|
|
||||||
XSettings::XSettings (QObject *parent) : QObject (parent)
|
|
||||||
{
|
|
||||||
// * dummy *
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
XSettings::change_settings ()
|
|
||||||
{
|
|
||||||
emit settingsChanged ();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
XClient::stdToQ (const std::string &str)
|
XClient::stdToQ (const std::string &str)
|
||||||
{
|
{
|
||||||
|
@ -94,6 +81,15 @@ void XClient::disconnect ()
|
||||||
emit disconnected (this);
|
emit disconnected (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
XClient::quit ()
|
||||||
|
{
|
||||||
|
if (!m_client)
|
||||||
|
return false;
|
||||||
|
m_client->quit ();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
XClient::connect (const char *ipcpath, const bool &sync, QWidget *parent)
|
XClient::connect (const char *ipcpath, const bool &sync, QWidget *parent)
|
||||||
{
|
{
|
||||||
|
@ -137,10 +133,10 @@ try_again:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_isconnected = true;
|
||||||
// useing normal disconnect callback, if that causes problems,
|
// useing normal disconnect callback, if that causes problems,
|
||||||
// an own method schould be created
|
// an own method schould be created
|
||||||
setDisconnectCallback (boost::bind (&XClient::disconnect, this));
|
setDisconnectCallback (boost::bind (&XClient::disconnect, this));
|
||||||
m_isconnected = true;
|
|
||||||
emit gotConnection (this);
|
emit gotConnection (this);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -93,6 +93,7 @@ class XClient : public QObject {
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void disconnect ();
|
void disconnect ();
|
||||||
|
bool quit ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Xmms::Client *m_client;
|
Xmms::Client *m_client;
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
|
|
||||||
#include "XMMSHandler.h"
|
#include "XMMSHandler.h"
|
||||||
|
|
||||||
|
#include "application.h"
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "Skin.h"
|
#include "Skin.h"
|
||||||
|
|
||||||
|
@ -23,19 +25,60 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
Application::Application (int &argc, char **argv) : QApplication (argc, argv)
|
||||||
|
{
|
||||||
|
m_want_quit = false;
|
||||||
|
|
||||||
|
//TODO: Change to XClient sometime later
|
||||||
|
XMMSHandler &client = XMMSHandler::getInstance ();
|
||||||
|
|
||||||
|
connect (&client, SIGNAL(disconnected(XClient *)),
|
||||||
|
this, SLOT(handleDisconnected ()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Application::quit ()
|
||||||
|
{
|
||||||
|
// quit for real in case something went wrong earlier
|
||||||
|
if (m_want_quit)
|
||||||
|
QApplication::quit ();
|
||||||
|
|
||||||
|
QSettings s;
|
||||||
|
if (s.value ("promoe/quitonclose", false).toBool ()) {
|
||||||
|
m_want_quit = true;
|
||||||
|
if (!XMMSHandler::getInstance ().quit ()) {
|
||||||
|
QApplication::quit ();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
QApplication::quit ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Application::handleDisconnected ()
|
||||||
|
{
|
||||||
|
if (!m_want_quit) {
|
||||||
|
// TODO: enable reconnect
|
||||||
|
QMessageBox::critical( NULL, "xmms2 daemon disconnected",
|
||||||
|
"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");
|
||||||
|
}
|
||||||
|
QApplication::quit ();
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
Application app(argc, argv);
|
||||||
|
|
||||||
QCoreApplication::setOrganizationName("xmms2");
|
QCoreApplication::setOrganizationName("xmms2");
|
||||||
QCoreApplication::setOrganizationDomain("xmms.org");
|
QCoreApplication::setOrganizationDomain("xmms.org");
|
||||||
QCoreApplication::setApplicationName("Promoe");
|
QCoreApplication::setApplicationName("Promoe");
|
||||||
|
|
||||||
//TODO: Change to XClient sometime later
|
|
||||||
XMMSHandler &client = XMMSHandler::getInstance ();
|
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
#ifdef Q_OS_MACX
|
#ifdef Q_OS_MACX
|
38
src/application.h
Normal file
38
src/application.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/**
|
||||||
|
* 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 <QApplication>
|
||||||
|
|
||||||
|
class Application;
|
||||||
|
#if defined(qApp)
|
||||||
|
#undef qApp
|
||||||
|
#endif
|
||||||
|
#define qApp (static_cast<Application *>(QCoreApplication::instance()))
|
||||||
|
|
||||||
|
class Application : public QApplication
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Application (int &argc, char **argv);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void quit ();
|
||||||
|
void handleDisconnected ();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_want_quit;
|
||||||
|
};
|
|
@ -121,20 +121,6 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent)
|
||||||
this, SLOT (setPlaytime (uint32_t)));
|
this, SLOT (setPlaytime (uint32_t)));
|
||||||
|
|
||||||
setupServerConfig ();
|
setupServerConfig ();
|
||||||
|
|
||||||
//TODO: move to better place
|
|
||||||
connect (&client, SIGNAL(disconnected(XClient *)), this, SLOT(handleDisconnected ()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
MainDisplay::handleDisconnected ()
|
|
||||||
{
|
|
||||||
QMessageBox::critical( this, "xmms2 daemon disconnected",
|
|
||||||
"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
|
void
|
||||||
|
|
|
@ -81,7 +81,7 @@ class MainDisplay : public SkinDisplay
|
||||||
protected slots:
|
protected slots:
|
||||||
void serverConfigChanged (QString key, QString value);
|
void serverConfigChanged (QString key, QString value);
|
||||||
void setRepeatAllEnabled (bool enabled);
|
void setRepeatAllEnabled (bool enabled);
|
||||||
void handleDisconnected ();
|
|
||||||
protected:
|
protected:
|
||||||
void SetupPushButtons (void);
|
void SetupPushButtons (void);
|
||||||
void SetupToggleButtons (void);
|
void SetupToggleButtons (void);
|
||||||
|
|
|
@ -328,10 +328,10 @@ SettingsTabMain::SettingsTabMain (QWidget *parent) : QWidget (parent)
|
||||||
vbox->addWidget (c, 1);
|
vbox->addWidget (c, 1);
|
||||||
|
|
||||||
m_quitonclose = new QCheckBox (tr ("Quit XMMS2D when closing Promoe"), c);
|
m_quitonclose = new QCheckBox (tr ("Quit XMMS2D when closing Promoe"), c);
|
||||||
if (s.contains ("promoe/quitonclose"))
|
if (!s.contains ("promoe/quitonclose"))
|
||||||
s.setValue ("promoe/quitonclose", false);
|
s.setValue ("promoe/quitonclose", false);
|
||||||
m_quitonclose->setCheckState (s.value ("promoe/quitonclose").toBool () ? Qt::Checked : Qt::Unchecked);
|
m_quitonclose->setCheckState (s.value ("promoe/quitonclose").toBool () ? Qt::Checked : Qt::Unchecked);
|
||||||
m_quitonclose->setEnabled (false); // FIXME: disabled for now, not working
|
//m_quitonclose->setEnabled (false); // FIXME: disabled for now, not working
|
||||||
h->addWidget (m_quitonclose);
|
h->addWidget (m_quitonclose);
|
||||||
|
|
||||||
c = new QWidget (dummy);
|
c = new QWidget (dummy);
|
||||||
|
|
|
@ -4,7 +4,8 @@ include($$PWD/playlist/playlist.pri)
|
||||||
include($$PWD/equalizer/equalizer.pri)
|
include($$PWD/equalizer/equalizer.pri)
|
||||||
include($$PWD/dialogs/dialogs.pri)
|
include($$PWD/dialogs/dialogs.pri)
|
||||||
|
|
||||||
HEADERS += Skin.h \
|
HEADERS += application.h \
|
||||||
|
Skin.h \
|
||||||
timedisplay.h \
|
timedisplay.h \
|
||||||
XMMSHandler.h \
|
XMMSHandler.h \
|
||||||
SkinChooser.h \
|
SkinChooser.h \
|
||||||
|
@ -14,7 +15,7 @@ HEADERS += Skin.h \
|
||||||
BrowseModel.h \
|
BrowseModel.h \
|
||||||
BrowseDialog.h
|
BrowseDialog.h
|
||||||
|
|
||||||
SOURCES += main.cpp \
|
SOURCES += application.cpp \
|
||||||
timedisplay.cpp \
|
timedisplay.cpp \
|
||||||
Skin.cpp \
|
Skin.cpp \
|
||||||
XMMSHandler.cpp \
|
XMMSHandler.cpp \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue