mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 16:07:19 +00:00
work on plugin
This commit is contained in:
parent
0288e6e1eb
commit
f5fbb80d91
@ -21,18 +21,23 @@
|
|||||||
#include <KNotifications/KNotification>
|
#include <KNotifications/KNotification>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QMessageBox>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkInterface>
|
#include <QNetworkInterface>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
#include <QProcess>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
#include <pdebug/pdebug.h>
|
#include <pdebug/pdebug.h>
|
||||||
#include <task/taskadds.h>
|
//#include <task/taskadds.h>
|
||||||
|
|
||||||
|
#include "extscript.h"
|
||||||
#include "graphicalitem.h"
|
#include "graphicalitem.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
@ -44,6 +49,8 @@ AWAdds::AWAdds(QObject *parent)
|
|||||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||||
debug = (debugEnv == QString("yes"));
|
debug = (debugEnv == QString("yes"));
|
||||||
|
|
||||||
|
initValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -53,6 +60,41 @@ AWAdds::~AWAdds()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWAdds::checkUpdates()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
||||||
|
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(versionReplyRecieved(QNetworkReply *)));
|
||||||
|
|
||||||
|
manager->get(QNetworkRequest(QUrl(VERSION_API)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWAdds::initValues()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
// clear
|
||||||
|
extScripts.clear();
|
||||||
|
graphicalItems.clear();
|
||||||
|
keys.clear();
|
||||||
|
|
||||||
|
// init
|
||||||
|
extScripts = getExtScripts();
|
||||||
|
graphicalItems = getGraphicalItems();
|
||||||
|
keys = dictKeys();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWAdds::isDebugEnabled()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString AWAdds::networkDevice(const QString custom)
|
QString AWAdds::networkDevice(const QString custom)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@ -79,14 +121,26 @@ int AWAdds::numberCpus()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QString cmd = QString("grep -c ^processor /proc/cpuinfo");
|
return QThread::idealThreadCount();
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
}
|
||||||
TaskResult process = runTask(cmd);
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
|
||||||
if (process.exitCode != 0)
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
|
||||||
|
|
||||||
return QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed().toInt();
|
|
||||||
|
QString AWAdds::parsePattern(const QString pattern, const QMap<QString, QVariant> dict,
|
||||||
|
const QMap<QString, QVariant> values,
|
||||||
|
const QStringList foundKeys, const QStringList foundBars)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Dictionary" << dict;
|
||||||
|
|
||||||
|
QString parsed = pattern;
|
||||||
|
parsed.replace(QString("$$"), QString("$\\$\\"));
|
||||||
|
for (int i=0; i<foundKeys.count(); i++)
|
||||||
|
parsed.replace(QString("$") + foundKeys[i], values[foundKeys[i]]);
|
||||||
|
for (int i=0; i<foundBars.count(); i++)
|
||||||
|
parsed.replace(QString("$") + foundBars[i], getItemByTag(foundBars[i])->getImage(values[foundBars[i]].toFloat()));
|
||||||
|
parsed.replace(QString("$\\$\\"), QString("$$"));
|
||||||
|
|
||||||
|
return parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -114,6 +168,136 @@ float AWAdds::tempepature(const float temp, const QString units)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QMap<QString, QVariant> AWAdds::counts()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QMap<QString, QVariant> awCounts;
|
||||||
|
awCounts[QString("cpu")] = numberCpus();
|
||||||
|
awCounts[QString("custom")] = getExtScripts().count();
|
||||||
|
// awCounts[QString("disk")] = configuration[QString("disk")].split(QString("@@")).count();
|
||||||
|
// awCounts[QString("fan")] = configuration[QString("fanDevice")].split(QString("@@")).count();
|
||||||
|
// awCounts[QString("hddtemp")] = configuration[QString("hdd")].split(QString("@@")).count();
|
||||||
|
// awCounts[QString("mount")] = configuration[QString("mount")].split(QString("@@")).count();
|
||||||
|
// awCounts[QString("pkg")] = deSettings[QString("PKGCMD")].split(QChar(',')).count();
|
||||||
|
// awCounts[QString("temp")] = configuration[QString("tempDevice")].split(QString("@@")).count();
|
||||||
|
// awCounts[QString("tooltip")] = 0;
|
||||||
|
// awCounts[QString("tooltip")] += configuration[QString("cpuTooltip")].toInt();
|
||||||
|
// awCounts[QString("tooltip")] += configuration[QString("cpuclTooltip")].toInt();
|
||||||
|
// awCounts[QString("tooltip")] += configuration[QString("memTooltip")].toInt();
|
||||||
|
// awCounts[QString("tooltip")] += configuration[QString("swapTooltip")].toInt();
|
||||||
|
// awCounts[QString("tooltip")] += configuration[QString("downTooltip")].toInt();
|
||||||
|
// awCounts[QString("tooltip")] += configuration[QString("batteryTooltip")].toInt();
|
||||||
|
// awCounts[QString("tooltip")] = counts[QString("tooltip")] / 2;
|
||||||
|
|
||||||
|
return awCounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList AWAdds::dictKeys()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QMap<QString, QVariant> awCounts = counts();
|
||||||
|
QStringList allKeys;
|
||||||
|
// 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"));
|
||||||
|
// cpuclock
|
||||||
|
for (int i=awCounts[QString("cpu")].toInt()-1; i>=0; i--)
|
||||||
|
allKeys.append(QString("cpucl") + QString::number(i));
|
||||||
|
allKeys.append(QString("cpucl"));
|
||||||
|
// cpu
|
||||||
|
for (int i=awCounts[QString("cpu")].toInt()-1; i>=0; i--)
|
||||||
|
allKeys.append(QString("cpu") + QString::number(i));
|
||||||
|
allKeys.append(QString("cpu"));
|
||||||
|
// temperature
|
||||||
|
for (int i=awCounts[QString("temp")].toInt()-1; i>=0; i--)
|
||||||
|
allKeys.append(QString("temp") + QString::number(i));
|
||||||
|
for (int i=awCounts[QString("fan")].toInt()-1; i>=0; i--)
|
||||||
|
allKeys.append(QString("fan") + QString::number(i));
|
||||||
|
// gputemp
|
||||||
|
allKeys.append(QString("gputemp"));
|
||||||
|
// gpu
|
||||||
|
allKeys.append(QString("gpu"));
|
||||||
|
// memory
|
||||||
|
allKeys.append(QString("memmb"));
|
||||||
|
allKeys.append(QString("memgb"));
|
||||||
|
allKeys.append(QString("memfreemb"));
|
||||||
|
allKeys.append(QString("memfreegb"));
|
||||||
|
allKeys.append(QString("memtotmb"));
|
||||||
|
allKeys.append(QString("memtotgb"));
|
||||||
|
allKeys.append(QString("memusedmb"));
|
||||||
|
allKeys.append(QString("memusedgb"));
|
||||||
|
allKeys.append(QString("mem"));
|
||||||
|
// swap
|
||||||
|
allKeys.append(QString("swapmb"));
|
||||||
|
allKeys.append(QString("swapgb"));
|
||||||
|
allKeys.append(QString("swapfreemb"));
|
||||||
|
allKeys.append(QString("swapfreegb"));
|
||||||
|
allKeys.append(QString("swaptotmb"));
|
||||||
|
allKeys.append(QString("swaptotgb"));
|
||||||
|
allKeys.append(QString("swap"));
|
||||||
|
// hdd
|
||||||
|
for (int i=awCounts[QString("mount")].toInt()-1; i>=0; i--) {
|
||||||
|
allKeys.append(QString("hddmb") + QString::number(i));
|
||||||
|
allKeys.append(QString("hddgb") + QString::number(i));
|
||||||
|
allKeys.append(QString("hddfreemb") + QString::number(i));
|
||||||
|
allKeys.append(QString("hddfreegb") + QString::number(i));
|
||||||
|
allKeys.append(QString("hddtotmb") + QString::number(i));
|
||||||
|
allKeys.append(QString("hddtotgb") + QString::number(i));
|
||||||
|
allKeys.append(QString("hdd") + QString::number(i));
|
||||||
|
}
|
||||||
|
// hdd speed
|
||||||
|
for (int i=awCounts[QString("disk")].toInt()-1; i>=0; i--) {
|
||||||
|
allKeys.append(QString("hddr") + QString::number(i));
|
||||||
|
allKeys.append(QString("hddw") + QString::number(i));
|
||||||
|
}
|
||||||
|
// hdd temp
|
||||||
|
for (int i=awCounts[QString("hddtemp")].toInt()-1; i>=0; i--) {
|
||||||
|
allKeys.append(QString("hddtemp") + QString::number(i));
|
||||||
|
allKeys.append(QString("hddtemp") + QString::number(i));
|
||||||
|
}
|
||||||
|
// network
|
||||||
|
allKeys.append(QString("down"));
|
||||||
|
allKeys.append(QString("up"));
|
||||||
|
allKeys.append(QString("netdev"));
|
||||||
|
// battery
|
||||||
|
allKeys.append(QString("ac"));
|
||||||
|
for (int i=awCounts[QString("bat")].toInt()-1; i>=0; i--)
|
||||||
|
allKeys.append(QString("bat") + QString::number(i));
|
||||||
|
allKeys.append(QString("bat"));
|
||||||
|
// player
|
||||||
|
allKeys.append(QString("album"));
|
||||||
|
allKeys.append(QString("artist"));
|
||||||
|
allKeys.append(QString("duration"));
|
||||||
|
allKeys.append(QString("progress"));
|
||||||
|
allKeys.append(QString("title"));
|
||||||
|
// ps
|
||||||
|
allKeys.append(QString("pscount"));
|
||||||
|
allKeys.append(QString("pstotal"));
|
||||||
|
allKeys.append(QString("ps"));
|
||||||
|
// package manager
|
||||||
|
for (int i=awCounts[QString("pkg")].toInt()-1; i>=0; i--)
|
||||||
|
allKeys.append(QString("pkgcount") + QString::number(i));
|
||||||
|
// custom
|
||||||
|
for (int i=awCounts[QString("custom")].toInt()-1; i>=0; i--)
|
||||||
|
allKeys.append(QString("custom") + QString::number(i));
|
||||||
|
// desktop
|
||||||
|
allKeys.append(QString("desktop"));
|
||||||
|
allKeys.append(QString("ndesktop"));
|
||||||
|
allKeys.append(QString("tdesktops"));
|
||||||
|
|
||||||
|
return allKeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList AWAdds::timeKeys()
|
QStringList AWAdds::timeKeys()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@ -140,6 +324,70 @@ QStringList AWAdds::timeKeys()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList AWAdds::findGraphicalItems(const QString pattern)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QStringList orderedKeys;
|
||||||
|
for (int i=0; i<graphicalItems.count(); i++)
|
||||||
|
orderedKeys.append(graphicalItems[i]->getName() + graphicalItems[i]->getBar());
|
||||||
|
orderedKeys.sort();
|
||||||
|
|
||||||
|
QStringList selectedKeys;
|
||||||
|
for (int i=orderedKeys.count()-1; i>=0; i--)
|
||||||
|
if (pattern.contains(QString("$") + orderedKeys[i])) {
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Found key" << orderedKeys[i];
|
||||||
|
selectedKeys.append(orderedKeys[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return selectedKeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AWAdds::findKeys(const QString pattern)
|
||||||
|
{
|
||||||
|
QStringList selectedKeys;
|
||||||
|
for (int i=0; i<keys.count(); i++)
|
||||||
|
if (pattern.contains(QString("$") + keys[i])) {
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Found key" << keys[i];
|
||||||
|
selectedKeys.append(keys[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return selectedKeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWAdds::runCmd(const QString cmd)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||||
|
|
||||||
|
QProcess command;
|
||||||
|
sendNotification(QString("Info"), i18n("Run %1", cmd));
|
||||||
|
|
||||||
|
command.startDetached(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWAdds::sendNotification(const QString eventId, const QString message)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Event" << eventId;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Message" << message;
|
||||||
|
|
||||||
|
KNotification *notification = KNotification::event(eventId, QString("Awesome Widget ::: ") + eventId, message);
|
||||||
|
notification->setComponentName(QString("plasma-applet-org.kde.plasma.awesome-widget"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWAdds::showReadme()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QDesktopServices::openUrl(QString(HOMEPAGE));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QMap<QString, QVariant> AWAdds::readDataEngineConfiguration()
|
QMap<QString, QVariant> AWAdds::readDataEngineConfiguration()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@ -204,3 +452,127 @@ void AWAdds::writeDataEngineConfiguration(const QMap<QString, QVariant> configur
|
|||||||
|
|
||||||
settings.sync();
|
settings.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWAdds::showUpdates(QString version)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QString text;
|
||||||
|
text += i18n("Current version : %1", QString(VERSION)) + QString("\n");
|
||||||
|
text += i18n("New version : %1", version) + QString("\n\n");
|
||||||
|
text += i18n("Click \"Ok\" to download");
|
||||||
|
|
||||||
|
int select = QMessageBox::information(0, i18n("There are updates"), text, QMessageBox::Ok | QMessageBox::Cancel);
|
||||||
|
switch(select) {
|
||||||
|
case QMessageBox::Ok:
|
||||||
|
QDesktopServices::openUrl(QString(RELEASES) + version);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWAdds::versionReplyRecieved(QNetworkReply *reply)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QString answer = reply->readAll();
|
||||||
|
if (!answer.contains(QString("tag_name"))) return;
|
||||||
|
QString version = QString(VERSION);
|
||||||
|
if (debug) qDebug() << PDEBUG << answer;
|
||||||
|
for (int i=0; i<answer.split(QString("tag_name")).count(); i++) {
|
||||||
|
version = answer.split(QString("tag_name"))[1].split(QChar(','))[0];
|
||||||
|
version.remove(QChar('"'));
|
||||||
|
version.remove(QChar(':'));
|
||||||
|
version.remove(QString("V."));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int old_major = QString(VERSION).split(QChar('.'))[0].toInt();
|
||||||
|
int old_minor = QString(VERSION).split(QChar('.'))[1].toInt();
|
||||||
|
int old_patch = QString(VERSION).split(QChar('.'))[2].toInt();
|
||||||
|
int new_major = QString(version).split(QChar('.'))[0].toInt();
|
||||||
|
int new_minor = QString(version).split(QChar('.'))[1].toInt();
|
||||||
|
int new_patch = QString(version).split(QChar('.'))[2].toInt();
|
||||||
|
if ((old_major < new_major) ||
|
||||||
|
((old_major == new_major) && (old_minor < new_minor)) ||
|
||||||
|
((old_major == new_major) && (old_minor == new_minor) && (old_patch < new_patch)))
|
||||||
|
showUpdates(version);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<ExtScript *> AWAdds::getExtScripts()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QList<ExtScript *> externalScripts;
|
||||||
|
// create directory at $HOME
|
||||||
|
QString localDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation) +
|
||||||
|
QString("/plasma_engine_extsysmon/scripts");
|
||||||
|
QDir localDirectory;
|
||||||
|
if (localDirectory.mkdir(localDir))
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
|
||||||
|
|
||||||
|
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::DataLocation,
|
||||||
|
QString("plasma_engine_extsysmon/scripts"),
|
||||||
|
QStandardPaths::LocateDirectory);
|
||||||
|
QStringList names;
|
||||||
|
for (int i=0; i<dirs.count(); i++) {
|
||||||
|
QStringList files = QDir(dirs[i]).entryList(QDir::Files, QDir::Name);
|
||||||
|
for (int j=0; j<files.count(); j++) {
|
||||||
|
if (!files[j].endsWith(QString(".desktop"))) continue;
|
||||||
|
if (names.contains(files[j])) continue;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Found file" << files[j] << "in" << dirs[i];
|
||||||
|
names.append(files[j]);
|
||||||
|
externalScripts.append(new ExtScript(0, files[j], dirs, debug));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return externalScripts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<GraphicalItem *> AWAdds::getGraphicalItems()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QList<GraphicalItem *> items;
|
||||||
|
// create directory at $HOME
|
||||||
|
QString localDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation) +
|
||||||
|
QString("/plasma_applet_awesome-widget/desktops");
|
||||||
|
QDir localDirectory;
|
||||||
|
if (localDirectory.mkdir(localDir))
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
|
||||||
|
|
||||||
|
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::DataLocation,
|
||||||
|
QString("plasma_applet_awesome-widget/desktops"),
|
||||||
|
QStandardPaths::LocateDirectory);
|
||||||
|
QStringList names;
|
||||||
|
for (int i=0; i<dirs.count(); i++) {
|
||||||
|
QStringList files = QDir(dirs[i]).entryList(QDir::Files, QDir::Name);
|
||||||
|
for (int j=0; j<files.count(); j++) {
|
||||||
|
if (!files[j].endsWith(QString(".desktop"))) continue;
|
||||||
|
if (names.contains(files[j])) continue;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Found file" << files[j] << "in" << dirs[i];
|
||||||
|
names.append(files[j]);
|
||||||
|
items.append(new GraphicalItem(0, files[j], dirs, debug));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GraphicalItem *AWAdds::getItemByTag(const QString tag)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
GraphicalItem *item = nullptr;
|
||||||
|
for (int i=0; i< graphicalItems.count(); i++) {
|
||||||
|
if ((graphicalItems[i]->getName() + graphicalItems[i]->getBar()) != tag) continue;
|
||||||
|
item = graphicalItems[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
@ -25,6 +25,10 @@
|
|||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
|
|
||||||
|
class ExtScript;
|
||||||
|
class GraphicalItem;
|
||||||
|
class QNetworkReply;
|
||||||
|
|
||||||
class AWAdds : public QObject
|
class AWAdds : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -33,17 +37,44 @@ public:
|
|||||||
AWAdds(QObject *parent = 0);
|
AWAdds(QObject *parent = 0);
|
||||||
~AWAdds();
|
~AWAdds();
|
||||||
|
|
||||||
|
Q_INVOKABLE void checkUpdates();
|
||||||
|
Q_INVOKABLE void initValues();
|
||||||
|
Q_INVOKABLE bool isDebugEnabled();
|
||||||
Q_INVOKABLE QString networkDevice(const QString custom = QString(""));
|
Q_INVOKABLE QString networkDevice(const QString custom = QString(""));
|
||||||
Q_INVOKABLE int numberCpus();
|
Q_INVOKABLE int numberCpus();
|
||||||
|
Q_INVOKABLE QString parsePattern(const QString pattern, const QMap<QString, QVariant> dict,
|
||||||
|
const QMap<QString, QVariant> values,
|
||||||
|
const QStringList foundKeys, const QStringList foundBars);
|
||||||
Q_INVOKABLE float tempepature(const float temp, const QString units = QString("Celsius"));
|
Q_INVOKABLE float tempepature(const float temp, const QString units = QString("Celsius"));
|
||||||
|
// keys
|
||||||
|
Q_INVOKABLE QMap<QString, QVariant> counts();
|
||||||
|
Q_INVOKABLE QStringList dictKeys();
|
||||||
|
// Q_INVOKABLE QStringList graphicalItemsNames();
|
||||||
Q_INVOKABLE QStringList timeKeys();
|
Q_INVOKABLE QStringList timeKeys();
|
||||||
|
Q_INVOKABLE QStringList findGraphicalItems(const QString pattern);
|
||||||
|
Q_INVOKABLE QStringList findKeys(const QString pattern);
|
||||||
|
// actions
|
||||||
|
Q_INVOKABLE void runCmd(const QString cmd = QString("/usr/bin/true"));
|
||||||
|
Q_INVOKABLE void sendNotification(const QString eventId, const QString message);
|
||||||
|
Q_INVOKABLE void showReadme();
|
||||||
// dataengine
|
// dataengine
|
||||||
Q_INVOKABLE QMap<QString, QVariant> readDataEngineConfiguration();
|
Q_INVOKABLE QMap<QString, QVariant> readDataEngineConfiguration();
|
||||||
Q_INVOKABLE void writeDataEngineConfiguration(const QMap<QString, QVariant> configuration);
|
Q_INVOKABLE void writeDataEngineConfiguration(const QMap<QString, QVariant> configuration);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void showUpdates(QString version);
|
||||||
|
void versionReplyRecieved(QNetworkReply *reply);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QList<ExtScript *> getExtScripts();
|
||||||
|
QList<GraphicalItem *> getGraphicalItems();
|
||||||
|
GraphicalItem *getItemByTag(const QString tag);
|
||||||
QMap<QString, QVariant> updateDataEngineConfiguration(QMap<QString, QVariant> rawConfig);
|
QMap<QString, QVariant> updateDataEngineConfiguration(QMap<QString, QVariant> rawConfig);
|
||||||
|
// variables
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
|
QList<GraphicalItem *> graphicalItems;
|
||||||
|
QList<ExtScript *> extScripts;
|
||||||
|
QStringList keys;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
[Global]
|
[Global]
|
||||||
IconName=system
|
IconName=system
|
||||||
Name=Awesome Widget
|
Name=Awesome Widget
|
||||||
Comment=Awesome widget information
|
Comment=Awesome widget notifications
|
||||||
|
|
||||||
|
[info]
|
||||||
|
Name=Information
|
||||||
|
Comment=Information
|
||||||
|
Action=Popup
|
||||||
|
|
||||||
[Event/system]
|
[Event/system]
|
||||||
Name=System information
|
Name=System information
|
||||||
|
Loading…
Reference in New Issue
Block a user