rework PlaylistWindow: move handling of visibilitychanges into Playlistwindow
and rely on signals and slots to get rid of MainWindow::togglePL(). cleaned up some unnecessary includes
This commit is contained in:
parent
b10ef97cfc
commit
a228d7a01b
14 changed files with 121 additions and 106 deletions
|
@ -81,7 +81,9 @@ void XClient::disconnect ()
|
|||
{
|
||||
delete m_client;
|
||||
m_client = NULL;
|
||||
m_isconnected = false;
|
||||
m_isconnected = false;
|
||||
|
||||
emit disconnected (this);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -94,7 +94,7 @@ class XClient : public QObject {
|
|||
|
||||
signals:
|
||||
void gotConnection (XClient *);
|
||||
|
||||
void disconnected (XClient *);
|
||||
|
||||
protected:
|
||||
Xmms::Client *m_client;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* This file is a part of Promoe, an XMMS2 Client
|
||||
*
|
||||
* Copyright (C) 2007 Thomas Frauendorfer
|
||||
* Copyright (C) 2007,2008 Thomas Frauendorfer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -22,42 +22,59 @@
|
|||
|
||||
XSettings::XSettings (QObject *parent, XClient *client) : QObject (parent)
|
||||
{
|
||||
connect (client, SIGNAL(gotConnection (XClient *)),
|
||||
this, SLOT (got_connection (XClient *)));
|
||||
connect (client, SIGNAL (gotConnection (XClient *)),
|
||||
this, SLOT (on_connect (XClient *)));
|
||||
|
||||
connect (client, SIGNAL (disconnected (XClient *)),
|
||||
this, SLOT (on_disconnect (XClient *)));
|
||||
|
||||
if (client->isConnected ()) {
|
||||
got_connection (client);
|
||||
on_connect (client);
|
||||
}
|
||||
}
|
||||
|
||||
QString
|
||||
XSettings::value_get (QString key)
|
||||
{
|
||||
/* local cache should be identical to serverside config */
|
||||
/* if XSettings is ready, the local cache should be in sync with the
|
||||
* serverside settings, otherwise the cache is empty */
|
||||
if (!m_ready) {
|
||||
return QString ();
|
||||
}
|
||||
return m_config_cache.value (key);
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
XSettings::value_set (QString key, QString val)
|
||||
{
|
||||
/* Only send change request to server here
|
||||
* update of local cache will be done through handle_config_value_changed
|
||||
*/
|
||||
if (!m_client->isConnected ()) {
|
||||
return false;
|
||||
}
|
||||
m_client->config ()->valueSet (key.toStdString (), val.toStdString ());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
XSettings::value_register (QString key, QString defval)
|
||||
{
|
||||
if (!m_client->isConnected ()) {
|
||||
return false;
|
||||
}
|
||||
m_client->config ()->valueRegister (key.toStdString (),
|
||||
defval.toStdString ());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
XSettings::got_connection (XClient *client)
|
||||
XSettings::on_connect (XClient *client)
|
||||
{
|
||||
client->config ()->valueList ()
|
||||
(Xmms::bind (&XSettings::handle_config_value_changed, this));
|
||||
(Xmms::bind (&XSettings::handle_config_value, this));
|
||||
|
||||
client->config ()->broadcastValueChanged ()
|
||||
(Xmms::bind (&XSettings::handle_config_value_changed, this));
|
||||
|
@ -65,6 +82,27 @@ XSettings::got_connection (XClient *client)
|
|||
m_client = client;
|
||||
}
|
||||
|
||||
void
|
||||
XSettings::on_disconnect (XClient *client)
|
||||
{
|
||||
/* We don't emit any signals here, as every class must be able to
|
||||
* react on the configChanged signal, which will be fired for every
|
||||
* configvalue on reonnect
|
||||
*/
|
||||
m_ready = false;
|
||||
m_config_cache.clear ();
|
||||
}
|
||||
|
||||
bool
|
||||
XSettings::handle_config_value (const Xmms::Dict &value)
|
||||
{
|
||||
bool ok = handle_config_value_changed (value);
|
||||
if (ok) {
|
||||
m_ready = true;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
XSettings::handle_config_value_changed (const Xmms::Dict &value)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* This file is a part of Promoe, an XMMS2 Client
|
||||
*
|
||||
* Copyright (C) 2007 Thomas Frauendorfer
|
||||
* Copyright (C) 2007,2008 Thomas Frauendorfer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -32,18 +32,23 @@ class XSettings : public QObject
|
|||
XSettings (QObject *parent, XClient *client);
|
||||
|
||||
QString value_get (QString key);
|
||||
void value_set (QString key, QString value);
|
||||
void value_register (QString key, QString defval);
|
||||
bool value_set (QString key, QString value);
|
||||
bool value_register (QString key, QString defval);
|
||||
|
||||
bool isReady (void) {return m_ready;}
|
||||
|
||||
signals:
|
||||
void configChanged(QString key, QString value);
|
||||
|
||||
public slots:
|
||||
void got_connection(XClient *);
|
||||
void on_connect (XClient *);
|
||||
void on_disconnect (XClient *);
|
||||
|
||||
private:
|
||||
bool handle_config_value (const Xmms::Dict &value);
|
||||
bool handle_config_value_changed (const Xmms::Dict &value);
|
||||
|
||||
bool m_ready;
|
||||
QHash < QString, QString > m_config_cache;
|
||||
XClient *m_client;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue