diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcher.h b/sources/awesome-widget/plugin/matchers/awpluginmatcher.h index 34729f7..d71fc78 100644 --- a/sources/awesome-widget/plugin/matchers/awpluginmatcher.h +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcher.h @@ -53,6 +53,12 @@ public: [[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: AWPluginMatcher() = default; }; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.cpp index adbaa96..6479bd4 100644 --- a/sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.cpp +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.cpp @@ -25,12 +25,10 @@ QHash AWPluginMatcherGPUCore::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const { - auto device = _source; - device.remove("gpu/").remove("/usage"); - - auto index = _settings.gpu.indexOf(device); + auto index = AWPluginMatcher::index(_source, _settings.gpu); if (index == -1) return {}; + return {{QString("gpu%1").arg(index), AWPluginFormatterFloat::instance()}}; } diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.cpp index d28c5ae..7f7120b 100644 --- a/sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.cpp +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.cpp @@ -26,12 +26,10 @@ QHash AWPluginMatcherGPUTemperature::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const { - auto device = _source; - device.remove("gpu/").remove("/temperature"); - - auto index = _settings.gpu.indexOf(device); + auto index = AWPluginMatcher::index(_source, _settings.gpu); if (index == -1) return {}; + return {{QString("gputemp%1").arg(index), AWPluginFormatterTemperature::instance()}}; } diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhdd.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherhdd.cpp index ed0be29..2575e0a 100644 --- a/sources/awesome-widget/plugin/matchers/awpluginmatcherhdd.cpp +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhdd.cpp @@ -25,11 +25,10 @@ QHash AWPluginMatcherHDD::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const { - auto device = AWPluginMatcher::device(_source); - auto index = _settings.disk.indexOf(device); - + auto index = AWPluginMatcher::index(_source, _settings.disk); if (index == -1) return {}; + return {{QString("hdd%1").arg(index), AWPluginFormatterFloat::instance()}}; } diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddfree.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddfree.cpp index 8f4381f..92750f2 100644 --- a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddfree.cpp +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddfree.cpp @@ -25,11 +25,10 @@ QHash AWPluginMatcherHDDFree::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const { - auto device = AWPluginMatcher::device(_source); - auto index = _settings.disk.indexOf(device); - + auto index = AWPluginMatcher::index(_source, _settings.disk); if (index == -1) return {}; + return { {QString("hddfreemb%1").arg(index), AWPluginFormatterMemoryMB::instance()}, {QString("hddfreegb%1").arg(index), AWPluginFormatterMemoryGB::instance()}, diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.cpp index 11db01b..353e5e4 100644 --- a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.cpp +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.cpp @@ -25,11 +25,10 @@ QHash AWPluginMatcherHDDRead::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const { - auto device = AWPluginMatcher::device(_source); - auto index = _settings.disk.indexOf(device); - + auto index = AWPluginMatcher::index(_source, _settings.disk); if (index == -1) return {}; + return {{QString("hddr%1").arg(index), AWPluginFormatterMemory::instance()}}; } diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddtotal.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddtotal.cpp index 53a9032..cd60859 100644 --- a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddtotal.cpp +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddtotal.cpp @@ -26,11 +26,10 @@ QHash AWPluginMatcherHDDTotal::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const { - auto device = AWPluginMatcher::device(_source); - auto index = _settings.disk.indexOf(device); - + auto index = AWPluginMatcher::index(_source, _settings.disk); if (index == -1) return {}; + return { {QString("hddtotmb%1").arg(index), AWPluginFormatterMemoryMB::instance()}, {QString("hddtotgb%1").arg(index), AWPluginFormatterMemoryGB::instance()}, diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddused.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddused.cpp index 31d311e..0b4dc3e 100644 --- a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddused.cpp +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddused.cpp @@ -25,11 +25,10 @@ QHash AWPluginMatcherHDDUsed::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const { - auto device = AWPluginMatcher::device(_source); - auto index = _settings.disk.indexOf(device); - + auto index = AWPluginMatcher::index(_source, _settings.disk); if (index == -1) return {}; + return { {QString("hddmb%1").arg(index), AWPluginFormatterMemoryMB::instance()}, {QString("hddgb%1").arg(index), AWPluginFormatterMemoryGB::instance()}, diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddwrite.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddwrite.cpp index 61f775e..b57939e 100644 --- a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddwrite.cpp +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddwrite.cpp @@ -26,11 +26,10 @@ QHash AWPluginMatcherHDDWrite::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const { - auto device = AWPluginMatcher::device(_source); - auto index = _settings.disk.indexOf(device); - + auto index = AWPluginMatcher::index(_source, _settings.disk); if (index == -1) return {}; + return {{QString("hddw%1").arg(index), AWPluginFormatterMemory::instance()}}; } diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchernetwork.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchernetwork.cpp index 1f7dc15..c818751 100644 --- a/sources/awesome-widget/plugin/matchers/awpluginmatchernetwork.cpp +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetwork.cpp @@ -25,13 +25,11 @@ QHash AWPluginMatcherNetwork::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const { - auto type = _source.endsWith("download") ? "down" : "up"; - auto device = AWPluginMatcher::device(_source); - auto index = _settings.network.indexOf(device); - + auto index = AWPluginMatcher::index(_source, _settings.network); if (index == -1) return {}; + auto type = _source.endsWith("download") ? "down" : "up"; return { {QString("%1%2").arg(type).arg(index), AWPluginFormatterNet::instance()}, {QString("%1kb%2").arg(type).arg(index), AWPluginFormatterMemory::instance()}, diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchernetworktotal.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworktotal.cpp index 5401b63..d26acd4 100644 --- a/sources/awesome-widget/plugin/matchers/awpluginmatchernetworktotal.cpp +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworktotal.cpp @@ -26,13 +26,11 @@ QHash AWPluginMatcherNetworkTotal::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const { - auto type = _source.endsWith("Download") ? "down" : "up"; - auto device = AWPluginMatcher::device(_source); - auto index = _settings.network.indexOf(device); - + auto index = AWPluginMatcher::index(_source, _settings.network); if (index == -1) return {}; + auto type = _source.endsWith("Download") ? "down" : "up"; return { {QString("%1tot%2").arg(type).arg(index), AWPluginFormatterMemoryMB::instance()}, {QString("%1totkb%2").arg(type).arg(index), AWPluginFormatterMemory::instance()}, diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchersensors.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchersensors.cpp index e1f7030..651d4ba 100644 --- a/sources/awesome-widget/plugin/matchers/awpluginmatchersensors.cpp +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchersensors.cpp @@ -28,7 +28,6 @@ QHash AWPluginMatcherSensors::keys(const Q // temperature auto index = _settings.sensors.indexOf(_source); auto key = QString("temp%1").arg(index); - if (index == -1) return {};