Compare commits

..

18 Commits

Author SHA1 Message Date
c73486aaf8 gpu memory demo 2026-02-02 16:31:57 +02:00
59e3b21071 feat: use singleton connection to systemstats
it has been found in #174, that if there are multiple instances of
widget, it keeps subscribing on all sources, because of how dbus
interface works.

In order to hande it, all subscriptions are now kept from singleton with
tracking active clients
2026-01-30 16:03:45 +02:00
7e13e1eef7 Release 4.0.5 2026-01-28 19:53:21 +02:00
da53052a6f fix: always unsubscribe on sources 2026-01-28 19:51:51 +02:00
1a0a1fb884 Release 4.0.4 2026-01-28 14:18:16 +02:00
7a4367734b fix: check if subscription optimisation is enabled explicitly
Previous implementation has used implicit logic with empty keys arrays,
which might lead to some errors in processing
2026-01-28 14:16:55 +02:00
cdcd929cec Release 4.0.3 2026-01-01 19:54:34 +02:00
8605f66535 fix: compilation error with the latest releases (#173)
As it has been found in the releated issue, compile error occurs because
of missing evaluation and appears to be caused by Qt6QmlTargets.cmake.
Instead of trying to hack generated files, lets just drop qml
definitions because we don't really use them explicitly
2026-01-01 19:49:26 +02:00
3abcd8d6ae Release 4.0.2 2025-07-25 09:34:56 +03:00
daveedmee
0725288595 feat: added German translation (#172)
* Added German translation

About 96% of the plasmaoid into German. Missing strings for:

- AC online tag (as well as AC online)
- AC offline tag (as well as AC offline) (I think they are used for when you have a charging cable plugged into your laptop? I am on a desktop so I can't check)
- Quotes Monitor (as well as quotes – are they used for stocks?)
- User keys
- Has return

Also worth noting is that your redirection to stooq.com doesn't make sense for a German as it is a Polish stocks site

* Fixed some spelling issues

* fixed spelling of openSUSE

* Update de.po

Confused minimal with minimalistic. Changed translation accordingly

* added missing translation strings

Missing translations added for
- AC
- AC online (+tag)
- AC offline (+tag)
- Quotes (+Monitor)
- User keys
- has return
- Player data symbols
2025-07-23 20:22:00 +03:00
Winter
8342d65ffa docs: update README.md (#169) 2025-03-14 14:41:06 +02:00
571417f786 Release 4.0.1 2024-12-11 17:12:24 +02:00
e3d24d1890 fix: disable tooltip painting for now, because it causes error during
png rendering in qt
2024-12-11 17:09:10 +02:00
ee7bd90aae Release 4.0.0 2024-05-05 15:55:56 +03:00
f79c94e9e2 fix: add buttons to import dialog 2024-05-05 15:55:03 +03:00
66baa78cda build: fix debug builds 2024-05-05 15:41:43 +03:00
transifex-integration[bot]
79a148a21a chore: translate awesome-widgets.pot in ru (#167)
100% translated source file: 'awesome-widgets.pot'
on 'ru'.

Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com>
2024-05-04 01:19:09 +03:00
64b4618904 refactor: split formatters and matchers into separated singleton classes (#166)
* split formatter into separated singleton classes

* split data engine matchers to classes

* nodiscard attribute for formatter methods

* small refactoring in matchers

* fix codefactor warnings

* fix test building
2024-04-30 21:53:21 +03:00
197 changed files with 3912 additions and 665 deletions

3
.gitignore vendored
View File

@@ -48,3 +48,6 @@ pkg
# clion settings # clion settings
.idea .idea
cmake-build* cmake-build*
# clang
.cache

View File

@@ -13,3 +13,4 @@ Steve Lemuel (Chinese)
Mariusz Kocoń (Polish) Mariusz Kocoń (Polish)
Ibnu Daru Aji (Indonesian) Ibnu Daru Aji (Indonesian)
Antonio Vivace (Italian) Antonio Vivace (Italian)
@daveedmee (German)

View File

@@ -1,5 +1,19 @@
Ver.4.0.3:
- drop qml definition to avoid compile errors
Ver.4.0.2:
+ German translation (#172, thanks to daveedmee)
Ver.4.0.1:
- temporary disable tooltip painting in main widget
Ver.4.0.0: Ver.4.0.0:
* migration to plasma 6 * migration to plasma 6
* dialog windows have been replaced by notifications
+ $gpuN keys have been added
+ new key $ssid
- $cuptime key has been removed in favour of $uptime
- $gputemp key has been replaced by $gpuN
Ver.3.5.0: Ver.3.5.0:
+ wayland support + wayland support

View File

@@ -75,5 +75,5 @@ Links
* [Scripts and bars](https://arcanis.me/en/2014/12/19/aw-v21-bells-and-whistles/) * [Scripts and bars](https://arcanis.me/en/2014/12/19/aw-v21-bells-and-whistles/)
* Plasmoid on [kde-look](http://kde-look.org/content/show.php/Awesome+Widgets?content=157124) * Plasmoid on [kde-look](http://kde-look.org/content/show.php/Awesome+Widgets?content=157124)
* DataEngine on [kde-look](http://kde-look.org/content/show.php/Extended+Systemmonitor+DataEngine?content=158773) * DataEngine on [kde-look](http://kde-look.org/content/show.php/Extended+Systemmonitor+DataEngine?content=158773)
* Archlinux [AUR](https://aur.archlinux.org/packages/plasma5-applet-awesome-widgets/) package * Archlinux [AUR](https://aur.archlinux.org/packages/plasma6-applets-awesome-widgets) package
* [OpenSuse](http://software.opensuse.org/search?q=awesome-widgets) packages, [KF5 OpenSuse](http://software.opensuse.org/package/plasma5-awesome-widgets) package * [OpenSuse](http://software.opensuse.org/search?q=awesome-widgets) packages, [KF5 OpenSuse](http://software.opensuse.org/package/plasma5-awesome-widgets) package

View File

@@ -2,7 +2,7 @@
pkgname=plasma6-applet-awesome-widgets pkgname=plasma6-applet-awesome-widgets
_pkgname=awesome-widgets _pkgname=awesome-widgets
pkgver=4.0.0alpha2 pkgver=4.0.5
pkgrel=1 pkgrel=1
pkgdesc="Collection of minimalistic Plasmoids which look like Awesome WM widgets (ex-PyTextMonitor)" pkgdesc="Collection of minimalistic Plasmoids which look like Awesome WM widgets (ex-PyTextMonitor)"
arch=('x86_64') arch=('x86_64')
@@ -27,5 +27,3 @@ build () {
package() { package() {
DESTDIR="$pkgdir" cmake --install build DESTDIR="$pkgdir" cmake --install build
} }
sha256sums=('b2a7b07a1df6f710f4e0d6e5898933f4ddb131818b922dc4b8e48afe3e98a664')

View File

@@ -19,7 +19,7 @@ set(PROJECT_CONTACT "esalexeev@gmail.com")
set(PROJECT_LICENSE "GPL3") set(PROJECT_LICENSE "GPL3")
set(PROJECT_VERSION_MAJOR "4") set(PROJECT_VERSION_MAJOR "4")
set(PROJECT_VERSION_MINOR "0") set(PROJECT_VERSION_MINOR "0")
set(PROJECT_VERSION_PATCH "0") set(PROJECT_VERSION_PATCH "5")
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
# append git version if any # append git version if any
set(PROJECT_COMMIT_SHA "Commit hash" CACHE INTERNAL "") set(PROJECT_COMMIT_SHA "Commit hash" CACHE INTERNAL "")

View File

@@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/ ***************************************************************************/
#ifndef NDEBUG
#define NDEBUG
#endif /* NDEBUG */
#include <KI18n/KLocalizedString> #include <KI18n/KLocalizedString>
#include "awdebug.h" #include "awdebug.h"

View File

@@ -130,7 +130,7 @@ PlasmoidItem {
Plasmoid.userConfiguringChanged(false) Plasmoid.userConfiguringChanged(false)
// connect data // connect data
awKeys.needTextToBeUpdated.connect(needTextUpdate) awKeys.needTextToBeUpdated.connect(needTextUpdate)
awKeys.needToolTipToBeUpdated.connect(needToolTipUpdate) //awKeys.needToolTipToBeUpdated.connect(needToolTipUpdate)
// check updates if required // check updates if required
if (plasmoid.configuration.checkUpdates) return awActions.checkUpdates(false) if (plasmoid.configuration.checkUpdates) return awActions.checkUpdates(false)
} }

View File

@@ -19,7 +19,7 @@
"Id": "org.kde.plasma.awesomewidget", "Id": "org.kde.plasma.awesomewidget",
"License": "GPLv3", "License": "GPLv3",
"Name": "Awesome Widget", "Name": "Awesome Widget",
"Version": "4.0.0", "Version": "4.0.5",
"Website": "https://arcanis.me/projects/awesome-widgets/" "Website": "https://arcanis.me/projects/awesome-widgets/"
}, },
"X-Plasma-API-Minimum-Version": "6.0" "X-Plasma-API-Minimum-Version": "6.0"

View File

@@ -23,7 +23,7 @@
class QNetworkAccessManager; class QNetworkAccessManager;
class QNetworkReply; class QNetworkReply;
class AWBugReporter : public QObject class __attribute__((visibility("default"))) AWBugReporter : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@@ -23,7 +23,7 @@
class QSettings; class QSettings;
class AWConfigHelper : public QObject class __attribute__((visibility("default"))) AWConfigHelper : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@@ -34,7 +34,7 @@ public:
[[nodiscard]] QStringList sources() const; [[nodiscard]] QStringList sources() const;
[[nodiscard]] QStringList refinedSources() const; [[nodiscard]] QStringList refinedSources() const;
// configuration related // configuration related
void editPairs() override{}; void editPairs() override {};
QStringList leftKeys() override; QStringList leftKeys() override;
QStringList rightKeys() override; QStringList rightKeys() override;
}; };

View File

@@ -17,7 +17,6 @@
#pragma once #pragma once
#include <QObject>
#include <QVariant> #include <QVariant>

View File

@@ -95,14 +95,55 @@ void AWDataEngineAggregator::loadSources()
} }
void AWDataEngineAggregator::registerClient(QObject *_client)
{
qCDebug(LOG_AW) << "Register client" << _client;
// register new client
m_clients.insert(_client);
// (re)connect sources for new client
connectSources();
}
void AWDataEngineAggregator::unregisterClient(QObject *_client)
{
qCDebug(LOG_AW) << "Unregister client" << _client;
m_clients.remove(_client);
for (auto [source, clients] : m_droppedBy.asKeyValueRange()) {
if (clients.remove(_client)) {
if (isSubscriptionUnused(source))
dropSource(source);
}
}
}
void AWDataEngineAggregator::dropSource(const QString &_source) void AWDataEngineAggregator::dropSource(const QString &_source)
{ {
qCDebug(LOG_AW) << "Disconnect sensor" << _source; qCDebug(LOG_AW) << "Disconnect sensor" << _source;
if (m_subscribed.contains(_source)) { if (m_subscribed.remove(_source))
m_interface->unsubscribe({_source}).waitForFinished(); m_interface->unsubscribe({_source}).waitForFinished();
m_subscribed.remove(_source); }
}
void AWDataEngineAggregator::dropSourceForClient(QObject *_client, const QString &_source)
{
qCDebug(LOG_AW) << "Client" << _client << "dropping source" << _source;
m_droppedBy[_source].insert(_client);
// only unsubscribe if ALL clients have dropped this source
if (isSubscriptionUnused(_source))
dropSource(_source);
}
bool AWDataEngineAggregator::isSubscriptionUnused(const QString &_source) const
{
return m_droppedBy.value(_source).size() >= m_clients.size() && !m_clients.isEmpty();
} }

View File

@@ -23,6 +23,7 @@
#include <QObject> #include <QObject>
#include <QSet> #include <QSet>
#include <memory>
namespace KSysGuard::SystemStats namespace KSysGuard::SystemStats
{ {
@@ -34,12 +35,26 @@ class AWDataEngineAggregator : public QObject
Q_OBJECT Q_OBJECT
public: public:
explicit AWDataEngineAggregator(QObject *_parent = nullptr);
~AWDataEngineAggregator() override; ~AWDataEngineAggregator() override;
AWDataEngineAggregator(AWDataEngineAggregator &) = delete;
void operator=(const AWDataEngineAggregator &) = delete;
[[nodiscard]] static AWDataEngineAggregator *instance(QObject *_client)
{
static auto instance = loadInstance();
instance->registerClient(_client);
return instance.get();
};
void connectSources(); void connectSources();
void disconnectSources(); void disconnectSources();
void dropSourceForClient(QObject *_client, const QString &_source);
[[nodiscard]] inline bool isSubscriptionUnused(const QString &_source) const;
[[nodiscard]] static bool isValidSensor(const KSysGuard::SensorInfo &_sensor); [[nodiscard]] static bool isValidSensor(const KSysGuard::SensorInfo &_sensor);
void loadSources(); void loadSources();
void registerClient(QObject *_client);
void unregisterClient(QObject *_client);
signals: signals:
void dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_sensors, const KSysGuard::SensorDataList &_data); void dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_sensors, const KSysGuard::SensorDataList &_data);
@@ -52,7 +67,18 @@ public slots:
void updateData(const KSysGuard::SensorDataList &_data); void updateData(const KSysGuard::SensorDataList &_data);
void updateSensors(const QHash<QString, KSysGuard::SensorInfo> &_sensors); void updateSensors(const QHash<QString, KSysGuard::SensorInfo> &_sensors);
protected:
explicit AWDataEngineAggregator(QObject *_parent = nullptr);
[[nodiscard]] static std::unique_ptr<AWDataEngineAggregator> loadInstance()
{
auto instance = new AWDataEngineAggregator();
return std::unique_ptr<AWDataEngineAggregator>(instance);
};
private: private:
QSet<QObject *> m_clients;
QHash<QString, QSet<QObject *>> m_droppedBy;
KSysGuard::SystemStats::DBusInterface *m_interface = nullptr; KSysGuard::SystemStats::DBusInterface *m_interface = nullptr;
QHash<QString, KSysGuard::SensorInfo> m_sensors; QHash<QString, KSysGuard::SensorInfo> m_sensors;
QSet<QString> m_subscribed; QSet<QString> m_subscribed;

View File

@@ -32,10 +32,6 @@ AWDataEngineMapper::AWDataEngineMapper(QObject *_parent, AWFormatterHelper *_cus
qCDebug(LOG_AW) << __PRETTY_FUNCTION__; qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
// default formatters // default formatters
// memory
m_formatter["mem"] = AWPluginFormatterFloat::instance();
m_formatter["memtotmb"] = AWPluginFormatterMemoryMB::instance();
m_formatter["memtotgb"] = AWPluginFormatterMemoryGB::instance();
// network // network
m_formatter["down"] = AWPluginFormatterNet::instance(); m_formatter["down"] = AWPluginFormatterNet::instance();
m_formatter["downkb"] = AWPluginFormatterMemory::instance(); m_formatter["downkb"] = AWPluginFormatterMemory::instance();
@@ -47,10 +43,10 @@ AWDataEngineMapper::AWDataEngineMapper(QObject *_parent, AWFormatterHelper *_cus
m_formatter["uptot"] = AWPluginFormatterMemoryMB::instance(); m_formatter["uptot"] = AWPluginFormatterMemoryMB::instance();
m_formatter["uptotkb"] = AWPluginFormatterMemory::instance(); m_formatter["uptotkb"] = AWPluginFormatterMemory::instance();
m_formatter["upunits"] = AWPluginFormatterNetUnits::instance(); m_formatter["upunits"] = AWPluginFormatterNetUnits::instance();
// swap // gpu memory
m_formatter["swap"] = AWPluginFormatterFloat::instance(); m_formatter["gpumem"] = AWPluginFormatterFloat::instance();
m_formatter["swaptotmb"] = AWPluginFormatterMemoryMB::instance(); m_formatter["gpufreemb"] = AWPluginFormatterMemoryMB::instance();
m_formatter["swaptotgb"] = AWPluginFormatterMemoryGB::instance(); m_formatter["gpufreegb"] = AWPluginFormatterMemoryGB::instance();
} }
@@ -73,217 +69,19 @@ QStringList AWDataEngineMapper::keysFromSource(const QString &_source) const
// HACK units required to define should the value be calculated as temperature // HACK units required to define should the value be calculated as temperature
// or fan data // or fan data
QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSysGuard::Unit _units, QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSysGuard::Unit _units,
const QStringList &_keys) const QStringList &_keys, const bool _disconnectUnused)
{ {
qCDebug(LOG_AW) << "Source" << _source << "with units" << _units; qCDebug(LOG_AW) << "Source" << _source << "with units" << _units;
// regular expressions
static auto cpuTempRegExp = QRegularExpression("^cpu/cpu.*/temperature$");
static auto mountFillRegExp = QRegularExpression("^disk/.*/usedPercent$");
static auto mountFreeRegExp = QRegularExpression("^disk/.*/free$");
static auto mountUsedRegExp = QRegularExpression("^disk/.*/used$");
static auto netRegExp = QRegularExpression("^network/.*/(download|upload)$");
static auto netTotalRegExp = QRegularExpression("^network/.*/(totalDownload|totalUpload)$");
auto matchers = AWPluginMatchers::matchers; auto matchers = AWPluginMatchers::matchers;
auto matcher = std::find_if(matchers.cbegin(), matchers.cend(), [&_source](auto matcher) { return matcher->matches(_source); }); auto matcher = std::find_if(matchers.cbegin(), matchers.cend(),
if (matcher == std::end(matchers)) [&_source](auto matcher) { return matcher->matches(_source); });
if (matcher == matchers.cend())
return {}; return {};
auto foundKeys = (*matcher)->keys(_source, _units, m_settings); auto foundKeys = (*matcher)->keys(_source, _units, m_settings);
auto keys = foundKeys.keys(); // speedup a little bit auto keys = foundKeys.keys(); // speedup a little bit
if (_source.contains(mountFillRegExp)) {
// fill level
auto device = _source;
device.remove("disk/").remove("/usedPercent");
auto index = m_devices["mount"].indexOf(device);
if (index > -1) {
auto key = QString("hdd%1").arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWPluginFormatterFloat::instance();
// additional keys
m_formatter[QString("hddtotmb%1").arg(index)] = AWPluginFormatterMemoryMB::instance();
m_formatter[QString("hddtotgb%1").arg(index)] = AWPluginFormatterMemoryGB::instance();
}
} else if (_source.contains(mountFreeRegExp)) {
// free space
auto device = _source;
device.remove("disk/").remove("/free");
auto index = m_devices["mount"].indexOf(device);
if (index > -1) {
// mb
auto key = QString("hddfreemb%1").arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWPluginFormatterMemoryMB::instance();
// gb
key = QString("hddfreegb%1").arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWPluginFormatterMemoryGB::instance();
}
} else if (_source.contains(mountUsedRegExp)) {
// used
auto device = _source;
device.remove("disk/").remove("/used");
auto index = m_devices["mount"].indexOf(device);
if (index > -1) {
// mb
auto key = QString("hddmb%1").arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWPluginFormatterMemoryMB::instance();
// gb
key = QString("hddgb%1").arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWPluginFormatterMemoryGB::instance();
}
} else if (_source.startsWith("extsysmon/requests/response")) {
// network response
auto key = _source;
key.remove("extsysmon/requests/");
m_map.insert(_source, key);
m_formatter[key] = AWPluginFormatterNoFormat::instance();
} else if (_source.contains(netRegExp)) {
// network speed
auto type = _source.endsWith("download") ? "down" : "up";
auto index = m_devices["net"].indexOf(_source.split('/')[1]);
if (index > -1) {
// kb
auto key = QString("%1kb%2").arg(type).arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWPluginFormatterMemory::instance();
// smart
key = QString("%1%2").arg(type).arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWPluginFormatterNet::instance();
// units
key = QString("%1units%2").arg(type).arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWPluginFormatterNetUnits::instance();
}
} else if (_source.contains(netTotalRegExp)) {
// network data total
auto type = _source.endsWith("Download") ? "down" : "up";
auto index = m_devices["net"].indexOf(_source.split('/')[1]);
if (index > -1) {
// kb
auto key = QString("%1totkb%2").arg(type).arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWPluginFormatterMemory::instance();
// mb
key = QString("%1tot%2").arg(type).arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWPluginFormatterMemoryMB::instance();
}
} else if (_source.startsWith("extsysmon/upgrade")) {
// package manager
auto key = _source;
key.remove("extsysmon/upgrade/");
m_map.insert(_source, key);
m_formatter[key] = AWPluginFormatterIntegerShort::instance();
} else if (_source.startsWith("extsysmon/player")) {
// player
auto key = _source;
key.remove("extsysmon/player/");
m_map.insert(_source, key);
m_formatter[key] = AWPluginFormatterNoFormat::instance();
} else if (_source == "extsysmon/ps/running") {
// running processes count
m_map.insert(_source, "pscount");
m_formatter["pscount"] = AWPluginFormatterNoFormat::instance();
} else if (_source == "extsysmon/ps/list") {
// list of running processes
m_map.insert(_source, "ps");
m_formatter["ps"] = AWPluginFormatterList::instance();
} else if (_source == "extsysmon/ps/count") {
// total processes count
m_map.insert(_source, "pstot");
m_formatter["pstot"] = AWPluginFormatterNoFormat::instance();
} else if (_source.startsWith("extsysmon/quotes")) {
// quotes
auto key = _source;
key.remove("extsysmon/quotes/");
m_map.insert(_source, key);
m_formatter[key] = AWPluginFormatterDouble::instance();
} else if (_source == "memory/swap/free") {
// free swap
// mb
m_map.insert(_source, "swapfreemb");
m_formatter["swapfreemb"] = AWPluginFormatterMemoryMB::instance();
// gb
m_map.insert(_source, "swapfreegb");
m_formatter["swapfreegb"] = AWPluginFormatterMemoryGB::instance();
} else if (_source == "memory/swap/used") {
// used swap
// mb
m_map.insert(_source, "swapmb");
m_formatter["swapmb"] = AWPluginFormatterMemoryMB::instance();
// gb
m_map.insert(_source, "swapgb");
m_formatter["swapgb"] = AWPluginFormatterMemoryGB::instance();
} else if (_source.startsWith("lmsensors/") || _source.contains(cpuTempRegExp)
|| _source == "cpu/all/averageTemperature") {
// temperature
auto index = m_devices["temp"].indexOf(_source);
// HACK on DE initialization there are no units key
if (_units == KSysGuard::UnitInvalid)
return QStringList({QString("temp%1").arg(index)});
if (index > -1) {
auto key = QString("temp%1").arg(index);
m_map.insert(_source, key);
if (_units == KSysGuard::UnitCelsius)
m_formatter[key] = AWPluginFormatterTemperature::instance();
else
m_formatter[key] = AWPluginFormatterInteger::instance();
}
} else if (_source == "extsysmon/time/now") {
// time
m_map.insert(_source, "time");
m_formatter["time"] = AWPluginFormatterTime::instance();
// custom time
m_map.insert(_source, "ctime");
m_formatter["ctime"] = AWPluginFormatterTimeCustom::instance();
// ISO time
m_map.insert(_source, "isotime");
m_formatter["isotime"] = AWPluginFormatterTimeISO::instance();
// long time
m_map.insert(_source, "longtime");
m_formatter["longtime"] = AWPluginFormatterTimeLong::instance();
// short time
m_map.insert(_source, "shorttime");
m_formatter["shorttime"] = AWPluginFormatterTimeShort::instance();
// timestamp
m_map.insert(_source, "tstime");
m_formatter["tstime"] = AWPluginFormatterNoFormat::instance();
} else if (_source == "extsysmon/system/brightness") {
m_map.insert(_source, "brightness");
m_formatter["brightness"] = AWPluginFormatterIntegerShort::instance();
} else if (_source == "extsysmon/system/volume") {
m_map.insert(_source, "volume");
m_formatter["volume"] = AWPluginFormatterIntegerShort::instance();
} else if (_source == "os/system/uptime") {
// uptime
m_map.insert(_source, "uptime");
m_formatter["uptime"] = AWPluginFormatterUptime::instance();
} else if (_source.startsWith("extsysmon/weather/temperature")) {
// temperature
auto key = _source;
key.remove("extsysmon/weather/");
m_map.insert(_source, key);
m_formatter[key] = AWPluginFormatterTemperature::instance();
} else if (_source.startsWith("extsysmon/weather/")) {
// other weather
auto key = _source;
key.remove("extsysmon/weather/");
m_map.insert(_source, key);
m_formatter[key] = AWPluginFormatterNoFormat::instance();
} else if (_source.startsWith("extsysmon/load/load")) {
// load source
auto key = _source;
key.remove("extsysmon/load/");
m_map.insert(_source, key);
m_formatter[key] = AWPluginFormatterTemperature::instance();
}
// rewrite formatters for custom ones // rewrite formatters for custom ones
QStringList customFormattersKeys; QStringList customFormattersKeys;
if (m_customFormatters) if (m_customFormatters)
@@ -297,9 +95,8 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
// check if keys were actually requested // check if keys were actually requested
qCInfo(LOG_AW) << "Looking for keys" << keys << "in" << _keys; qCInfo(LOG_AW) << "Looking for keys" << keys << "in" << _keys;
auto required = _keys.isEmpty() || std::any_of(keys.cbegin(), keys.cend(), [&_keys](auto &key) { auto required = !_disconnectUnused
return _keys.contains(key); || std::any_of(keys.cbegin(), keys.cend(), [&_keys](auto &key) { return _keys.contains(key); });
});
if (!required) if (!required)
return {}; return {};
@@ -316,4 +113,12 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
void AWDataEngineMapper::setDevices(const AWPluginMatcherSettings &_settings) void AWDataEngineMapper::setDevices(const AWPluginMatcherSettings &_settings)
{ {
m_settings = _settings; m_settings = _settings;
// update formatters
// gpu memory per device
for (auto i = 0; i < m_settings.gpu.count(); ++i) {
m_formatter[QString("gpumem%1").arg(i)] = AWPluginFormatterFloat::instance();
m_formatter[QString("gpufreemb%1").arg(i)] = AWPluginFormatterMemoryMB::instance();
m_formatter[QString("gpufreegb%1").arg(i)] = AWPluginFormatterMemoryGB::instance();
}
} }

View File

@@ -39,7 +39,8 @@ public:
[[nodiscard]] AWPluginFormaterInterface *formatter(const QString &_key) const; [[nodiscard]] AWPluginFormaterInterface *formatter(const QString &_key) const;
[[nodiscard]] QStringList keysFromSource(const QString &_source) const; [[nodiscard]] QStringList keysFromSource(const QString &_source) const;
// set methods // set methods
QStringList registerSource(const QString &_source, KSysGuard::Unit _units, const QStringList &_keys); QStringList registerSource(const QString &_source, KSysGuard::Unit _units, const QStringList &_keys,
const bool _disconnectUnused);
void setDevices(const AWPluginMatcherSettings &_settings); void setDevices(const AWPluginMatcherSettings &_settings);
private: private:

View File

@@ -70,61 +70,21 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
qCDebug(LOG_AW) << "Looking for required keys in" << _keys << _bars << "using tooltip settings" << _tooltip; qCDebug(LOG_AW) << "Looking for required keys in" << _keys << _bars << "using tooltip settings" << _tooltip;
// initial copy // initial copy
QSet<QString> used(_keys.cbegin(), _keys.cend()); QSet used(_keys.cbegin(), _keys.cend());
used.unite(QSet(_bars.cbegin(), _bars.cend())); used.unite(QSet(_bars.cbegin(), _bars.cend()));
used.unite(QSet(_userKeys.cbegin(), _userKeys.cend())); used.unite(QSet(_userKeys.cbegin(), _userKeys.cend()));
// insert keys from tooltip // insert keys from tooltip
for (auto [key, value] : _tooltip.asKeyValueRange()) { for (auto [key, value] : _tooltip.asKeyValueRange()) {
if ((key.endsWith("Tooltip")) && value.toBool()) { if (key.endsWith("Tooltip") && value.toBool()) {
auto local = key; auto local = key;
local.remove("Tooltip"); local.remove("Tooltip");
used << local; used << local;
} }
} }
// insert depending keys, refer to AWKeys::calculateValues() // insert keys which depend on others, refer to AWKeys::calculateValues()
// hddtotmb*
for (auto &key : _allKeys.filter(QRegularExpression("^hddtotmb"))) {
if (!used.contains(key))
continue;
key.remove("hddtotmb");
auto index = key.toInt();
used << QString("hddfreemb%1").arg(index) << QString("hddmb%1").arg(index);
}
// hddtotgb*
for (auto &key : _allKeys.filter(QRegularExpression("^hddtotgb"))) {
if (!used.contains(key))
continue;
key.remove("hddtotgb");
auto index = key.toInt();
used << QString("hddfreegb%1").arg(index) << QString("hddgb%1").arg(index);
}
// mem
if (used.contains("mem"))
used << "memmb"
<< "memtotmb";
// memtotmb
if (used.contains("memtotmb"))
used << "memusedmb"
<< "memfreemb";
// memtotgb
if (used.contains("memtotgb"))
used << "memusedgb"
<< "memfreegb";
// swap
if (used.contains("swap"))
used << "swapmb"
<< "swaptotmb";
// swaptotmb
if (used.contains("swaptotmb"))
used << "swapmb"
<< "swapfreemb";
// memtotgb
if (used.contains("swaptotgb"))
used << "swapgb"
<< "swapfreegb";
// network keys // network keys
QStringList netKeys( static QStringList netKeys(
{"up", "upkb", "uptot", "uptotkb", "upunits", "down", "downkb", "downtot", "downtotkb", "downunits"}); {"up", "upkb", "uptot", "uptotkb", "upunits", "down", "downkb", "downtot", "downtotkb", "downunits"});
for (auto &key : netKeys) { for (auto &key : netKeys) {
if (!used.contains(key)) if (!used.contains(key))
@@ -136,11 +96,13 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
// netdev key // netdev key
if (std::any_of(netKeys.cbegin(), netKeys.cend(), [&used](auto &key) { return used.contains(key); })) if (std::any_of(netKeys.cbegin(), netKeys.cend(), [&used](auto &key) { return used.contains(key); }))
used << "netdev"; used << "netdev";
// gpu memory keys
// HACK append dummy if there are no other keys. This hack is required static auto gpuMemoryCalculatedRegExp = QRegularExpression("^gpu(mem|freemb|freegb)");
// because empty list leads to the same behaviour as skip checking for (auto key : _keys.filter(gpuMemoryCalculatedRegExp)) {
if (used.isEmpty()) auto index = key.remove(gpuMemoryCalculatedRegExp);
used << "dummy"; used << QString("gpuusedmb%1").arg(index) << QString("gputotmb%1").arg(index)
<< QString("gpuusedgb%1").arg(index) << QString("gputotgb%1").arg(index);
}
return used.values(); return used.values();
} }
@@ -155,11 +117,8 @@ AWPluginMatcherSettings AWKeyCache::loadKeysFromCache()
AWPluginMatcherSettings devices; AWPluginMatcherSettings devices;
QHash<QString, QStringList *> groups = { QHash<QString, QStringList *> groups = {
{"disk", &devices.disk}, {"disk", &devices.disk}, {"gpu", &devices.gpu}, {"mount", &devices.mount},
{"gpu", &devices.gpu}, {"net", &devices.network}, {"temp", &devices.sensors},
{"mount", &devices.mount},
{"net", &devices.network},
{"temp", &devices.sensors},
}; };
for (auto [group, list] : groups.asKeyValueRange()) { for (auto [group, list] : groups.asKeyValueRange()) {

View File

@@ -85,6 +85,13 @@ QStringList AWKeyOperations::dictKeys() const
// gpu // gpu
for (auto i = 0; i < m_devices.gpu.count(); ++i) { for (auto i = 0; i < m_devices.gpu.count(); ++i) {
allKeys.append(QString("gpu%1").arg(i)); allKeys.append(QString("gpu%1").arg(i));
allKeys.append(QString("gpumem%1").arg(i));
allKeys.append(QString("gpufreemb%1").arg(i));
allKeys.append(QString("gpufreegb%1").arg(i));
allKeys.append(QString("gputotmb%1").arg(i));
allKeys.append(QString("gputotgb%1").arg(i));
allKeys.append(QString("gpuusedmb%1").arg(i));
allKeys.append(QString("gpuusedgb%1").arg(i));
allKeys.append(QString("gputemp%1").arg(i)); allKeys.append(QString("gputemp%1").arg(i));
} }
// hdd // hdd

View File

@@ -43,7 +43,7 @@ AWKeys::AWKeys(QObject *_parent)
m_aggregator = new AWKeysAggregator(this); m_aggregator = new AWKeysAggregator(this);
m_dataAggregator = new AWDataAggregator(this); m_dataAggregator = new AWDataAggregator(this);
m_dataEngineAggregator = new AWDataEngineAggregator(this); m_dataEngineAggregator = AWDataEngineAggregator::instance(this);
m_keyOperator = new AWKeyOperations(this); m_keyOperator = new AWKeyOperations(this);
m_timer = new QTimer(this); m_timer = new QTimer(this);
@@ -59,7 +59,8 @@ AWKeys::AWKeys(QObject *_parent)
connect(m_dataAggregator, &AWDataAggregator::toolTipPainted, connect(m_dataAggregator, &AWDataAggregator::toolTipPainted,
[this](const QString &_tooltip) { emit(needToolTipToBeUpdated(_tooltip)); }); [this](const QString &_tooltip) { emit(needToolTipToBeUpdated(_tooltip)); });
connect(this, &AWKeys::dropSourceFromDataengine, m_dataEngineAggregator, &AWDataEngineAggregator::dropSource); connect(this, &AWKeys::dropSourceFromDataengine, this,
[this](const QString &_source) { m_dataEngineAggregator->dropSourceForClient(this, _source); });
connect(m_dataEngineAggregator, &AWDataEngineAggregator::dataUpdated, this, &AWKeys::dataUpdated); connect(m_dataEngineAggregator, &AWDataEngineAggregator::dataUpdated, this, &AWKeys::dataUpdated);
// transfer signal from dataengine to update source list // transfer signal from dataengine to update source list
connect(m_dataEngineAggregator, &AWDataEngineAggregator::deviceAdded, m_keyOperator, &AWKeyOperations::addDevice); connect(m_dataEngineAggregator, &AWDataEngineAggregator::deviceAdded, m_keyOperator, &AWKeyOperations::addDevice);
@@ -70,6 +71,8 @@ AWKeys::~AWKeys()
{ {
qCDebug(LOG_AW) << __PRETTY_FUNCTION__; qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
m_dataEngineAggregator->unregisterClient(this);
m_timer->stop(); m_timer->stop();
// delete dbus session // delete dbus session
auto id = reinterpret_cast<qlonglong>(this); auto id = reinterpret_cast<qlonglong>(this);
@@ -206,9 +209,8 @@ void AWKeys::reinitKeys(const QStringList &_currentKeys)
barKeys.append(item->usedKeys()); barKeys.append(item->usedKeys());
} }
// get required keys // get required keys
m_requiredKeys = m_optimize ? AWKeyCache::getRequiredKeys(m_foundKeys, barKeys, m_tooltipParams, m_requiredKeys = AWKeyCache::getRequiredKeys(m_foundKeys, barKeys, m_tooltipParams,
m_keyOperator->requiredUserKeys(), _currentKeys) m_keyOperator->requiredUserKeys(), _currentKeys);
: QStringList();
// set key data to m_aggregator // set key data to m_aggregator
m_aggregator->setDevices(m_keyOperator->devices()); m_aggregator->setDevices(m_keyOperator->devices());
@@ -233,20 +235,6 @@ void AWKeys::calculateValues()
{ {
auto devices = m_keyOperator->devices(); auto devices = m_keyOperator->devices();
// hddtot*
for (auto i = 0; i < devices.mount.count(); ++i) {
m_values[QString("hddtotmb%1").arg(i)] = m_values[QString("hddfreemb%1").arg(i)].toDouble()
+ m_values[QString("hddmb%1").arg(i)].toDouble();
m_values[QString("hddtotgb%1").arg(i)] = m_values[QString("hddfreegb%1").arg(i)].toDouble()
+ m_values[QString("hddgb%1").arg(i)].toDouble();
}
// memtot*
m_values["memtotmb"] = m_values["memusedmb"].toLongLong() + m_values["memfreemb"].toLongLong();
m_values["memtotgb"] = m_values["memusedgb"].toDouble() + m_values["memfreegb"].toDouble();
// mem
m_values["mem"] = 100.0 * m_values["memmb"].toDouble() / m_values["memtotmb"].toDouble();
// up, down, upkb, downkb, upunits, downunits // up, down, upkb, downkb, upunits, downunits
auto netIndex = devices.network.indexOf(m_values["netdev"].toString()); auto netIndex = devices.network.indexOf(m_values["netdev"].toString());
m_values["down"] = m_values[QString("down%1").arg(netIndex)]; m_values["down"] = m_values[QString("down%1").arg(netIndex)];
@@ -260,11 +248,18 @@ void AWKeys::calculateValues()
m_values["uptotkb"] = m_values[QString("uptotkb%1").arg(netIndex)]; m_values["uptotkb"] = m_values[QString("uptotkb%1").arg(netIndex)];
m_values["upunits"] = m_values[QString("upunits%1").arg(netIndex)]; m_values["upunits"] = m_values[QString("upunits%1").arg(netIndex)];
// swaptot* // gpu memory keys
m_values["swaptotmb"] = m_values["swapmb"].toLongLong() + m_values["swapfreemb"].toLongLong(); m_values["gpufreemb"] = m_values["gputotmb"].toLongLong() - m_values["gpuusedmb"].toLongLong();
m_values["swaptotgb"] = m_values["swapgb"].toDouble() + m_values["swapfreegb"].toDouble(); m_values["gpufreegb"] = m_values["gputotgb"].toDouble() - m_values["gpuusedgb"].toDouble();
// swap m_values["gpumem"] = 100.0 * m_values["gpuusedmb"].toDouble() / m_values["gputotmb"].toDouble();
m_values["swap"] = 100.0 * m_values["swapmb"].toDouble() / m_values["swaptotmb"].toDouble(); for (auto i = 0; i < devices.gpu.count(); ++i) {
m_values[QString("gpufreemb%1").arg(i)] = m_values[QString("gputotmb%1").arg(i)].toLongLong()
- m_values[QString("gpuusedmb%1").arg(i)].toLongLong();
m_values[QString("gpufreegb%1").arg(i)]
= m_values[QString("gputotgb%1").arg(i)].toDouble() - m_values[QString("gpuusedgb%1").arg(i)].toDouble();
m_values[QString("gpumem%1").arg(i)] = 100.0 * m_values[QString("gpuusedmb%1").arg(i)].toDouble()
/ m_values[QString("gputotmb%1").arg(i)].toDouble();
}
// user defined keys // user defined keys
for (auto &key : m_keyOperator->userKeys()) for (auto &key : m_keyOperator->userKeys())
@@ -315,8 +310,8 @@ QString AWKeys::parsePattern(QString _pattern) const
// bars // bars
for (auto &bar : m_foundBars) { for (auto &bar : m_foundBars) {
auto item = m_keyOperator->giByKey(bar); auto item = m_keyOperator->giByKey(bar);
auto image = item->isCustom() ? item->image( auto image = item->isCustom() ? item->image(AWPatternFunctions::expandLambdas(item->bar(), m_aggregator,
AWPatternFunctions::expandLambdas(item->bar(), m_aggregator, m_values, item->usedKeys())) m_values, item->usedKeys()))
: item->image(m_values[item->bar()]); : item->image(m_values[item->bar()]);
_pattern.replace(QString("$%1").arg(bar), image); _pattern.replace(QString("$%1").arg(bar), image);
} }
@@ -337,7 +332,7 @@ void AWKeys::setDataBySource(const QString &_source, const KSysGuard::SensorInfo
// first list init // first list init
auto tags = m_aggregator->keysFromSource(_source); auto tags = m_aggregator->keysFromSource(_source);
if (tags.isEmpty()) if (tags.isEmpty())
tags = m_aggregator->registerSource(_source, _sensor.unit, m_requiredKeys); tags = m_aggregator->registerSource(_source, _sensor.unit, m_requiredKeys, m_optimize);
// update data or drop source if there are no matches and exit // update data or drop source if there are no matches and exit
if (tags.isEmpty()) { if (tags.isEmpty()) {

View File

@@ -28,7 +28,7 @@ class AWKeyOperations;
class AWKeysAggregator; class AWKeysAggregator;
class QTimer; class QTimer;
class AWKeys : public QObject class __attribute__((visibility("default"))) AWKeys : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@@ -151,9 +151,9 @@ void AWKeysAggregator::setTranslate(const bool _translate)
QStringList AWKeysAggregator::registerSource(const QString &_source, const KSysGuard::Unit _units, QStringList AWKeysAggregator::registerSource(const QString &_source, const KSysGuard::Unit _units,
const QStringList &_keys) const QStringList &_keys, const bool _disconnectUnused)
{ {
qCDebug(LOG_AW) << "Source" << _source << "with units" << _units; qCDebug(LOG_AW) << "Source" << _source << "with units" << _units;
return m_mapper->registerSource(_source, _units, _keys); return m_mapper->registerSource(_source, _units, _keys, _disconnectUnused);
} }

View File

@@ -39,7 +39,6 @@ class AWKeysAggregator : public QObject
Q_PROPERTY(bool translate READ translate WRITE setTranslate); Q_PROPERTY(bool translate READ translate WRITE setTranslate);
public: public:
explicit AWKeysAggregator(QObject *_parent = nullptr); explicit AWKeysAggregator(QObject *_parent = nullptr);
~AWKeysAggregator() override = default; ~AWKeysAggregator() override = default;
void initFormatters(); void initFormatters();
@@ -62,7 +61,8 @@ public:
void setTranslate(bool _translate); void setTranslate(bool _translate);
public slots: public slots:
QStringList registerSource(const QString &_source, KSysGuard::Unit _units, const QStringList &_keys); QStringList registerSource(const QString &_source, KSysGuard::Unit _units, const QStringList &_keys,
const bool _disconnectUnused);
private: private:
AWPluginFormatSettings m_settings; AWPluginFormatSettings m_settings;

View File

@@ -29,6 +29,4 @@ public:
~AWPairConfigFactory() override = default; ~AWPairConfigFactory() override = default;
Q_INVOKABLE static void showFormatterDialog(const QStringList &_keys); Q_INVOKABLE static void showFormatterDialog(const QStringList &_keys);
Q_INVOKABLE static void showKeysDialog(const QStringList &_keys); Q_INVOKABLE static void showKeysDialog(const QStringList &_keys);
private:
}; };

View File

@@ -23,7 +23,7 @@
class AWKeysAggregator; class AWKeysAggregator;
namespace AWPatternFunctions namespace __attribute__((visibility("default"))) AWPatternFunctions
{ {
typedef struct { typedef struct {
QStringList args; QStringList args;

View File

@@ -20,7 +20,7 @@
#include <QObject> #include <QObject>
class AWTelemetryHandler : public QObject class __attribute__((visibility("default"))) AWTelemetryHandler : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@@ -17,6 +17,9 @@
#include "awupdatehelper.h" #include "awupdatehelper.h"
#ifndef NDEBUG
#define NDEBUG
#endif /* NDEBUG */
#include <KI18n/KLocalizedString> #include <KI18n/KLocalizedString>
#include <KNotifications/KNotification> #include <KNotifications/KNotification>

View File

@@ -24,7 +24,7 @@
class KNotification; class KNotification;
class QNetworkReply; class QNetworkReply;
class AWUpdateHelper : public QObject class __attribute__((visibility("default"))) AWUpdateHelper : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@@ -25,16 +25,19 @@
#include "awpluginformatsettings.h" #include "awpluginformatsettings.h"
class AWPluginFormaterInterface { class AWPluginFormaterInterface
{
public: public:
virtual ~AWPluginFormaterInterface() = default; virtual ~AWPluginFormaterInterface() = default;
virtual QString format(const QVariant &_value, const QString &_key, const AWPluginFormatSettings &_settings) const = 0; [[nodiscard]] virtual QString format(const QVariant &_value, const QString &_key,
const AWPluginFormatSettings &_settings) const
= 0;
virtual void load() {}; virtual void load() {};
}; };
template<typename Formatter> class AWPluginFormatter : public AWPluginFormaterInterface { template <typename Formatter> class AWPluginFormatter : public AWPluginFormaterInterface
{
public: public:
static constexpr double KBinBytes = 1024.0; static constexpr double KBinBytes = 1024.0;
static constexpr double MBinBytes = 1024.0 * KBinBytes; static constexpr double MBinBytes = 1024.0 * KBinBytes;
@@ -43,19 +46,21 @@ public:
AWPluginFormatter(AWPluginFormatter &) = delete; AWPluginFormatter(AWPluginFormatter &) = delete;
void operator=(const AWPluginFormatter &) = delete; void operator=(const AWPluginFormatter &) = delete;
static Formatter *instance() [[nodiscard]] static Formatter *instance()
{ {
static auto instance = loadInstance(); static auto instance = loadInstance();
return instance.get(); return instance.get();
}; };
static QLocale locale(const AWPluginFormatSettings &_settings)
[[nodiscard]] static QLocale locale(const AWPluginFormatSettings &_settings)
{ {
return _settings.translate ? QLocale::system() : QLocale::c(); return _settings.translate ? QLocale::system() : QLocale::c();
}; };
protected: protected:
AWPluginFormatter() = default; AWPluginFormatter() = default;
static std::unique_ptr<Formatter> loadInstance()
[[nodiscard]] static std::unique_ptr<Formatter> loadInstance()
{ {
auto instance = std::make_unique<Formatter>(); auto instance = std::make_unique<Formatter>();
instance->load(); instance->load();

View File

@@ -18,7 +18,8 @@
#include "awpluginformatterac.h" #include "awpluginformatterac.h"
QString AWPluginFormatterAC::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const QString AWPluginFormatterAC::format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &_settings) const
{ {
return _value.toBool() ? _settings.acOnline : _settings.acOffline; return _value.toBool() ? _settings.acOnline : _settings.acOffline;
} }

View File

@@ -20,8 +20,9 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterAC : public AWPluginFormatter<AWPluginFormatterAC> { class AWPluginFormatterAC : public AWPluginFormatter<AWPluginFormatterAC>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &_settings) const override;
}; };

View File

@@ -20,7 +20,8 @@
#include "awformatterhelper.h" #include "awformatterhelper.h"
QString AWPluginFormatterCustom::format(const QVariant &_value, const QString &_key, const AWPluginFormatSettings &_settings) const QString AWPluginFormatterCustom::format(const QVariant &_value, const QString &_key,
const AWPluginFormatSettings &_settings) const
{ {
if (_settings.customFormatters) if (_settings.customFormatters)
return _settings.customFormatters->convert(_value, _key); return _settings.customFormatters->convert(_value, _key);

View File

@@ -20,8 +20,9 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterCustom : public AWPluginFormatter<AWPluginFormatterCustom> { class AWPluginFormatterCustom : public AWPluginFormatter<AWPluginFormatterCustom>
{
public: public:
QString format(const QVariant &_value, const QString &_key, const AWPluginFormatSettings &_settings) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &_key,
const AWPluginFormatSettings &_settings) const override;
}; };

View File

@@ -20,8 +20,9 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterDouble : public AWPluginFormatter<AWPluginFormatterDouble> { class AWPluginFormatterDouble : public AWPluginFormatter<AWPluginFormatterDouble>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &) const override;
}; };

View File

@@ -20,8 +20,9 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterFloat : public AWPluginFormatter<AWPluginFormatterFloat>{ class AWPluginFormatterFloat : public AWPluginFormatter<AWPluginFormatterFloat>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &) const override;
}; };

View File

@@ -18,7 +18,8 @@
#include "awpluginformatterfloatprecise.h" #include "awpluginformatterfloatprecise.h"
QString AWPluginFormatterFloatPrecise::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const QString AWPluginFormatterFloatPrecise::format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &) const
{ {
return QString("%1").arg(_value.toDouble(), 5, 'f', 2); return QString("%1").arg(_value.toDouble(), 5, 'f', 2);
} }

View File

@@ -20,8 +20,9 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterFloatPrecise : public AWPluginFormatter<AWPluginFormatterFloatPrecise> { class AWPluginFormatterFloatPrecise : public AWPluginFormatter<AWPluginFormatterFloatPrecise>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &) const override;
}; };

View File

@@ -20,8 +20,9 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterInteger : public AWPluginFormatter<AWPluginFormatterInteger> { class AWPluginFormatterInteger : public AWPluginFormatter<AWPluginFormatterInteger>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &) const override;
}; };

View File

@@ -18,7 +18,8 @@
#include "awpluginformatterintegershort.h" #include "awpluginformatterintegershort.h"
QString AWPluginFormatterIntegerShort::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const QString AWPluginFormatterIntegerShort::format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &) const
{ {
return QString("%1").arg(_value.toDouble(), 3, 'f', 0); return QString("%1").arg(_value.toDouble(), 3, 'f', 0);
} }

View File

@@ -20,8 +20,9 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterIntegerShort : public AWPluginFormatter<AWPluginFormatterIntegerShort> { class AWPluginFormatterIntegerShort : public AWPluginFormatter<AWPluginFormatterIntegerShort>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &) const override;
}; };

View File

@@ -18,7 +18,8 @@
#include "awpluginformatterintegerwide.h" #include "awpluginformatterintegerwide.h"
QString AWPluginFormatterIntegerWide::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const QString AWPluginFormatterIntegerWide::format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &) const
{ {
return QString("%1").arg(_value.toDouble(), 5, 'f', 0); return QString("%1").arg(_value.toDouble(), 5, 'f', 0);
} }

View File

@@ -20,8 +20,9 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterIntegerWide : public AWPluginFormatter<AWPluginFormatterIntegerWide> { class AWPluginFormatterIntegerWide : public AWPluginFormatter<AWPluginFormatterIntegerWide>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &) const override;
}; };

View File

@@ -20,8 +20,9 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterList : public AWPluginFormatter<AWPluginFormatterList> { class AWPluginFormatterList : public AWPluginFormatter<AWPluginFormatterList>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &) const override;
}; };

