mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-05-04 12:23:49 +00:00
Compare commits
2 Commits
803d6d631a
...
cee37c6a4a
Author | SHA1 | Date | |
---|---|---|---|
cee37c6a4a | |||
0fcfb7d7e4 |
75
sources/3rdparty/fontdialog/fontdialog.cpp
vendored
75
sources/3rdparty/fontdialog/fontdialog.cpp
vendored
@ -39,81 +39,6 @@ void CFont::setCurrentColor(const QColor color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int CFont::html2QFont(const int htmlWeight)
|
|
||||||
{
|
|
||||||
int weight = 16;
|
|
||||||
switch(htmlWeight) {
|
|
||||||
case 100:
|
|
||||||
weight = 16;
|
|
||||||
break;
|
|
||||||
case 200:
|
|
||||||
case 300:
|
|
||||||
weight = 25;
|
|
||||||
break;
|
|
||||||
case 400:
|
|
||||||
weight = 50;
|
|
||||||
break;
|
|
||||||
case 500:
|
|
||||||
case 600:
|
|
||||||
weight = 63;
|
|
||||||
break;
|
|
||||||
case 700:
|
|
||||||
case 800:
|
|
||||||
weight = 75;
|
|
||||||
break;
|
|
||||||
case 900:
|
|
||||||
weight = 87;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return weight;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CFont::qFont2html(const int weight)
|
|
||||||
{
|
|
||||||
int htmlWeight = 400;
|
|
||||||
switch(weight) {
|
|
||||||
case 16:
|
|
||||||
htmlWeight = 100;
|
|
||||||
break;
|
|
||||||
case 25:
|
|
||||||
htmlWeight = 300;
|
|
||||||
break;
|
|
||||||
case 50:
|
|
||||||
htmlWeight = 400;
|
|
||||||
break;
|
|
||||||
case 63:
|
|
||||||
htmlWeight = 600;
|
|
||||||
break;
|
|
||||||
case 75:
|
|
||||||
htmlWeight = 800;
|
|
||||||
break;
|
|
||||||
case 87:
|
|
||||||
htmlWeight = 900;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return htmlWeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CFont::htmlWeight()
|
|
||||||
{
|
|
||||||
return CFont::qFont2html(weight());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CFont::setHtmlWeight(const int htmlWeight)
|
|
||||||
{
|
|
||||||
setWeight(CFont::html2QFont(htmlWeight));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CFont CFont::fromQFont(const QFont font, const QColor color)
|
CFont CFont::fromQFont(const QFont font, const QColor color)
|
||||||
{
|
{
|
||||||
return CFont(font.family(), font.pointSize(), font.weight(), font.italic(), color);
|
return CFont(font.family(), font.pointSize(), font.weight(), font.italic(), color);
|
||||||
|
5
sources/3rdparty/fontdialog/fontdialog.h
vendored
5
sources/3rdparty/fontdialog/fontdialog.h
vendored
@ -34,11 +34,6 @@ public:
|
|||||||
// color properties
|
// color properties
|
||||||
QColor color();
|
QColor color();
|
||||||
void setCurrentColor(const QColor color);
|
void setCurrentColor(const QColor color);
|
||||||
// html weight properties
|
|
||||||
static int html2QFont(const int htmlWeight);
|
|
||||||
static int qFont2html(const int weight);
|
|
||||||
int htmlWeight();
|
|
||||||
void setHtmlWeight(const int htmlWeight);
|
|
||||||
// conversion to QFont
|
// conversion to QFont
|
||||||
static CFont fromQFont(const QFont font,
|
static CFont fromQFont(const QFont font,
|
||||||
const QColor color = QColor(QString("#000000")));
|
const QColor color = QColor(QString("#000000")));
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#include <QQmlPropertyMap>
|
#include <QQmlPropertyMap>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QTextCodec>
|
|
||||||
|
|
||||||
#include "awdebug.h"
|
#include "awdebug.h"
|
||||||
|
|
||||||
@ -285,7 +284,6 @@ void AWConfigHelper::writeFile(QSettings &_settings, const QString &_key, const
|
|||||||
QFile file(_fileName);
|
QFile file(_fileName);
|
||||||
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
QTextStream out(&file);
|
QTextStream out(&file);
|
||||||
out.setCodec("UTF-8");
|
|
||||||
out << _settings.value(_key).toString().toUtf8();
|
out << _settings.value(_key).toString().toUtf8();
|
||||||
out.flush();
|
out.flush();
|
||||||
file.close();
|
file.close();
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
|
|
||||||
#include "awdataengineaggregator.h"
|
#include "awdataengineaggregator.h"
|
||||||
|
|
||||||
#include <Plasma/DataContainer>
|
#include <QDBusConnection>
|
||||||
|
#include <ksysguard/systemstats/DBusInterface.h>
|
||||||
|
|
||||||
#include "awdebug.h"
|
#include "awdebug.h"
|
||||||
|
|
||||||
@ -27,20 +28,19 @@ AWDataEngineAggregator::AWDataEngineAggregator(QObject *_parent)
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
||||||
|
|
||||||
m_consumer = new Plasma::DataEngineConsumer();
|
qDBusRegisterMetaType<KSysGuard::SensorData>();
|
||||||
m_dataEngines["systemmonitor"] = m_consumer->dataEngine("systemmonitor");
|
qDBusRegisterMetaType<KSysGuard::SensorInfo>();
|
||||||
m_dataEngines["extsysmon"] = m_consumer->dataEngine("extsysmon");
|
qDBusRegisterMetaType<KSysGuard::SensorDataList>();
|
||||||
m_dataEngines["time"] = m_consumer->dataEngine("time");
|
qDBusRegisterMetaType<QHash<QString, KSysGuard::SensorInfo>>();
|
||||||
|
|
||||||
// additional method required by systemmonitor structure
|
m_interface = new KSysGuard::SystemStats::DBusInterface(
|
||||||
m_newSourceConnection
|
KSysGuard::SystemStats::ServiceName, KSysGuard::SystemStats::ObjectPath, QDBusConnection::sessionBus(), this);
|
||||||
= connect(m_dataEngines["systemmonitor"], &Plasma::DataEngine::sourceAdded, [this](const QString &source) {
|
connect(m_interface, SIGNAL(newSensorData(KSysGuard::SensorDataList)), this,
|
||||||
emit(deviceAdded(source));
|
SLOT(updateData(KSysGuard::SensorDataList)));
|
||||||
m_dataEngines["systemmonitor"]->connectSource(source, parent(), 1000);
|
connect(m_interface, SIGNAL(sensorAdded(const QString &)), this, SLOT(sensorAdded(const QString &)));
|
||||||
});
|
connect(m_interface, SIGNAL(sensorMetaDataChanged(const QHash<QString, KSysGuard::SensorInfo> &)), this,
|
||||||
|
SLOT(updateSensor(const QHash<QString, KSysGuard::SensorInfo> &)));
|
||||||
// required to define Qt::QueuedConnection for signal-slot connection
|
connect(m_interface, SIGNAL(sensorRemoved(const QString &)), this, SLOT(sensorRemoved(const QString &)));
|
||||||
qRegisterMetaType<Plasma::DataEngine::Data>("Plasma::DataEngine::Data");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -54,62 +54,5 @@ AWDataEngineAggregator::~AWDataEngineAggregator()
|
|||||||
|
|
||||||
void AWDataEngineAggregator::disconnectSources()
|
void AWDataEngineAggregator::disconnectSources()
|
||||||
{
|
{
|
||||||
for (auto dataEngine : m_dataEngines.values())
|
m_interface->unsubscribe(m_sensors.values());
|
||||||
for (auto &source : dataEngine->sources())
|
|
||||||
dataEngine->disconnectSource(source, parent());
|
|
||||||
disconnect(m_newSourceConnection);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AWDataEngineAggregator::reconnectSources(const int _interval)
|
|
||||||
{
|
|
||||||
qCDebug(LOG_AW) << "Reconnect sources with interval" << _interval;
|
|
||||||
|
|
||||||
disconnectSources();
|
|
||||||
|
|
||||||
m_dataEngines["systemmonitor"]->connectAllSources(parent(), (uint)_interval);
|
|
||||||
m_dataEngines["extsysmon"]->connectAllSources(parent(), (uint)_interval);
|
|
||||||
m_dataEngines["time"]->connectSource("Local", parent(), 1000);
|
|
||||||
|
|
||||||
m_newSourceConnection = connect(
|
|
||||||
m_dataEngines["systemmonitor"], &Plasma::DataEngine::sourceAdded, [this, _interval](const QString &source) {
|
|
||||||
emit(deviceAdded(source));
|
|
||||||
m_dataEngines["systemmonitor"]->connectSource(source, parent(), (uint)_interval);
|
|
||||||
});
|
|
||||||
|
|
||||||
#ifdef BUILD_FUTURE
|
|
||||||
createQueuedConnection();
|
|
||||||
#endif /* BUILD_FUTURE */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AWDataEngineAggregator::dropSource(const QString &_source)
|
|
||||||
{
|
|
||||||
qCDebug(LOG_AW) << "Source" << _source;
|
|
||||||
|
|
||||||
// HACK there is no possibility to check to which dataengine source
|
|
||||||
// connected we will try to disconnect it from all engines
|
|
||||||
for (auto dataEngine : m_dataEngines.values())
|
|
||||||
dataEngine->disconnectSource(_source, parent());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AWDataEngineAggregator::createQueuedConnection()
|
|
||||||
{
|
|
||||||
// HACK additional method which forces QueuedConnection instead of Auto one
|
|
||||||
// for more details refer to plasma-framework source code
|
|
||||||
for (auto &dataEngine : m_dataEngines.keys()) {
|
|
||||||
// different source set for different engines
|
|
||||||
QStringList sources = dataEngine == "time" ? QStringList() << "Local" : m_dataEngines[dataEngine]->sources();
|
|
||||||
// reconnect sources
|
|
||||||
for (auto &source : sources) {
|
|
||||||
Plasma::DataContainer *container = m_dataEngines[dataEngine]->containerForSource(source);
|
|
||||||
// disconnect old connections first
|
|
||||||
disconnect(container, SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data)), parent(),
|
|
||||||
SLOT(dataUpdated(QString, Plasma::DataEngine::Data)));
|
|
||||||
// and now reconnect with Qt::QueuedConnection type
|
|
||||||
connect(container, SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data)), parent(),
|
|
||||||
SLOT(dataUpdated(QString, Plasma::DataEngine::Data)), Qt::QueuedConnection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,16 @@
|
|||||||
#ifndef AWDATAENGINEAGGREGATOR_H
|
#ifndef AWDATAENGINEAGGREGATOR_H
|
||||||
#define AWDATAENGINEAGGREGATOR_H
|
#define AWDATAENGINEAGGREGATOR_H
|
||||||
|
|
||||||
#include <Plasma/DataEngine>
|
#include <ksysguard/systemstats/SensorInfo.h>
|
||||||
#include <Plasma/DataEngineConsumer>
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QSet>
|
||||||
|
|
||||||
|
|
||||||
|
namespace KSysGuard::SystemStats
|
||||||
|
{
|
||||||
|
class DBusInterface;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class AWDataEngineAggregator : public QObject
|
class AWDataEngineAggregator : public QObject
|
||||||
@ -33,19 +39,20 @@ public:
|
|||||||
explicit AWDataEngineAggregator(QObject *_parent = nullptr);
|
explicit AWDataEngineAggregator(QObject *_parent = nullptr);
|
||||||
~AWDataEngineAggregator() override;
|
~AWDataEngineAggregator() override;
|
||||||
void disconnectSources();
|
void disconnectSources();
|
||||||
void reconnectSources(int _interval);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deviceAdded(const QString &_source);
|
void deviceAdded(const QString &_source);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void dropSource(const QString &_source);
|
void sensorAdded(const QString &_sensor);
|
||||||
|
void sensorRemoved(const QString &_sensor);
|
||||||
|
void updateData(KSysGuard::SensorDataList _data);
|
||||||
|
void updateSensor(const QHash<QString, KSysGuard::SensorInfo> &_sensor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createQueuedConnection();
|
void createQueuedConnection();
|
||||||
Plasma::DataEngineConsumer *m_consumer = nullptr;
|
KSysGuard::SystemStats::DBusInterface *m_interface = nullptr;
|
||||||
QHash<QString, Plasma::DataEngine *> m_dataEngines;
|
QSet<QString> m_sensors;
|
||||||
QMetaObject::Connection m_newSourceConnection;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include "awdataenginemapper.h"
|
#include "awdataenginemapper.h"
|
||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#include "awdebug.h"
|
#include "awdebug.h"
|
||||||
#include "awformatterhelper.h"
|
#include "awformatterhelper.h"
|
||||||
@ -81,15 +81,15 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
|||||||
qCDebug(LOG_AW) << "Source" << _source << "with units" << _units;
|
qCDebug(LOG_AW) << "Source" << _source << "with units" << _units;
|
||||||
|
|
||||||
// regular expressions
|
// regular expressions
|
||||||
QRegExp cpuRegExp = QRegExp("cpu/cpu.*/TotalLoad");
|
auto cpuRegExp = QRegularExpression("cpu/cpu.*/TotalLoad");
|
||||||
QRegExp cpuclRegExp = QRegExp("cpu/cpu.*/clock");
|
auto cpuclRegExp = QRegularExpression("cpu/cpu.*/clock");
|
||||||
QRegExp hddrRegExp = QRegExp("disk/.*/Rate/rblk");
|
auto hddrRegExp = QRegularExpression("disk/.*/Rate/rblk");
|
||||||
QRegExp hddwRegExp = QRegExp("disk/.*/Rate/wblk");
|
auto hddwRegExp = QRegularExpression("disk/.*/Rate/wblk");
|
||||||
QRegExp mountFillRegExp = QRegExp("partitions/.*/filllevel");
|
auto mountFillRegExp = QRegularExpression("partitions/.*/filllevel");
|
||||||
QRegExp mountFreeRegExp = QRegExp("partitions/.*/freespace");
|
auto mountFreeRegExp = QRegularExpression("partitions/.*/freespace");
|
||||||
QRegExp mountUsedRegExp = QRegExp("partitions/.*/usedspace");
|
auto mountUsedRegExp = QRegularExpression("partitions/.*/usedspace");
|
||||||
QRegExp netRegExp = QRegExp("network/interfaces/.*/(receiver|transmitter)/data$");
|
auto netRegExp = QRegularExpression("network/interfaces/.*/(receiver|transmitter)/data$");
|
||||||
QRegExp netTotalRegExp = QRegExp("network/interfaces/.*/(receiver|transmitter)/dataTotal$");
|
auto netTotalRegExp = QRegularExpression("network/interfaces/.*/(receiver|transmitter)/dataTotal$");
|
||||||
|
|
||||||
if (_source == "battery/ac") {
|
if (_source == "battery/ac") {
|
||||||
// AC
|
// AC
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QNetworkInterface>
|
#include <QNetworkInterface>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ bool AWKeyCache::addKeyToCache(const QString &_type, const QString &_key)
|
|||||||
|
|
||||||
if (_type == "hdd") {
|
if (_type == "hdd") {
|
||||||
QStringList allDevices = QDir("/dev").entryList(QDir::System, QDir::Name);
|
QStringList allDevices = QDir("/dev").entryList(QDir::System, QDir::Name);
|
||||||
QStringList devices = allDevices.filter(QRegExp("^[hms]d[a-z]$"));
|
QStringList devices = allDevices.filter(QRegularExpression("^[hms]d[a-z]$"));
|
||||||
for (auto &dev : devices) {
|
for (auto &dev : devices) {
|
||||||
QString device = QString("/dev/%1").arg(dev);
|
QString device = QString("/dev/%1").arg(dev);
|
||||||
if (cachedValues.contains(device))
|
if (cachedValues.contains(device))
|
||||||
@ -93,7 +94,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
|
|||||||
|
|
||||||
// insert depending keys, refer to AWKeys::calculateValues()
|
// insert depending keys, refer to AWKeys::calculateValues()
|
||||||
// hddtotmb*
|
// hddtotmb*
|
||||||
for (auto &key : _allKeys.filter(QRegExp("^hddtotmb"))) {
|
for (auto &key : _allKeys.filter(QRegularExpression("^hddtotmb"))) {
|
||||||
if (!used.contains(key))
|
if (!used.contains(key))
|
||||||
continue;
|
continue;
|
||||||
key.remove("hddtotmb");
|
key.remove("hddtotmb");
|
||||||
@ -101,7 +102,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
|
|||||||
used << QString("hddfreemb%1").arg(index) << QString("hddmb%1").arg(index);
|
used << QString("hddfreemb%1").arg(index) << QString("hddmb%1").arg(index);
|
||||||
}
|
}
|
||||||
// hddtotgb*
|
// hddtotgb*
|
||||||
for (auto &key : _allKeys.filter(QRegExp("^hddtotgb"))) {
|
for (auto &key : _allKeys.filter(QRegularExpression("^hddtotgb"))) {
|
||||||
if (!used.contains(key))
|
if (!used.contains(key))
|
||||||
continue;
|
continue;
|
||||||
key.remove("hddtotgb");
|
key.remove("hddtotgb");
|
||||||
@ -138,7 +139,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
|
|||||||
for (auto &key : netKeys) {
|
for (auto &key : netKeys) {
|
||||||
if (!used.contains(key))
|
if (!used.contains(key))
|
||||||
continue;
|
continue;
|
||||||
QStringList filt = _allKeys.filter(QRegExp(QString("^%1[0-9]{1,}").arg(key)));
|
QStringList filt = _allKeys.filter(QRegularExpression(QString("^%1[0-9]{1,}").arg(key)));
|
||||||
for (auto &filtered : filt)
|
for (auto &filtered : filt)
|
||||||
used << filtered;
|
used << filtered;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "awkeyoperations.h"
|
#include "awkeyoperations.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
#include "awcustomkeyshelper.h"
|
#include "awcustomkeyshelper.h"
|
||||||
@ -206,7 +206,7 @@ QString AWKeyOperations::infoByKey(const QString &_key) const
|
|||||||
qCDebug(LOG_AW) << "Requested key" << _key;
|
qCDebug(LOG_AW) << "Requested key" << _key;
|
||||||
|
|
||||||
QString stripped = _key;
|
QString stripped = _key;
|
||||||
stripped.remove(QRegExp("\\d+"));
|
stripped.remove(QRegularExpression("\\d+"));
|
||||||
QString output;
|
QString output;
|
||||||
|
|
||||||
if (_key.startsWith("bar")) {
|
if (_key.startsWith("bar")) {
|
||||||
@ -217,31 +217,31 @@ QString AWKeyOperations::infoByKey(const QString &_key) const
|
|||||||
AbstractExtItem *item = m_extScripts->itemByTag(_key, stripped);
|
AbstractExtItem *item = m_extScripts->itemByTag(_key, stripped);
|
||||||
if (item)
|
if (item)
|
||||||
output = item->uniq();
|
output = item->uniq();
|
||||||
} else if (_key.contains(QRegExp("^hdd[rw]"))) {
|
} else if (_key.contains(QRegularExpression("^hdd[rw]"))) {
|
||||||
QString index = _key;
|
QString index = _key;
|
||||||
index.remove(QRegExp("hdd[rw]"));
|
index.remove(QRegularExpression("hdd[rw]"));
|
||||||
output = m_devices["disk"][index.toInt()];
|
output = m_devices["disk"][index.toInt()];
|
||||||
} else if (_key.contains(QRegExp("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)"))) {
|
} else if (_key.contains(QRegularExpression("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)"))) {
|
||||||
QString index = _key;
|
QString index = _key;
|
||||||
index.remove(QRegExp("^hdd(|mb|gb|freemb|freegb|totmb|totgb)"));
|
index.remove(QRegularExpression("^hdd(|mb|gb|freemb|freegb|totmb|totgb)"));
|
||||||
output = m_devices["mount"][index.toInt()];
|
output = m_devices["mount"][index.toInt()];
|
||||||
} else if (_key.startsWith("hddtemp")) {
|
} else if (_key.startsWith("hddtemp")) {
|
||||||
QString index = _key;
|
QString index = _key;
|
||||||
index.remove("hddtemp");
|
index.remove("hddtemp");
|
||||||
output = m_devices["hdd"][index.toInt()];
|
output = m_devices["hdd"][index.toInt()];
|
||||||
} else if (_key.contains(QRegExp("^(down|up)[0-9]"))) {
|
} else if (_key.contains(QRegularExpression("^(down|up)[0-9]"))) {
|
||||||
QString index = _key;
|
QString index = _key;
|
||||||
index.remove(QRegExp("^(down|up)"));
|
index.remove(QRegularExpression("^(down|up)"));
|
||||||
output = m_devices["net"][index.toInt()];
|
output = m_devices["net"][index.toInt()];
|
||||||
} else if (_key.startsWith("pkgcount")) {
|
} else if (_key.startsWith("pkgcount")) {
|
||||||
AbstractExtItem *item = m_extUpgrade->itemByTag(_key, stripped);
|
AbstractExtItem *item = m_extUpgrade->itemByTag(_key, stripped);
|
||||||
if (item)
|
if (item)
|
||||||
output = item->uniq();
|
output = item->uniq();
|
||||||
} else if (_key.contains(QRegExp("(^|perc)(ask|bid|price)(chg|)"))) {
|
} else if (_key.contains(QRegularExpression("(^|perc)(ask|bid|price)(chg|)"))) {
|
||||||
AbstractExtItem *item = m_extQuotes->itemByTag(_key, stripped);
|
AbstractExtItem *item = m_extQuotes->itemByTag(_key, stripped);
|
||||||
if (item)
|
if (item)
|
||||||
output = item->uniq();
|
output = item->uniq();
|
||||||
} else if (_key.contains(QRegExp("(weather|weatherId|humidity|pressure|temperature)"))) {
|
} else if (_key.contains(QRegularExpression("(weather|weatherId|humidity|pressure|temperature)"))) {
|
||||||
AbstractExtItem *item = m_extWeather->itemByTag(_key, stripped);
|
AbstractExtItem *item = m_extWeather->itemByTag(_key, stripped);
|
||||||
if (item)
|
if (item)
|
||||||
output = item->uniq();
|
output = item->uniq();
|
||||||
@ -280,7 +280,7 @@ void AWKeyOperations::editItem(const QString &_type)
|
|||||||
qCDebug(LOG_AW) << "Item type" << _type;
|
qCDebug(LOG_AW) << "Item type" << _type;
|
||||||
|
|
||||||
if (_type == "graphicalitem") {
|
if (_type == "graphicalitem") {
|
||||||
QStringList keys = dictKeys().filter(QRegExp("^(cpu(?!cl).*|gpu$|mem$|swap$|hdd[0-9].*|bat.*)"));
|
QStringList keys = dictKeys().filter(QRegularExpression("^(cpu(?!cl).*|gpu$|mem$|swap$|hdd[0-9].*|bat.*)"));
|
||||||
keys.sort();
|
keys.sort();
|
||||||
m_graphicalItems->setConfigArgs(keys);
|
m_graphicalItems->setConfigArgs(keys);
|
||||||
return m_graphicalItems->editItems();
|
return m_graphicalItems->editItems();
|
||||||
@ -302,8 +302,8 @@ void AWKeyOperations::addDevice(const QString &_source)
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Source" << _source;
|
qCDebug(LOG_AW) << "Source" << _source;
|
||||||
|
|
||||||
QRegExp diskRegexp = QRegExp("disk/(?:md|sd|hd)[a-z|0-9]_.*/Rate/(?:rblk)");
|
auto diskRegexp = QRegularExpression("disk/(?:md|sd|hd)[a-z|0-9]_.*/Rate/(?:rblk)");
|
||||||
QRegExp mountRegexp = QRegExp("partitions/.*/filllevel");
|
auto mountRegexp = QRegularExpression("partitions/.*/filllevel");
|
||||||
|
|
||||||
if (_source.contains(diskRegexp)) {
|
if (_source.contains(diskRegexp)) {
|
||||||
QString device = _source;
|
QString device = _source;
|
||||||
|
@ -148,7 +148,7 @@ QStringList AWKeys::dictKeys(const bool _sorted, const QString &_regexp) const
|
|||||||
if (_sorted)
|
if (_sorted)
|
||||||
allKeys.sort();
|
allKeys.sort();
|
||||||
|
|
||||||
return allKeys.filter(QRegExp(_regexp));
|
return allKeys.filter(QRegularExpression(_regexp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -199,10 +199,11 @@ void AWKeys::editItem(const QString &_type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWKeys::dataUpdated(const QString &_sourceName, const Plasma::DataEngine::Data &_data)
|
void AWKeys::dataUpdated(const KSysGuard::SensorDataList &_data)
|
||||||
{
|
{
|
||||||
// run concurrent data update
|
// TODO use QtConcurrent::map or something like that
|
||||||
QtConcurrent::run(m_threadPool, this, &AWKeys::setDataBySource, _sourceName, _data);
|
for (auto &sensor : _data)
|
||||||
|
QtConcurrent::run(m_threadPool, this, &AWKeys::setDataBySource, sensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -351,9 +352,9 @@ QString AWKeys::parsePattern(QString _pattern) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWKeys::setDataBySource(const QString &_sourceName, const QVariantMap &_data)
|
void AWKeys::setDataBySource(const QString &_sourceName, const KSysGuard::SensorData &_data)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Source" << _sourceName << "with data" << _data;
|
qCDebug(LOG_AW) << "Source" << _sourceName << "with data" << _data.payload;
|
||||||
|
|
||||||
// first list init
|
// first list init
|
||||||
QStringList tags = m_aggregator->keysFromSource(_sourceName);
|
QStringList tags = m_aggregator->keysFromSource(_sourceName);
|
||||||
|
@ -19,11 +19,11 @@
|
|||||||
#ifndef AWKEYS_H
|
#ifndef AWKEYS_H
|
||||||
#define AWKEYS_H
|
#define AWKEYS_H
|
||||||
|
|
||||||
#include <Plasma/DataEngine>
|
|
||||||
|
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
#include <ksysguard/systemstats/SensorInfo.h>
|
||||||
|
|
||||||
|
|
||||||
class AWDataAggregator;
|
class AWDataAggregator;
|
||||||
class AWDataEngineAggregator;
|
class AWDataEngineAggregator;
|
||||||
@ -56,9 +56,7 @@ public:
|
|||||||
Q_INVOKABLE void editItem(const QString &_type);
|
Q_INVOKABLE void editItem(const QString &_type);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void dataUpdated(const QString &_sourceName, const Plasma::DataEngine::Data &_data);
|
void dataUpdated(const KSysGuard::SensorDataList &_data);
|
||||||
// dummy method required by DataEngine connections
|
|
||||||
static void modelChanged(const QString &, QAbstractItemModel *){};
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dropSourceFromDataengine(const QString &_source);
|
void dropSourceFromDataengine(const QString &_source);
|
||||||
@ -74,7 +72,7 @@ private:
|
|||||||
void calculateValues();
|
void calculateValues();
|
||||||
void createDBusInterface();
|
void createDBusInterface();
|
||||||
[[nodiscard]] QString parsePattern(QString _pattern) const;
|
[[nodiscard]] QString parsePattern(QString _pattern) const;
|
||||||
void setDataBySource(const QString &_sourceName, const QVariantMap &_data);
|
void setDataBySource(const KSysGuard::SensorData &_data);
|
||||||
// objects
|
// objects
|
||||||
AWDataAggregator *m_dataAggregator = nullptr;
|
AWDataAggregator *m_dataAggregator = nullptr;
|
||||||
AWDataEngineAggregator *m_dataEngineAggregator = nullptr;
|
AWDataEngineAggregator *m_dataEngineAggregator = nullptr;
|
||||||
|
@ -130,7 +130,7 @@ QString AWPatternFunctions::insertAllKeys(QString _code, const QStringList &_key
|
|||||||
QList<AWPatternFunctions::AWFunction> found = AWPatternFunctions::findFunctionCalls("aw_all", _code);
|
QList<AWPatternFunctions::AWFunction> found = AWPatternFunctions::findFunctionCalls("aw_all", _code);
|
||||||
for (auto &function : found) {
|
for (auto &function : found) {
|
||||||
QString separator = function.args.isEmpty() ? "," : function.args.at(0);
|
QString separator = function.args.isEmpty() ? "," : function.args.at(0);
|
||||||
QStringList required = _keys.filter(QRegExp(function.body));
|
QStringList required = _keys.filter(QRegularExpression(function.body));
|
||||||
std::for_each(required.begin(), required.end(), [](QString &value) { value = QString("%1: $%1").arg(value); });
|
std::for_each(required.begin(), required.end(), [](QString &value) { value = QString("%1: $%1").arg(value); });
|
||||||
|
|
||||||
_code.replace(function.what, required.join(separator));
|
_code.replace(function.what, required.join(separator));
|
||||||
@ -146,7 +146,7 @@ QString AWPatternFunctions::insertKeyCount(QString _code, const QStringList &_ke
|
|||||||
|
|
||||||
QList<AWPatternFunctions::AWFunction> found = AWPatternFunctions::findFunctionCalls("aw_count", _code);
|
QList<AWPatternFunctions::AWFunction> found = AWPatternFunctions::findFunctionCalls("aw_count", _code);
|
||||||
for (auto &function : found) {
|
for (auto &function : found) {
|
||||||
int count = _keys.filter(QRegExp(function.body)).count();
|
int count = _keys.filter(QRegularExpression(function.body)).count();
|
||||||
|
|
||||||
_code.replace(function.what, QString::number(count));
|
_code.replace(function.what, QString::number(count));
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ QString AWPatternFunctions::insertKeyNames(QString _code, const QStringList &_ke
|
|||||||
QList<AWPatternFunctions::AWFunction> found = AWPatternFunctions::findFunctionCalls("aw_names", _code);
|
QList<AWPatternFunctions::AWFunction> found = AWPatternFunctions::findFunctionCalls("aw_names", _code);
|
||||||
for (auto &function : found) {
|
for (auto &function : found) {
|
||||||
QString separator = function.args.isEmpty() ? "," : function.args.at(0);
|
QString separator = function.args.isEmpty() ? "," : function.args.at(0);
|
||||||
QStringList required = _keys.filter(QRegExp(function.body));
|
QStringList required = _keys.filter(QRegularExpression(function.body));
|
||||||
|
|
||||||
_code.replace(function.what, required.join(separator));
|
_code.replace(function.what, required.join(separator));
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ QString AWPatternFunctions::insertKeys(QString _code, const QStringList &_keys)
|
|||||||
QList<AWPatternFunctions::AWFunction> found = AWPatternFunctions::findFunctionCalls("aw_keys", _code);
|
QList<AWPatternFunctions::AWFunction> found = AWPatternFunctions::findFunctionCalls("aw_keys", _code);
|
||||||
for (auto &function : found) {
|
for (auto &function : found) {
|
||||||
QString separator = function.args.isEmpty() ? "," : function.args.at(0);
|
QString separator = function.args.isEmpty() ? "," : function.args.at(0);
|
||||||
QStringList required = _keys.filter(QRegExp(function.body));
|
QStringList required = _keys.filter(QRegularExpression(function.body));
|
||||||
std::for_each(required.begin(), required.end(), [](QString &value) { value = QString("$%1").arg(value); });
|
std::for_each(required.begin(), required.end(), [](QString &value) { value = QString("$%1").arg(value); });
|
||||||
|
|
||||||
_code.replace(function.what, required.join(separator));
|
_code.replace(function.what, required.join(separator));
|
||||||
|
@ -92,7 +92,7 @@ QStringList DPAdds::dictKeys(const bool _sorted, const QString &_regexp)
|
|||||||
if (_sorted)
|
if (_sorted)
|
||||||
allKeys.sort();
|
allKeys.sort();
|
||||||
|
|
||||||
return allKeys.filter(QRegExp(_regexp));
|
return allKeys.filter(QRegularExpression(_regexp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "extsysmon.h"
|
#include "extsysmon.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
@ -127,7 +128,7 @@ QHash<QString, QString> ExtendedSysMon::updateConfiguration(QHash<QString, QStri
|
|||||||
} else {
|
} else {
|
||||||
QStringList deviceList = _rawConfig["HDDDEV"].split(',', Qt::SkipEmptyParts);
|
QStringList deviceList = _rawConfig["HDDDEV"].split(',', Qt::SkipEmptyParts);
|
||||||
QStringList devices;
|
QStringList devices;
|
||||||
QRegExp diskRegexp = QRegExp("^/dev/[hms]d[a-z]$");
|
auto diskRegexp = QRegularExpression("^/dev/[hms]d[a-z]$");
|
||||||
for (auto &device : deviceList)
|
for (auto &device : deviceList)
|
||||||
if ((QFile::exists(device)) && (device.contains(diskRegexp)))
|
if ((QFile::exists(device)) && (device.contains(diskRegexp)))
|
||||||
devices.append(device);
|
devices.append(device);
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
static int index(const QString &_source)
|
static int index(const QString &_source)
|
||||||
{
|
{
|
||||||
QRegularExpression rx("\\d+");
|
QRegularExpression rx("\\d+");
|
||||||
return rx.globalMatch(_source).next().captured(1).toInt();
|
return rx.match(_source).captured().toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -22,8 +22,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_D
|
|||||||
find_package(KF6 REQUIRED COMPONENTS I18n Notifications Service WindowSystem)
|
find_package(KF6 REQUIRED COMPONENTS I18n Notifications Service WindowSystem)
|
||||||
find_package(LibTaskManager REQUIRED)
|
find_package(LibTaskManager REQUIRED)
|
||||||
find_package(Plasma REQUIRED)
|
find_package(Plasma REQUIRED)
|
||||||
|
find_package(KSysGuard REQUIRED)
|
||||||
include(KDEInstallDirs)
|
include(KDEInstallDirs)
|
||||||
include(KDECMakeSettings)
|
include(KDECMakeSettings)
|
||||||
include(KDECompilerSettings)
|
include(KDECompilerSettings)
|
||||||
set(Kf6_INCLUDE ${KDE_INSTALL_FULL_INCLUDEDIR_KF})
|
set(Kf6_INCLUDE ${KDE_INSTALL_FULL_INCLUDEDIR_KF})
|
||||||
set(Kf6_LIBRARIES KF6::I18n KF6::Notifications KF6::WindowSystem PW::LibTaskManager)
|
set(Kf6_LIBRARIES KF6::I18n KF6::Notifications KF6::WindowSystem KSysGuard::Sensors KSysGuard::SensorFaces PW::LibTaskManager)
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "testawpatternfunctions.h"
|
#include "testawpatternfunctions.h"
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
|
||||||
#include "awpatternfunctions.h"
|
#include "awpatternfunctions.h"
|
||||||
@ -57,7 +58,7 @@ void TestAWPatternFunctions::test_findKeys()
|
|||||||
QStringList allKeys;
|
QStringList allKeys;
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
auto key = AWTestLibrary::randomString(1, 20);
|
auto key = AWTestLibrary::randomString(1, 20);
|
||||||
while (allKeys.indexOf(QRegExp(QString("^%1.*").arg(key))) != -1)
|
while (allKeys.indexOf(QRegularExpression(QString("^%1.*").arg(key))) != -1)
|
||||||
key = AWTestLibrary::randomString(1, 20);
|
key = AWTestLibrary::randomString(1, 20);
|
||||||
allKeys.append(key);
|
allKeys.append(key);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user