fix update pkg

add notify flag
This commit is contained in:
arcan1s 2015-02-13 08:11:56 +03:00
parent 3bd73d0458
commit e5006ed2d6
9 changed files with 41 additions and 16 deletions

View File

@ -20,7 +20,7 @@ optdepends=("amarok: for music player monitor"
makedepends=('automoc4' 'cmake') makedepends=('automoc4' 'cmake')
source=(https://github.com/arcan1s/awesome-widgets/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz) source=(https://github.com/arcan1s/awesome-widgets/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
install=${pkgname}.install install=${pkgname}.install
md5sums=('b9e77735ca866164395b2b9d4124e0ac') md5sums=('acfaaec09f7b8544e8e844b26f763388')
backup=('usr/share/config/plasma-dataengine-extsysmon.conf') backup=('usr/share/config/plasma-dataengine-extsysmon.conf')
prepare() { prepare() {

View File

@ -20,7 +20,7 @@ optdepends=("amarok: for music player monitor"
makedepends=('cmake' 'extra-cmake-modules') makedepends=('cmake' 'extra-cmake-modules')
source=(https://github.com/arcan1s/awesome-widgets/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz) source=(https://github.com/arcan1s/awesome-widgets/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
install=${pkgname}.install install=${pkgname}.install
md5sums=('b9e77735ca866164395b2b9d4124e0ac') md5sums=('acfaaec09f7b8544e8e844b26f763388')
backup=('etc/xdg/plasma-dataengine-extsysmon.conf') backup=('etc/xdg/plasma-dataengine-extsysmon.conf')
prepare() { prepare() {

View File

@ -14,6 +14,9 @@
<group name="Advanced"> <group name="Advanced">
<!-- advanced --> <!-- advanced -->
<entry name="notify" type="bool">
<default>true</default>
</entry>
<entry name="background" type="bool"> <entry name="background" type="bool">
<default>true</default> <default>true</default>
</entry> </entry>

View File

@ -58,6 +58,7 @@ Item {
"batInTooltipColor": plasmoid.configuration.batInTooltipColor "batInTooltipColor": plasmoid.configuration.batInTooltipColor
} }
property alias cfg_notify: notify.checked
property alias cfg_background: background.checked property alias cfg_background: background.checked
property alias cfg_customTime: customTime.text property alias cfg_customTime: customTime.text
property alias cfg_customUptime: customUptime.text property alias cfg_customUptime: customUptime.text
@ -69,6 +70,20 @@ Item {
Column { Column {
id: pageColumn id: pageColumn
width: units.gridUnit * 25 width: units.gridUnit * 25
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.heigth
width: parent.width * 2 / 5
}
QtControls.CheckBox {
id: notify
width: parent.width * 3 / 5
text: i18n("Enable notifications")
}
}
Row { Row {
height: implicitHeight height: implicitHeight
width: parent.width width: parent.width

View File

@ -179,7 +179,7 @@ Item {
if (debug) console.log("[main::onUserConfiguringChanged]") if (debug) console.log("[main::onUserConfiguringChanged]")
// init submodule // init submodule
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings) AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings, plasmoid.configuration.notify)
} }
function action_checkUpdates() { function action_checkUpdates() {

View File

@ -84,7 +84,8 @@ AWKeys::~AWKeys()
void AWKeys::initKeys(const QString pattern, void AWKeys::initKeys(const QString pattern,
const QMap<QString, QVariant> tooltipParams) const QMap<QString, QVariant> tooltipParams,
const bool popup)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
@ -107,6 +108,7 @@ void AWKeys::initKeys(const QString pattern,
toolTip = new AWToolTip(this, tooltipParams); toolTip = new AWToolTip(this, tooltipParams);
ready = true; ready = true;
enablePopup = popup;
} }
@ -438,7 +440,8 @@ bool AWKeys::setDataBySource(const QString sourceName,
for (int i=0; i<data.keys().count(); i++) { for (int i=0; i<data.keys().count(); i++) {
if (data.keys()[i] == QString("ac")) { if (data.keys()[i] == QString("ac")) {
// notification // notification
if ((values[QString("ac")] == params[QString("acOnline")].toString()) != data[QString("ac")].toBool()) { if ((enablePopup) &&
((values[QString("ac")] == params[QString("acOnline")].toString()) != data[QString("ac")].toBool())) {
if (data[QString("ac")].toBool()) if (data[QString("ac")].toBool())
AWActions::sendNotification(QString("event"), i18n("AC online")); AWActions::sendNotification(QString("event"), i18n("AC online"));
else else
@ -458,7 +461,8 @@ bool AWKeys::setDataBySource(const QString sourceName,
} else if (sourceName == QString("cpu/system/TotalLoad")) { } else if (sourceName == QString("cpu/system/TotalLoad")) {
// cpu // cpu
// notification // notification
if ((data[QString("value")].toFloat() >= 90.0) && (values[QString("cpu")].toFloat() < 90.0)) if ((enablePopup) &&
((data[QString("value")].toFloat() >= 90.0) && (values[QString("cpu")].toFloat() < 90.0)))
AWActions::sendNotification(QString("event"), i18n("High CPU load")); AWActions::sendNotification(QString("event"), i18n("High CPU load"));
// value // value
values[QString("cpu")] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1); values[QString("cpu")] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
@ -517,7 +521,8 @@ bool AWKeys::setDataBySource(const QString sourceName,
mount.remove(QString("partitions")).remove(QString("/filllevel")); mount.remove(QString("partitions")).remove(QString("/filllevel"));
for (int i=0; i<mountDevices.count(); i++) for (int i=0; i<mountDevices.count(); i++)
if (mountDevices[i] == mount) { if (mountDevices[i] == mount) {
if ((data[QString("value")].toFloat() >= 90.0) && (values[QString("hdd") + QString::number(i)].toFloat() < 90.0)) if ((enablePopup) &&
((data[QString("value")].toFloat() >= 90.0) && (values[QString("hdd") + QString::number(i)].toFloat() < 90.0)))
AWActions::sendNotification(QString("event"), i18n("Free space on %1 less than 10%", mount)); AWActions::sendNotification(QString("event"), i18n("Free space on %1 less than 10%", mount));
values[QString("hdd") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1); values[QString("hdd") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
break; break;
@ -583,7 +588,7 @@ bool AWKeys::setDataBySource(const QString sourceName,
// percentage // percentage
float value = 100.0 * values[QString("memmb")].toFloat() / values[QString("memtotmb")].toFloat(); float value = 100.0 * values[QString("memmb")].toFloat() / values[QString("memtotmb")].toFloat();
// notification // notification
if ((value >= 90.0) && (values[QString("mem")].toFloat() < 90.0)) if ((enablePopup) && ((value >= 90.0) && (values[QString("mem")].toFloat() < 90.0)))
AWActions::sendNotification(QString("event"), i18n("High memory usage")); AWActions::sendNotification(QString("event"), i18n("High memory usage"));
// value // value
values[QString("mem")] = QString("%1").arg(value, 5, 'f', 1); values[QString("mem")] = QString("%1").arg(value, 5, 'f', 1);
@ -591,7 +596,7 @@ bool AWKeys::setDataBySource(const QString sourceName,
} else if (sourceName == QString("netdev")) { } else if (sourceName == QString("netdev")) {
// network device // network device
// notification // notification
if (values[QString("netdev")] != data[QString("value")].toString()) if ((enablePopup) && (values[QString("netdev")] != data[QString("value")].toString()))
AWActions::sendNotification(QString("event"), i18n("Network device has been changed to %1", AWActions::sendNotification(QString("event"), i18n("Network device has been changed to %1",
data[QString("value")].toString())); data[QString("value")].toString()));
// value // value
@ -656,7 +661,7 @@ bool AWKeys::setDataBySource(const QString sourceName,
// percentage // percentage
float value = 100.0 * values[QString("swapmb")].toFloat() / values[QString("swaptotmb")].toFloat(); float value = 100.0 * values[QString("swapmb")].toFloat() / values[QString("swaptotmb")].toFloat();
// notification // notification
if ((value > 0.0) && (values[QString("swap")].toFloat() == 0.0)) if ((enablePopup) && ((value > 0.0) && (values[QString("swap")].toFloat() == 0.0)))
AWActions::sendNotification(QString("event"), i18n("Swap is used")); AWActions::sendNotification(QString("event"), i18n("Swap is used"));
// value // value
values[QString("swap")] = QString("%1").arg(value, 5, 'f', 1); values[QString("swap")] = QString("%1").arg(value, 5, 'f', 1);

View File

@ -50,7 +50,8 @@ public:
~AWKeys(); ~AWKeys();
Q_INVOKABLE void initKeys(const QString pattern, Q_INVOKABLE void initKeys(const QString pattern,
const QMap<QString, QVariant> tooltipParams); const QMap<QString, QVariant> tooltipParams,
const bool popup = false);
Q_INVOKABLE bool isDebugEnabled(); Q_INVOKABLE bool isDebugEnabled();
Q_INVOKABLE QString parsePattern(const QString pattern); Q_INVOKABLE QString parsePattern(const QString pattern);
Q_INVOKABLE QString toolTipImage(); Q_INVOKABLE QString toolTipImage();
@ -106,6 +107,7 @@ private:
RequestedItem requestedItem = Nothing; RequestedItem requestedItem = Nothing;
// variables // variables
bool debug = false; bool debug = false;
bool enablePopup = false;
bool ready = false; bool ready = false;
QList<GraphicalItem *> graphicalItems; QList<GraphicalItem *> graphicalItems;
QList<ExtScript *> extScripts; QList<ExtScript *> extScripts;

View File

@ -694,7 +694,7 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
} else if (source == QString("netdev")) { } else if (source == QString("netdev")) {
setData(source, QString("value"), getNetworkDevice()); setData(source, QString("value"), getNetworkDevice());
} else if (source == QString("pkg")) { } else if (source == QString("pkg")) {
if (pkgTimeUpdate > MSEC_IN_HOUR) { if (pkgTimeUpdate > SEC_IN_HOUR) {
for (int i=0; i<externalUpgrade.count(); i++) for (int i=0; i<externalUpgrade.count(); i++)
setData(source, QString("pkgcount") + QString::number(i), externalUpgrade[i]->run()); setData(source, QString("pkgcount") + QString::number(i), externalUpgrade[i]->run());
pkgTimeUpdate = 0; pkgTimeUpdate = 0;

View File

@ -18,9 +18,9 @@
#ifndef EXTSYSMON_H #ifndef EXTSYSMON_H
#define EXTSYSMON_H #define EXTSYSMON_H
#ifndef MSEC_IN_HOUR #ifndef SEC_IN_HOUR
#define MSEC_IN_HOUR 60*60*1000 #define SEC_IN_HOUR 60*60
#endif /* MSEC_IN_HOUR */ #endif /* SEC_IN_HOUR */
#include <Plasma/DataEngine> #include <Plasma/DataEngine>
#include <QProcess> #include <QProcess>
@ -64,7 +64,7 @@ private:
QList<int> times; QList<int> times;
bool debug; bool debug;
// FIXME dirty hack to avoid update package information every second // FIXME dirty hack to avoid update package information every second
int pkgTimeUpdate = MSEC_IN_HOUR; int pkgTimeUpdate = SEC_IN_HOUR;
// reread configuration // reread configuration
QStringList allHddDevices; QStringList allHddDevices;
QString getAllHdd(); QString getAllHdd();