View File

@@ -20,8 +20,9 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterMemory : public AWPluginFormatter<AWPluginFormatterMemory> { class AWPluginFormatterMemory : public AWPluginFormatter<AWPluginFormatterMemory>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &) const override;
}; };

View File

@@ -20,8 +20,9 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterMemoryGB : public AWPluginFormatter<AWPluginFormatterMemoryGB> { class AWPluginFormatterMemoryGB : public AWPluginFormatter<AWPluginFormatterMemoryGB>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &) const override;
}; };

View File

@@ -20,8 +20,9 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterMemoryMB : public AWPluginFormatter<AWPluginFormatterMemoryMB> { class AWPluginFormatterMemoryMB : public AWPluginFormatter<AWPluginFormatterMemoryMB>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &) const override;
}; };

View File

@@ -20,12 +20,13 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterNet : public AWPluginFormatter<AWPluginFormatterNet> { class AWPluginFormatterNet : public AWPluginFormatter<AWPluginFormatterNet>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &) const override;
private: private:
static QString formatKB(const double &_value); [[nodiscard]] static QString formatKB(const double &_value);
static QString formatMB(const double &_value); [[nodiscard]] static QString formatMB(const double &_value);
}; };

View File

@@ -20,7 +20,8 @@
#include <KI18n/KLocalizedString> #include <KI18n/KLocalizedString>
QString AWPluginFormatterNetUnits::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const QString AWPluginFormatterNetUnits::format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &_settings) const
{ {
auto value = _value.toDouble(); auto value = _value.toDouble();
return (value > MBinBytes) ? formatMB(_settings) : formatKB(_settings); return (value > MBinBytes) ? formatMB(_settings) : formatKB(_settings);

View File

@@ -20,12 +20,13 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterNetUnits : public AWPluginFormatter<AWPluginFormatterNetUnits> { class AWPluginFormatterNetUnits : public AWPluginFormatter<AWPluginFormatterNetUnits>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &_settings) const override;
private: private:
static QString formatKB(const AWPluginFormatSettings &_settings); [[nodiscard]] static QString formatKB(const AWPluginFormatSettings &_settings);
static QString formatMB(const AWPluginFormatSettings &_settings); [[nodiscard]] static QString formatMB(const AWPluginFormatSettings &_settings);
}; };

