mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
it works!
This commit is contained in:
parent
ef5d319337
commit
0f5cd12f17
@ -1,4 +1,4 @@
|
||||
netctlmonitor
|
||||
=============
|
||||
netctl-plasmoid
|
||||
===============
|
||||
|
||||
Plasmoid written on C++ which interacts with netctl
|
||||
|
@ -200,15 +200,19 @@ bool Netctl::updateSourceEvent(const QString &source)
|
||||
command.start(cmd + QString(" status ") + currentProfile);
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
value = QString("static");
|
||||
if (cmdOutput != QString("")) {
|
||||
QStringList profile = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profile.count(); i++)
|
||||
if (profile[i].split(QString(" "), QString::SkipEmptyParts)[0] == QString("Loaded:"))
|
||||
if (profile[i].split(QString(" "), QString::SkipEmptyParts)[0] == QString("Loaded:")) {
|
||||
if (profile[i].indexOf(QString("enabled")) > -1) {
|
||||
value = QString("enabled");
|
||||
break;
|
||||
}
|
||||
else if (profile[i].indexOf(QString("static")) > -1) {
|
||||
value = QString("static");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
setData(source, QString("value"), value);
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -36,8 +36,11 @@ public:
|
||||
void init();
|
||||
|
||||
public slots:
|
||||
// ui
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
||||
int sendNotification(QString eventId, int num);
|
||||
// for dataengine
|
||||
void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data);
|
||||
// for configuration interface
|
||||
void configAccepted();
|
||||
void configChanged();
|
||||
@ -51,6 +54,10 @@ private:
|
||||
Plasma::IconWidget *iconWidget;
|
||||
Plasma::Label *textLabel;
|
||||
QStringList formatLine;
|
||||
// data engine
|
||||
void connectToEngine();
|
||||
// configuration interface
|
||||
Ui::ConfigWindow uiConfig;
|
||||
// configuration
|
||||
int autoUpdateInterval;
|
||||
QString guiPath;
|
||||
@ -65,8 +72,6 @@ private:
|
||||
QString fontStyle;
|
||||
QString activeIconPath;
|
||||
QString inactiveIconPath;
|
||||
// configuration interface
|
||||
Ui::ConfigWindow uiConfig;
|
||||
};
|
||||
|
||||
K_EXPORT_PLASMA_APPLET(netctl, Netctl)
|
||||
|
Loading…
Reference in New Issue
Block a user