/*************************************************************************** * This file is part of pytextmonitor * * * * pytextmonitor is free software: you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation, either version 3 of the * * License, or (at your option) any later version. * * * * pytextmonitor is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with pytextmonitor. If not, see http://www.gnu.org/licenses/ * ***************************************************************************/ #include "awesome-widget.h" #include #include #include #include #include #include "customlabel.h" #include #include AwesomeWidget::AwesomeWidget(QObject *parent, const QVariantList &args) : Plasma::Applet(parent, args) { // debug QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); QString debugEnv = environment.value(QString("PTM_DEBUG"), QString("no")); if (debugEnv == QString("yes")) debug = true; else debug = false; setHasConfigurationInterface(true); // text format init formatLine.append(QString("")); formatLine.append(QString("")); } AwesomeWidget::~AwesomeWidget() { } QString AwesomeWidget::getNetworkDevice() { if (debug) qDebug() << PDEBUG; QString device = QString("lo"); if (configuration[QString("useCustomNetdev")].toInt() == 2) device = configuration[QString("customNetdev")]; else { QList rawInterfaceList = QNetworkInterface::allInterfaces(); for (int i=0; itoUnicode(process.output).toInt(); } void AwesomeWidget::init() { if (debug) qDebug() << PDEBUG; extsysmonEngine = dataEngine(QString("ext-sysmon")); sysmonEngine = dataEngine(QString("systemmonitor")); timeEngine = dataEngine(QString("time")); mainLayout = new QGraphicsLinearLayout(); mainLayout->setContentsMargins(1, 1, 1, 1); setLayout(mainLayout); textLabel = new CustomLabel(this, debug); // read variables configChanged(); timer = new QTimer(this); timer->setSingleShot(false); timer->setInterval(configuration[QString("interval")].toInt()); connect(timer, SIGNAL(timeout()), this, SLOT(updateText())); connect(timer, SIGNAL(timeout()), this, SLOT(updateTooltip())); timer->start(); } QStringList AwesomeWidget::findKeys() { if (debug) qDebug() << PDEBUG; QStringList selectedKeys; for (int i=0; i -1) { if (debug) qDebug() << PDEBUG << ":" << "Found key" << keys[i]; selectedKeys.append(keys[i]); } return selectedKeys; } QStringList AwesomeWidget::getKeys() { if (debug) qDebug() << PDEBUG; QStringList allKeys; int numCpus = getNumberCpus(); QMap deSettings = readDataEngineConfiguration(); // time allKeys.append(QString("time")); allKeys.append(QString("isotime")); allKeys.append(QString("shorttime")); allKeys.append(QString("longtime")); allKeys.append(QString("ctime")); // uptime allKeys.append(QString("uptime")); allKeys.append(QString("cuptime")); // cpu allKeys.append(QString("cpu")); for (int i=0; i