View File

@@ -20,8 +20,9 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterNoFormat : public AWPluginFormatter<AWPluginFormatterNoFormat> { class AWPluginFormatterNoFormat : public AWPluginFormatter<AWPluginFormatterNoFormat>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &) const override;
}; };

View File

@@ -18,7 +18,8 @@
#include "awpluginformattertemperature.h" #include "awpluginformattertemperature.h"
QString AWPluginFormatterTemperature::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const QString AWPluginFormatterTemperature::format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &_settings) const
{ {
auto converted = convert(_value.toDouble(), _settings.tempUnits); auto converted = convert(_value.toDouble(), _settings.tempUnits);
return QString("%1").arg(converted, 5, 'f', 1); return QString("%1").arg(converted, 5, 'f', 1);

View File

@@ -20,11 +20,12 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterTemperature : public AWPluginFormatter<AWPluginFormatterTemperature> { class AWPluginFormatterTemperature : public AWPluginFormatter<AWPluginFormatterTemperature>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &_settings) const override;
private: private:
static double convert(const double &_value, const QString &_units); [[nodiscard]] static double convert(const double &_value, const QString &_units);
}; };

View File

@@ -20,8 +20,9 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterTime : public AWPluginFormatter<AWPluginFormatterTime> { class AWPluginFormatterTime : public AWPluginFormatter<AWPluginFormatterTime>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &) const override;
}; };

