diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp index b8045fb..5667b76 100644 --- a/sources/awesome-widget/plugin/awkeys.cpp +++ b/sources/awesome-widget/plugin/awkeys.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "awdataaggregator.h" #include "awdataengineaggregator.h" @@ -49,13 +50,16 @@ AWKeys::AWKeys(QObject *parent) dataEngineAggregator = new AWDataEngineAggregator(this); keyOperator = new AWKeyOperations(this); + m_timer = new QTimer(this); + m_timer->setSingleShot(false); + // update key data if required connect(keyOperator, SIGNAL(updateKeys(QStringList)), this, SLOT(reinitKeys(QStringList))); + connect(m_timer, SIGNAL(timeout()), this, SLOT(updateTextData())); // transfer signal from AWDataAggregator object to QML ui connect(dataAggregator, SIGNAL(toolTipPainted(const QString)), this, SIGNAL(needToolTipToBeUpdated(const QString))); - connect(this, SIGNAL(needToBeUpdated()), this, SLOT(updateTextData())); connect(this, SIGNAL(dropSourceFromDataengine(QString)), dataEngineAggregator, SLOT(dropSource(QString))); // transfer signal from dataengine to update source list @@ -68,6 +72,9 @@ AWKeys::~AWKeys() { qCDebug(LOG_AW) << __PRETTY_FUNCTION__; + m_timer->stop(); + delete m_timer; + // core delete dataEngineAggregator; delete m_threadPool; @@ -103,7 +110,11 @@ void AWKeys::initKeys(const QString currentPattern, const int interval, keyOperator->updateCache(); dataEngineAggregator->clear(); - return dataEngineAggregator->initDataEngines(interval); + dataEngineAggregator->initDataEngines(interval); + + // timer + m_timer->setInterval(interval); + m_timer->start(); } @@ -183,12 +194,6 @@ void AWKeys::editItem(const QString type) void AWKeys::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data) { - // do not log these parameters - if (sourceName == QString("update")) { - qCInfo(LOG_AW) << "Update data"; - return emit(needToBeUpdated()); - } - // run concurrent data update QtConcurrent::run(m_threadPool, this, &AWKeys::setDataBySource, sourceName, data); diff --git a/sources/awesome-widget/plugin/awkeys.h b/sources/awesome-widget/plugin/awkeys.h index ace101f..5fdf556 100644 --- a/sources/awesome-widget/plugin/awkeys.h +++ b/sources/awesome-widget/plugin/awkeys.h @@ -30,6 +30,7 @@ class AWDataEngineAggregator; class AWKeyOperations; class AWKeysAggregator; class QThreadPool; +class QTimer; class AWKeys : public QObject { @@ -67,7 +68,6 @@ signals: void dropSourceFromDataengine(const QString source); void needTextToBeUpdated(const QString newText) const; void needToolTipToBeUpdated(const QString newText) const; - void needToBeUpdated(); private slots: void reinitKeys(const QStringList currentKeys); @@ -83,6 +83,7 @@ private: AWDataEngineAggregator *dataEngineAggregator = nullptr; AWKeysAggregator *aggregator = nullptr; AWKeyOperations *keyOperator = nullptr; + QTimer *m_timer = nullptr; // variables QVariantMap m_tooltipParams; QStringList m_foundBars, m_foundKeys, m_foundLambdas, m_requiredKeys; diff --git a/sources/extsysmon/extsysmonaggregator.cpp b/sources/extsysmon/extsysmonaggregator.cpp index 7a43d7e..de0419d 100644 --- a/sources/extsysmon/extsysmonaggregator.cpp +++ b/sources/extsysmon/extsysmonaggregator.cpp @@ -29,7 +29,6 @@ #include "sources/playersource.h" #include "sources/processessource.h" #include "sources/quotessource.h" -#include "sources/updatesource.h" #include "sources/upgradesource.h" #include "sources/weathersource.h" #include "version.h" @@ -140,10 +139,6 @@ void ExtSysMonAggregator::init(const QHash config) AbstractExtSysMonSource *quotesItem = new QuotesSource(this, QStringList()); for (auto source : quotesItem->sources()) m_map[source] = quotesItem; - // update - AbstractExtSysMonSource *updateItem = new UpdateSource(this, QStringList()); - for (auto source : updateItem->sources()) - m_map[source] = updateItem; // upgrade AbstractExtSysMonSource *upgradeItem = new UpgradeSource(this, QStringList()); diff --git a/sources/extsysmon/sources/updatesource.cpp b/sources/extsysmon/sources/updatesource.cpp deleted file mode 100644 index 709cc8c..0000000 --- a/sources/extsysmon/sources/updatesource.cpp +++ /dev/null @@ -1,69 +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/ * - ***************************************************************************/ - - -#include "updatesource.h" - -#include "awdebug.h" - - -UpdateSource::UpdateSource(QObject *parent, const QStringList args) - : AbstractExtSysMonSource(parent, args) -{ - Q_ASSERT(args.count() == 0); - qCDebug(LOG_ESM) << __PRETTY_FUNCTION__; -} - - -UpdateSource::~UpdateSource() -{ - qCDebug(LOG_ESM) << __PRETTY_FUNCTION__; -} - - -QVariant UpdateSource::data(QString source) -{ - qCDebug(LOG_ESM) << "Source" << source; - - return true; -} - - -QVariantMap UpdateSource::initialData(QString source) const -{ - qCDebug(LOG_ESM) << "Source" << source; - - QVariantMap data; - if (source == QString("update")) { - data[QString("min")] = true; - data[QString("max")] = true; - data[QString("name")] = QString("Simple value which is always true"); - data[QString("type")] = QString("bool"); - data[QString("units")] = QString(""); - } - - return data; -} - - -QStringList UpdateSource::sources() const -{ - QStringList sources; - sources.append(QString("update")); - - return sources; -} diff --git a/sources/extsysmon/sources/updatesource.h b/sources/extsysmon/sources/updatesource.h deleted file mode 100644 index 521534d..0000000 --- a/sources/extsysmon/sources/updatesource.h +++ /dev/null @@ -1,38 +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 UPDATESOURCE_H -#define UPDATESOURCE_H - -#include - -#include "abstractextsysmonsource.h" - - -class UpdateSource : public AbstractExtSysMonSource -{ -public: - explicit UpdateSource(QObject *parent, const QStringList args); - virtual ~UpdateSource(); - QVariant data(QString source); - QVariantMap initialData(QString source) const; - void run(){}; - QStringList sources() const; -}; - - -#endif /* UPDATESOURCE_H */