mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
add notifications
edit widget.qml fix bug in monitor
This commit is contained in:
parent
f01fd96cf6
commit
bb88892125
@ -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()
|
||||
}
|
||||
}
|
||||
|
@ -240,6 +240,8 @@ Item {
|
||||
var message = i18n("Tag: %1", tags.currentText)
|
||||
message += "<br>"
|
||||
message += i18n("Value: %1", AWKeys.valueByKey(tags.currentText))
|
||||
message += "<br>"
|
||||
message += i18n("Info: %1", AWKeys.infoByKey(tags.currentText))
|
||||
AWActions.sendNotification("tag", message)
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#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("<br>");
|
||||
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)");
|
||||
}
|
||||
|
||||
|
||||
|
@ -68,7 +68,8 @@ public:
|
||||
const QMap<QString, QVariant> data,
|
||||
const QMap<QString, QVariant> 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);
|
||||
|
@ -17,12 +17,16 @@
|
||||
|
||||
#include "awtooltip.h"
|
||||
|
||||
#include <KI18n/KLocalizedString>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QProcessEnvironment>
|
||||
#include <math.h>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "awactions.h"
|
||||
|
||||
|
||||
AWToolTip::AWToolTip(QObject *parent,
|
||||
QMap<QString, QVariant> 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"));
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user