View File

@@ -20,7 +20,8 @@
#include "awdebug.h" #include "awdebug.h"
QString AWPluginFormatterTimeCustom::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const QString AWPluginFormatterTimeCustom::format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &_settings) const
{ {
auto value = QDateTime::fromSecsSinceEpoch(_value.toLongLong()); auto value = QDateTime::fromSecsSinceEpoch(_value.toLongLong());
return format(value, _settings.customTime, locale(_settings)); return format(value, _settings.customTime, locale(_settings));
@@ -35,7 +36,8 @@ void AWPluginFormatterTimeCustom::load()
} }
QString AWPluginFormatterTimeCustom::format(const QDateTime &_value, QString _formatString, const QLocale &_locale) const QString AWPluginFormatterTimeCustom::format(const QDateTime &_value, QString _formatString,
const QLocale &_locale) const
{ {
for (auto &key : m_timeKeys) for (auto &key : m_timeKeys)
_formatString.replace(QString("$%1").arg(key), _locale.toString(_value, key)); _formatString.replace(QString("$%1").arg(key), _locale.toString(_value, key));

View File

@@ -22,13 +22,14 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterTimeCustom : public AWPluginFormatter<AWPluginFormatterTimeCustom> { class AWPluginFormatterTimeCustom : public AWPluginFormatter<AWPluginFormatterTimeCustom>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &_settings) const override;
void load() override; void load() override;
private: private:
QString format(const QDateTime &_value, QString _formatString, const QLocale &_locale) const; [[nodiscard]] QString format(const QDateTime &_value, QString _formatString, const QLocale &_locale) const;
QStringList m_timeKeys; QStringList m_timeKeys;
}; };

