possible fix #43
This commit is contained in:
arcan1s
2015-06-21 01:13:37 +03:00
parent 69f6a3135b
commit b65ba2ebe2
7 changed files with 45 additions and 11 deletions

View File

@ -41,6 +41,8 @@ NetctlAdds::NetctlAdds(QObject *parent)
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
debug = (debugEnv == QString("yes"));
connect(this, SIGNAL(needToNotify(bool)), this, SLOT(notifyAboutStatusChanging(bool)));
}
@ -50,6 +52,18 @@ NetctlAdds::~NetctlAdds()
}
void NetctlAdds::notifyAboutStatusChanging(const bool currentStatus)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Status" << currentStatus;
if (currentStatus)
return NetctlAdds::sendNotification(QString("Info"), i18n("Network status has been changed to active"));
else
return NetctlAdds::sendNotification(QString("Info"), i18n("Network status has been changed to inactive"));
}
QList<QVariant> NetctlAdds::sendDBusRequest(const QString cmd, const QList<QVariant> args)
{
if (debug) qDebug() << PDEBUG;
@ -158,28 +172,30 @@ void NetctlAdds::setDataBySource(const QString sourceName, const QVariantMap dat
bool needUpdate = (values[sourceName] != data[QString("value")].toString());
values[sourceName] = data[QString("value")].toString();
// if ((needUpdate) && (sourceName == QString("active"))) {
// if (values[sourceName] == QString("true"))
// sendNotification(QString("Info"), i18n("Network status has been changed to active"));
// else
// sendNotification(QString("Info"), i18n("Network status has been changed to inactive"));
// }
if (needUpdate) emit(needToBeUpdated());
if (needUpdate) {
emit(needToBeUpdated());
// if (sourceName == QString("active"))
// emit(needToNotify(values[QString("active")] == QString("true")));
}
}
void NetctlAdds::sendNotification(const QString eventId, const QString message)
{
// since it is a static method we need to identify is debug enabled again
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
bool debugLocal = (debugEnv == QString("yes"));
if (debugLocal) qDebug() << PDEBUG;
if (debugLocal) qDebug() << PDEBUG << ":" << "Event" << eventId;
if (debugLocal) qDebug() << PDEBUG << ":" << "Message" << message;
KNotification *notification = KNotification::event(eventId, QString("Netctl ::: %1").arg(eventId), message);
notification->setComponentName(QString("plasma-applet-org.kde.plasma.netctl"));
notification->deleteLater();
}

View File

@ -64,6 +64,10 @@ public:
signals:
void needToBeUpdated();
void needToNotify(const bool currentStatus);
private slots:
void notifyAboutStatusChanging(const bool currentStatus);
private:
bool debug = false;