Changes: BoosterKiller polished

RevBy: Antti Kervinen
pull/1/head
Jussi Lind 15 years ago
parent 77de29cbff
commit b4480b410b

@ -17,36 +17,35 @@
** **
****************************************************************************/ ****************************************************************************/
#include <QString>
#include <QCoreApplication> #include <QCoreApplication>
#include <QObject> #include <QObject>
#include <MGConfItem>
#include "boosterkiller.h"
#include <cstdlib> #include <cstdlib>
#include "boosterkiller.h"
void BoosterKiller::addKey(const QString & key) void BoosterKiller::addKey(const QString & key)
{ {
MGConfItem * item = new MGConfItem(key, 0); MGConfItem * item = new MGConfItem(key, 0);
m_gConfItems << QSharedPointer<MGConfItem>(item);
QObject::connect(item, SIGNAL(valueChanged()), QObject::connect(item, SIGNAL(valueChanged()),
this, SLOT(killProcesses())); this, SLOT(killProcesses()));
} }
void BoosterKiller::addProcessName(const QString & processName) void BoosterKiller::addProcessName(const QString & processName)
{ {
processNames << processName; m_processNames << processName;
} }
void BoosterKiller::start() void BoosterKiller::start()
{ {
int argc = 0; int argc = 0;
//char **argv = 0;
QCoreApplication(argc, 0).exec(); QCoreApplication(argc, 0).exec();
} }
void BoosterKiller::killProcesses() void BoosterKiller::killProcesses()
{ {
Q_FOREACH(QString processName, processNames) { Q_FOREACH(QString processName, m_processNames) {
system( (QString("pkill ") + processName).toStdString().c_str() ); system( (QString("pkill ") + processName).toStdString().c_str() );
} }
} }

@ -22,33 +22,42 @@
#include <QObject> #include <QObject>
#include <QStringList> #include <QStringList>
#include <QSharedPointer>
#include <MGConfItem>
class QString; class QString;
class MGConfItem;
/*! \class BoosterKiller
*
* BoosterKiller kills certain boosters e.g. when themeing or language changes.
* Daemon will then restart the boosters.
*/
class BoosterKiller : public QObject class BoosterKiller : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
/* Add a GConf key and the name of the process that should be
killed in case the value associated to the key is changed. //! Add a GConf key to trigger booster process termination
*/
void addKey(const QString & key); void addKey(const QString & key);
//! Add a booster process name to be killed
void addProcessName(const QString & processName); void addProcessName(const QString & processName);
/* Starts the killer. This will initialize qcoreapplication, does /*! Starts the killer. This will initialize a QCoreApplication, does
not return. * not return.
*/ */
void start(); void start();
private slots: private Q_SLOTS:
//! Kill all added processes
void killProcesses(); void killProcesses();
private: private:
QList<MGConfItem*> gconfItems;
QStringList processNames;
QStringList m_processNames;
QList<QSharedPointer<MGConfItem> > m_gConfItems;
}; };
#endif #endif // BOOSTERKILLER_H

Loading…
Cancel
Save