View File

@@ -20,8 +20,9 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterTimeISO : public AWPluginFormatter<AWPluginFormatterTimeISO> { class AWPluginFormatterTimeISO : public AWPluginFormatter<AWPluginFormatterTimeISO>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &) const override;
}; };

View File

@@ -20,7 +20,8 @@
#include <QDateTime> #include <QDateTime>
QString AWPluginFormatterTimeLong::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const QString AWPluginFormatterTimeLong::format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &_settings) const
{ {
return locale(_settings).toString(QDateTime::fromSecsSinceEpoch(_value.toLongLong()), QLocale::LongFormat); return locale(_settings).toString(QDateTime::fromSecsSinceEpoch(_value.toLongLong()), QLocale::LongFormat);
} }

View File

@@ -20,8 +20,9 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterTimeLong : public AWPluginFormatter<AWPluginFormatterTimeLong> { class AWPluginFormatterTimeLong : public AWPluginFormatter<AWPluginFormatterTimeLong>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &_settings) const override;
}; };

View File

@@ -20,7 +20,8 @@
#include <QDateTime> #include <QDateTime>
QString AWPluginFormatterTimeShort::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const QString AWPluginFormatterTimeShort::format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &_settings) const
{ {
return locale(_settings).toString(QDateTime::fromSecsSinceEpoch(_value.toLongLong()), QLocale::ShortFormat); return locale(_settings).toString(QDateTime::fromSecsSinceEpoch(_value.toLongLong()), QLocale::ShortFormat);
} }

