diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp index 529a90f..ab5f6cd 100644 --- a/sources/awesome-widget/plugin/awkeys.cpp +++ b/sources/awesome-widget/plugin/awkeys.cpp @@ -170,14 +170,13 @@ QStringList AWKeys::dictKeys(const bool sorted, const QString regexp) const QStringList allKeys; // weather - for (int i=extWeather->items().count()-1; i>=0; i--) { - if (!extWeather->items().at(i)->isActive()) continue; - allKeys.append(extWeather->items().at(i)->tag(QString("weatherId"))); - allKeys.append(extWeather->items().at(i)->tag(QString("weather"))); - allKeys.append(extWeather->items().at(i)->tag(QString("humidity"))); - allKeys.append(extWeather->items().at(i)->tag(QString("pressure"))); - allKeys.append(extWeather->items().at(i)->tag(QString("temperature"))); - allKeys.append(extWeather->items().at(i)->tag(QString("timestamp"))); + for (int i=extWeather->activeItems().count()-1; i>=0; i--) { + allKeys.append(extWeather->activeItems().at(i)->tag(QString("weatherId"))); + allKeys.append(extWeather->activeItems().at(i)->tag(QString("weather"))); + allKeys.append(extWeather->activeItems().at(i)->tag(QString("humidity"))); + allKeys.append(extWeather->activeItems().at(i)->tag(QString("pressure"))); + allKeys.append(extWeather->activeItems().at(i)->tag(QString("temperature"))); + allKeys.append(extWeather->activeItems().at(i)->tag(QString("timestamp"))); } // time allKeys.append(QString("time")); @@ -280,28 +279,23 @@ QStringList AWKeys::dictKeys(const bool sorted, const QString regexp) const allKeys.append(QString("pstotal")); allKeys.append(QString("ps")); // package manager - for (int i=extUpgrade->items().count()-1; i>=0; i--) { - if (!extUpgrade->items().at(i)->isActive()) continue; - allKeys.append(extUpgrade->items().at(i)->tag(QString("pkgcount"))); - } + for (int i=extUpgrade->activeItems().count()-1; i>=0; i--) + allKeys.append(extUpgrade->activeItems().at(i)->tag(QString("pkgcount"))); // quotes - for (int i=extQuotes->items().count()-1; i>=0; i--) { - if (!extQuotes->items().at(i)->isActive()) continue; - allKeys.append(extQuotes->items().at(i)->tag(QString("ask"))); - allKeys.append(extQuotes->items().at(i)->tag(QString("askchg"))); - allKeys.append(extQuotes->items().at(i)->tag(QString("percaskchg"))); - allKeys.append(extQuotes->items().at(i)->tag(QString("bid"))); - allKeys.append(extQuotes->items().at(i)->tag(QString("bidchg"))); - allKeys.append(extQuotes->items().at(i)->tag(QString("percbidchg"))); - allKeys.append(extQuotes->items().at(i)->tag(QString("price"))); - allKeys.append(extQuotes->items().at(i)->tag(QString("pricechg"))); - allKeys.append(extQuotes->items().at(i)->tag(QString("percpricechg"))); + for (int i=extQuotes->activeItems().count()-1; i>=0; i--) { + allKeys.append(extQuotes->activeItems().at(i)->tag(QString("ask"))); + allKeys.append(extQuotes->activeItems().at(i)->tag(QString("askchg"))); + allKeys.append(extQuotes->activeItems().at(i)->tag(QString("percaskchg"))); + allKeys.append(extQuotes->activeItems().at(i)->tag(QString("bid"))); + allKeys.append(extQuotes->activeItems().at(i)->tag(QString("bidchg"))); + allKeys.append(extQuotes->activeItems().at(i)->tag(QString("percbidchg"))); + allKeys.append(extQuotes->activeItems().at(i)->tag(QString("price"))); + allKeys.append(extQuotes->activeItems().at(i)->tag(QString("pricechg"))); + allKeys.append(extQuotes->activeItems().at(i)->tag(QString("percpricechg"))); } // custom - for (int i=extScripts->items().count()-1; i>=0; i--) { - if (!extScripts->items().at(i)->isActive()) continue; - allKeys.append(extScripts->items().at(i)->tag(QString("custom"))); - } + for (int i=extScripts->activeItems().count()-1; i>=0; i--) + allKeys.append(extScripts->activeItems().at(i)->tag(QString("custom"))); // desktop allKeys.append(QString("desktop")); allKeys.append(QString("ndesktop")); @@ -313,7 +307,7 @@ QStringList AWKeys::dictKeys(const bool sorted, const QString regexp) const // bars QStringList graphicalItemsKeys; foreach(GraphicalItem *item, graphicalItems->items()) - graphicalItemsKeys.append(QString("%1%2").arg(item->name()).arg(item->bar())); + graphicalItemsKeys.append(item->tag()); graphicalItemsKeys.sort(); for (int i=graphicalItemsKeys.count()-1; i>=0; i--) allKeys.append(graphicalItemsKeys.at(i)); @@ -345,9 +339,13 @@ void AWKeys::dataUpdateReceived(const QString sourceName, const QVariantMap data qCDebug(LOG_AW) << "Source" << sourceName; qCDebug(LOG_AW) << "Data" << data; +#ifdef BUILD_FUTURE QtConcurrent::run([this, sourceName, data, params]() { return setDataBySource(sourceName, data, params); }); +#else + return setDataBySource(sourceName, data, params); +#endif } @@ -646,11 +644,16 @@ QString AWKeys::parsePattern() const void AWKeys::setDataBySource(const QString sourceName, const QVariantMap data, const QVariantMap params) { + if (lock) { + lock = (queue > 1); + return; + } qCDebug(LOG_AW); qCDebug(LOG_AW) << "Source" << sourceName; qCDebug(LOG_AW) << "Data" << data; if (sourceName == QString("update")) return emit(needToBeUpdated()); + // drop if limits are reached if (++queue > QUEUE_LIMIT) { qCWarning(LOG_AW) << "Messages queue" << queue-- << "more than limits" << QUEUE_LIMIT; return; @@ -717,20 +720,14 @@ void AWKeys::setDataBySource(const QString sourceName, const QVariantMap data, // read speed QString device = sourceName; device.remove(QString("/Rate/rblk")); - for (int i=0; i= 90.0) && (values[QString("hdd%1").arg(i)].toFloat() < 90.0)) - AWActions::sendNotification(QString("event"), i18n("Free space on %1 less than 10%", mount), enablePopup); - values[QString("hdd%1").arg(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1); - break; - } + int index = mountDevices.indexOf(mount); + if ((data[QString("value")].toFloat() >= 90.0) && (values[QString("hdd%1").arg(index)].toFloat() < 90.0)) + AWActions::sendNotification(QString("event"), i18n("Free space on %1 less than 10%", mount), enablePopup); + values[QString("hdd%1").arg(index)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1); } else if (sourceName.contains(mountFreeRegExp)) { // free space QString mount = sourceName; mount.remove(QString("partitions")).remove(QString("/freespace")); - for (int i=0; i 1000.0 ? QString("MB/s") : QString("KB/s"); // update - for (int i=0; i *extScripts; ExtItemAggregator *extUpgrade; ExtItemAggregator *extWeather; + bool lock = false; int queue = 0; QString pattern; QStringList foundBars, foundKeys, foundLambdas; diff --git a/sources/awesomewidgets/extitemaggregator.h b/sources/awesomewidgets/extitemaggregator.h index 1eddfbc..3eb8f0c 100644 --- a/sources/awesomewidgets/extitemaggregator.h +++ b/sources/awesomewidgets/extitemaggregator.h @@ -50,7 +50,15 @@ public: qCDebug(LOG_LIB); m_items.clear(); - } + m_activeItems.clear(); + }; + + QList activeItems() + { + qCDebug(LOG_LIB); + + return m_activeItems; + }; void editItems() { @@ -61,14 +69,6 @@ public: qCInfo(LOG_LIB) << "Dialog returns" << ret; }; - void initItems() - { - qCDebug(LOG_LIB); - - m_items.clear(); - m_items = getItems(); - }; - T *itemByTag(const QString _tag) const { qCDebug(LOG_LIB); @@ -84,7 +84,7 @@ public: qCWarning(LOG_LIB) << "Could not find item by tag" << _tag; return found; - } + }; T *itemByTagNumber(const int _number) const { @@ -101,7 +101,7 @@ public: qCWarning(LOG_LIB) << "Could not find item by number" << _number; return found; - } + }; T *itemFromWidget() const { @@ -143,6 +143,7 @@ public: private: QList m_items; + QList m_activeItems; QString m_type; // init method @@ -181,6 +182,18 @@ private: return items; }; + void initItems() + { + qCDebug(LOG_LIB); + + m_items.clear(); + m_activeItems.clear(); + + m_items = getItems(); + foreach(T *item, m_items) + if (item->isActive()) m_activeItems.append(item); + }; + void repaint() { qCDebug(LOG_LIB); diff --git a/sources/extsysmon/extsysmon.cpp b/sources/extsysmon/extsysmon.cpp index 232a6c4..f982b9a 100644 --- a/sources/extsysmon/extsysmon.cpp +++ b/sources/extsysmon/extsysmon.cpp @@ -470,7 +470,7 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source) QVariantHash battery = getBattery(configuration[QString("ACPIPATH")]); foreach(QString key, battery.keys()) setData(source, key, battery[key]); } else if (source == QString("custom")) { - foreach(ExtScript *script, extScripts->items()) { + foreach(ExtScript *script, extScripts->activeItems()) { QVariantHash data = script->run(); foreach(QString key, data.keys()) setData(source, key, data[key]); } @@ -490,7 +490,7 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source) } else if (source == QString("netdev")) { setData(source, QString("value"), getNetworkDevice()); } else if (source == QString("pkg")) { - foreach(ExtUpgrade *upgrade, extUpgrade->items()) { + foreach(ExtUpgrade *upgrade, extUpgrade->activeItems()) { QVariantHash data = upgrade->run(); foreach(QString key, data.keys()) setData(source, key, data[key]); } @@ -504,14 +504,14 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source) QVariantHash ps = getPsStats(); foreach(QString key, ps.keys()) setData(source, key, ps[key]); } else if (source == QString("quotes")) { - foreach(ExtQuotes *quote, extQuotes->items()) { + foreach(ExtQuotes *quote, extQuotes->activeItems()) { QVariantHash data = quote->run(); foreach(QString key, data.keys()) setData(source, key, data[key]); } } else if (source == QString("update")) { setData(source, QString("value"), true); } else if (source == QString("weather")) { - foreach(ExtWeather *weather, extWeather->items()) { + foreach(ExtWeather *weather, extWeather->activeItems()) { QVariantHash data = weather->run(); foreach(QString key, data.keys()) setData(source, key, data[key]); }