it works!

This commit is contained in:
arcan1s
2014-01-31 15:50:42 +04:00
parent ef5d319337
commit 0f5cd12f17
4 changed files with 54 additions and 7 deletions

View File

@ -24,6 +24,7 @@
#include <KNotification>
#include <QGraphicsLinearLayout>
#include <QGraphicsSceneMouseEvent>
#include <Plasma/DataEngine>
#include <Plasma/Frame>
#include <plasma/theme.h>
#include <stdio.h>
@ -75,7 +76,11 @@ void Netctl::init()
// read variables
configChanged();
this->resize(-1,48);
this->resize(100,48);
// connect to dataengine
connectToEngine();
printf ("done init\n");
}
@ -100,6 +105,39 @@ int Netctl::sendNotification(QString eventId, int num)
}
// data engine interaction
void Netctl::connectToEngine()
{
printf ("source\n");
Plasma::DataEngine *netctlEngine = dataEngine(QString("netctl"));
netctlEngine->connectSource(QString("currentProfile"), this, autoUpdateInterval);
netctlEngine->connectSource(QString("extIp"), this, autoUpdateInterval);
netctlEngine->connectSource(QString("interfaces"), this, autoUpdateInterval);
netctlEngine->connectSource(QString("intIp"), this, autoUpdateInterval);
netctlEngine->connectSource(QString("profiles"), this, autoUpdateInterval);
netctlEngine->connectSource(QString("statusBool"), this, autoUpdateInterval);
netctlEngine->connectSource(QString("statusString"), this, autoUpdateInterval);
}
void Netctl::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
{
if (data.keys().count() == 0)
return;
QString value;
printf ("dataupdate\n");
if (sourceName == QString("currentProfile"))
{
value = data[QString("value")].toString();
if (value == QString(""))
value = QString("N\\A");
textLabel->setText(value);
}
update();
}
// configuration interface
void Netctl::createConfigurationInterface(KConfigDialog *parent)
{