mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
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
This commit is contained in:
parent
95572364c1
commit
64b4618904
@ -10,7 +10,7 @@ include_directories(
|
|||||||
${Kf6_INCLUDE}
|
${Kf6_INCLUDE}
|
||||||
)
|
)
|
||||||
|
|
||||||
file(GLOB SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp ${CMAKE_SOURCE_DIR}/*.cpp)
|
file(GLOB SUBPROJECT_SOURCE *.cpp formatters/*.cpp matchers/*.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp ${CMAKE_SOURCE_DIR}/*.cpp)
|
||||||
file(GLOB SUBPROJECT_UI *.ui)
|
file(GLOB SUBPROJECT_UI *.ui)
|
||||||
file(GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
file(GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
class QSettings;
|
class QSettings;
|
||||||
|
|
||||||
class AWConfigHelper : public QObject
|
class __attribute__((visibility("default"))) AWConfigHelper : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include "awdebug.h"
|
#include "awdebug.h"
|
||||||
#include "awformatterhelper.h"
|
#include "awformatterhelper.h"
|
||||||
|
#include "formatters/formatters.h"
|
||||||
|
#include "matchers/matchers.h"
|
||||||
|
|
||||||
|
|
||||||
AWDataEngineMapper::AWDataEngineMapper(QObject *_parent, AWFormatterHelper *_custom)
|
AWDataEngineMapper::AWDataEngineMapper(QObject *_parent, AWFormatterHelper *_custom)
|
||||||
@ -30,33 +32,25 @@ AWDataEngineMapper::AWDataEngineMapper(QObject *_parent, AWFormatterHelper *_cus
|
|||||||
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
||||||
|
|
||||||
// default formatters
|
// default formatters
|
||||||
// memory
|
|
||||||
m_formatter["mem"] = AWKeysAggregator::FormatterType::Float;
|
|
||||||
m_formatter["memtotmb"] = AWKeysAggregator::FormatterType::MemMBFormat;
|
|
||||||
m_formatter["memtotgb"] = AWKeysAggregator::FormatterType::MemGBFormat;
|
|
||||||
// network
|
// network
|
||||||
m_formatter["down"] = AWKeysAggregator::FormatterType::NetSmartFormat;
|
m_formatter["down"] = AWPluginFormatterNet::instance();
|
||||||
m_formatter["downkb"] = AWKeysAggregator::FormatterType::Integer;
|
m_formatter["downkb"] = AWPluginFormatterMemory::instance();
|
||||||
m_formatter["downtot"] = AWKeysAggregator::FormatterType::MemMBFormat;
|
m_formatter["downtot"] = AWPluginFormatterMemoryMB::instance();
|
||||||
m_formatter["downtotkb"] = AWKeysAggregator::FormatterType::Integer;
|
m_formatter["downtotkb"] = AWPluginFormatterMemory::instance();
|
||||||
m_formatter["downunits"] = AWKeysAggregator::FormatterType::NetSmartUnits;
|
m_formatter["downunits"] = AWPluginFormatterNetUnits::instance();
|
||||||
m_formatter["up"] = AWKeysAggregator::FormatterType::NetSmartFormat;
|
m_formatter["up"] = AWPluginFormatterNet::instance();
|
||||||
m_formatter["upkb"] = AWKeysAggregator::FormatterType::Integer;
|
m_formatter["upkb"] = AWPluginFormatterMemory::instance();
|
||||||
m_formatter["uptot"] = AWKeysAggregator::FormatterType::MemMBFormat;
|
m_formatter["uptot"] = AWPluginFormatterMemoryMB::instance();
|
||||||
m_formatter["uptotkb"] = AWKeysAggregator::FormatterType::Integer;
|
m_formatter["uptotkb"] = AWPluginFormatterMemory::instance();
|
||||||
m_formatter["upunits"] = AWKeysAggregator::FormatterType::NetSmartUnits;
|
m_formatter["upunits"] = AWPluginFormatterNetUnits::instance();
|
||||||
// swap
|
|
||||||
m_formatter["swap"] = AWKeysAggregator::FormatterType::Float;
|
|
||||||
m_formatter["swaptotmb"] = AWKeysAggregator::FormatterType::MemMBFormat;
|
|
||||||
m_formatter["swaptotgb"] = AWKeysAggregator::FormatterType::MemGBFormat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AWKeysAggregator::FormatterType AWDataEngineMapper::formatter(const QString &_key) const
|
AWPluginFormaterInterface *AWDataEngineMapper::formatter(const QString &_key) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Get formatter for key" << _key;
|
qCDebug(LOG_AW) << "Get formatter for key" << _key;
|
||||||
|
|
||||||
return m_formatter.value(_key, AWKeysAggregator::FormatterType::NoFormat);
|
return m_formatter.value(_key, AWPluginFormatterNoFormat::instance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -75,376 +69,44 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Source" << _source << "with units" << _units;
|
qCDebug(LOG_AW) << "Source" << _source << "with units" << _units;
|
||||||
|
|
||||||
// regular expressions
|
auto matchers = AWPluginMatchers::matchers;
|
||||||
static auto cpuRegExp = QRegularExpression("^cpu/cpu.*/usage$");
|
auto matcher = std::find_if(matchers.cbegin(), matchers.cend(),
|
||||||
static auto cpuclRegExp = QRegularExpression("^cpu/cpu.*/frequency$");
|
[&_source](auto matcher) { return matcher->matches(_source); });
|
||||||
static auto cpuTempRegExp = QRegularExpression("^cpu/cpu.*/temperature$");
|
if (matcher == matchers.cend())
|
||||||
static auto gpuRegExp = QRegularExpression("^gpu/gpu.*/usage$");
|
return {};
|
||||||
static auto gpuTempRegExp = QRegularExpression("^gpu/gpu.*/temperature$");
|
|
||||||
static auto hddrRegExp = QRegularExpression("^disk/.*/read$");
|
|
||||||
static auto hddwRegExp = QRegularExpression("^disk/.*/write$");
|
|
||||||
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)$");
|
|
||||||
|
|
||||||
if (_source == "extsysmon/battery/ac") {
|
auto foundKeys = (*matcher)->keys(_source, _units, m_settings);
|
||||||
// AC
|
auto keys = foundKeys.keys(); // speedup a little bit
|
||||||
m_map.insert(_source, "ac");
|
|
||||||
m_formatter["ac"] = AWKeysAggregator::FormatterType::ACFormat;
|
|
||||||
} else if (_source.startsWith("extsysmon/battery/")) {
|
|
||||||
// battery stats
|
|
||||||
auto key = _source;
|
|
||||||
key.remove("extsysmon/battery/");
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = _source.contains("rate") ? AWKeysAggregator::FormatterType::Float
|
|
||||||
: AWKeysAggregator::FormatterType::IntegerThree;
|
|
||||||
} else if (_source == "cpu/all/usage") {
|
|
||||||
// cpu
|
|
||||||
m_map.insert(_source, "cpu");
|
|
||||||
m_formatter["cpu"] = AWKeysAggregator::FormatterType::Float;
|
|
||||||
} else if (_source.contains(cpuRegExp)) {
|
|
||||||
// cpus
|
|
||||||
auto key = _source;
|
|
||||||
key.remove("cpu/").remove("/usage");
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::Float;
|
|
||||||
} else if (_source == "cpu/all/averageFrequency") {
|
|
||||||
// cpucl
|
|
||||||
m_map.insert(_source, "cpucl");
|
|
||||||
m_formatter["cpucl"] = AWKeysAggregator::FormatterType::Integer;
|
|
||||||
} else if (_source.contains(cpuclRegExp)) {
|
|
||||||
// cpucls
|
|
||||||
auto key = _source;
|
|
||||||
key.remove("cpu/cpu").remove("/frequency");
|
|
||||||
key = QString("cpucl%1").arg(key);
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::Integer;
|
|
||||||
} else if (_source.startsWith("extsysmon/custom")) {
|
|
||||||
// custom
|
|
||||||
auto key = _source;
|
|
||||||
key.remove("extsysmon/custom/");
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat;
|
|
||||||
} else if (_source == "extsysmon/desktop/name") {
|
|
||||||
// current desktop name
|
|
||||||
m_map.insert(_source, "desktop");
|
|
||||||
m_formatter["desktop"] = AWKeysAggregator::FormatterType::NoFormat;
|
|
||||||
} else if (_source == "extsysmon/desktop/number") {
|
|
||||||
// current desktop number
|
|
||||||
m_map.insert(_source, "ndesktop");
|
|
||||||
m_formatter["ndesktop"] = AWKeysAggregator::FormatterType::NoFormat;
|
|
||||||
} else if (_source == "extsysmon/desktop/count") {
|
|
||||||
// desktop count
|
|
||||||
m_map.insert(_source, "tdesktops");
|
|
||||||
m_formatter["tdesktops"] = AWKeysAggregator::FormatterType::NoFormat;
|
|
||||||
} else if (_source.contains(hddrRegExp)) {
|
|
||||||
// read speed
|
|
||||||
auto device = _source;
|
|
||||||
device.remove("disk/").remove("/read");
|
|
||||||
auto index = m_devices["disk"].indexOf(device);
|
|
||||||
if (index > -1) {
|
|
||||||
QString key = QString("hddr%1").arg(index);
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::MemKBFormat;
|
|
||||||
}
|
|
||||||
} else if (_source.contains(hddwRegExp)) {
|
|
||||||
// write speed
|
|
||||||
auto device = _source;
|
|
||||||
device.remove("disk/").remove("/write");
|
|
||||||
auto index = m_devices["disk"].indexOf(device);
|
|
||||||
if (index > -1) {
|
|
||||||
QString key = QString("hddw%1").arg(index);
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::MemKBFormat;
|
|
||||||
}
|
|
||||||
} else if (_source == "gpu/all/usage") {
|
|
||||||
// gpu load
|
|
||||||
m_map.insert(_source, "gpu");
|
|
||||||
m_formatter["gpu"] = AWKeysAggregator::FormatterType::Float;
|
|
||||||
} else if (_source.contains(gpuRegExp)) {
|
|
||||||
// gpus
|
|
||||||
auto device = _source;
|
|
||||||
device.remove("gpu/").remove("/usage");
|
|
||||||
auto index = m_devices["gpu"].indexOf(device);
|
|
||||||
if (index > -1) {
|
|
||||||
auto key = QString("gpu%1").arg(index);
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::Float;
|
|
||||||
}
|
|
||||||
} else if (_source.contains(gpuTempRegExp)) {
|
|
||||||
// gpus temps
|
|
||||||
auto device = _source;
|
|
||||||
device.remove("gpu/").remove("/temperature");
|
|
||||||
auto index = m_devices["gpu"].indexOf(device);
|
|
||||||
if (index > -1) {
|
|
||||||
auto key = QString("gputemp%1").arg(index);
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::Temperature;
|
|
||||||
}
|
|
||||||
} else 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] = AWKeysAggregator::FormatterType::Float;
|
|
||||||
// additional keys
|
|
||||||
m_formatter[QString("hddtotmb%1").arg(index)] = AWKeysAggregator::FormatterType::MemMBFormat;
|
|
||||||
m_formatter[QString("hddtotgb%1").arg(index)] = AWKeysAggregator::FormatterType::MemGBFormat;
|
|
||||||
}
|
|
||||||
} 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] = AWKeysAggregator::FormatterType::MemMBFormat;
|
|
||||||
// gb
|
|
||||||
key = QString("hddfreegb%1").arg(index);
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::MemGBFormat;
|
|
||||||
}
|
|
||||||
} 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] = AWKeysAggregator::FormatterType::MemMBFormat;
|
|
||||||
// gb
|
|
||||||
key = QString("hddgb%1").arg(index);
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::MemGBFormat;
|
|
||||||
}
|
|
||||||
} else if (_source.startsWith("cpu/loadaverages/loadaverage")) {
|
|
||||||
// load average
|
|
||||||
auto time = _source;
|
|
||||||
time.remove("cpu/loadaverages/loadaverage");
|
|
||||||
auto key = QString("la%1").arg(time);
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::FloatTwoSymbols;
|
|
||||||
} else if (_source == "memory/physical/application") {
|
|
||||||
// app memory
|
|
||||||
// mb
|
|
||||||
m_map.insert(_source, "memmb");
|
|
||||||
m_formatter["memmb"] = AWKeysAggregator::FormatterType::MemMBFormat;
|
|
||||||
// gb
|
|
||||||
m_map.insert(_source, "memgb");
|
|
||||||
m_formatter["memgb"] = AWKeysAggregator::FormatterType::MemGBFormat;
|
|
||||||
} else if (_source == "memory/physical/free") {
|
|
||||||
// free memory
|
|
||||||
// mb
|
|
||||||
m_map.insert(_source, "memfreemb");
|
|
||||||
m_formatter["memfreemb"] = AWKeysAggregator::FormatterType::MemMBFormat;
|
|
||||||
// gb
|
|
||||||
m_map.insert(_source, "memfreegb");
|
|
||||||
m_formatter["memfreegb"] = AWKeysAggregator::FormatterType::MemGBFormat;
|
|
||||||
} else if (_source == "memory/physical/used") {
|
|
||||||
// used memory
|
|
||||||
// mb
|
|
||||||
m_map.insert(_source, "memusedmb");
|
|
||||||
m_formatter["memusedmb"] = AWKeysAggregator::FormatterType::MemMBFormat;
|
|
||||||
// gb
|
|
||||||
m_map.insert(_source, "memusedgb");
|
|
||||||
m_formatter["memusedgb"] = AWKeysAggregator::FormatterType::MemGBFormat;
|
|
||||||
} else if (_source == "extsysmon/network/device") {
|
|
||||||
// network device
|
|
||||||
m_map.insert(_source, "netdev");
|
|
||||||
m_formatter["netdev"] = AWKeysAggregator::FormatterType::NoFormat;
|
|
||||||
} else if (_source == "extsysmon/network/ssid") {
|
|
||||||
// current ssid
|
|
||||||
m_map.insert(_source, "ssid");
|
|
||||||
m_formatter["ssid"] = AWKeysAggregator::FormatterType::NoFormat;
|
|
||||||
} else if (_source.startsWith("extsysmon/requests/response")) {
|
|
||||||
// network response
|
|
||||||
auto key = _source;
|
|
||||||
key.remove("extsysmon/requests/");
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat;
|
|
||||||
} 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] = AWKeysAggregator::FormatterType::MemKBFormat;
|
|
||||||
// smart
|
|
||||||
key = QString("%1%2").arg(type).arg(index);
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::NetSmartFormat;
|
|
||||||
// units
|
|
||||||
key = QString("%1units%2").arg(type).arg(index);
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::NetSmartUnits;
|
|
||||||
}
|
|
||||||
} 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] = AWKeysAggregator::FormatterType::MemKBFormat;
|
|
||||||
// mb
|
|
||||||
key = QString("%1tot%2").arg(type).arg(index);
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::MemMBFormat;
|
|
||||||
}
|
|
||||||
} else if (_source.startsWith("extsysmon/upgrade")) {
|
|
||||||
// package manager
|
|
||||||
auto key = _source;
|
|
||||||
key.remove("extsysmon/upgrade/");
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::IntegerThree;
|
|
||||||
} else if (_source.startsWith("extsysmon/player")) {
|
|
||||||
// player
|
|
||||||
auto key = _source;
|
|
||||||
key.remove("extsysmon/player/");
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat;
|
|
||||||
} else if (_source == "extsysmon/ps/running") {
|
|
||||||
// running processes count
|
|
||||||
m_map.insert(_source, "pscount");
|
|
||||||
m_formatter["pscount"] = AWKeysAggregator::FormatterType::NoFormat;
|
|
||||||
} else if (_source == "extsysmon/ps/list") {
|
|
||||||
// list of running processes
|
|
||||||
m_map.insert(_source, "ps");
|
|
||||||
m_formatter["ps"] = AWKeysAggregator::FormatterType::List;
|
|
||||||
} else if (_source == "extsysmon/ps/count") {
|
|
||||||
// total processes count
|
|
||||||
m_map.insert(_source, "pstot");
|
|
||||||
m_formatter["pstot"] = AWKeysAggregator::FormatterType::NoFormat;
|
|
||||||
} else if (_source.startsWith("extsysmon/quotes")) {
|
|
||||||
// quotes
|
|
||||||
auto key = _source;
|
|
||||||
key.remove("extsysmon/quotes/");
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::Quotes;
|
|
||||||
} else if (_source == "memory/swap/free") {
|
|
||||||
// free swap
|
|
||||||
// mb
|
|
||||||
m_map.insert(_source, "swapfreemb");
|
|
||||||
m_formatter["swapfreemb"] = AWKeysAggregator::FormatterType::MemMBFormat;
|
|
||||||
// gb
|
|
||||||
m_map.insert(_source, "swapfreegb");
|
|
||||||
m_formatter["swapfreegb"] = AWKeysAggregator::FormatterType::MemGBFormat;
|
|
||||||
} else if (_source == "memory/swap/used") {
|
|
||||||
// used swap
|
|
||||||
// mb
|
|
||||||
m_map.insert(_source, "swapmb");
|
|
||||||
m_formatter["swapmb"] = AWKeysAggregator::FormatterType::MemMBFormat;
|
|
||||||
// gb
|
|
||||||
m_map.insert(_source, "swapgb");
|
|
||||||
m_formatter["swapgb"] = AWKeysAggregator::FormatterType::MemGBFormat;
|
|
||||||
} 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);
|
|
||||||
m_formatter[key] = _units == KSysGuard::UnitCelsius ? AWKeysAggregator::FormatterType::Temperature
|
|
||||||
: AWKeysAggregator::FormatterType::Integer;
|
|
||||||
}
|
|
||||||
} else if (_source == "extsysmon/time/now") {
|
|
||||||
// time
|
|
||||||
m_map.insert(_source, "time");
|
|
||||||
m_formatter["time"] = AWKeysAggregator::FormatterType::Time;
|
|
||||||
// custom time
|
|
||||||
m_map.insert(_source, "ctime");
|
|
||||||
m_formatter["ctime"] = AWKeysAggregator::FormatterType::TimeCustom;
|
|
||||||
// ISO time
|
|
||||||
m_map.insert(_source, "isotime");
|
|
||||||
m_formatter["isotime"] = AWKeysAggregator::FormatterType::TimeISO;
|
|
||||||
// long time
|
|
||||||
m_map.insert(_source, "longtime");
|
|
||||||
m_formatter["longtime"] = AWKeysAggregator::FormatterType::TimeLong;
|
|
||||||
// short time
|
|
||||||
m_map.insert(_source, "shorttime");
|
|
||||||
m_formatter["shorttime"] = AWKeysAggregator::FormatterType::TimeShort;
|
|
||||||
// timestamp
|
|
||||||
m_map.insert(_source, "tstime");
|
|
||||||
m_formatter["tstime"] = AWKeysAggregator::FormatterType::Timestamp;
|
|
||||||
} else if (_source == "extsysmon/system/brightness") {
|
|
||||||
m_map.insert(_source, "brightness");
|
|
||||||
m_formatter["brightness"] = AWKeysAggregator::FormatterType::IntegerThree;
|
|
||||||
} else if (_source == "extsysmon/system/volume") {
|
|
||||||
m_map.insert(_source, "volume");
|
|
||||||
m_formatter["volume"] = AWKeysAggregator::FormatterType::IntegerThree;
|
|
||||||
} else if (_source == "os/system/uptime") {
|
|
||||||
// uptime
|
|
||||||
m_map.insert(_source, "uptime");
|
|
||||||
m_formatter["uptime"] = AWKeysAggregator::FormatterType::Uptime;
|
|
||||||
// custom uptime
|
|
||||||
m_map.insert(_source, "cuptime");
|
|
||||||
m_formatter["cuptime"] = AWKeysAggregator::FormatterType::UptimeCustom;
|
|
||||||
} else if (_source.startsWith("extsysmon/weather/temperature")) {
|
|
||||||
// temperature
|
|
||||||
auto key = _source;
|
|
||||||
key.remove("extsysmon/weather/");
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::Temperature;
|
|
||||||
} else if (_source.startsWith("extsysmon/weather/")) {
|
|
||||||
// other weather
|
|
||||||
auto key = _source;
|
|
||||||
key.remove("extsysmon/weather/");
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat;
|
|
||||||
} else if (_source.startsWith("extsysmon/load/load")) {
|
|
||||||
// load source
|
|
||||||
auto key = _source;
|
|
||||||
key.remove("extsysmon/load/");
|
|
||||||
m_map.insert(_source, key);
|
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::Temperature;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto foundKeys = keysFromSource(_source);
|
|
||||||
|
|
||||||
// rewrite formatters for custom ones
|
// rewrite formatters for custom ones
|
||||||
QStringList customFormattersKeys;
|
QStringList customFormattersKeys;
|
||||||
if (m_customFormatters)
|
if (m_customFormatters)
|
||||||
customFormattersKeys = m_customFormatters->definedFormatters();
|
customFormattersKeys = m_customFormatters->definedFormatters();
|
||||||
qCInfo(LOG_AW) << "Looking for formatters" << foundKeys << "in" << customFormattersKeys;
|
qCInfo(LOG_AW) << "Looking for formatters" << keys << "in" << customFormattersKeys;
|
||||||
for (auto &key : foundKeys) {
|
for (auto &key : keys) {
|
||||||
if (!customFormattersKeys.contains(key))
|
if (!customFormattersKeys.contains(key))
|
||||||
continue;
|
continue;
|
||||||
m_formatter[key] = AWKeysAggregator::FormatterType::Custom;
|
foundKeys[key] = AWPluginFormatterCustom::instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
// drop key from dictionary if no one user requested key required it
|
// check if keys were actually requested
|
||||||
qCInfo(LOG_AW) << "Looking for keys" << foundKeys << "in" << _keys;
|
qCInfo(LOG_AW) << "Looking for keys" << keys << "in" << _keys;
|
||||||
auto required = _keys.isEmpty() || std::any_of(foundKeys.cbegin(), foundKeys.cend(), [&_keys](auto &key) {
|
auto required = _keys.isEmpty()
|
||||||
return _keys.contains(key);
|
|| std::any_of(keys.cbegin(), keys.cend(), [&_keys](auto &key) { return _keys.contains(key); });
|
||||||
});
|
if (!required)
|
||||||
if (!required) {
|
return {};
|
||||||
m_map.remove(_source);
|
|
||||||
for (auto &key : foundKeys)
|
// insert keys into memory
|
||||||
m_formatter.remove(key);
|
for (auto [key, formatter] : foundKeys.asKeyValueRange()) {
|
||||||
|
m_map.insert(_source, key);
|
||||||
|
m_formatter[key] = formatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return keysFromSource(_source);
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWDataEngineMapper::setDevices(const QHash<QString, QStringList> &_devices)
|
void AWDataEngineMapper::setDevices(const AWPluginMatcherSettings &_settings)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Devices" << _devices;
|
m_settings = _settings;
|
||||||
|
|
||||||
m_devices = _devices;
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
#include <QMultiHash>
|
#include <QMultiHash>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "awkeysaggregator.h"
|
#include "formatters/awpluginformatter.h"
|
||||||
|
#include "matchers/awpluginmatchersettings.h"
|
||||||
|
|
||||||
|
|
||||||
class AWFormatterHelper;
|
class AWFormatterHelper;
|
||||||
@ -35,16 +36,17 @@ public:
|
|||||||
explicit AWDataEngineMapper(QObject *_parent = nullptr, AWFormatterHelper *_custom = nullptr);
|
explicit AWDataEngineMapper(QObject *_parent = nullptr, AWFormatterHelper *_custom = nullptr);
|
||||||
~AWDataEngineMapper() override = default;
|
~AWDataEngineMapper() override = default;
|
||||||
// get methods
|
// get methods
|
||||||
[[nodiscard]] AWKeysAggregator::FormatterType 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);
|
||||||
void setDevices(const QHash<QString, QStringList> &_devices);
|
void setDevices(const AWPluginMatcherSettings &_settings);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AWFormatterHelper *m_customFormatters = nullptr;
|
AWFormatterHelper *m_customFormatters = nullptr;
|
||||||
|
AWPluginMatcherSettings m_settings;
|
||||||
// variables
|
// variables
|
||||||
QHash<QString, QStringList> m_devices;
|
QHash<QString, QStringList> m_devices;
|
||||||
QHash<QString, AWKeysAggregator::FormatterType> m_formatter;
|
QHash<QString, AWPluginFormaterInterface *> m_formatter;
|
||||||
QMultiHash<QString, QString> m_map;
|
QMultiHash<QString, QString> m_map;
|
||||||
};
|
};
|
||||||
|
@ -82,47 +82,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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(
|
QStringList netKeys(
|
||||||
{"up", "upkb", "uptot", "uptotkb", "upunits", "down", "downkb", "downtot", "downtotkb", "downunits"});
|
{"up", "upkb", "uptot", "uptotkb", "upunits", "down", "downkb", "downtot", "downtotkb", "downunits"});
|
||||||
@ -146,18 +106,23 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QHash<QString, QStringList> AWKeyCache::loadKeysFromCache()
|
AWPluginMatcherSettings AWKeyCache::loadKeysFromCache()
|
||||||
{
|
{
|
||||||
auto fileName
|
auto fileName
|
||||||
= QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
= QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
||||||
qCInfo(LOG_AW) << "Cache file" << fileName;
|
qCInfo(LOG_AW) << "Cache file" << fileName;
|
||||||
QSettings cache(fileName, QSettings::IniFormat);
|
QSettings cache(fileName, QSettings::IniFormat);
|
||||||
|
|
||||||
QHash<QString, QStringList> devices;
|
AWPluginMatcherSettings devices;
|
||||||
for (auto &group : cache.childGroups()) {
|
QHash<QString, QStringList *> groups = {
|
||||||
|
{"disk", &devices.disk}, {"gpu", &devices.gpu}, {"mount", &devices.mount},
|
||||||
|
{"net", &devices.network}, {"temp", &devices.sensors},
|
||||||
|
};
|
||||||
|
|
||||||
|
for (auto [group, list] : groups.asKeyValueRange()) {
|
||||||
cache.beginGroup(group);
|
cache.beginGroup(group);
|
||||||
for (auto &key : cache.allKeys())
|
for (auto &key : cache.allKeys())
|
||||||
devices[group].append(cache.value(key).toString());
|
list->append(cache.value(key).toString());
|
||||||
cache.endGroup();
|
cache.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,15 +17,16 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QHash>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
|
#include <matchers/awpluginmatchersettings.h>
|
||||||
|
|
||||||
|
|
||||||
namespace AWKeyCache
|
namespace AWKeyCache
|
||||||
{
|
{
|
||||||
bool addKeyToCache(const QString &_type, const QString &_key = "");
|
bool addKeyToCache(const QString &_type, const QString &_key = "");
|
||||||
QStringList getRequiredKeys(const QStringList &_keys, const QStringList &_bars, const QVariantMap &_tooltip,
|
QStringList getRequiredKeys(const QStringList &_keys, const QStringList &_bars, const QVariantMap &_tooltip,
|
||||||
const QStringList &_userKeys, const QStringList &_allKeys);
|
const QStringList &_userKeys, const QStringList &_allKeys);
|
||||||
QHash<QString, QStringList> loadKeysFromCache();
|
AWPluginMatcherSettings loadKeysFromCache();
|
||||||
} // namespace AWKeyCache
|
} // namespace AWKeyCache
|
||||||
|
@ -49,15 +49,7 @@ AWKeyOperations::AWKeyOperations(QObject *_parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList AWKeyOperations::devices(const QString &_type) const
|
AWPluginMatcherSettings AWKeyOperations::devices() const
|
||||||
{
|
|
||||||
qCDebug(LOG_AW) << "Looking for type" << _type;
|
|
||||||
|
|
||||||
return m_devices[_type];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QHash<QString, QStringList> AWKeyOperations::devices() const
|
|
||||||
{
|
{
|
||||||
return m_devices;
|
return m_devices;
|
||||||
}
|
}
|
||||||
@ -88,15 +80,15 @@ QStringList AWKeyOperations::dictKeys() const
|
|||||||
allKeys.append(QString("cpu%1").arg(i));
|
allKeys.append(QString("cpu%1").arg(i));
|
||||||
}
|
}
|
||||||
// temperature
|
// temperature
|
||||||
for (auto i = 0; i < m_devices["temp"].count(); ++i)
|
for (auto i = 0; i < m_devices.sensors.count(); ++i)
|
||||||
allKeys.append(QString("temp%1").arg(i));
|
allKeys.append(QString("temp%1").arg(i));
|
||||||
// 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("gputemp%1").arg(i));
|
allKeys.append(QString("gputemp%1").arg(i));
|
||||||
}
|
}
|
||||||
// hdd
|
// hdd
|
||||||
for (auto i = 0; i < m_devices["mount"].count(); ++i) {
|
for (auto i = 0; i < m_devices.mount.count(); ++i) {
|
||||||
allKeys.append(QString("hddmb%1").arg(i));
|
allKeys.append(QString("hddmb%1").arg(i));
|
||||||
allKeys.append(QString("hddgb%1").arg(i));
|
allKeys.append(QString("hddgb%1").arg(i));
|
||||||
allKeys.append(QString("hddfreemb%1").arg(i));
|
allKeys.append(QString("hddfreemb%1").arg(i));
|
||||||
@ -106,12 +98,12 @@ QStringList AWKeyOperations::dictKeys() const
|
|||||||
allKeys.append(QString("hdd%1").arg(i));
|
allKeys.append(QString("hdd%1").arg(i));
|
||||||
}
|
}
|
||||||
// hdd speed
|
// hdd speed
|
||||||
for (auto i = 0; i < m_devices["disk"].count(); ++i) {
|
for (auto i = 0; i < m_devices.disk.count(); ++i) {
|
||||||
allKeys.append(QString("hddr%1").arg(i));
|
allKeys.append(QString("hddr%1").arg(i));
|
||||||
allKeys.append(QString("hddw%1").arg(i));
|
allKeys.append(QString("hddw%1").arg(i));
|
||||||
}
|
}
|
||||||
// network
|
// network
|
||||||
for (auto i = 0; i < m_devices["net"].count(); ++i) {
|
for (auto i = 0; i < m_devices.network.count(); ++i) {
|
||||||
allKeys.append(QString("downunits%1").arg(i));
|
allKeys.append(QString("downunits%1").arg(i));
|
||||||
allKeys.append(QString("upunits%1").arg(i));
|
allKeys.append(QString("upunits%1").arg(i));
|
||||||
allKeys.append(QString("downtotkb%1").arg(i));
|
allKeys.append(QString("downtotkb%1").arg(i));
|
||||||
@ -224,15 +216,15 @@ QString AWKeyOperations::infoByKey(const QString &_key) const
|
|||||||
} else if (_key.contains(hddrwRegExp)) {
|
} else if (_key.contains(hddrwRegExp)) {
|
||||||
auto index = _key;
|
auto index = _key;
|
||||||
index.remove(hddrwRegExp);
|
index.remove(hddrwRegExp);
|
||||||
output = m_devices["disk"][index.toInt()];
|
output = m_devices.disk[index.toInt()];
|
||||||
} else if (_key.contains(hddMatchRegExp)) {
|
} else if (_key.contains(hddMatchRegExp)) {
|
||||||
auto index = _key;
|
auto index = _key;
|
||||||
index.remove(hddRegExp);
|
index.remove(hddRegExp);
|
||||||
output = m_devices["mount"][index.toInt()];
|
output = m_devices.mount[index.toInt()];
|
||||||
} else if (_key.contains(netMatchRegExp)) {
|
} else if (_key.contains(netMatchRegExp)) {
|
||||||
auto index = _key;
|
auto index = _key;
|
||||||
index.remove(netRegExp);
|
index.remove(netRegExp);
|
||||||
output = m_devices["net"][index.toInt()];
|
output = m_devices.network[index.toInt()];
|
||||||
} else if (_key.startsWith("pkgcount")) {
|
} else if (_key.startsWith("pkgcount")) {
|
||||||
auto item = m_extUpgrade->itemByTag(_key, stripped);
|
auto item = m_extUpgrade->itemByTag(_key, stripped);
|
||||||
if (item)
|
if (item)
|
||||||
@ -248,7 +240,7 @@ QString AWKeyOperations::infoByKey(const QString &_key) const
|
|||||||
} else if (_key.startsWith("temp")) {
|
} else if (_key.startsWith("temp")) {
|
||||||
auto index = _key;
|
auto index = _key;
|
||||||
index.remove("temp");
|
index.remove("temp");
|
||||||
output = m_devices["temp"][index.toInt()];
|
output = m_devices.sensors[index.toInt()];
|
||||||
} else if (_key.startsWith("response")) {
|
} else if (_key.startsWith("response")) {
|
||||||
auto item = m_extNetRequest->itemByTag(_key, stripped);
|
auto item = m_extNetRequest->itemByTag(_key, stripped);
|
||||||
if (item)
|
if (item)
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "extitemaggregator.h"
|
#include "extitemaggregator.h"
|
||||||
|
#include "matchers/awpluginmatchersettings.h"
|
||||||
|
|
||||||
|
|
||||||
class AWCustomKeysHelper;
|
class AWCustomKeysHelper;
|
||||||
@ -38,8 +39,7 @@ class AWKeyOperations : public QObject
|
|||||||
public:
|
public:
|
||||||
explicit AWKeyOperations(QObject *_parent = nullptr);
|
explicit AWKeyOperations(QObject *_parent = nullptr);
|
||||||
~AWKeyOperations() override = default;
|
~AWKeyOperations() override = default;
|
||||||
[[nodiscard]] QStringList devices(const QString &_type) const;
|
[[nodiscard]] AWPluginMatcherSettings devices() const;
|
||||||
[[nodiscard]] QHash<QString, QStringList> devices() const;
|
|
||||||
void updateCache();
|
void updateCache();
|
||||||
// keys
|
// keys
|
||||||
[[nodiscard]] QStringList dictKeys() const;
|
[[nodiscard]] QStringList dictKeys() const;
|
||||||
@ -73,6 +73,6 @@ private:
|
|||||||
ExtItemAggregator<ExtUpgrade> *m_extUpgrade = nullptr;
|
ExtItemAggregator<ExtUpgrade> *m_extUpgrade = nullptr;
|
||||||
ExtItemAggregator<ExtWeather> *m_extWeather = nullptr;
|
ExtItemAggregator<ExtWeather> *m_extWeather = nullptr;
|
||||||
// variables
|
// variables
|
||||||
QHash<QString, QStringList> m_devices;
|
AWPluginMatcherSettings m_devices;
|
||||||
QString m_pattern;
|
QString m_pattern;
|
||||||
};
|
};
|
||||||
|
@ -231,24 +231,10 @@ void AWKeys::updateTextData()
|
|||||||
// specified pattern. Usually they are values which depend on several others
|
// specified pattern. Usually they are values which depend on several others
|
||||||
void AWKeys::calculateValues()
|
void AWKeys::calculateValues()
|
||||||
{
|
{
|
||||||
// hddtot*
|
auto devices = m_keyOperator->devices();
|
||||||
auto mountDevices = m_keyOperator->devices("mount");
|
|
||||||
for (auto &device : mountDevices) {
|
|
||||||
auto index = mountDevices.indexOf(device);
|
|
||||||
m_values[QString("hddtotmb%1").arg(index)] = m_values[QString("hddfreemb%1").arg(index)].toDouble()
|
|
||||||
+ m_values[QString("hddmb%1").arg(index)].toDouble();
|
|
||||||
m_values[QString("hddtotgb%1").arg(index)] = m_values[QString("hddfreegb%1").arg(index)].toDouble()
|
|
||||||
+ m_values[QString("hddgb%1").arg(index)].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 = m_keyOperator->devices("net").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)];
|
||||||
m_values["downkb"] = m_values[QString("downkb%1").arg(netIndex)];
|
m_values["downkb"] = m_values[QString("downkb%1").arg(netIndex)];
|
||||||
m_values["downtot"] = m_values[QString("downtot%1").arg(netIndex)];
|
m_values["downtot"] = m_values[QString("downtot%1").arg(netIndex)];
|
||||||
@ -260,12 +246,6 @@ 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*
|
|
||||||
m_values["swaptotmb"] = m_values["swapmb"].toLongLong() + m_values["swapfreemb"].toLongLong();
|
|
||||||
m_values["swaptotgb"] = m_values["swapgb"].toDouble() + m_values["swapfreegb"].toDouble();
|
|
||||||
// swap
|
|
||||||
m_values["swap"] = 100.0 * m_values["swapmb"].toDouble() / m_values["swaptotmb"].toDouble();
|
|
||||||
|
|
||||||
// user defined keys
|
// user defined keys
|
||||||
for (auto &key : m_keyOperator->userKeys())
|
for (auto &key : m_keyOperator->userKeys())
|
||||||
m_values[key] = m_values[m_keyOperator->userKeySource(key)];
|
m_values[key] = m_values[m_keyOperator->userKeySource(key)];
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -17,15 +17,9 @@
|
|||||||
|
|
||||||
#include "awkeysaggregator.h"
|
#include "awkeysaggregator.h"
|
||||||
|
|
||||||
#include <KI18n/KLocalizedString>
|
|
||||||
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QLocale>
|
|
||||||
|
|
||||||
#include "awdataenginemapper.h"
|
#include "awdataenginemapper.h"
|
||||||
#include "awdebug.h"
|
#include "awdebug.h"
|
||||||
#include "awformatterhelper.h"
|
#include "awformatterhelper.h"
|
||||||
#include "version.h"
|
|
||||||
|
|
||||||
|
|
||||||
AWKeysAggregator::AWKeysAggregator(QObject *_parent)
|
AWKeysAggregator::AWKeysAggregator(QObject *_parent)
|
||||||
@ -33,19 +27,38 @@ AWKeysAggregator::AWKeysAggregator(QObject *_parent)
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
||||||
|
|
||||||
m_customFormatters = new AWFormatterHelper(this);
|
m_settings.customFormatters = new AWFormatterHelper(this);
|
||||||
m_mapper = new AWDataEngineMapper(this, m_customFormatters);
|
m_mapper = new AWDataEngineMapper(this, m_settings.customFormatters);
|
||||||
|
|
||||||
// sort time keys
|
|
||||||
m_timeKeys = QString(TIME_KEYS).split(',');
|
|
||||||
m_timeKeys.sort();
|
|
||||||
std::reverse(m_timeKeys.begin(), m_timeKeys.end());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWKeysAggregator::initFormatters()
|
void AWKeysAggregator::initFormatters()
|
||||||
{
|
{
|
||||||
m_customFormatters->initItems();
|
m_settings.customFormatters->initItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AWKeysAggregator::acOffline() const
|
||||||
|
{
|
||||||
|
return m_settings.acOffline;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AWKeysAggregator::acOnline() const
|
||||||
|
{
|
||||||
|
return m_settings.acOnline;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AWKeysAggregator::customTime() const
|
||||||
|
{
|
||||||
|
return m_settings.customTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AWKeysAggregator::customUptime() const
|
||||||
|
{
|
||||||
|
return m_settings.customUptime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -53,113 +66,7 @@ QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key,
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Data" << _data << "for key" << _key;
|
qCDebug(LOG_AW) << "Data" << _data << "for key" << _key;
|
||||||
|
|
||||||
QString output;
|
auto output = m_mapper->formatter(_key)->format(_data, _key, m_settings);
|
||||||
QLocale loc = m_translate ? QLocale::system() : QLocale::c();
|
|
||||||
// case block
|
|
||||||
switch (m_mapper->formatter(_key)) {
|
|
||||||
case FormatterType::Float:
|
|
||||||
output = QString("%1").arg(_data.toDouble(), 5, 'f', 1);
|
|
||||||
break;
|
|
||||||
case FormatterType::FloatTwoSymbols:
|
|
||||||
output = QString("%1").arg(_data.toDouble(), 5, 'f', 2);
|
|
||||||
break;
|
|
||||||
case FormatterType::Integer:
|
|
||||||
output = QString("%1").arg(_data.toDouble(), 4, 'f', 0);
|
|
||||||
break;
|
|
||||||
case FormatterType::IntegerFive:
|
|
||||||
output = QString("%1").arg(_data.toDouble(), 5, 'f', 0);
|
|
||||||
break;
|
|
||||||
case FormatterType::IntegerThree:
|
|
||||||
output = QString("%1").arg(_data.toDouble(), 3, 'f', 0);
|
|
||||||
break;
|
|
||||||
case FormatterType::List:
|
|
||||||
output = _data.toStringList().join(',');
|
|
||||||
break;
|
|
||||||
case FormatterType::ACFormat:
|
|
||||||
output = _data.toBool() ? m_acOnline : m_acOffline;
|
|
||||||
break;
|
|
||||||
case FormatterType::MemGBFormat:
|
|
||||||
output = QString("%1").arg(_data.toDouble() / GBinBytes, 5, 'f', 1);
|
|
||||||
break;
|
|
||||||
case FormatterType::MemMBFormat:
|
|
||||||
output = QString("%1").arg(_data.toDouble() / MBinBytes, 5, 'f', 0);
|
|
||||||
break;
|
|
||||||
case FormatterType::MemKBFormat:
|
|
||||||
output = QString("%1").arg(_data.toDouble() / KBinBytes, 5, 'f', 0);
|
|
||||||
break;
|
|
||||||
case FormatterType::NetSmartFormat:
|
|
||||||
output = [](const double value) {
|
|
||||||
if (value > MBinBytes)
|
|
||||||
return QString("%1").arg(value / MBinBytes, 4, 'f', 1);
|
|
||||||
else
|
|
||||||
return QString("%1").arg(value / KBinBytes, 4, 'f', 0);
|
|
||||||
}(_data.toDouble());
|
|
||||||
break;
|
|
||||||
case FormatterType::NetSmartUnits:
|
|
||||||
if (_data.toDouble() > MBinBytes)
|
|
||||||
output = m_translate ? i18n("MB/s") : "MB/s";
|
|
||||||
else
|
|
||||||
output = m_translate ? i18n("KB/s") : "KB/s";
|
|
||||||
break;
|
|
||||||
case FormatterType::Quotes:
|
|
||||||
// first cast
|
|
||||||
output = QString("%1").arg(_data.toDouble(), 0, 'f');
|
|
||||||
output = output.rightJustified(8, QLatin1Char(' '), true);
|
|
||||||
break;
|
|
||||||
case FormatterType::Temperature:
|
|
||||||
output = QString("%1").arg(temperature(_data.toDouble()), 5, 'f', 1);
|
|
||||||
break;
|
|
||||||
case FormatterType::Time:
|
|
||||||
output = QDateTime::fromSecsSinceEpoch(_data.toLongLong()).toString();
|
|
||||||
break;
|
|
||||||
case FormatterType::TimeCustom:
|
|
||||||
output = m_customTime;
|
|
||||||
[&output, loc, this](const QDateTime &dt) {
|
|
||||||
for (auto &key : m_timeKeys)
|
|
||||||
output.replace(QString("$%1").arg(key), loc.toString(dt, key));
|
|
||||||
}(QDateTime::fromSecsSinceEpoch(_data.toLongLong()));
|
|
||||||
break;
|
|
||||||
case FormatterType::TimeISO:
|
|
||||||
output = QDateTime::fromSecsSinceEpoch(_data.toLongLong()).toString(Qt::ISODate);
|
|
||||||
break;
|
|
||||||
case FormatterType::TimeLong:
|
|
||||||
output = loc.toString(QDateTime::fromSecsSinceEpoch(_data.toLongLong()), QLocale::LongFormat);
|
|
||||||
break;
|
|
||||||
case FormatterType::TimeShort:
|
|
||||||
output = loc.toString(QDateTime::fromSecsSinceEpoch(_data.toLongLong()), QLocale::ShortFormat);
|
|
||||||
break;
|
|
||||||
case FormatterType::Timestamp:
|
|
||||||
output = _data.toString();
|
|
||||||
break;
|
|
||||||
case FormatterType::Uptime:
|
|
||||||
case FormatterType::UptimeCustom:
|
|
||||||
output =
|
|
||||||
[](auto source, auto uptime) {
|
|
||||||
auto seconds = uptime - uptime % 60;
|
|
||||||
auto minutes = seconds / 60 % 60;
|
|
||||||
auto hours = ((seconds / 60) - minutes) / 60 % 24;
|
|
||||||
auto days = (((seconds / 60) - minutes) / 60 - hours) / 24;
|
|
||||||
|
|
||||||
source.replace("$dd", QString("%1").arg(days, 3, 10, QChar('0')));
|
|
||||||
source.replace("$d", QString("%1").arg(days));
|
|
||||||
source.replace("$hh", QString("%1").arg(hours, 2, 10, QChar('0')));
|
|
||||||
source.replace("$h", QString("%1").arg(hours));
|
|
||||||
source.replace("$mm", QString("%1").arg(minutes, 2, 10, QChar('0')));
|
|
||||||
source.replace("$m", QString("%1").arg(minutes));
|
|
||||||
|
|
||||||
return source;
|
|
||||||
}(m_mapper->formatter(_key) == FormatterType::Uptime ? "$ddd$hhh$mmm" : m_customUptime,
|
|
||||||
static_cast<int>(_data.toDouble()));
|
|
||||||
break;
|
|
||||||
case FormatterType::NoFormat:
|
|
||||||
output = _data.toString();
|
|
||||||
break;
|
|
||||||
case FormatterType::Custom:
|
|
||||||
if (m_customFormatters)
|
|
||||||
output = m_customFormatters->convert(_data, _key);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// replace spaces to non-breakable ones
|
// replace spaces to non-breakable ones
|
||||||
replaceSpace &= (!_key.startsWith("custom") && (!_key.startsWith("weather")));
|
replaceSpace &= (!_key.startsWith("custom") && (!_key.startsWith("weather")));
|
||||||
if (replaceSpace)
|
if (replaceSpace)
|
||||||
@ -177,11 +84,23 @@ QStringList AWKeysAggregator::keysFromSource(const QString &_source) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AWKeysAggregator::tempUnits() const
|
||||||
|
{
|
||||||
|
return m_settings.tempUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWKeysAggregator::translate() const
|
||||||
|
{
|
||||||
|
return m_settings.translate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWKeysAggregator::setAcOffline(const QString &_inactive)
|
void AWKeysAggregator::setAcOffline(const QString &_inactive)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Inactive AC string" << _inactive;
|
qCDebug(LOG_AW) << "Inactive AC string" << _inactive;
|
||||||
|
|
||||||
m_acOffline = _inactive;
|
m_settings.acOffline = _inactive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -189,7 +108,7 @@ void AWKeysAggregator::setAcOnline(const QString &_active)
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Active AC string" << _active;
|
qCDebug(LOG_AW) << "Active AC string" << _active;
|
||||||
|
|
||||||
m_acOnline = _active;
|
m_settings.acOnline = _active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -197,7 +116,7 @@ void AWKeysAggregator::setCustomTime(const QString &_customTime)
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Format" << _customTime;
|
qCDebug(LOG_AW) << "Format" << _customTime;
|
||||||
|
|
||||||
m_customTime = _customTime;
|
m_settings.customTime = _customTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -205,15 +124,13 @@ void AWKeysAggregator::setCustomUptime(const QString &_customUptime)
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Format" << _customUptime;
|
qCDebug(LOG_AW) << "Format" << _customUptime;
|
||||||
|
|
||||||
m_customUptime = _customUptime;
|
m_settings.customUptime = _customUptime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWKeysAggregator::setDevices(const QHash<QString, QStringList> &_devices)
|
void AWKeysAggregator::setDevices(const AWPluginMatcherSettings &_settings)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Devices" << _devices;
|
m_mapper->setDevices(_settings);
|
||||||
|
|
||||||
m_mapper->setDevices(_devices);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -221,7 +138,7 @@ void AWKeysAggregator::setTempUnits(const QString &_units)
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Units" << _units;
|
qCDebug(LOG_AW) << "Units" << _units;
|
||||||
|
|
||||||
m_tempUnits = _units;
|
m_settings.tempUnits = _units;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -229,7 +146,7 @@ void AWKeysAggregator::setTranslate(const bool _translate)
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Translate" << _translate;
|
qCDebug(LOG_AW) << "Translate" << _translate;
|
||||||
|
|
||||||
m_translate = _translate;
|
m_settings.translate = _translate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -240,29 +157,3 @@ QStringList AWKeysAggregator::registerSource(const QString &_source, const KSysG
|
|||||||
|
|
||||||
return m_mapper->registerSource(_source, _units, _keys);
|
return m_mapper->registerSource(_source, _units, _keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double AWKeysAggregator::temperature(const double temp) const
|
|
||||||
{
|
|
||||||
qCDebug(LOG_AW) << "Temperature value" << temp;
|
|
||||||
|
|
||||||
auto converted = temp;
|
|
||||||
if (m_tempUnits == "Celsius") {
|
|
||||||
} else if (m_tempUnits == "Fahrenheit") {
|
|
||||||
converted = temp * 9.0f / 5.0 + 32.0;
|
|
||||||
} else if (m_tempUnits == "Kelvin") {
|
|
||||||
converted = temp + 273.15;
|
|
||||||
} else if (m_tempUnits == "Reaumur") {
|
|
||||||
converted = temp * 0.8;
|
|
||||||
} else if (m_tempUnits == "cm^-1") {
|
|
||||||
converted = (temp + 273.15) * 0.695;
|
|
||||||
} else if (m_tempUnits == "kJ/mol") {
|
|
||||||
converted = (temp + 273.15) * 8.31;
|
|
||||||
} else if (m_tempUnits == "kcal/mol") {
|
|
||||||
converted = (temp + 273.15) * 1.98;
|
|
||||||
} else {
|
|
||||||
qCWarning(LOG_AW) << "Invalid units" << m_tempUnits;
|
|
||||||
}
|
|
||||||
|
|
||||||
return converted;
|
|
||||||
}
|
|
||||||
|
@ -22,66 +22,41 @@
|
|||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "formatters/awpluginformatsettings.h"
|
||||||
|
#include "matchers/awpluginmatchersettings.h"
|
||||||
|
|
||||||
|
|
||||||
class AWFormatterHelper;
|
|
||||||
class AWDataEngineMapper;
|
class AWDataEngineMapper;
|
||||||
|
|
||||||
class AWKeysAggregator : public QObject
|
class AWKeysAggregator : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString acOffline MEMBER m_acOffline WRITE setAcOffline);
|
Q_PROPERTY(QString acOffline READ acOffline WRITE setAcOffline);
|
||||||
Q_PROPERTY(QString acOnline MEMBER m_acOnline WRITE setAcOnline);
|
Q_PROPERTY(QString acOnline READ acOnline WRITE setAcOnline);
|
||||||
Q_PROPERTY(QString customTime MEMBER m_customTime WRITE setCustomTime);
|
Q_PROPERTY(QString customTime READ customTime WRITE setCustomTime);
|
||||||
Q_PROPERTY(QString customUptime MEMBER m_customUptime WRITE setCustomUptime);
|
Q_PROPERTY(QString customUptime READ customUptime WRITE setCustomUptime);
|
||||||
Q_PROPERTY(QString tempUnits MEMBER m_tempUnits WRITE setTempUnits);
|
Q_PROPERTY(QString tempUnits READ tempUnits WRITE setTempUnits);
|
||||||
Q_PROPERTY(bool translate MEMBER m_translate WRITE setTranslate);
|
Q_PROPERTY(bool translate READ translate WRITE setTranslate);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class FormatterType {
|
|
||||||
// general formatters
|
|
||||||
Custom,
|
|
||||||
NoFormat,
|
|
||||||
Float,
|
|
||||||
FloatTwoSymbols,
|
|
||||||
Integer,
|
|
||||||
IntegerFive,
|
|
||||||
IntegerThree,
|
|
||||||
List,
|
|
||||||
// unit specific formatters
|
|
||||||
ACFormat,
|
|
||||||
MemGBFormat,
|
|
||||||
MemMBFormat,
|
|
||||||
MemKBFormat,
|
|
||||||
NetSmartFormat,
|
|
||||||
NetSmartUnits,
|
|
||||||
Quotes,
|
|
||||||
Temperature,
|
|
||||||
Time,
|
|
||||||
TimeCustom,
|
|
||||||
TimeISO,
|
|
||||||
TimeLong,
|
|
||||||
TimeShort,
|
|
||||||
Timestamp,
|
|
||||||
Uptime,
|
|
||||||
UptimeCustom
|
|
||||||
};
|
|
||||||
|
|
||||||
static constexpr double KBinBytes = 1024.0;
|
|
||||||
static constexpr double MBinBytes = 1024.0 * KBinBytes;
|
|
||||||
static constexpr double GBinBytes = 1024.0 * MBinBytes;
|
|
||||||
|
|
||||||
explicit AWKeysAggregator(QObject *_parent = nullptr);
|
explicit AWKeysAggregator(QObject *_parent = nullptr);
|
||||||
~AWKeysAggregator() override = default;
|
~AWKeysAggregator() override = default;
|
||||||
void initFormatters();
|
void initFormatters();
|
||||||
// get methods
|
// get methods
|
||||||
|
[[nodiscard]] QString acOffline() const;
|
||||||
|
[[nodiscard]] QString acOnline() const;
|
||||||
|
[[nodiscard]] QString customTime() const;
|
||||||
|
[[nodiscard]] QString customUptime() const;
|
||||||
[[nodiscard]] QString formatter(const QVariant &_data, const QString &_key, bool replaceSpace) const;
|
[[nodiscard]] QString formatter(const QVariant &_data, const QString &_key, bool replaceSpace) const;
|
||||||
[[nodiscard]] QStringList keysFromSource(const QString &_source) const;
|
[[nodiscard]] QStringList keysFromSource(const QString &_source) const;
|
||||||
|
[[nodiscard]] QString tempUnits() const;
|
||||||
|
[[nodiscard]] bool translate() const;
|
||||||
// set methods
|
// set methods
|
||||||
void setAcOffline(const QString &_inactive);
|
void setAcOffline(const QString &_inactive);
|
||||||
void setAcOnline(const QString &_active);
|
void setAcOnline(const QString &_active);
|
||||||
void setCustomTime(const QString &_customTime);
|
void setCustomTime(const QString &_customTime);
|
||||||
void setCustomUptime(const QString &_customUptime);
|
void setCustomUptime(const QString &_customUptime);
|
||||||
void setDevices(const QHash<QString, QStringList> &_devices);
|
void setDevices(const AWPluginMatcherSettings &_settings);
|
||||||
void setTempUnits(const QString &_units);
|
void setTempUnits(const QString &_units);
|
||||||
void setTranslate(bool _translate);
|
void setTranslate(bool _translate);
|
||||||
|
|
||||||
@ -89,15 +64,6 @@ public slots:
|
|||||||
QStringList registerSource(const QString &_source, KSysGuard::Unit _units, const QStringList &_keys);
|
QStringList registerSource(const QString &_source, KSysGuard::Unit _units, const QStringList &_keys);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
[[nodiscard]] double temperature(double temp) const;
|
AWPluginFormatSettings m_settings;
|
||||||
AWFormatterHelper *m_customFormatters = nullptr;
|
|
||||||
AWDataEngineMapper *m_mapper = nullptr;
|
AWDataEngineMapper *m_mapper = nullptr;
|
||||||
QStringList m_timeKeys;
|
|
||||||
// variables
|
|
||||||
QString m_acOffline;
|
|
||||||
QString m_acOnline;
|
|
||||||
QString m_customTime;
|
|
||||||
QString m_customUptime;
|
|
||||||
QString m_tempUnits;
|
|
||||||
bool m_translate = false;
|
|
||||||
};
|
};
|
||||||
|
@ -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:
|
|
||||||
};
|
};
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
class AWKeysAggregator;
|
class AWKeysAggregator;
|
||||||
|
|
||||||
namespace AWPatternFunctions
|
namespace __attribute__((visibility("default"))) AWPatternFunctions
|
||||||
{
|
{
|
||||||
typedef struct {
|
typedef struct {
|
||||||
QStringList args;
|
QStringList args;
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
|
||||||
class AWTelemetryHandler : public QObject
|
class __attribute__((visibility("default"))) AWTelemetryHandler : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 <QString>
|
||||||
|
|
||||||
|
|
||||||
|
class AWFormatterHelper;
|
||||||
|
|
||||||
|
struct AWPluginFormatSettings {
|
||||||
|
QString acOffline;
|
||||||
|
QString acOnline;
|
||||||
|
|
||||||
|
QString customTime;
|
||||||
|
QString customUptime;
|
||||||
|
|
||||||
|
QString tempUnits;
|
||||||
|
|
||||||
|
bool translate = false;
|
||||||
|
|
||||||
|
AWFormatterHelper *customFormatters = nullptr;
|
||||||
|
};
|
69
sources/awesome-widget/plugin/formatters/awpluginformatter.h
Normal file
69
sources/awesome-widget/plugin/formatters/awpluginformatter.h
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 <QLocale>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "awpluginformatsettings.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormaterInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~AWPluginFormaterInterface() = default;
|
||||||
|
[[nodiscard]] virtual QString format(const QVariant &_value, const QString &_key,
|
||||||
|
const AWPluginFormatSettings &_settings) const
|
||||||
|
= 0;
|
||||||
|
virtual void load(){};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <typename Formatter> class AWPluginFormatter : public AWPluginFormaterInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr double KBinBytes = 1024.0;
|
||||||
|
static constexpr double MBinBytes = 1024.0 * KBinBytes;
|
||||||
|
static constexpr double GBinBytes = 1024.0 * MBinBytes;
|
||||||
|
|
||||||
|
AWPluginFormatter(AWPluginFormatter &) = delete;
|
||||||
|
void operator=(const AWPluginFormatter &) = delete;
|
||||||
|
|
||||||
|
[[nodiscard]] static Formatter *instance()
|
||||||
|
{
|
||||||
|
static auto instance = loadInstance();
|
||||||
|
return instance.get();
|
||||||
|
};
|
||||||
|
|
||||||
|
[[nodiscard]] static QLocale locale(const AWPluginFormatSettings &_settings)
|
||||||
|
{
|
||||||
|
return _settings.translate ? QLocale::system() : QLocale::c();
|
||||||
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
AWPluginFormatter() = default;
|
||||||
|
|
||||||
|
[[nodiscard]] static std::unique_ptr<Formatter> loadInstance()
|
||||||
|
{
|
||||||
|
auto instance = std::make_unique<Formatter>();
|
||||||
|
instance->load();
|
||||||
|
return instance;
|
||||||
|
};
|
||||||
|
};
|
@ -0,0 +1,25 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatterac.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterAC::format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &_settings) const
|
||||||
|
{
|
||||||
|
return _value.toBool() ? _settings.acOnline : _settings.acOffline;
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterAC : public AWPluginFormatter<AWPluginFormatterAC>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &_settings) const override;
|
||||||
|
};
|
@ -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/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "awpluginformattercustom.h"
|
||||||
|
|
||||||
|
#include "awformatterhelper.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterCustom::format(const QVariant &_value, const QString &_key,
|
||||||
|
const AWPluginFormatSettings &_settings) const
|
||||||
|
{
|
||||||
|
if (_settings.customFormatters)
|
||||||
|
return _settings.customFormatters->convert(_value, _key);
|
||||||
|
return _value.toString();
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterCustom : public AWPluginFormatter<AWPluginFormatterCustom>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &_key,
|
||||||
|
const AWPluginFormatSettings &_settings) const override;
|
||||||
|
};
|
@ -0,0 +1,25 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatterdouble.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterDouble::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const
|
||||||
|
{
|
||||||
|
auto output = QString("%1").arg(_value.toDouble(), 0, 'f');
|
||||||
|
return output.rightJustified(8, QLatin1Char(' '), true);
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterDouble : public AWPluginFormatter<AWPluginFormatterDouble>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &) const override;
|
||||||
|
};
|
@ -0,0 +1,24 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatterfloat.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterFloat::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const
|
||||||
|
{
|
||||||
|
return QString("%1").arg(_value.toDouble(), 5, 'f', 1);
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterFloat : public AWPluginFormatter<AWPluginFormatterFloat>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &) const override;
|
||||||
|
};
|
@ -0,0 +1,25 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatterfloatprecise.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterFloatPrecise::format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &) const
|
||||||
|
{
|
||||||
|
return QString("%1").arg(_value.toDouble(), 5, 'f', 2);
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterFloatPrecise : public AWPluginFormatter<AWPluginFormatterFloatPrecise>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &) const override;
|
||||||
|
};
|
@ -0,0 +1,24 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatterinteger.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterInteger::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const
|
||||||
|
{
|
||||||
|
return QString("%1").arg(_value.toDouble(), 4, 'f', 0);
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterInteger : public AWPluginFormatter<AWPluginFormatterInteger>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &) const override;
|
||||||
|
};
|
@ -0,0 +1,25 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatterintegershort.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterIntegerShort::format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &) const
|
||||||
|
{
|
||||||
|
return QString("%1").arg(_value.toDouble(), 3, 'f', 0);
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterIntegerShort : public AWPluginFormatter<AWPluginFormatterIntegerShort>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &) const override;
|
||||||
|
};
|
@ -0,0 +1,25 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatterintegerwide.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterIntegerWide::format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &) const
|
||||||
|
{
|
||||||
|
return QString("%1").arg(_value.toDouble(), 5, 'f', 0);
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterIntegerWide : public AWPluginFormatter<AWPluginFormatterIntegerWide>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &) const override;
|
||||||
|
};
|
@ -0,0 +1,24 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatterlist.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterList::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const
|
||||||
|
{
|
||||||
|
return _value.toStringList().join(",");
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterList : public AWPluginFormatter<AWPluginFormatterList>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &) const override;
|
||||||
|
};
|
@ -0,0 +1,24 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformattermemory.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterMemory::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const
|
||||||
|
{
|
||||||
|
return QString("%1").arg(_value.toDouble() / KBinBytes, 5, 'f', 0);
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterMemory : public AWPluginFormatter<AWPluginFormatterMemory>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &) const override;
|
||||||
|
};
|
@ -0,0 +1,24 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformattermemorygb.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterMemoryGB::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const
|
||||||
|
{
|
||||||
|
return QString("%1").arg(_value.toDouble() / GBinBytes, 5, 'f', 1);
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterMemoryGB : public AWPluginFormatter<AWPluginFormatterMemoryGB>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &) const override;
|
||||||
|
};
|
@ -0,0 +1,24 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformattermemorymb.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterMemoryMB::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const
|
||||||
|
{
|
||||||
|
return QString("%1").arg(_value.toDouble() / MBinBytes, 5, 'f', 0);
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterMemoryMB : public AWPluginFormatter<AWPluginFormatterMemoryMB>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &) const override;
|
||||||
|
};
|
@ -0,0 +1,37 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatternet.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterNet::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const
|
||||||
|
{
|
||||||
|
auto value = _value.toDouble();
|
||||||
|
return (value > MBinBytes) ? formatMB(value) : formatKB(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterNet::formatKB(const double &_value)
|
||||||
|
{
|
||||||
|
return QString("%1").arg(_value / KBinBytes, 4, 'f', 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterNet::formatMB(const double &_value)
|
||||||
|
{
|
||||||
|
return QString("%1").arg(_value / MBinBytes, 4, 'f', 1);
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterNet : public AWPluginFormatter<AWPluginFormatterNet>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
[[nodiscard]] static QString formatKB(const double &_value);
|
||||||
|
[[nodiscard]] static QString formatMB(const double &_value);
|
||||||
|
};
|
@ -0,0 +1,40 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatternetunits.h"
|
||||||
|
|
||||||
|
#include <KI18n/KLocalizedString>
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterNetUnits::format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &_settings) const
|
||||||
|
{
|
||||||
|
auto value = _value.toDouble();
|
||||||
|
return (value > MBinBytes) ? formatMB(_settings) : formatKB(_settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterNetUnits::formatKB(const AWPluginFormatSettings &_settings)
|
||||||
|
{
|
||||||
|
return _settings.translate ? i18n("KB/s") : "KB/s";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterNetUnits::formatMB(const AWPluginFormatSettings &_settings)
|
||||||
|
{
|
||||||
|
return _settings.translate ? i18n("MB/s") : "MB/s";
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterNetUnits : public AWPluginFormatter<AWPluginFormatterNetUnits>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &_settings) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
[[nodiscard]] static QString formatKB(const AWPluginFormatSettings &_settings);
|
||||||
|
[[nodiscard]] static QString formatMB(const AWPluginFormatSettings &_settings);
|
||||||
|
};
|
@ -0,0 +1,24 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatternoformat.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterNoFormat::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const
|
||||||
|
{
|
||||||
|
return _value.toString();
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterNoFormat : public AWPluginFormatter<AWPluginFormatterNoFormat>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &) const override;
|
||||||
|
};
|
@ -0,0 +1,48 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformattertemperature.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterTemperature::format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &_settings) const
|
||||||
|
{
|
||||||
|
auto converted = convert(_value.toDouble(), _settings.tempUnits);
|
||||||
|
return QString("%1").arg(converted, 5, 'f', 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double AWPluginFormatterTemperature::convert(const double &_value, const QString &_units)
|
||||||
|
{
|
||||||
|
auto converted = _value;
|
||||||
|
if (_units == "Celsius") {
|
||||||
|
} else if (_units == "Fahrenheit") {
|
||||||
|
converted = _value * 9.0f / 5.0 + 32.0;
|
||||||
|
} else if (_units == "Kelvin") {
|
||||||
|
converted = _value + 273.15;
|
||||||
|
} else if (_units == "Reaumur") {
|
||||||
|
converted = _value * 0.8;
|
||||||
|
} else if (_units == "cm^-1") {
|
||||||
|
converted = (_value + 273.15) * 0.695;
|
||||||
|
} else if (_units == "kJ/mol") {
|
||||||
|
converted = (_value + 273.15) * 8.31;
|
||||||
|
} else if (_units == "kcal/mol") {
|
||||||
|
converted = (_value + 273.15) * 1.98;
|
||||||
|
}
|
||||||
|
|
||||||
|
return converted;
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterTemperature : public AWPluginFormatter<AWPluginFormatterTemperature>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &_settings) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
[[nodiscard]] static double convert(const double &_value, const QString &_units);
|
||||||
|
};
|
@ -0,0 +1,26 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformattertime.h"
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterTime::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const
|
||||||
|
{
|
||||||
|
return QDateTime::fromSecsSinceEpoch(_value.toLongLong()).toString();
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterTime : public AWPluginFormatter<AWPluginFormatterTime>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &) const override;
|
||||||
|
};
|
@ -0,0 +1,46 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformattertimecustom.h"
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterTimeCustom::format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &_settings) const
|
||||||
|
{
|
||||||
|
auto value = QDateTime::fromSecsSinceEpoch(_value.toLongLong());
|
||||||
|
return format(value, _settings.customTime, locale(_settings));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWPluginFormatterTimeCustom::load()
|
||||||
|
{
|
||||||
|
m_timeKeys = QString(TIME_KEYS).split(',');
|
||||||
|
m_timeKeys.sort();
|
||||||
|
std::reverse(m_timeKeys.begin(), m_timeKeys.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterTimeCustom::format(const QDateTime &_value, QString _formatString,
|
||||||
|
const QLocale &_locale) const
|
||||||
|
{
|
||||||
|
for (auto &key : m_timeKeys)
|
||||||
|
_formatString.replace(QString("$%1").arg(key), _locale.toString(_value, key));
|
||||||
|
|
||||||
|
return _formatString;
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 <QDateTime>
|
||||||
|
|
||||||
|
#include "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterTimeCustom : public AWPluginFormatter<AWPluginFormatterTimeCustom>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &_settings) const override;
|
||||||
|
void load() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
[[nodiscard]] QString format(const QDateTime &_value, QString _formatString, const QLocale &_locale) const;
|
||||||
|
QStringList m_timeKeys;
|
||||||
|
};
|
@ -0,0 +1,26 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformattertimeiso.h"
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterTimeISO::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const
|
||||||
|
{
|
||||||
|
return QDateTime::fromSecsSinceEpoch(_value.toLongLong()).toString(Qt::ISODate);
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterTimeISO : public AWPluginFormatter<AWPluginFormatterTimeISO>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &) const override;
|
||||||
|
};
|
@ -0,0 +1,27 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformattertimelong.h"
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterTimeLong::format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &_settings) const
|
||||||
|
{
|
||||||
|
return locale(_settings).toString(QDateTime::fromSecsSinceEpoch(_value.toLongLong()), QLocale::LongFormat);
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterTimeLong : public AWPluginFormatter<AWPluginFormatterTimeLong>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &_settings) const override;
|
||||||
|
};
|
@ -0,0 +1,27 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformattertimeshort.h"
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterTimeShort::format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &_settings) const
|
||||||
|
{
|
||||||
|
return locale(_settings).toString(QDateTime::fromSecsSinceEpoch(_value.toLongLong()), QLocale::ShortFormat);
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterTimeShort : public AWPluginFormatter<AWPluginFormatterTimeShort>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &_settings) const override;
|
||||||
|
};
|
@ -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 "awpluginformatteruptime.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterUptime::format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &_settings) const
|
||||||
|
{
|
||||||
|
auto value = static_cast<long>(_value.toDouble());
|
||||||
|
return format(value, _settings.customUptime);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AWPluginFormatterUptime::format(const long &_value, QString _formatString)
|
||||||
|
{
|
||||||
|
auto seconds = _value - _value % 60;
|
||||||
|
auto minutes = seconds / 60 % 60;
|
||||||
|
auto hours = ((seconds / 60) - minutes) / 60 % 24;
|
||||||
|
auto days = (((seconds / 60) - minutes) / 60 - hours) / 24;
|
||||||
|
|
||||||
|
_formatString.replace("$dd", QString("%1").arg(days, 3, 10, QChar('0')));
|
||||||
|
_formatString.replace("$d", QString("%1").arg(days));
|
||||||
|
_formatString.replace("$hh", QString("%1").arg(hours, 2, 10, QChar('0')));
|
||||||
|
_formatString.replace("$h", QString("%1").arg(hours));
|
||||||
|
_formatString.replace("$mm", QString("%1").arg(minutes, 2, 10, QChar('0')));
|
||||||
|
_formatString.replace("$m", QString("%1").arg(minutes));
|
||||||
|
|
||||||
|
return _formatString;
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatter.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormatterUptime : public AWPluginFormatter<AWPluginFormatterUptime>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QString format(const QVariant &_value, const QString &,
|
||||||
|
const AWPluginFormatSettings &_settings) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
[[nodiscard]] static QString format(const long &_value, QString _formatString);
|
||||||
|
};
|
39
sources/awesome-widget/plugin/formatters/formatters.h
Normal file
39
sources/awesome-widget/plugin/formatters/formatters.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginformatterac.h"
|
||||||
|
#include "awpluginformattercustom.h"
|
||||||
|
#include "awpluginformatterdouble.h"
|
||||||
|
#include "awpluginformatterfloat.h"
|
||||||
|
#include "awpluginformatterfloatprecise.h"
|
||||||
|
#include "awpluginformatterinteger.h"
|
||||||
|
#include "awpluginformatterintegershort.h"
|
||||||
|
#include "awpluginformatterintegerwide.h"
|
||||||
|
#include "awpluginformatterlist.h"
|
||||||
|
#include "awpluginformattermemory.h"
|
||||||
|
#include "awpluginformattermemorygb.h"
|
||||||
|
#include "awpluginformattermemorymb.h"
|
||||||
|
#include "awpluginformatternet.h"
|
||||||
|
#include "awpluginformatternetunits.h"
|
||||||
|
#include "awpluginformatternoformat.h"
|
||||||
|
#include "awpluginformattertemperature.h"
|
||||||
|
#include "awpluginformattertime.h"
|
||||||
|
#include "awpluginformattertimecustom.h"
|
||||||
|
#include "awpluginformattertimeiso.h"
|
||||||
|
#include "awpluginformattertimelong.h"
|
||||||
|
#include "awpluginformattertimeshort.h"
|
||||||
|
#include "awpluginformatteruptime.h"
|
63
sources/awesome-widget/plugin/matchers/awpluginmatcher.h
Normal file
63
sources/awesome-widget/plugin/matchers/awpluginmatcher.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 <ksysguard/formatter/Unit.h>
|
||||||
|
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "awpluginmatchersettings.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWPluginFormaterInterface;
|
||||||
|
|
||||||
|
class AWPluginMatcherInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~AWPluginMatcherInterface() = default;
|
||||||
|
[[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;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <typename Matcher> class AWPluginMatcher : public AWPluginMatcherInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AWPluginMatcher(AWPluginMatcher &) = delete;
|
||||||
|
void operator=(const AWPluginMatcher &) = delete;
|
||||||
|
|
||||||
|
[[nodiscard]] static Matcher *instance()
|
||||||
|
{
|
||||||
|
static auto instance = std::make_unique<Matcher>();
|
||||||
|
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:
|
||||||
|
AWPluginMatcher() = default;
|
||||||
|
};
|
33
sources/awesome-widget/plugin/matchers/awpluginmatcherac.cpp
Normal file
33
sources/awesome-widget/plugin/matchers/awpluginmatcherac.cpp
Normal 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 "awpluginmatcherac.h"
|
||||||
|
|
||||||
|
#include "formatters/formatters.h"
|
||||||
|
|
||||||
|
|
||||||
|
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherAC::keys(const QString &, const KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const
|
||||||
|
{
|
||||||
|
return {{"ac", AWPluginFormatterAC::instance()}};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWPluginMatcherAC::matches(const QString &_source) const
|
||||||
|
{
|
||||||
|
return _source == "extsysmon/battery/ac";
|
||||||
|
}
|
29
sources/awesome-widget/plugin/matchers/awpluginmatcherac.h
Normal file
29
sources/awesome-widget/plugin/matchers/awpluginmatcherac.h
Normal 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 AWPluginMatcherAC : public AWPluginMatcher<AWPluginMatcherAC>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const override;
|
||||||
|
[[nodiscard]] bool matches(const QString &_source) const override;
|
||||||
|
};
|
@ -0,0 +1,38 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "awpluginmatcherbattery.h"
|
||||||
|
|
||||||
|
#include "formatters/formatters.h"
|
||||||
|
|
||||||
|
|
||||||
|
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherBattery::keys(const QString &_source, const KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const
|
||||||
|
{
|
||||||
|
auto key = _source;
|
||||||
|
key.remove("extsysmon/battery/");
|
||||||
|
|
||||||
|
if (key.contains("rate"))
|
||||||
|
return {{key, AWPluginFormatterFloat::instance()}};
|
||||||
|
return {{key, AWPluginFormatterIntegerShort::instance()}};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWPluginMatcherBattery::matches(const QString &_source) const
|
||||||
|
{
|
||||||
|
return _source.startsWith("extsysmon/battery/");
|
||||||
|
}
|
@ -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 AWPluginMatcherBattery : public AWPluginMatcher<AWPluginMatcherBattery>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &_source, KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const override;
|
||||||
|
[[nodiscard]] bool matches(const QString &_source) const override;
|
||||||
|
};
|
@ -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";
|
||||||
|
}
|
@ -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;
|
||||||
|
};
|
@ -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 "awpluginmatchercpu.h"
|
||||||
|
|
||||||
|
#include "formatters/formatters.h"
|
||||||
|
|
||||||
|
|
||||||
|
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherCPU::keys(const QString &, const KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const
|
||||||
|
{
|
||||||
|
return {{"cpu", AWPluginFormatterFloat::instance()}};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWPluginMatcherCPU::matches(const QString &_source) const
|
||||||
|
{
|
||||||
|
return _source == "cpu/all/usage";
|
||||||
|
}
|
29
sources/awesome-widget/plugin/matchers/awpluginmatchercpu.h
Normal file
29
sources/awesome-widget/plugin/matchers/awpluginmatchercpu.h
Normal 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 AWPluginMatcherCPU : public AWPluginMatcher<AWPluginMatcherCPU>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const override;
|
||||||
|
[[nodiscard]] bool matches(const QString &_source) const override;
|
||||||
|
};
|
@ -0,0 +1,38 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "awpluginmatchercpucore.h"
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
#include "formatters/formatters.h"
|
||||||
|
|
||||||
|
|
||||||
|
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherCPUCore::keys(const QString &_source, const KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const
|
||||||
|
{
|
||||||
|
auto key = _source;
|
||||||
|
key.remove("cpu/").remove("/usage");
|
||||||
|
return {{key, AWPluginFormatterFloat::instance()}};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWPluginMatcherCPUCore::matches(const QString &_source) const
|
||||||
|
{
|
||||||
|
static auto regexp = QRegularExpression("^cpu/cpu.*/usage$");
|
||||||
|
return _source.contains(regexp);
|
||||||
|
}
|
@ -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 AWPluginMatcherCPUCore : public AWPluginMatcher<AWPluginMatcherCPUCore>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &_source, KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const override;
|
||||||
|
[[nodiscard]] bool matches(const QString &_source) const override;
|
||||||
|
};
|
@ -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 "awpluginmatchercpufrequency.h"
|
||||||
|
|
||||||
|
#include "formatters/formatters.h"
|
||||||
|
|
||||||
|
|
||||||
|
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherCPUFrequency::keys(const QString &, const KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const
|
||||||
|
{
|
||||||
|
return {{"cpucl", AWPluginFormatterInteger::instance()}};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWPluginMatcherCPUFrequency::matches(const QString &_source) const
|
||||||
|
{
|
||||||
|
return _source == "cpu/all/averageFrequency";
|
||||||
|
}
|
@ -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 AWPluginMatcherCPUFrequency : public AWPluginMatcher<AWPluginMatcherCPUFrequency>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const override;
|
||||||
|
[[nodiscard]] bool matches(const QString &_source) const override;
|
||||||
|
};
|
@ -0,0 +1,39 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginmatchercpufrequencycore.h"
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
#include "formatters/formatters.h"
|
||||||
|
|
||||||
|
|
||||||
|
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherCPUFrequencyCore::keys(const QString &_source,
|
||||||
|
const KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const
|
||||||
|
{
|
||||||
|
auto index = _source;
|
||||||
|
index.remove("cpu/cpu").remove("/frequency");
|
||||||
|
return {{QString("cpucl%1").arg(index), AWPluginFormatterInteger::instance()}};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWPluginMatcherCPUFrequencyCore::matches(const QString &_source) const
|
||||||
|
{
|
||||||
|
static auto regexp = QRegularExpression("^cpu/cpu.*/frequency$");
|
||||||
|
return _source.contains(regexp);
|
||||||
|
}
|
@ -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 AWPluginMatcherCPUFrequencyCore : public AWPluginMatcher<AWPluginMatcherCPUFrequencyCore>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &_source, KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const override;
|
||||||
|
[[nodiscard]] bool matches(const QString &_source) const override;
|
||||||
|
};
|
@ -0,0 +1,35 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginmatchercustom.h"
|
||||||
|
|
||||||
|
#include "formatters/formatters.h"
|
||||||
|
|
||||||
|
|
||||||
|
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherCustom::keys(const QString &_source, const KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const
|
||||||
|
{
|
||||||
|
auto key = _source;
|
||||||
|
key.remove("extsysmon/custom/");
|
||||||
|
return {{key, AWPluginFormatterNoFormat::instance()}};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWPluginMatcherCustom::matches(const QString &_source) const
|
||||||
|
{
|
||||||
|
return _source.startsWith("extsysmon/custom/");
|
||||||
|
}
|
@ -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 AWPluginMatcherCustom : public AWPluginMatcher<AWPluginMatcherCustom>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &_source, KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const override;
|
||||||
|
[[nodiscard]] bool matches(const QString &_source) const override;
|
||||||
|
};
|
@ -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 "awpluginmatcherdesktop.h"
|
||||||
|
|
||||||
|
#include "formatters/formatters.h"
|
||||||
|
|
||||||
|
|
||||||
|
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherDesktop::keys(const QString &, const KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const
|
||||||
|
{
|
||||||
|
return {{"desktop", AWPluginFormatterNoFormat::instance()}};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWPluginMatcherDesktop::matches(const QString &_source) const
|
||||||
|
{
|
||||||
|
return _source == "extsysmon/desktop/name";
|
||||||
|
}
|
@ -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 AWPluginMatcherDesktop : public AWPluginMatcher<AWPluginMatcherDesktop>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const override;
|
||||||
|
[[nodiscard]] bool matches(const QString &_source) const override;
|
||||||
|
};
|
@ -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 "awpluginmatcherdesktopcount.h"
|
||||||
|
|
||||||
|
#include "formatters/formatters.h"
|
||||||
|
|
||||||
|
|
||||||
|
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherDesktopCount::keys(const QString &, const KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const
|
||||||
|
{
|
||||||
|
return {{"tdesktops", AWPluginFormatterNoFormat::instance()}};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWPluginMatcherDesktopCount::matches(const QString &_source) const
|
||||||
|
{
|
||||||
|
return _source == "extsysmon/desktop/count";
|
||||||
|
}
|
@ -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 AWPluginMatcherDesktopCount : public AWPluginMatcher<AWPluginMatcherDesktopCount>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const override;
|
||||||
|
[[nodiscard]] bool matches(const QString &_source) const override;
|
||||||
|
};
|
@ -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 "awpluginmatcherdesktopnumber.h"
|
||||||
|
|
||||||
|
#include "formatters/formatters.h"
|
||||||
|
|
||||||
|
|
||||||
|
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherDesktopNumber::keys(const QString &, const KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const
|
||||||
|
{
|
||||||
|
return {{"ndesktop", AWPluginFormatterNoFormat::instance()}};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWPluginMatcherDesktopNumber::matches(const QString &_source) const
|
||||||
|
{
|
||||||
|
return _source == "extsysmon/desktop/number";
|
||||||
|
}
|
@ -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 AWPluginMatcherDesktopNumber : public AWPluginMatcher<AWPluginMatcherDesktopNumber>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const override;
|
||||||
|
[[nodiscard]] bool matches(const QString &_source) const override;
|
||||||
|
};
|
@ -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 "awpluginmatchergpu.h"
|
||||||
|
|
||||||
|
#include "formatters/formatters.h"
|
||||||
|
|
||||||
|
|
||||||
|
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherGPU::keys(const QString &, const KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const
|
||||||
|
{
|
||||||
|
return {{"gpu", AWPluginFormatterFloat::instance()}};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWPluginMatcherGPU::matches(const QString &_source) const
|
||||||
|
{
|
||||||
|
return _source == "gpu/all/usage";
|
||||||
|
}
|
29
sources/awesome-widget/plugin/matchers/awpluginmatchergpu.h
Normal file
29
sources/awesome-widget/plugin/matchers/awpluginmatchergpu.h
Normal 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 AWPluginMatcherGPU : public AWPluginMatcher<AWPluginMatcherGPU>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &) const override;
|
||||||
|
[[nodiscard]] bool matches(const QString &_source) const override;
|
||||||
|
};
|
@ -0,0 +1,40 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginmatchergpucore.h"
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
#include "formatters/formatters.h"
|
||||||
|
|
||||||
|
|
||||||
|
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherGPUCore::keys(const QString &_source, const KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &_settings) const
|
||||||
|
{
|
||||||
|
auto index = AWPluginMatcher::index(_source, _settings.gpu);
|
||||||
|
if (index == -1)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
return {{QString("gpu%1").arg(index), AWPluginFormatterFloat::instance()}};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWPluginMatcherGPUCore::matches(const QString &_source) const
|
||||||
|
{
|
||||||
|
static auto regexp = QRegularExpression("^gpu/gpu.*/usage$");
|
||||||
|
return _source.contains(regexp);
|
||||||
|
}
|
@ -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 AWPluginMatcherGPUCore : public AWPluginMatcher<AWPluginMatcherGPUCore>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *>
|
||||||
|
keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override;
|
||||||
|
[[nodiscard]] bool matches(const QString &_source) const override;
|
||||||
|
};
|
@ -0,0 +1,41 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginmatchergputemperature.h"
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
#include "formatters/formatters.h"
|
||||||
|
|
||||||
|
|
||||||
|
QHash<QString, AWPluginFormaterInterface *>
|
||||||
|
AWPluginMatcherGPUTemperature::keys(const QString &_source, const KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &_settings) const
|
||||||
|
{
|
||||||
|
auto index = AWPluginMatcher::index(_source, _settings.gpu);
|
||||||
|
if (index == -1)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
return {{QString("gputemp%1").arg(index), AWPluginFormatterTemperature::instance()}};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWPluginMatcherGPUTemperature::matches(const QString &_source) const
|
||||||
|
{
|
||||||
|
static auto regexp = QRegularExpression("^gpu/gpu.*/temperature$");
|
||||||
|
return _source.contains(regexp);
|
||||||
|
}
|
@ -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 AWPluginMatcherGPUTemperature : public AWPluginMatcher<AWPluginMatcherGPUTemperature>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *>
|
||||||
|
keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override;
|
||||||
|
[[nodiscard]] bool matches(const QString &_source) const override;
|
||||||
|
};
|
@ -0,0 +1,40 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginmatcherhdd.h"
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
#include "formatters/formatters.h"
|
||||||
|
|
||||||
|
|
||||||
|
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherHDD::keys(const QString &_source, const KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &_settings) const
|
||||||
|
{
|
||||||
|
auto index = AWPluginMatcher::index(_source, _settings.disk);
|
||||||
|
if (index == -1)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
return {{QString("hdd%1").arg(index), AWPluginFormatterFloat::instance()}};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWPluginMatcherHDD::matches(const QString &_source) const
|
||||||
|
{
|
||||||
|
static auto regexp = QRegularExpression("^disk/.*/usedPercent$");
|
||||||
|
return _source.contains(regexp);
|
||||||
|
}
|
29
sources/awesome-widget/plugin/matchers/awpluginmatcherhdd.h
Normal file
29
sources/awesome-widget/plugin/matchers/awpluginmatcherhdd.h
Normal 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 AWPluginMatcherHDD : public AWPluginMatcher<AWPluginMatcherHDD>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *>
|
||||||
|
keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override;
|
||||||
|
[[nodiscard]] bool matches(const QString &_source) const override;
|
||||||
|
};
|
@ -0,0 +1,43 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginmatcherhddfree.h"
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
#include "formatters/formatters.h"
|
||||||
|
|
||||||
|
|
||||||
|
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherHDDFree::keys(const QString &_source, const KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &_settings) const
|
||||||
|
{
|
||||||
|
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()},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWPluginMatcherHDDFree::matches(const QString &_source) const
|
||||||
|
{
|
||||||
|
static auto regexp = QRegularExpression("^disk/.*/free$");
|
||||||
|
return _source.contains(regexp);
|
||||||
|
}
|
@ -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 AWPluginMatcherHDDFree : public AWPluginMatcher<AWPluginMatcherHDDFree>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *>
|
||||||
|
keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override;
|
||||||
|
[[nodiscard]] bool matches(const QString &_source) const override;
|
||||||
|
};
|
@ -0,0 +1,40 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awpluginmatcherhddread.h"
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
#include "formatters/formatters.h"
|
||||||
|
|
||||||
|
|
||||||
|
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherHDDRead::keys(const QString &_source, const KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &_settings) const
|
||||||
|
{
|
||||||
|
auto index = AWPluginMatcher::index(_source, _settings.disk);
|
||||||
|
if (index == -1)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
return {{QString("hddr%1").arg(index), AWPluginFormatterMemory::instance()}};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWPluginMatcherHDDRead::matches(const QString &_source) const
|
||||||
|
{
|
||||||
|
static auto regexp = QRegularExpression("^disk/.*/read$");
|
||||||
|
return _source.contains(regexp);
|
||||||
|
}
|
@ -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 AWPluginMatcherHDDRead : public AWPluginMatcher<AWPluginMatcherHDDRead>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *>
|
||||||
|
keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override;
|
||||||
|
[[nodiscard]] bool matches(const QString &_source) const override;
|
||||||
|
};
|
@ -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 "awpluginmatcherhddtotal.h"
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
#include "formatters/formatters.h"
|
||||||
|
|
||||||
|
|
||||||
|
QHash<QString, AWPluginFormaterInterface *>
|
||||||
|
AWPluginMatcherHDDTotal::keys(const QString &_source, const KSysGuard::Unit,
|
||||||
|
const AWPluginMatcherSettings &_settings) const
|
||||||
|
{
|
||||||
|
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()},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWPluginMatcherHDDTotal::matches(const QString &_source) const
|
||||||
|
{
|
||||||
|
static auto regexp = QRegularExpression("^disk/.*/total$");
|
||||||
|
return _source.contains(regexp);
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user