add work with key cache

fix bug with invalid dataengine settings in UI
This commit is contained in:
arcan1s 2015-05-03 03:49:39 +03:00
parent 9a6b883905
commit 104bb52557
22 changed files with 226 additions and 1654 deletions

View File

@ -34,7 +34,7 @@ Item {
Column { Column {
id: pageColumn id: pageColumn
width: units.gridUnit * 25 anchors.fill: parent
QtControls.TabView { QtControls.TabView {
height: parent.height height: parent.height
width: parent.width width: parent.width

View File

@ -69,7 +69,7 @@ Item {
Column { Column {
id: pageColumn id: pageColumn
width: units.gridUnit * 25 anchors.fill: parent
Row { Row {
height: implicitHeight height: implicitHeight
width: parent.width width: parent.width

View File

@ -49,7 +49,7 @@ Item {
Column { Column {
id: pageColumn id: pageColumn
width: units.gridUnit * 25 anchors.fill: parent
Row { Row {
height: implicitHeight height: implicitHeight
width: parent.width width: parent.width

View File

@ -57,7 +57,7 @@ Item {
Column { Column {
id: pageColumn id: pageColumn
width: units.gridUnit * 25 anchors.fill: parent
Row { Row {
height: implicitHeight height: implicitHeight
width: parent.width width: parent.width
@ -105,11 +105,11 @@ Item {
id: gpuDev id: gpuDev
width: parent.width * 3 / 5 width: parent.width * 3 / 5
model: ["auto", "disable", "ati", "nvidia"] model: ["auto", "disable", "ati", "nvidia"]
onCurrentIndexChanged: cfg_dataengine["GPUDEV"] = model[currentIndex]
Component.onCompleted: { Component.onCompleted: {
for (var i=0; i<model.length; i++) { for (var i=0; i<model.length; i++) {
console.log(cfg_dataengine["GPUDEV"])
if (model[i] == cfg_dataengine["GPUDEV"]) { if (model[i] == cfg_dataengine["GPUDEV"]) {
gpuDev.currentIndex = i; currentIndex = i;
} }
} }
} }
@ -130,7 +130,6 @@ Item {
id: hdd id: hdd
width: parent.width * 3 / 5 width: parent.width * 3 / 5
model: AWKeys.getHddDevices(true) model: AWKeys.getHddDevices(true)
onCurrentIndexChanged: cfg_dataengine["HDDDEV"] = model[currentIndex]
Component.onCompleted: { Component.onCompleted: {
for (var i=0; i<model.length; i++) { for (var i=0; i<model.length; i++) {
if (model[i] == cfg_dataengine["HDDDEV"]) { if (model[i] == cfg_dataengine["HDDDEV"]) {
@ -226,7 +225,6 @@ Item {
id: player id: player
width: parent.width * 3 / 5 width: parent.width * 3 / 5
model: ["mpris", "mpd"] model: ["mpris", "mpd"]
onCurrentIndexChanged: cfg_dataengine["PLAYER"] = model[currentIndex]
Component.onCompleted: { Component.onCompleted: {
for (var i=0; i<model.length; i++) { for (var i=0; i<model.length; i++) {
if (model[i] == cfg_dataengine["PLAYER"]) { if (model[i] == cfg_dataengine["PLAYER"]) {
@ -282,6 +280,9 @@ Item {
Component.onDestruction: { Component.onDestruction: {
if (debug) console.log("[dataengine::onDestruction]") if (debug) console.log("[dataengine::onDestruction]")
cfg_dataengine["GPUDEV"] = gpuDev.currentText
cfg_dataengine["HDDDEV"] = hdd.currentText
cfg_dataengine["PLAYER"] = player.currentText
cfg_dataengine["MPRIS"] = mpris.currentText cfg_dataengine["MPRIS"] = mpris.currentText
AWActions.writeDataEngineConfiguration(cfg_dataengine) AWActions.writeDataEngineConfiguration(cfg_dataengine)
} }

View File

@ -96,8 +96,8 @@ Item {
PlasmaCore.DataSource { PlasmaCore.DataSource {
id: extsysmonDE id: extsysmonDE
engine: "extsysmon" engine: "extsysmon"
connectedSources: ["battery", "custom", "desktop", "netdev", "gpu", connectedSources: ["battery", "custom", "desktop", "netdev", "gpu", "gputemp",
"gputemp", "hddtemp", "pkg", "player", "ps", "update"] "hddtemp", "quotes", "pkg", "player", "ps", "update"]
interval: plasmoid.configuration.interval interval: plasmoid.configuration.interval
onNewData: { onNewData: {
@ -171,7 +171,7 @@ Item {
onNeedUpdate: { onNeedUpdate: {
if (debug) console.log("[main::onNeedUpdate]") if (debug) console.log("[main::onNeedUpdate]")
text.text = AWKeys.parsePattern(plasmoid.configuration.text) text.text = AWKeys.parsePattern()
tooltip.text = AWKeys.toolTipImage() tooltip.text = AWKeys.toolTipImage()
} }

View File

@ -53,7 +53,7 @@ Item {
Column { Column {
id: pageColumn id: pageColumn
width: units.gridUnit * 25 anchors.fill: parent
QtControls.Label { QtControls.Label {
width: parent.width width: parent.width
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter

View File

@ -63,7 +63,7 @@ Item {
Column { Column {
id: pageColumn id: pageColumn
width: units.gridUnit * 25 anchors.fill: parent
QtControls.Label { QtControls.Label {
width: parent.width width: parent.width
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter

View File

@ -0,0 +1,28 @@
[Desktop Entry]
Encoding=UTF-8
Name=Awesome Widget
Comment=A minimalistic Plasmoid
Comment[en]=A minimalistic Plasmoid
Comment[es]=Un plasmoide minimalista
Comment[es]=Un script Plasmoïde minimaliste
Comment[pt_BR]=Um script Plasmoid
Comment[ru]=Минималистичный плазмоид
Comment[uk]=Мінімалістичний плазмоїд
X-KDE-ServiceTypes=Plasma/Applet
Type=Service
Icon=utilities-system-monitor
X-KDE-ServiceTypes=Plasma/Applet
X-Plasma-API=declarativeappletscript
X-Plasma-MainScript=ui/main.qml
X-Plasma-RemoteLocation=
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
X-KDE-PluginInfo-Email=esalexeev@gmail.com
X-KDE-PluginInfo-Name=org.kde.plasma.awesomewidget
X-KDE-PluginInfo-Version=2.2.2
X-KDE-PluginInfo-Website=http://arcanis.name/projects/awesome-widgets/
X-KDE-PluginInfo-Category=System Information
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPLv3
X-KDE-PluginInfo-EnabledByDefault=true

View File

@ -28,6 +28,7 @@
#include <QNetworkInterface> #include <QNetworkInterface>
#include <QProcessEnvironment> #include <QProcessEnvironment>
#include <QRegExp> #include <QRegExp>
#include <QSettings>
#include <QStandardPaths> #include <QStandardPaths>
#include <QThread> #include <QThread>
@ -39,7 +40,6 @@
#include "extscript.h" #include "extscript.h"
#include "extupgrade.h" #include "extupgrade.h"
#include "graphicalitem.h" #include "graphicalitem.h"
#include "version.h"
AWKeys::AWKeys(QObject *parent) AWKeys::AWKeys(QObject *parent)
@ -50,9 +50,6 @@ AWKeys::AWKeys(QObject *parent)
QString debugEnv = environment.value(QString("DEBUG"), QString("no")); QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
debug = (debugEnv == QString("yes")); debug = (debugEnv == QString("yes"));
// signals
connect(this, SIGNAL(sourceAdded(QString)), this, SLOT(addSource(QString)));
// init dialog // init dialog
dialog = new QDialog(nullptr); dialog = new QDialog(nullptr);
widgetDialog = new QListWidget(dialog); widgetDialog = new QListWidget(dialog);
@ -88,7 +85,7 @@ AWKeys::~AWKeys()
} }
void AWKeys::initKeys(const QString pattern, void AWKeys::initKeys(const QString currentPattern,
const QMap<QString, QVariant> tooltipParams, const QMap<QString, QVariant> tooltipParams,
const bool popup) const bool popup)
{ {
@ -105,16 +102,18 @@ void AWKeys::initKeys(const QString pattern,
if (toolTip != nullptr) delete toolTip; if (toolTip != nullptr) delete toolTip;
// init // init
pattern = currentPattern;
extQuotes = getExtQuotes(); extQuotes = getExtQuotes();
extScripts = getExtScripts(); extScripts = getExtScripts();
extUpgrade = getExtUpgrade(); extUpgrade = getExtUpgrade();
graphicalItems = getGraphicalItems(); graphicalItems = getGraphicalItems();
keys = dictKeys(); // update network and hdd list
foundBars = findGraphicalItems(pattern); addKeyToCache(QString("Hdd"));
foundKeys = findKeys(pattern); addKeyToCache(QString("Network"));
loadKeysFromCache();
reinitKeys();
toolTip = new AWToolTip(this, tooltipParams); toolTip = new AWToolTip(this, tooltipParams);
ready = true;
enablePopup = popup; enablePopup = popup;
} }
@ -127,10 +126,10 @@ bool AWKeys::isDebugEnabled()
} }
QString AWKeys::parsePattern(const QString pattern) QString AWKeys::parsePattern()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (!ready) return pattern; if (keys.isEmpty()) return pattern;
QString parsed = pattern; QString parsed = pattern;
parsed.replace(QString("$$"), QString("$\\$\\")); parsed.replace(QString("$$"), QString("$\\$\\"));
@ -149,7 +148,7 @@ QString AWKeys::toolTipImage()
{ {
if(debug) qDebug() << PDEBUG; if(debug) qDebug() << PDEBUG;
if (!ready) return QString(); if (keys.isEmpty()) return QString();
QPixmap tooltip = toolTip->image(); QPixmap tooltip = toolTip->image();
QByteArray byteArray; QByteArray byteArray;
@ -168,7 +167,7 @@ QSize AWKeys::toolTipSize()
} }
bool AWKeys::addDevice(const QString source) void AWKeys::addDevice(const QString source)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Source" << source; if (debug) qDebug() << PDEBUG << ":" << "Source" << source;
@ -181,49 +180,15 @@ bool AWKeys::addDevice(const QString source)
if (diskRegexp.indexIn(source) > -1) { if (diskRegexp.indexIn(source) > -1) {
QString device = source; QString device = source;
device.remove(QString("/Rate/rblk")); device.remove(QString("/Rate/rblk"));
diskDevices.append(device); addKeyToCache(QString("Disk"), device);
} else if (fanRegexp.indexIn(source) > -1) } else if (fanRegexp.indexIn(source) > -1) {
fanDevices.append(source); addKeyToCache(QString("Fan"), source);
else if (mountRegexp.indexIn(source) > -1) { } else if (mountRegexp.indexIn(source) > -1) {
QString device = source; QString device = source;
device.remove(QString("partitions")).remove(QString("/filllevel")); device.remove(QString("partitions")).remove(QString("/filllevel"));
mountDevices.append(device); addKeyToCache(QString("Mount"), device);
} else if (tempRegexp.indexIn(source) > -1) } else if (tempRegexp.indexIn(source) > -1) {
tempDevices.append(source); addKeyToCache(QString("Temp"), source);
// check sources to be connected
if ((source.endsWith(QString("/TotalLoad"))) ||
(source.endsWith(QString("/clock"))) ||
(source.endsWith(QString("/AverageClock"))) ||
(source.endsWith(QString("/Rate/rblk"))) ||
(source.endsWith(QString("/Rate/wblk"))) ||
(source.endsWith(QString("/filllevel"))) ||
(source.endsWith(QString("/freespace"))) ||
(source.endsWith(QString("/usedspace"))) ||
(source.endsWith(QString("/receiver/data"))) ||
(source.endsWith(QString("/receiver/data"))) ||
(source.endsWith(QString("/transmitter/data"))) ||
(source.startsWith(QString("lmsensors/"))) ||
(source.startsWith(QString("mem/physical/"))) ||
(source.startsWith(QString("mem/swap/"))) ||
(source == QString("system/uptime")) ||
(source == QString("Local")) ||
(source == QString("battery")) ||
(source == QString("custom")) ||
(source == QString("desktop")) ||
(source == QString("netdev")) ||
(source == QString("gpu")) ||
(source == QString("gputemp")) ||
(source == QString("hddtemp")) ||
(source == QString("pkg")) ||
(source == QString("player")) ||
(source == QString("ps")) ||
(source == QString("update"))) {
return true;
} else {
if (debug) qDebug() << PDEBUG << ":" << "Source" << source << "not found";
return false;
} }
} }
@ -293,12 +258,12 @@ QStringList AWKeys::dictKeys()
allKeys.append(QString("hddw%1").arg(i)); allKeys.append(QString("hddw%1").arg(i));
} }
// hdd temp // hdd temp
for (int i=getHddDevices().count()-1; i>=0; i--) { for (int i=hddDevices.count()-1; i>=0; i--) {
allKeys.append(QString("hddtemp%1").arg(i)); allKeys.append(QString("hddtemp%1").arg(i));
allKeys.append(QString("hddtemp%1").arg(i)); allKeys.append(QString("hddtemp%1").arg(i));
} }
// network // network
for (int i=getNetworkDevices().count()-1; i>=0; i--) { for (int i=networkDevices.count()-1; i>=0; i--) {
allKeys.append(QString("down%1").arg(i)); allKeys.append(QString("down%1").arg(i));
allKeys.append(QString("up%1").arg(i)); allKeys.append(QString("up%1").arg(i));
} }
@ -351,79 +316,19 @@ QStringList AWKeys::dictKeys()
} }
QStringList AWKeys::getDiskDevices() QStringList AWKeys::getHddDevices()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
diskDevices.sort(); QStringList devices = hddDevices;
// required by ui interface
return diskDevices; devices.insert(0, QString("disable"));
} devices.insert(0, QString("auto"));
QStringList AWKeys::getFanDevices()
{
if (debug) qDebug() << PDEBUG;
fanDevices.sort();
return fanDevices;
}
QStringList AWKeys::getHddDevices(const bool needAbstract)
{
if (debug) qDebug() << PDEBUG;
QStringList allDevices = QDir(QString("/dev")).entryList(QDir::System, QDir::Name);
QStringList devices = allDevices.filter(QRegExp(QString("^[hms]d[a-z]$")));
for (int i=0; i<devices.count(); i++)
devices[i] = QString("/dev/") + devices[i];
devices.sort();
if (needAbstract) {
devices.insert(0, QString("disable"));
devices.insert(0, QString("auto"));
}
return devices; return devices;
} }
QStringList AWKeys::getMountDevices()
{
if (debug) qDebug() << PDEBUG;
mountDevices.sort();
return mountDevices;
}
QStringList AWKeys::getNetworkDevices()
{
if (debug) qDebug() << PDEBUG;
QStringList interfaceList;
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
for (int i=0; i<rawInterfaceList.count(); i++)
interfaceList.append(rawInterfaceList[i].name());
interfaceList.sort();
return interfaceList;
}
QStringList AWKeys::getTempDevices()
{
if (debug) qDebug() << PDEBUG;
tempDevices.sort();
return tempDevices;
}
bool AWKeys::setDataBySource(const QString sourceName, bool AWKeys::setDataBySource(const QString sourceName,
const QMap<QString, QVariant> data, const QMap<QString, QVariant> data,
const QMap<QString, QVariant> params) const QMap<QString, QVariant> params)
@ -435,7 +340,7 @@ bool AWKeys::setDataBySource(const QString sourceName,
// checking // checking
if (!checkKeys(data)) return false; if (!checkKeys(data)) return false;
if (!ready) return false; if (keys.isEmpty()) return false;
// regular expressions // regular expressions
QRegExp cpuRegExp = QRegExp(QString("cpu/cpu.*/TotalLoad")); QRegExp cpuRegExp = QRegExp(QString("cpu/cpu.*/TotalLoad"));
@ -523,7 +428,7 @@ bool AWKeys::setDataBySource(const QString sourceName,
} else if (sourceName == QString("gpu")) { } else if (sourceName == QString("gpu")) {
// gpu load // gpu load
// notification // notification
if ((data[QString("value")].toFloat() >= 90.0) && (values[QString("gpu")].toFloat() < 90.0)) if ((data[QString("value")].toFloat() >= 75.0) && (values[QString("gpu")].toFloat() < 75.0))
AWActions::sendNotification(QString("event"), i18n("High GPU load"), enablePopup); AWActions::sendNotification(QString("event"), i18n("High GPU load"), enablePopup);
// value // value
values[QString("gpu")] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1); values[QString("gpu")] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
@ -575,7 +480,6 @@ bool AWKeys::setDataBySource(const QString sourceName,
} }
} else if (sourceName == QString("hddtemp")) { } else if (sourceName == QString("hddtemp")) {
// hdd temperature // hdd temperature
QStringList hddDevices = getHddDevices();
for (int i=0; i<data.keys().count(); i++) for (int i=0; i<data.keys().count(); i++)
for (int j=0; j<hddDevices.count(); j++) for (int j=0; j<hddDevices.count(); j++)
if (hddDevices[j] == data.keys()[i]) { if (hddDevices[j] == data.keys()[i]) {
@ -621,7 +525,7 @@ bool AWKeys::setDataBySource(const QString sourceName,
// download speed // download speed
QString device = sourceName; QString device = sourceName;
device.remove(QString("network/interfaces/")).remove(QString("/receiver/data")); device.remove(QString("network/interfaces/")).remove(QString("/receiver/data"));
QStringList allNetworkDevices = getNetworkDevices(); QStringList allNetworkDevices = networkDevices;
for (int i=0; i<allNetworkDevices.count(); i++) for (int i=0; i<allNetworkDevices.count(); i++)
if (allNetworkDevices[i] == device) { if (allNetworkDevices[i] == device) {
values[QString("down%1").arg(i)] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0); values[QString("down%1").arg(i)] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
@ -635,7 +539,7 @@ bool AWKeys::setDataBySource(const QString sourceName,
// upload speed // upload speed
QString device = sourceName; QString device = sourceName;
device.remove(QString("network/interfaces/")).remove(QString("/transmitter/data")); device.remove(QString("network/interfaces/")).remove(QString("/transmitter/data"));
QStringList allNetworkDevices = getNetworkDevices(); QStringList allNetworkDevices = networkDevices;
for (int i=0; i<allNetworkDevices.count(); i++) for (int i=0; i<allNetworkDevices.count(); i++)
if (allNetworkDevices[i] == device) { if (allNetworkDevices[i] == device) {
values[QString("up%1").arg(i)] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0); values[QString("up%1").arg(i)] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
@ -769,9 +673,9 @@ QString AWKeys::infoByKey(QString key)
else if (key.contains(QRegExp(QString("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)")))) else if (key.contains(QRegExp(QString("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)"))))
return QString("%1").arg(mountDevices[key.remove(QRegExp(QString("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)"))).toInt()]); return QString("%1").arg(mountDevices[key.remove(QRegExp(QString("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)"))).toInt()]);
else if (key.startsWith(QString("hddtemp"))) else if (key.startsWith(QString("hddtemp")))
return QString("%1").arg(getHddDevices()[key.remove(QString("hddtemp")).toInt()]); return QString("%1").arg(hddDevices[key.remove(QString("hddtemp")).toInt()]);
else if (key.contains(QRegExp(QString("^(down|up)[0-9]")))) else if (key.contains(QRegExp(QString("^(down|up)[0-9]"))))
return QString("%1").arg(getNetworkDevices()[key.remove(QRegExp(QString("^(down|up)"))).toInt()]); return QString("%1").arg(networkDevices[key.remove(QRegExp(QString("^(down|up)"))).toInt()]);
else if (key.startsWith(QString("pkgcount"))) else if (key.startsWith(QString("pkgcount")))
return QString("%1").arg(extUpgrade[key.remove(QString("pkgcount")).toInt()]->executable()); return QString("%1").arg(extUpgrade[key.remove(QString("pkgcount")).toInt()]->executable());
else if ((key.startsWith(QString("ask"))) || else if ((key.startsWith(QString("ask"))) ||
@ -852,11 +756,66 @@ void AWKeys::editItem(const QString type)
} }
void AWKeys::addSource() void AWKeys::loadKeysFromCache()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
QString fileName = QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
if (debug) qDebug() << PDEBUG << ":" << "Cache file" << fileName;
QSettings cache(fileName, QSettings::IniFormat);
QStringList cachedKeys;
cache.beginGroup(QString("Disk"));
diskDevices.clear();
cachedKeys = cache.allKeys();
for (int i=0; i<cachedKeys.count(); i++)
diskDevices.append(cache.value(cachedKeys[i]).toString());
cache.endGroup();
cache.beginGroup(QString("Fan"));
fanDevices.clear();
cachedKeys = cache.allKeys();
for (int i=0; i<cachedKeys.count(); i++)
fanDevices.append(cache.value(cachedKeys[i]).toString());
cache.endGroup();
cache.beginGroup(QString("Hdd"));
hddDevices.clear();
cachedKeys = cache.allKeys();
for (int i=0; i<cachedKeys.count(); i++)
hddDevices.append(cache.value(cachedKeys[i]).toString());
cache.endGroup();
cache.beginGroup(QString("Mount"));
mountDevices.clear();
cachedKeys = cache.allKeys();
for (int i=0; i<cachedKeys.count(); i++)
mountDevices.append(cache.value(cachedKeys[i]).toString());
cache.endGroup();
cache.beginGroup(QString("Network"));
networkDevices.clear();
cachedKeys = cache.allKeys();
for (int i=0; i<cachedKeys.count(); i++)
networkDevices.append(cache.value(cachedKeys[i]).toString());
cache.endGroup();
cache.beginGroup(QString("Temp"));
tempDevices.clear();
cachedKeys = cache.allKeys();
for (int i=0; i<cachedKeys.count(); i++)
tempDevices.append(cache.value(cachedKeys[i]).toString());
cache.endGroup();
}
void AWKeys::reinitKeys()
{
if (debug) qDebug() << PDEBUG;
keys = dictKeys();
foundBars = findGraphicalItems();
foundKeys = findKeys();
} }
@ -1209,6 +1168,51 @@ void AWKeys::copyUpgrade(const QString original)
} }
void AWKeys::addKeyToCache(const QString type, const QString key)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Key type" << type;
if (debug) qDebug() << PDEBUG << ":" << "Key" << key;
QString fileName = QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
if (debug) qDebug() << PDEBUG << ":" << "Cache file" << fileName;
QSettings cache(fileName, QSettings::IniFormat);
cache.beginGroup(type);
QStringList cachedValues;
for (int i=0; i<cache.allKeys().count(); i++)
cachedValues.append(cache.value(cache.allKeys()[i]).toString());
if (type == QString("Hdd")) {
QStringList allDevices = QDir(QString("/dev")).entryList(QDir::System, QDir::Name);
QStringList devices = allDevices.filter(QRegExp(QString("^[hms]d[a-z]$")));
for (int i=0; i<devices.count(); i++) {
QString device = QString("/dev/%1").arg(devices[i]);
if (cachedValues.contains(devices[i])) continue;
if (debug) qDebug() << PDEBUG << ":" << "Found new key" << device << "for type" << type;
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device);
}
} else if (type == QString("Network")) {
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
for (int i=0; i<rawInterfaceList.count(); i++) {
QString device = rawInterfaceList[i].name();
if (cachedValues.contains(device)) continue;
if (debug) qDebug() << PDEBUG << ":" << "Found new key" << device << "for type" << type;
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device);
}
} else {
if (cachedValues.contains(key)) return;
if (debug) qDebug() << PDEBUG << ":" << "Found new key" << key << "for type" << type;
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), key);
}
cache.endGroup();
cache.sync();
loadKeysFromCache();
return reinitKeys();
}
bool AWKeys::checkKeys(const QMap<QString, QVariant> data) bool AWKeys::checkKeys(const QMap<QString, QVariant> data)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
@ -1269,7 +1273,7 @@ float AWKeys::temperature(const float temp, const QString units)
} }
QStringList AWKeys::findGraphicalItems(const QString pattern) QStringList AWKeys::findGraphicalItems()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
@ -1289,7 +1293,7 @@ QStringList AWKeys::findGraphicalItems(const QString pattern)
} }
QStringList AWKeys::findKeys(const QString pattern) QStringList AWKeys::findKeys()
{ {
QStringList selectedKeys; QStringList selectedKeys;
for (int i=0; i<keys.count(); i++) { for (int i=0; i<keys.count(); i++) {

View File

@ -51,22 +51,17 @@ public:
AWKeys(QObject *parent = 0); AWKeys(QObject *parent = 0);
~AWKeys(); ~AWKeys();
Q_INVOKABLE void initKeys(const QString pattern, Q_INVOKABLE void initKeys(const QString currentPattern,
const QMap<QString, QVariant> tooltipParams, const QMap<QString, QVariant> tooltipParams,
const bool popup = false); const bool popup = false);
Q_INVOKABLE bool isDebugEnabled(); Q_INVOKABLE bool isDebugEnabled();
Q_INVOKABLE QString parsePattern(const QString pattern); Q_INVOKABLE QString parsePattern();
Q_INVOKABLE QString toolTipImage(); Q_INVOKABLE QString toolTipImage();
Q_INVOKABLE QSize toolTipSize(); Q_INVOKABLE QSize toolTipSize();
// keys // keys
Q_INVOKABLE bool addDevice(const QString source); Q_INVOKABLE void addDevice(const QString source);
Q_INVOKABLE QStringList dictKeys(); Q_INVOKABLE QStringList dictKeys();
Q_INVOKABLE QStringList getDiskDevices(); Q_INVOKABLE QStringList getHddDevices();
Q_INVOKABLE QStringList getFanDevices();
Q_INVOKABLE QStringList getHddDevices(const bool needAbstract = false);
Q_INVOKABLE QStringList getMountDevices();
Q_INVOKABLE QStringList getNetworkDevices();
Q_INVOKABLE QStringList getTempDevices();
Q_INVOKABLE bool setDataBySource(const QString sourceName, Q_INVOKABLE bool setDataBySource(const QString sourceName,
const QMap<QString, QVariant> data, const QMap<QString, QVariant> data,
const QMap<QString, QVariant> params); const QMap<QString, QVariant> params);
@ -77,11 +72,9 @@ public:
// configuration // configuration
Q_INVOKABLE void editItem(const QString type); Q_INVOKABLE void editItem(const QString type);
signals:
void sourceAdded(const QString source);
private slots: private slots:
void addSource(const QString source); void loadKeysFromCache();
void reinitKeys();
// editor // editor
void editItemButtonPressed(QAbstractButton *button); void editItemButtonPressed(QAbstractButton *button);
void copyBar(const QString original); void copyBar(const QString original);
@ -91,13 +84,14 @@ private slots:
private: private:
// methods // methods
void addKeyToCache(const QString type, const QString key = QString(""));
bool checkKeys(const QMap<QString, QVariant> data); bool checkKeys(const QMap<QString, QVariant> data);
QString networkDevice(); QString networkDevice();
int numberCpus(); int numberCpus();
float temperature(const float temp, const QString units = QString("Celsius")); float temperature(const float temp, const QString units);
// find methods // find methods
QStringList findGraphicalItems(const QString pattern); QStringList findGraphicalItems();
QStringList findKeys(const QString pattern); QStringList findKeys();
// get methods // get methods
QList<ExtQuotes *> getExtQuotes(); QList<ExtQuotes *> getExtQuotes();
QList<ExtScript *> getExtScripts(); QList<ExtScript *> getExtScripts();
@ -117,14 +111,14 @@ private:
// variables // variables
bool debug = false; bool debug = false;
bool enablePopup = false; bool enablePopup = false;
bool ready = false;
QList<GraphicalItem *> graphicalItems; QList<GraphicalItem *> graphicalItems;
QList<ExtQuotes *> extQuotes; QList<ExtQuotes *> extQuotes;
QList<ExtScript *> extScripts; QList<ExtScript *> extScripts;
QList<ExtUpgrade *> extUpgrade; QList<ExtUpgrade *> extUpgrade;
QStringList foundBars, foundKeys, keys; QStringList foundBars, foundKeys, keys;
QString pattern;
QMap<QString, QString> values; QMap<QString, QString> values;
QStringList diskDevices, fanDevices, mountDevices, tempDevices; QStringList diskDevices, fanDevices, hddDevices, mountDevices, networkDevices, tempDevices;
}; };

File diff suppressed because it is too large Load Diff

View File

@ -1,126 +0,0 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets 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. *
* *
* awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef AWKEYS_H
#define AWKEYS_H
#include <QDialog>
#include <QDialogButtonBox>
#include <QListWidget>
#include <QMap>
#include <QObject>
#include <QStringList>
#include <QPushButton>
#include <QVariant>
class ExtQuotes;
class ExtScript;
class ExtUpgrade;
class GraphicalItem;
class AWKeysOperations : public QObject
{
Q_OBJECT
enum RequestedItem {
Nothing,
RequestedGraphicalItem,
RequestedExtQuotes,
RequestedExtScript,
RequestedExtUpgrade
};
typedef struct {
QString key = QString();
QString value = QString();
} AWStruct;
public:
AWKeysOperations(QObject *parent = 0);
~AWKeysOperations();
// keys
AWStruct addDevice(const QString source);
Q_INVOKABLE QStringList dictKeys();
Q_INVOKABLE QStringList getDiskDevices();
Q_INVOKABLE QStringList getFanDevices();
Q_INVOKABLE QStringList getHddDevices(const bool needAbstract = false);
Q_INVOKABLE QStringList getMountDevices();
Q_INVOKABLE QStringList getNetworkDevices();
Q_INVOKABLE QStringList getTempDevices();
Q_INVOKABLE bool setDataBySource(const QString sourceName,
const QMap<QString, QVariant> data,
const QMap<QString, QVariant> params);
// values
Q_INVOKABLE void graphicalValueByKey();
Q_INVOKABLE QString infoByKey(QString key);
Q_INVOKABLE QString valueByKey(QString key);
// configuration
Q_INVOKABLE void editItem(const QString type);
signals:
void sourceAdded(const QString source);
private slots:
void addSource(const QString source);
// editor
void editItemButtonPressed(QAbstractButton *button);
void copyBar(const QString original);
void copyQuotes(const QString original);
void copyScript(const QString original);
void copyUpgrade(const QString original);
private:
// methods
bool checkKeys(const QMap<QString, QVariant> data);
QString networkDevice();
int numberCpus();
float temperature(const float temp, const QString units = QString("Celsius"));
// find methods
QStringList findGraphicalItems(const QString pattern);
QStringList findKeys(const QString pattern);
// get methods
QList<ExtQuotes *> getExtQuotes();
QList<ExtScript *> getExtScripts();
QList<ExtUpgrade *> getExtUpgrade();
QList<GraphicalItem *> getGraphicalItems();
GraphicalItem *getItemByTag(const QString tag);
QStringList getTimeKeys();
// graphical elements
QDialog *dialog = nullptr;
QListWidget *widgetDialog = nullptr;
QDialogButtonBox *dialogButtons = nullptr;
QPushButton *copyButton = nullptr;
QPushButton *createButton = nullptr;
QPushButton *deleteButton = nullptr;
RequestedItem requestedItem = Nothing;
// variables
bool debug = false;
bool enablePopup = false;
bool ready = false;
QList<GraphicalItem *> graphicalItems;
QList<ExtQuotes *> extQuotes;
QList<ExtScript *> extScripts;
QList<ExtUpgrade *> extUpgrade;
QStringList foundBars, foundKeys, keys;
QMap<QString, QString> values;
QStringList diskDevices, fanDevices, mountDevices, tempDevices;
};
#endif /* AWKEYS_H */

View File

@ -0,0 +1,28 @@
[Desktop Entry]
Encoding=UTF-8
Name=Desktop Panel
Comment=A minimalistic Plasmoid
Comment[en]=A minimalistic Plasmoid
Comment[es]=Un plasmoide minimalista
Comment[es]=Un script Plasmoïde minimaliste
Comment[pt_BR]=Um script Plasmoid
Comment[ru]=Минималистичный плазмоид
Comment[uk]=Мінімалістичний плазмоїд
X-KDE-ServiceTypes=Plasma/Applet
Type=Service
Icon=utilities-system-monitor
X-KDE-ServiceTypes=Plasma/Applet
X-Plasma-API=declarativeappletscript
X-Plasma-MainScript=ui/main.qml
X-Plasma-RemoteLocation=
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
X-KDE-PluginInfo-Email=esalexeev@gmail.com
X-KDE-PluginInfo-Name=org.kde.plasma.desktoppanel
X-KDE-PluginInfo-Version=2.2.2
X-KDE-PluginInfo-Website=http://arcanis.name/projects/awesome-widgets/
X-KDE-PluginInfo-Category=System Information
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPLv3
X-KDE-PluginInfo-EnabledByDefault=true

View File

@ -3,6 +3,6 @@ Encoding=UTF-8
Name=AAPL.NASDAQ Name=AAPL.NASDAQ
Comment=Apple Inc Comment=Apple Inc
X-AW-Ticker=AAPL X-AW-Ticker=AAPL
X-AW-Active=true X-AW-Active=false
X-AW-ApiVersion=1 X-AW-ApiVersion=1
X-AW-Interval=60 X-AW-Interval=60

View File

@ -3,6 +3,6 @@ Encoding=UTF-8
Name=EUR/RUB Name=EUR/RUB
Comment=EUR/RUB Comment=EUR/RUB
X-AW-Ticker=EURRUB=X X-AW-Ticker=EURRUB=X
X-AW-Active=true X-AW-Active=false
X-AW-ApiVersion=1 X-AW-ApiVersion=1
X-AW-Interval=60 X-AW-Interval=60

View File

@ -3,6 +3,6 @@ Encoding=UTF-8
Name=EUR/USD Name=EUR/USD
Comment=EUR/USD Comment=EUR/USD
X-AW-Ticker=EURUSD=X X-AW-Ticker=EURUSD=X
X-AW-Active=true X-AW-Active=false
X-AW-ApiVersion=1 X-AW-ApiVersion=1
X-AW-Interval=60 X-AW-Interval=60

View File

@ -3,6 +3,6 @@ Encoding=UTF-8
Name=GOOG.NASDAQ Name=GOOG.NASDAQ
Comment=Google Inc Comment=Google Inc
X-AW-Ticker=GOOG X-AW-Ticker=GOOG
X-AW-Active=true X-AW-Active=false
X-AW-ApiVersion=1 X-AW-ApiVersion=1
X-AW-Interval=60 X-AW-Interval=60

View File

@ -3,6 +3,6 @@ Encoding=UTF-8
Name=MSFT.NASDAQ Name=MSFT.NASDAQ
Comment=Microsoft Corp Comment=Microsoft Corp
X-AW-Ticker=MSFT X-AW-Ticker=MSFT
X-AW-Active=true X-AW-Active=false
X-AW-ApiVersion=1 X-AW-ApiVersion=1
X-AW-Interval=60 X-AW-Interval=60

View File

@ -3,6 +3,6 @@ Encoding=UTF-8
Name=RTS Name=RTS
Comment=RTS Index Comment=RTS Index
X-AW-Ticker=RTS.RS X-AW-Ticker=RTS.RS
X-AW-Active=true X-AW-Active=false
X-AW-ApiVersion=1 X-AW-ApiVersion=1
X-AW-Interval=60 X-AW-Interval=60

View File

@ -3,6 +3,6 @@ Encoding=UTF-8
Name=S&P Name=S&P
Comment=S&P 500 Index Comment=S&P 500 Index
X-AW-Ticker=^GSPC X-AW-Ticker=^GSPC
X-AW-Active=true X-AW-Active=false
X-AW-ApiVersion=1 X-AW-ApiVersion=1
X-AW-Interval=60 X-AW-Interval=60

View File

@ -3,6 +3,6 @@ Encoding=UTF-8
Name=USD/RUB Name=USD/RUB
Comment=USD/RUB Comment=USD/RUB
X-AW-Ticker=USDRUB=X X-AW-Ticker=USDRUB=X
X-AW-Active=true X-AW-Active=false
X-AW-ApiVersion=1 X-AW-ApiVersion=1
X-AW-Interval=60 X-AW-Interval=60

View File

@ -3,6 +3,6 @@ Encoding=UTF-8
Name=VIX Name=VIX
Comment=Volatility S&P 500 Comment=Volatility S&P 500
X-AW-Ticker=^VIX X-AW-Ticker=^VIX
X-AW-Active=true X-AW-Active=false
X-AW-ApiVersion=1 X-AW-ApiVersion=1
X-AW-Interval=60 X-AW-Interval=60