diff --git a/sources/awesome-widget-kf5/package/contents/ui/main.qml b/sources/awesome-widget-kf5/package/contents/ui/main.qml index da09468..fa1c910 100644 --- a/sources/awesome-widget-kf5/package/contents/ui/main.qml +++ b/sources/awesome-widget-kf5/package/contents/ui/main.qml @@ -205,8 +205,6 @@ Item { function action_requestKey() { if (debug) console.log("[main::action_requestKey]") - var message = AWKeys.graphicalValueByKey(); - if (message.length == 0) return - AWActions.sendNotification("tag", message) + AWKeys.graphicalValueByKey() } } diff --git a/sources/awesome-widget-kf5/package/contents/ui/widget.qml b/sources/awesome-widget-kf5/package/contents/ui/widget.qml index f232e56..b0810c7 100644 --- a/sources/awesome-widget-kf5/package/contents/ui/widget.qml +++ b/sources/awesome-widget-kf5/package/contents/ui/widget.qml @@ -240,6 +240,8 @@ Item { var message = i18n("Tag: %1", tags.currentText) message += "
" message += i18n("Value: %1", AWKeys.valueByKey(tags.currentText)) + message += "
" + message += i18n("Info: %1", AWKeys.infoByKey(tags.currentText)) AWActions.sendNotification("tag", message) } } diff --git a/sources/awesome-widget-kf5/plugin/awkeys.cpp b/sources/awesome-widget-kf5/plugin/awkeys.cpp index 00cd702..535fcba 100644 --- a/sources/awesome-widget-kf5/plugin/awkeys.cpp +++ b/sources/awesome-widget-kf5/plugin/awkeys.cpp @@ -33,6 +33,7 @@ #include +#include "awactions.h" #include "awtooltip.h" #include "extscript.h" #include "extupgrade.h" @@ -569,6 +570,9 @@ bool AWKeys::setDataBySource(const QString sourceName, toolTip->setData(QString("memTooltip"), values[QString("mem")].toFloat()); } else if (sourceName == QString("netdev")) { // network device + if (values[QString("netdev")] != data[QString("value")].toString()) + AWActions::sendNotification(QString("event"), i18n("Network device has been changed to %1", + data[QString("value")].toString())); values[QString("netdev")] = data[QString("value")].toString(); } else if (sourceName.contains(netRecRegExp)) { // download speed @@ -682,7 +686,7 @@ bool AWKeys::setDataBySource(const QString sourceName, } -QString AWKeys::graphicalValueByKey() +void AWKeys::graphicalValueByKey() { if (debug) qDebug() << PDEBUG; @@ -690,12 +694,39 @@ QString AWKeys::graphicalValueByKey() QString tag = QInputDialog::getItem(0, i18n("Select tag"), i18n("Tag"), keys, 0, false, &ok); - if ((!ok) || (tag.isEmpty())) return QString(""); + if ((!ok) || (tag.isEmpty())) return; QString message = i18n("Tag: %1", tag); message += QString("
"); message += i18n("Value: %1", valueByKey(tag)); - return message; + return AWActions::sendNotification(QString("tag"), message); +} + + +QString AWKeys::infoByKey(QString key) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "Requested key" << key; + + key.remove(QRegExp(QString("^bar[0-9]{1,}"))); + if (key.startsWith(QString("custom"))) + return QString("%1").arg(extScripts[key.remove(QString("custom")).toInt()]->executable()); + else if (key.contains(QRegExp(QString("^hdd[rw]")))) + return QString("%1").arg(diskDevices[key.remove(QRegExp(QString("hdd[rw]"))).toInt()]); + else if (key.startsWith(QString("fan"))) + return QString("%1").arg(fanDevices[key.remove(QString("fan")).toInt()]); + 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()]); + else if (key.startsWith(QString("hddtemp"))) + return QString("%1").arg(getHddDevices()[key.remove(QString("hddtemp")).toInt()]); + else if (key.contains(QRegExp(QString("^(down|up)[0-9]")))) + return QString("%1").arg(getNetworkDevices()[key.remove(QRegExp(QString("^(down|up)"))).toInt()]); + else if (key.startsWith(QString("pkgcount"))) + return QString("%1").arg(extUpgrade[key.remove(QString("pkgcount")).toInt()]->executable()); + else if (key.startsWith(QString("temp"))) + return QString("%1").arg(tempDevices[key.remove(QString("temp")).toInt()]); + + return QString("(none)"); } diff --git a/sources/awesome-widget-kf5/plugin/awkeys.h b/sources/awesome-widget-kf5/plugin/awkeys.h index 58639c0..6446b0d 100644 --- a/sources/awesome-widget-kf5/plugin/awkeys.h +++ b/sources/awesome-widget-kf5/plugin/awkeys.h @@ -68,7 +68,8 @@ public: const QMap data, const QMap params); // values - Q_INVOKABLE QString graphicalValueByKey(); + Q_INVOKABLE void graphicalValueByKey(); + Q_INVOKABLE QString infoByKey(QString key); Q_INVOKABLE QString valueByKey(QString key); // configuration Q_INVOKABLE void editItem(const QString type); diff --git a/sources/awesome-widget-kf5/plugin/awtooltip.cpp b/sources/awesome-widget-kf5/plugin/awtooltip.cpp index b6cad96..af97ee3 100644 --- a/sources/awesome-widget-kf5/plugin/awtooltip.cpp +++ b/sources/awesome-widget-kf5/plugin/awtooltip.cpp @@ -17,12 +17,16 @@ #include "awtooltip.h" +#include + #include #include #include #include +#include "awactions.h" + AWToolTip::AWToolTip(QObject *parent, QMap settings) @@ -139,7 +143,7 @@ void AWToolTip::setData(const QString source, float value, const bool ac) data[source].append(0.0); else if (data[source].count() > configuration[QString("tooltipNumber")].toInt()) data[source].takeFirst(); - if (isnan(value)) value = 100.0; + if (isnan(value)) value = 0.0; if (ac) data[source].append(value); @@ -155,5 +159,12 @@ void AWToolTip::setData(const QString source, float value, const bool ac) boundaries[QString("downTooltip")] = data[QString("upTooltip")][i]; boundaries[QString("downTooltip")] *= 1.2; boundaries[QString("upTooltip")] = boundaries[QString("downTooltip")]; + } else if (source == QString("batTooltip")) { + int size = data[source].count(); + if (data[source][size-1] * data[source][size-2] >= 0) return; + if (data[source].last() > 0.0) + AWActions::sendNotification(QString("event"), i18n("AC online")); + else + AWActions::sendNotification(QString("event"), i18n("AC offline")); } } diff --git a/sources/extsysmon/extsysmon.cpp b/sources/extsysmon/extsysmon.cpp index cffe788..41d641a 100644 --- a/sources/extsysmon/extsysmon.cpp +++ b/sources/extsysmon/extsysmon.cpp @@ -461,7 +461,7 @@ float ExtendedSysMon::getHddTemp(const QString cmd, const QString device) break; } } else { - if (qoutput.split(QChar(':'), QString::SkipEmptyParts).count() < 3) { + if (qoutput.split(QChar(':'), QString::SkipEmptyParts).count() >= 3) { QString temp = qoutput.split(QChar(':'), QString::SkipEmptyParts)[2]; temp.remove(QChar(0260)).remove(QChar('C')); value = temp.toFloat();