mirror of
				https://github.com/arcan1s/awesome-widgets.git
				synced 2025-10-31 05:13:40 +00:00 
			
		
		
		
	add loadsource for testing needs
This commit is contained in:
		| @ -500,6 +500,12 @@ QStringList AWKeysAggregator::registerSource(const QString source, const QString | |||||||
|         key.remove(QString("weather/")); |         key.remove(QString("weather/")); | ||||||
|         m_map[source] = key; |         m_map[source] = key; | ||||||
|         m_formater[key] = NoFormat; |         m_formater[key] = NoFormat; | ||||||
|  |     } else if (source.startsWith(QString("load/load"))) { | ||||||
|  |         // load source | ||||||
|  |         QString key = source; | ||||||
|  |         key.remove(QString("load/")); | ||||||
|  |         m_map[source] = key; | ||||||
|  |         m_formater[key] = Temperature; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return keysFromSource(source); |     return keysFromSource(source); | ||||||
|  | |||||||
| @ -18,12 +18,14 @@ | |||||||
| #include "extsysmonaggregator.h" | #include "extsysmonaggregator.h" | ||||||
|  |  | ||||||
| #include "awdebug.h" | #include "awdebug.h" | ||||||
|  | #include "version.h" | ||||||
| #include "sources/batterysource.h" | #include "sources/batterysource.h" | ||||||
| #include "sources/customsource.h" | #include "sources/customsource.h" | ||||||
| #include "sources/desktopsource.h" | #include "sources/desktopsource.h" | ||||||
| #include "sources/gpuloadsource.h" | #include "sources/gpuloadsource.h" | ||||||
| #include "sources/gputempsource.h" | #include "sources/gputempsource.h" | ||||||
| #include "sources/hddtempsource.h" | #include "sources/hddtempsource.h" | ||||||
|  | #include "sources/loadsource.h" | ||||||
| #include "sources/networksource.h" | #include "sources/networksource.h" | ||||||
| #include "sources/playersource.h" | #include "sources/playersource.h" | ||||||
| #include "sources/processessource.h" | #include "sources/processessource.h" | ||||||
| @ -152,4 +154,10 @@ void ExtSysMonAggregator::init(const QHash<QString, QString> config) | |||||||
|     AbstractExtSysMonSource *weatherItem = new WeatherSource(this, QStringList()); |     AbstractExtSysMonSource *weatherItem = new WeatherSource(this, QStringList()); | ||||||
|     foreach(QString source, weatherItem->sources()) |     foreach(QString source, weatherItem->sources()) | ||||||
|         m_map[source] = weatherItem; |         m_map[source] = weatherItem; | ||||||
|  | #ifdef BUILD_TEST | ||||||
|  |     // additional load source | ||||||
|  |     AbstractExtSysMonSource *loadItem = new LoadSource(this, QStringList()); | ||||||
|  |     foreach(QString source, loadItem->sources()) | ||||||
|  |         m_map[source] = loadItem; | ||||||
|  | #endif /* BUILD_TEST */ | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										75
									
								
								sources/extsysmon/sources/loadsource.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								sources/extsysmon/sources/loadsource.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,75 @@ | |||||||
|  | /*************************************************************************** | ||||||
|  |  *   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 "loadsource.h" | ||||||
|  |  | ||||||
|  | #include "awdebug.h" | ||||||
|  |  | ||||||
|  |  | ||||||
|  | LoadSource::LoadSource(QObject *parent, const QStringList args) | ||||||
|  |     : AbstractExtSysMonSource(parent, args) | ||||||
|  | { | ||||||
|  |     Q_ASSERT(args.count() == 0); | ||||||
|  |     qCDebug(LOG_ESM); | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | LoadSource::~LoadSource() | ||||||
|  | { | ||||||
|  |     qCDebug(LOG_ESM); | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | QVariant LoadSource::data(QString source) | ||||||
|  | { | ||||||
|  |     qCDebug(LOG_ESM); | ||||||
|  |     qCDebug(LOG_ESM) << "Source" << source; | ||||||
|  |  | ||||||
|  |     source.remove(QString("load/load")); | ||||||
|  |     return source.toInt(); | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | QVariantMap LoadSource::initialData(QString source) const | ||||||
|  | { | ||||||
|  |     qCDebug(LOG_ESM); | ||||||
|  |     qCDebug(LOG_ESM) << "Source" << source; | ||||||
|  |  | ||||||
|  |     QVariantMap data; | ||||||
|  |     if (source.startsWith(QString("load/load"))) { | ||||||
|  |         data[QString("min")] = 0; | ||||||
|  |         data[QString("max")] = 0; | ||||||
|  |         data[QString("name")] = QString("Simple sources for load tests"); | ||||||
|  |         data[QString("type")] = QString("int"); | ||||||
|  |         data[QString("units")] = QString(""); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     return data; | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | QStringList LoadSource::sources() const | ||||||
|  | { | ||||||
|  |     qCDebug(LOG_ESM); | ||||||
|  |  | ||||||
|  |     QStringList sources; | ||||||
|  |     for (int i=0; i<1000; i++) | ||||||
|  |       sources.append(QString("load/load%1").arg(i)); | ||||||
|  |  | ||||||
|  |     return sources; | ||||||
|  | } | ||||||
							
								
								
									
										38
									
								
								sources/extsysmon/sources/loadsource.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								sources/extsysmon/sources/loadsource.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,38 @@ | |||||||
|  | /*************************************************************************** | ||||||
|  |  *   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 LOADSOURCE_H | ||||||
|  | #define LOADSOURCE_H | ||||||
|  |  | ||||||
|  | #include <QObject> | ||||||
|  |  | ||||||
|  | #include "abstractextsysmonsource.h" | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class LoadSource : public AbstractExtSysMonSource | ||||||
|  | { | ||||||
|  | public: | ||||||
|  |     explicit LoadSource(QObject *parent, const QStringList args); | ||||||
|  |     virtual ~LoadSource(); | ||||||
|  |     QVariant data(QString source); | ||||||
|  |     QVariantMap initialData(QString source) const; | ||||||
|  |     void run() {}; | ||||||
|  |     QStringList sources() const; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #endif /* LOADSOURCE_H */ | ||||||
		Reference in New Issue
	
	Block a user