View File

@@ -20,8 +20,9 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterTimeShort : public AWPluginFormatter<AWPluginFormatterTimeShort> { class AWPluginFormatterTimeShort : public AWPluginFormatter<AWPluginFormatterTimeShort>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &_settings) const override;
}; };

View File

@@ -18,7 +18,8 @@
#include "awpluginformatteruptime.h" #include "awpluginformatteruptime.h"
QString AWPluginFormatterUptime::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const QString AWPluginFormatterUptime::format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &_settings) const
{ {
auto value = static_cast<long>(_value.toDouble()); auto value = static_cast<long>(_value.toDouble());
return format(value, _settings.customUptime); return format(value, _settings.customUptime);

View File

@@ -20,11 +20,12 @@
#include "awpluginformatter.h" #include "awpluginformatter.h"
class AWPluginFormatterUptime : public AWPluginFormatter<AWPluginFormatterUptime> { class AWPluginFormatterUptime : public AWPluginFormatter<AWPluginFormatterUptime>
{
public: public:
QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const override; [[nodiscard]] QString format(const QVariant &_value, const QString &,
const AWPluginFormatSettings &_settings) const override;
private: private:
static QString format(const long &_value, QString _formatString); [[nodiscard]] static QString format(const long &_value, QString _formatString);
}; };

View File

@@ -15,6 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/ ***************************************************************************/
#pragma once
#include "awpluginformatterac.h" #include "awpluginformatterac.h"
#include "awpluginformattercustom.h" #include "awpluginformattercustom.h"
#include "awpluginformatterdouble.h" #include "awpluginformatterdouble.h"

View File

@@ -28,26 +28,36 @@
class AWPluginFormaterInterface; class AWPluginFormaterInterface;
class AWPluginMatcherInterface { class AWPluginMatcherInterface
{
public: public:
virtual ~AWPluginMatcherInterface() = default; virtual ~AWPluginMatcherInterface() = default;
[[nodiscard]] virtual QHash<QString, AWPluginFormaterInterface *> keys(const QString &_source, KSysGuard::Unit _units, const AWPluginMatcherSettings &_settings) const = 0; [[nodiscard]] virtual QHash<QString, AWPluginFormaterInterface *>
keys(const QString &_source, KSysGuard::Unit _units, const AWPluginMatcherSettings &_settings) const = 0;
[[nodiscard]] virtual bool matches(const QString &_source) const = 0; [[nodiscard]] virtual bool matches(const QString &_source) const = 0;
}; };
template<typename Matcher> class AWPluginMatcher : public AWPluginMatcherInterface { template <typename Matcher> class AWPluginMatcher : public AWPluginMatcherInterface
{
public: public:
AWPluginMatcher(AWPluginMatcher &) = delete; AWPluginMatcher(AWPluginMatcher &) = delete;
void operator=(const AWPluginMatcher &) = delete; void operator=(const AWPluginMatcher &) = delete;
static Matcher *instance() [[nodiscard]] static Matcher *instance()
{ {
static auto instance = std::make_unique<Matcher>(); static auto instance = std::make_unique<Matcher>();
return instance.get(); return instance.get();
}; };
[[nodiscard]] static QString device(const QString &_source) { return _source.split('/')[1]; };
[[nodiscard]] static qsizetype index(const QString &_source, const QStringList &_devices)
{
auto device = AWPluginMatcher::device(_source);
return _devices.indexOf(device);
}
protected: protected:
AWPluginMatcher() = default; AWPluginMatcher() = default;
}; };

View File

@@ -20,7 +20,8 @@
#include "formatters/formatters.h" #include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherAC::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherAC::keys(const QString &, const KSysGuard::Unit,
const AWPluginMatcherSettings &) const
{ {
return {{"ac", AWPluginFormatterAC::instance()}}; return {{"ac", AWPluginFormatterAC::instance()}};
} }

View File

@@ -20,9 +20,10 @@
#include "awpluginmatcher.h" #include "awpluginmatcher.h"
class AWPluginMatcherAC : public AWPluginMatcher<AWPluginMatcherAC> { class AWPluginMatcherAC : public AWPluginMatcher<AWPluginMatcherAC>
{
public: public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; [[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit,
const AWPluginMatcherSettings &) const override;
[[nodiscard]] bool matches(const QString &_source) const override; [[nodiscard]] bool matches(const QString &_source) const override;
}; };

View File

@@ -20,7 +20,8 @@
#include "formatters/formatters.h" #include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherBattery::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &) const QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherBattery::keys(const QString &_source, const KSysGuard::Unit,
const AWPluginMatcherSettings &) const
{ {
auto key = _source; auto key = _source;
key.remove("extsysmon/battery/"); key.remove("extsysmon/battery/");

View File

@@ -20,9 +20,10 @@
#include "awpluginmatcher.h" #include "awpluginmatcher.h"
class AWPluginMatcherBattery : public AWPluginMatcher<AWPluginMatcherBattery> { class AWPluginMatcherBattery : public AWPluginMatcher<AWPluginMatcherBattery>
{
public: public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; [[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &_source, KSysGuard::Unit,
const AWPluginMatcherSettings &) const override;
[[nodiscard]] bool matches(const QString &_source) const override; [[nodiscard]] bool matches(const QString &_source) const override;
}; };

View File

@@ -0,0 +1,33 @@
/***************************************************************************
* 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 "awpluginmatcherbrightness.h"
#include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherBrightness::keys(const QString &, const KSysGuard::Unit,
const AWPluginMatcherSettings &) const
{
return {{"brightness", AWPluginFormatterIntegerShort::instance()}};
}
bool AWPluginMatcherBrightness::matches(const QString &_source) const
{
return _source == "extsysmon/system/brightness";
}

View File

@@ -0,0 +1,29 @@
/***************************************************************************
* 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/ *
***************************************************************************/
#pragma once
#include "awpluginmatcher.h"
class AWPluginMatcherBrightness : public AWPluginMatcher<AWPluginMatcherBrightness>
{
public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit,
const AWPluginMatcherSettings &) const override;
[[nodiscard]] bool matches(const QString &_source) const override;
};

View File

@@ -20,7 +20,8 @@
#include "formatters/formatters.h" #include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherCPU::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherCPU::keys(const QString &, const KSysGuard::Unit,
const AWPluginMatcherSettings &) const
{ {
return {{"cpu", AWPluginFormatterFloat::instance()}}; return {{"cpu", AWPluginFormatterFloat::instance()}};
} }

View File

@@ -20,9 +20,10 @@
#include "awpluginmatcher.h" #include "awpluginmatcher.h"
class AWPluginMatcherCPU : public AWPluginMatcher<AWPluginMatcherCPU> { class AWPluginMatcherCPU : public AWPluginMatcher<AWPluginMatcherCPU>
{
public: public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; [[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit,
const AWPluginMatcherSettings &) const override;
[[nodiscard]] bool matches(const QString &_source) const override; [[nodiscard]] bool matches(const QString &_source) const override;
}; };

View File

@@ -22,7 +22,8 @@
#include "formatters/formatters.h" #include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherCPUCore::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &) const QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherCPUCore::keys(const QString &_source, const KSysGuard::Unit,
const AWPluginMatcherSettings &) const
{ {
auto key = _source; auto key = _source;
key.remove("cpu/").remove("/usage"); key.remove("cpu/").remove("/usage");

View File

@@ -20,9 +20,10 @@
#include "awpluginmatcher.h" #include "awpluginmatcher.h"
class AWPluginMatcherCPUCore : public AWPluginMatcher<AWPluginMatcherCPUCore> { class AWPluginMatcherCPUCore : public AWPluginMatcher<AWPluginMatcherCPUCore>
{
public: public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; [[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &_source, KSysGuard::Unit,
const AWPluginMatcherSettings &) const override;
[[nodiscard]] bool matches(const QString &_source) const override; [[nodiscard]] bool matches(const QString &_source) const override;
}; };

View File

@@ -20,7 +20,8 @@
#include "formatters/formatters.h" #include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherCPUFrequency::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherCPUFrequency::keys(const QString &, const KSysGuard::Unit,
const AWPluginMatcherSettings &) const
{ {
return {{"cpucl", AWPluginFormatterInteger::instance()}}; return {{"cpucl", AWPluginFormatterInteger::instance()}};
} }

View File

@@ -20,9 +20,10 @@
#include "awpluginmatcher.h" #include "awpluginmatcher.h"
class AWPluginMatcherCPUFrequency : public AWPluginMatcher<AWPluginMatcherCPUFrequency> { class AWPluginMatcherCPUFrequency : public AWPluginMatcher<AWPluginMatcherCPUFrequency>
{
public: public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; [[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit,
const AWPluginMatcherSettings &) const override;
[[nodiscard]] bool matches(const QString &_source) const override; [[nodiscard]] bool matches(const QString &_source) const override;
}; };

View File

@@ -22,7 +22,9 @@
#include "formatters/formatters.h" #include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherCPUFrequencyCore::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &) const QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherCPUFrequencyCore::keys(const QString &_source,
const KSysGuard::Unit,
const AWPluginMatcherSettings &) const
{ {
auto index = _source; auto index = _source;
index.remove("cpu/cpu").remove("/frequency"); index.remove("cpu/cpu").remove("/frequency");

View File

@@ -20,9 +20,10 @@
#include "awpluginmatcher.h" #include "awpluginmatcher.h"
class AWPluginMatcherCPUFrequencyCore : public AWPluginMatcher<AWPluginMatcherCPUFrequencyCore> { class AWPluginMatcherCPUFrequencyCore : public AWPluginMatcher<AWPluginMatcherCPUFrequencyCore>
{
public: public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; [[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &_source, KSysGuard::Unit,
const AWPluginMatcherSettings &) const override;
[[nodiscard]] bool matches(const QString &_source) const override; [[nodiscard]] bool matches(const QString &_source) const override;
}; };

View File

@@ -20,7 +20,8 @@
#include "formatters/formatters.h" #include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherCustom::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &) const QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherCustom::keys(const QString &_source, const KSysGuard::Unit,
const AWPluginMatcherSettings &) const
{ {
auto key = _source; auto key = _source;
key.remove("extsysmon/custom/"); key.remove("extsysmon/custom/");

View File

@@ -20,9 +20,10 @@
#include "awpluginmatcher.h" #include "awpluginmatcher.h"
class AWPluginMatcherCustom : public AWPluginMatcher<AWPluginMatcherCustom> { class AWPluginMatcherCustom : public AWPluginMatcher<AWPluginMatcherCustom>
{
public: public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; [[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &_source, KSysGuard::Unit,
const AWPluginMatcherSettings &) const override;
[[nodiscard]] bool matches(const QString &_source) const override; [[nodiscard]] bool matches(const QString &_source) const override;
}; };

View File

@@ -20,7 +20,8 @@
#include "formatters/formatters.h" #include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherDesktop::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherDesktop::keys(const QString &, const KSysGuard::Unit,
const AWPluginMatcherSettings &) const
{ {
return {{"desktop", AWPluginFormatterNoFormat::instance()}}; return {{"desktop", AWPluginFormatterNoFormat::instance()}};
} }

View File

@@ -20,9 +20,10 @@
#include "awpluginmatcher.h" #include "awpluginmatcher.h"
class AWPluginMatcherDesktop : public AWPluginMatcher<AWPluginMatcherDesktop> { class AWPluginMatcherDesktop : public AWPluginMatcher<AWPluginMatcherDesktop>
{
public: public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; [[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit,
const AWPluginMatcherSettings &) const override;
[[nodiscard]] bool matches(const QString &_source) const override; [[nodiscard]] bool matches(const QString &_source) const override;
}; };

View File

@@ -20,7 +20,8 @@
#include "formatters/formatters.h" #include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherDesktopCount::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherDesktopCount::keys(const QString &, const KSysGuard::Unit,
const AWPluginMatcherSettings &) const
{ {
return {{"tdesktops", AWPluginFormatterNoFormat::instance()}}; return {{"tdesktops", AWPluginFormatterNoFormat::instance()}};
} }

View File

@@ -20,9 +20,10 @@
#include "awpluginmatcher.h" #include "awpluginmatcher.h"
class AWPluginMatcherDesktopCount : public AWPluginMatcher<AWPluginMatcherDesktopCount> { class AWPluginMatcherDesktopCount : public AWPluginMatcher<AWPluginMatcherDesktopCount>
{
public: public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; [[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit,
const AWPluginMatcherSettings &) const override;
[[nodiscard]] bool matches(const QString &_source) const override; [[nodiscard]] bool matches(const QString &_source) const override;
}; };

View File

@@ -20,7 +20,8 @@
#include "formatters/formatters.h" #include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherDesktopNumber::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherDesktopNumber::keys(const QString &, const KSysGuard::Unit,
const AWPluginMatcherSettings &) const
{ {
return {{"ndesktop", AWPluginFormatterNoFormat::instance()}}; return {{"ndesktop", AWPluginFormatterNoFormat::instance()}};
} }

View File

@@ -20,9 +20,10 @@
#include "awpluginmatcher.h" #include "awpluginmatcher.h"
class AWPluginMatcherDesktopNumber : public AWPluginMatcher<AWPluginMatcherDesktopNumber> { class AWPluginMatcherDesktopNumber : public AWPluginMatcher<AWPluginMatcherDesktopNumber>
{
public: public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; [[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit,
const AWPluginMatcherSettings &) const override;
[[nodiscard]] bool matches(const QString &_source) const override; [[nodiscard]] bool matches(const QString &_source) const override;
}; };

View File

@@ -20,7 +20,8 @@
#include "formatters/formatters.h" #include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherGPU::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherGPU::keys(const QString &, const KSysGuard::Unit,
const AWPluginMatcherSettings &) const
{ {
return {{"gpu", AWPluginFormatterFloat::instance()}}; return {{"gpu", AWPluginFormatterFloat::instance()}};
} }

View File

@@ -20,9 +20,10 @@
#include "awpluginmatcher.h" #include "awpluginmatcher.h"
class AWPluginMatcherGPU : public AWPluginMatcher<AWPluginMatcherGPU> { class AWPluginMatcherGPU : public AWPluginMatcher<AWPluginMatcherGPU>
{
public: public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; [[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit,
const AWPluginMatcherSettings &) const override;
[[nodiscard]] bool matches(const QString &_source) const override; [[nodiscard]] bool matches(const QString &_source) const override;
}; };

View File

@@ -22,14 +22,13 @@
#include "formatters/formatters.h" #include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherGPUCore::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherGPUCore::keys(const QString &_source, const KSysGuard::Unit,
const AWPluginMatcherSettings &_settings) const
{ {
auto device = _source; auto index = AWPluginMatcher::index(_source, _settings.gpu);
device.remove("gpu/").remove("/usage");
auto index = _settings.gpu.indexOf(device);
if (index == -1) if (index == -1)
return {}; return {};
return {{QString("gpu%1").arg(index), AWPluginFormatterFloat::instance()}}; return {{QString("gpu%1").arg(index), AWPluginFormatterFloat::instance()}};
} }

View File

@@ -20,9 +20,10 @@
#include "awpluginmatcher.h" #include "awpluginmatcher.h"
class AWPluginMatcherGPUCore : public AWPluginMatcher<AWPluginMatcherGPUCore> { class AWPluginMatcherGPUCore : public AWPluginMatcher<AWPluginMatcherGPUCore>
{
public: public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override; [[nodiscard]] QHash<QString, AWPluginFormaterInterface *>
keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override;
[[nodiscard]] bool matches(const QString &_source) const override; [[nodiscard]] bool matches(const QString &_source) const override;
}; };

View File

@@ -0,0 +1,36 @@
/***************************************************************************
* 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 "awpluginmatchergpumemorytotal.h"
#include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherGPUMemoryTotal::keys(const QString &, const KSysGuard::Unit,
const AWPluginMatcherSettings &) const
{
return {
{"gputotmb", AWPluginFormatterMemoryMB::instance()},
{"gputotgb", AWPluginFormatterMemoryGB::instance()},
};
}
bool AWPluginMatcherGPUMemoryTotal::matches(const QString &_source) const
{
return _source == "gpu/all/totalVram";
}

View File

@@ -0,0 +1,29 @@
/***************************************************************************
* 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/ *
***************************************************************************/
#pragma once
#include "awpluginmatcher.h"
class AWPluginMatcherGPUMemoryTotal : public AWPluginMatcher<AWPluginMatcherGPUMemoryTotal>
{
public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit,
const AWPluginMatcherSettings &) const override;
[[nodiscard]] bool matches(const QString &_source) const override;
};

View File

@@ -0,0 +1,44 @@
/***************************************************************************
* 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 "awpluginmatchergpumemorytotalcore.h"
#include <QRegularExpression>
#include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *>
AWPluginMatcherGPUMemoryTotalCore::keys(const QString &_source, const KSysGuard::Unit,
const AWPluginMatcherSettings &_settings) const
{
auto index = AWPluginMatcher::index(_source, _settings.gpu);
if (index == -1)
return {};
return {
{QString("gputotmb%1").arg(index), AWPluginFormatterMemoryMB::instance()},
{QString("gputotgb%1").arg(index), AWPluginFormatterMemoryGB::instance()},
};
}
bool AWPluginMatcherGPUMemoryTotalCore::matches(const QString &_source) const
{
static auto regexp = QRegularExpression("^gpu/gpu.*/totalVram$");
return _source.contains(regexp);
}

View File

@@ -0,0 +1,29 @@
/***************************************************************************
* 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/ *
***************************************************************************/
#pragma once
#include "awpluginmatcher.h"
class AWPluginMatcherGPUMemoryTotalCore : public AWPluginMatcher<AWPluginMatcherGPUMemoryTotalCore>
{
public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *>
keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override;
[[nodiscard]] bool matches(const QString &_source) const override;
};

View File

@@ -0,0 +1,36 @@
/***************************************************************************
* 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 "awpluginmatchergpumemoryused.h"
#include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherGPUMemoryUsed::keys(const QString &, const KSysGuard::Unit,
const AWPluginMatcherSettings &) const
{
return {
{"gpuusedmb", AWPluginFormatterMemoryMB::instance()},
{"gpuusedgb", AWPluginFormatterMemoryGB::instance()},
};
}
bool AWPluginMatcherGPUMemoryUsed::matches(const QString &_source) const
{
return _source == "gpu/all/usedVram";
}

View File

@@ -0,0 +1,29 @@
/***************************************************************************
* 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/ *
***************************************************************************/
#pragma once
#include "awpluginmatcher.h"
class AWPluginMatcherGPUMemoryUsed : public AWPluginMatcher<AWPluginMatcherGPUMemoryUsed>
{
public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit,
const AWPluginMatcherSettings &) const override;
[[nodiscard]] bool matches(const QString &_source) const override;
};

View File

@@ -0,0 +1,44 @@
/***************************************************************************
* 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 "awpluginmatchergpumemoryusedcore.h"
#include <QRegularExpression>
#include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *>
AWPluginMatcherGPUMemoryUsedCore::keys(const QString &_source, const KSysGuard::Unit,
const AWPluginMatcherSettings &_settings) const
{
auto index = AWPluginMatcher::index(_source, _settings.gpu);
if (index == -1)
return {};
return {
{QString("gpuusedmb%1").arg(index), AWPluginFormatterMemoryMB::instance()},
{QString("gpuusedgb%1").arg(index), AWPluginFormatterMemoryGB::instance()},
};
}
bool AWPluginMatcherGPUMemoryUsedCore::matches(const QString &_source) const
{
static auto regexp = QRegularExpression("^gpu/gpu.*/usedVram$");
return _source.contains(regexp);
}

View File

@@ -0,0 +1,29 @@
/***************************************************************************
* 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/ *
***************************************************************************/
#pragma once
#include "awpluginmatcher.h"
class AWPluginMatcherGPUMemoryUsedCore : public AWPluginMatcher<AWPluginMatcherGPUMemoryUsedCore>
{
public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *>
keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override;
[[nodiscard]] bool matches(const QString &_source) const override;
};

View File

@@ -22,14 +22,14 @@
#include "formatters/formatters.h" #include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherGPUTemperature::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const QHash<QString, AWPluginFormaterInterface *>
AWPluginMatcherGPUTemperature::keys(const QString &_source, const KSysGuard::Unit,
const AWPluginMatcherSettings &_settings) const
{ {
auto device = _source; auto index = AWPluginMatcher::index(_source, _settings.gpu);
device.remove("gpu/").remove("/temperature");
auto index = _settings.gpu.indexOf(device);
if (index == -1) if (index == -1)
return {}; return {};
return {{QString("gputemp%1").arg(index), AWPluginFormatterTemperature::instance()}}; return {{QString("gputemp%1").arg(index), AWPluginFormatterTemperature::instance()}};
} }

View File

@@ -20,9 +20,10 @@
#include "awpluginmatcher.h" #include "awpluginmatcher.h"
class AWPluginMatcherGPUTemperature : public AWPluginMatcher<AWPluginMatcherGPUTemperature> { class AWPluginMatcherGPUTemperature : public AWPluginMatcher<AWPluginMatcherGPUTemperature>
{
public: public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override; [[nodiscard]] QHash<QString, AWPluginFormaterInterface *>
keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override;
[[nodiscard]] bool matches(const QString &_source) const override; [[nodiscard]] bool matches(const QString &_source) const override;
}; };

Some files were not shown because too many files have changed in this diff Show More