mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 23:47:20 +00:00
drop own workaround for update functions
use qtimer instead
This commit is contained in:
parent
77388deab6
commit
097b63415e
@ -21,6 +21,7 @@
|
|||||||
#include <QJSEngine>
|
#include <QJSEngine>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include "awdataaggregator.h"
|
#include "awdataaggregator.h"
|
||||||
#include "awdataengineaggregator.h"
|
#include "awdataengineaggregator.h"
|
||||||
@ -49,13 +50,16 @@ AWKeys::AWKeys(QObject *parent)
|
|||||||
dataEngineAggregator = new AWDataEngineAggregator(this);
|
dataEngineAggregator = new AWDataEngineAggregator(this);
|
||||||
keyOperator = new AWKeyOperations(this);
|
keyOperator = new AWKeyOperations(this);
|
||||||
|
|
||||||
|
m_timer = new QTimer(this);
|
||||||
|
m_timer->setSingleShot(false);
|
||||||
|
|
||||||
// update key data if required
|
// update key data if required
|
||||||
connect(keyOperator, SIGNAL(updateKeys(QStringList)), this,
|
connect(keyOperator, SIGNAL(updateKeys(QStringList)), this,
|
||||||
SLOT(reinitKeys(QStringList)));
|
SLOT(reinitKeys(QStringList)));
|
||||||
|
connect(m_timer, SIGNAL(timeout()), this, SLOT(updateTextData()));
|
||||||
// transfer signal from AWDataAggregator object to QML ui
|
// transfer signal from AWDataAggregator object to QML ui
|
||||||
connect(dataAggregator, SIGNAL(toolTipPainted(const QString)), this,
|
connect(dataAggregator, SIGNAL(toolTipPainted(const QString)), this,
|
||||||
SIGNAL(needToolTipToBeUpdated(const QString)));
|
SIGNAL(needToolTipToBeUpdated(const QString)));
|
||||||
connect(this, SIGNAL(needToBeUpdated()), this, SLOT(updateTextData()));
|
|
||||||
connect(this, SIGNAL(dropSourceFromDataengine(QString)),
|
connect(this, SIGNAL(dropSourceFromDataengine(QString)),
|
||||||
dataEngineAggregator, SLOT(dropSource(QString)));
|
dataEngineAggregator, SLOT(dropSource(QString)));
|
||||||
// transfer signal from dataengine to update source list
|
// transfer signal from dataengine to update source list
|
||||||
@ -68,6 +72,9 @@ AWKeys::~AWKeys()
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
||||||
|
|
||||||
|
m_timer->stop();
|
||||||
|
delete m_timer;
|
||||||
|
|
||||||
// core
|
// core
|
||||||
delete dataEngineAggregator;
|
delete dataEngineAggregator;
|
||||||
delete m_threadPool;
|
delete m_threadPool;
|
||||||
@ -103,7 +110,11 @@ void AWKeys::initKeys(const QString currentPattern, const int interval,
|
|||||||
keyOperator->updateCache();
|
keyOperator->updateCache();
|
||||||
dataEngineAggregator->clear();
|
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,
|
void AWKeys::dataUpdated(const QString &sourceName,
|
||||||
const Plasma::DataEngine::Data &data)
|
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
|
// run concurrent data update
|
||||||
QtConcurrent::run(m_threadPool, this, &AWKeys::setDataBySource, sourceName,
|
QtConcurrent::run(m_threadPool, this, &AWKeys::setDataBySource, sourceName,
|
||||||
data);
|
data);
|
||||||
|
@ -30,6 +30,7 @@ class AWDataEngineAggregator;
|
|||||||
class AWKeyOperations;
|
class AWKeyOperations;
|
||||||
class AWKeysAggregator;
|
class AWKeysAggregator;
|
||||||
class QThreadPool;
|
class QThreadPool;
|
||||||
|
class QTimer;
|
||||||
|
|
||||||
class AWKeys : public QObject
|
class AWKeys : public QObject
|
||||||
{
|
{
|
||||||
@ -67,7 +68,6 @@ signals:
|
|||||||
void dropSourceFromDataengine(const QString source);
|
void dropSourceFromDataengine(const QString source);
|
||||||
void needTextToBeUpdated(const QString newText) const;
|
void needTextToBeUpdated(const QString newText) const;
|
||||||
void needToolTipToBeUpdated(const QString newText) const;
|
void needToolTipToBeUpdated(const QString newText) const;
|
||||||
void needToBeUpdated();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void reinitKeys(const QStringList currentKeys);
|
void reinitKeys(const QStringList currentKeys);
|
||||||
@ -83,6 +83,7 @@ private:
|
|||||||
AWDataEngineAggregator *dataEngineAggregator = nullptr;
|
AWDataEngineAggregator *dataEngineAggregator = nullptr;
|
||||||
AWKeysAggregator *aggregator = nullptr;
|
AWKeysAggregator *aggregator = nullptr;
|
||||||
AWKeyOperations *keyOperator = nullptr;
|
AWKeyOperations *keyOperator = nullptr;
|
||||||
|
QTimer *m_timer = nullptr;
|
||||||
// variables
|
// variables
|
||||||
QVariantMap m_tooltipParams;
|
QVariantMap m_tooltipParams;
|
||||||
QStringList m_foundBars, m_foundKeys, m_foundLambdas, m_requiredKeys;
|
QStringList m_foundBars, m_foundKeys, m_foundLambdas, m_requiredKeys;
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include "sources/playersource.h"
|
#include "sources/playersource.h"
|
||||||
#include "sources/processessource.h"
|
#include "sources/processessource.h"
|
||||||
#include "sources/quotessource.h"
|
#include "sources/quotessource.h"
|
||||||
#include "sources/updatesource.h"
|
|
||||||
#include "sources/upgradesource.h"
|
#include "sources/upgradesource.h"
|
||||||
#include "sources/weathersource.h"
|
#include "sources/weathersource.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
@ -140,10 +139,6 @@ void ExtSysMonAggregator::init(const QHash<QString, QString> config)
|
|||||||
AbstractExtSysMonSource *quotesItem = new QuotesSource(this, QStringList());
|
AbstractExtSysMonSource *quotesItem = new QuotesSource(this, QStringList());
|
||||||
for (auto source : quotesItem->sources())
|
for (auto source : quotesItem->sources())
|
||||||
m_map[source] = quotesItem;
|
m_map[source] = quotesItem;
|
||||||
// update
|
|
||||||
AbstractExtSysMonSource *updateItem = new UpdateSource(this, QStringList());
|
|
||||||
for (auto source : updateItem->sources())
|
|
||||||
m_map[source] = updateItem;
|
|
||||||
// upgrade
|
// upgrade
|
||||||
AbstractExtSysMonSource *upgradeItem
|
AbstractExtSysMonSource *upgradeItem
|
||||||
= new UpgradeSource(this, QStringList());
|
= new UpgradeSource(this, QStringList());
|
||||||
|
@ -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;
|
|
||||||
}
|
|
@ -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 <QObject>
|
|
||||||
|
|
||||||
#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 */
|
|
Loading…
Reference in New Issue
Block a user