port library

This commit is contained in:
2024-03-07 17:57:05 +02:00
parent 5fd3a4a21a
commit 0fcfb7d7e4
38 changed files with 208 additions and 139 deletions

View File

@ -7,7 +7,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../../${PROJECT_LIBRARY}/
${PROJECT_TRDPARTY_DIR}
${Qt_INCLUDE}
${Kf5_INCLUDE}
${Kf6_INCLUDE}
)
file(GLOB SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp ${CMAKE_SOURCE_DIR}/*.cpp)
@ -16,8 +16,8 @@ file(GLOB SUBPROJECT_NOTIFY *.notifyrc)
qt6_wrap_ui(SUBPROJECT_UI_HEADER ${SUBPROJECT_UI})
add_library(${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE} ${SUBPROJECT_UI_HEADER})
target_link_libraries(${PLUGIN_NAME} ${PROJECT_LIBRARY} ${Qt_LIBRARIES} ${Kf5_LIBRARIES})
target_link_libraries(${PLUGIN_NAME} ${PROJECT_LIBRARY} ${Qt_LIBRARIES} ${Kf6_LIBRARIES})
install(TARGETS ${PLUGIN_NAME} DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/awesomewidget)
install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/awesomewidget)
install(FILES ${SUBPROJECT_NOTIFY} DESTINATION ${KNOTIFYRC_INSTALL_DIR})
install(FILES ${SUBPROJECT_NOTIFY} DESTINATION ${KDE_INSTALL_KNOTIFYRCDIR})

View File

@ -17,7 +17,7 @@
#include "awdataenginemapper.h"
#include <QRegExp>
#include <QRegularExpression>
#include "awdebug.h"
#include "awformatterhelper.h"
@ -81,15 +81,15 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
qCDebug(LOG_AW) << "Source" << _source << "with units" << _units;
// regular expressions
QRegExp cpuRegExp = QRegExp("cpu/cpu.*/TotalLoad");
QRegExp cpuclRegExp = QRegExp("cpu/cpu.*/clock");
QRegExp hddrRegExp = QRegExp("disk/.*/Rate/rblk");
QRegExp hddwRegExp = QRegExp("disk/.*/Rate/wblk");
QRegExp mountFillRegExp = QRegExp("partitions/.*/filllevel");
QRegExp mountFreeRegExp = QRegExp("partitions/.*/freespace");
QRegExp mountUsedRegExp = QRegExp("partitions/.*/usedspace");
QRegExp netRegExp = QRegExp("network/interfaces/.*/(receiver|transmitter)/data$");
QRegExp netTotalRegExp = QRegExp("network/interfaces/.*/(receiver|transmitter)/dataTotal$");
auto cpuRegExp = QRegularExpression("cpu/cpu.*/TotalLoad");
auto cpuclRegExp = QRegularExpression("cpu/cpu.*/clock");
auto hddrRegExp = QRegularExpression("disk/.*/Rate/rblk");
auto hddwRegExp = QRegularExpression("disk/.*/Rate/wblk");
auto mountFillRegExp = QRegularExpression("partitions/.*/filllevel");
auto mountFreeRegExp = QRegularExpression("partitions/.*/freespace");
auto mountUsedRegExp = QRegularExpression("partitions/.*/usedspace");
auto netRegExp = QRegularExpression("network/interfaces/.*/(receiver|transmitter)/data$");
auto netTotalRegExp = QRegularExpression("network/interfaces/.*/(receiver|transmitter)/dataTotal$");
if (_source == "battery/ac") {
// AC

View File

@ -20,6 +20,7 @@
#include <QDir>
#include <QNetworkInterface>
#include <QRegularExpression>
#include <QSettings>
#include <QStandardPaths>
@ -42,7 +43,7 @@ bool AWKeyCache::addKeyToCache(const QString &_type, const QString &_key)
if (_type == "hdd") {
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) {
QString device = QString("/dev/%1").arg(dev);
if (cachedValues.contains(device))
@ -93,7 +94,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
// insert depending keys, refer to AWKeys::calculateValues()
// hddtotmb*
for (auto &key : _allKeys.filter(QRegExp("^hddtotmb"))) {
for (auto &key : _allKeys.filter(QRegularExpression("^hddtotmb"))) {
if (!used.contains(key))
continue;
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);
}
// hddtotgb*
for (auto &key : _allKeys.filter(QRegExp("^hddtotgb"))) {
for (auto &key : _allKeys.filter(QRegularExpression("^hddtotgb"))) {
if (!used.contains(key))
continue;
key.remove("hddtotgb");
@ -138,7 +139,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
for (auto &key : netKeys) {
if (!used.contains(key))
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)
used << filtered;
}

View File

@ -18,7 +18,7 @@
#include "awkeyoperations.h"
#include <QDir>
#include <QRegExp>
#include <QRegularExpression>
#include <QThread>
#include "awcustomkeyshelper.h"
@ -206,7 +206,7 @@ QString AWKeyOperations::infoByKey(const QString &_key) const
qCDebug(LOG_AW) << "Requested key" << _key;
QString stripped = _key;
stripped.remove(QRegExp("\\d+"));
stripped.remove(QRegularExpression("\\d+"));
QString output;
if (_key.startsWith("bar")) {
@ -217,31 +217,31 @@ QString AWKeyOperations::infoByKey(const QString &_key) const
AbstractExtItem *item = m_extScripts->itemByTag(_key, stripped);
if (item)
output = item->uniq();
} else if (_key.contains(QRegExp("^hdd[rw]"))) {
} else if (_key.contains(QRegularExpression("^hdd[rw]"))) {
QString index = _key;
index.remove(QRegExp("hdd[rw]"));
index.remove(QRegularExpression("hdd[rw]"));
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;
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()];
} else if (_key.startsWith("hddtemp")) {
QString index = _key;
index.remove("hddtemp");
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;
index.remove(QRegExp("^(down|up)"));
index.remove(QRegularExpression("^(down|up)"));
output = m_devices["net"][index.toInt()];
} else if (_key.startsWith("pkgcount")) {
AbstractExtItem *item = m_extUpgrade->itemByTag(_key, stripped);
if (item)
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);
if (item)
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);
if (item)
output = item->uniq();
@ -280,7 +280,7 @@ void AWKeyOperations::editItem(const QString &_type)
qCDebug(LOG_AW) << "Item type" << _type;
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();
m_graphicalItems->setConfigArgs(keys);
return m_graphicalItems->editItems();
@ -302,8 +302,8 @@ void AWKeyOperations::addDevice(const QString &_source)
{
qCDebug(LOG_AW) << "Source" << _source;
QRegExp diskRegexp = QRegExp("disk/(?:md|sd|hd)[a-z|0-9]_.*/Rate/(?:rblk)");
QRegExp mountRegexp = QRegExp("partitions/.*/filllevel");
auto diskRegexp = QRegularExpression("disk/(?:md|sd|hd)[a-z|0-9]_.*/Rate/(?:rblk)");
auto mountRegexp = QRegularExpression("partitions/.*/filllevel");
if (_source.contains(diskRegexp)) {
QString device = _source;

View File

@ -148,7 +148,7 @@ QStringList AWKeys::dictKeys(const bool _sorted, const QString &_regexp) const
if (_sorted)
allKeys.sort();
return allKeys.filter(QRegExp(_regexp));
return allKeys.filter(QRegularExpression(_regexp));
}

View File

@ -130,7 +130,7 @@ QString AWPatternFunctions::insertAllKeys(QString _code, const QStringList &_key
QList<AWPatternFunctions::AWFunction> found = AWPatternFunctions::findFunctionCalls("aw_all", _code);
for (auto &function : found) {
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); });
_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);
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));
}
@ -162,7 +162,7 @@ QString AWPatternFunctions::insertKeyNames(QString _code, const QStringList &_ke
QList<AWPatternFunctions::AWFunction> found = AWPatternFunctions::findFunctionCalls("aw_names", _code);
for (auto &function : found) {
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));
}
@ -178,7 +178,7 @@ QString AWPatternFunctions::insertKeys(QString _code, const QStringList &_keys)
QList<AWPatternFunctions::AWFunction> found = AWPatternFunctions::findFunctionCalls("aw_keys", _code);
for (auto &function : found) {
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); });
_code.replace(function.what, required.join(separator));