Compare commits

..

17 Commits

Author SHA1 Message Date
63f1aa8125 release alpha2 2024-03-27 02:36:13 +02:00
3c8bf1baf1 test cases update 2024-03-27 02:30:08 +02:00
3f20aa8878 massive qml edit 2024-03-27 01:45:35 +02:00
4fcea42e8e qml improvements 2024-03-26 15:41:34 +02:00
0b2b58bd33 gpu support 2024-03-26 10:39:09 +02:00
7b60e8a42f disablle deskttop soourec 2024-03-25 15:31:42 +02:00
161ff64293 Release 4.0.0 2024-03-25 14:04:30 +02:00
115bef3dbe correct subscription processing 2024-03-24 00:42:03 +02:00
b6ade7310a extend temperature sensors 2024-03-23 15:30:35 +02:00
0555185044 add time source 2024-03-23 15:11:49 +02:00
23e197789f make it build together 2024-03-23 13:57:28 +02:00
67640cccdc do not derive from qwidget in aggregates 2024-03-22 16:57:47 +02:00
33a41bb6c0 do not derive from qwidget 2024-03-21 16:51:29 +02:00
42c11a6b60 port dataengin 2024-03-20 18:45:17 +02:00
423597dbd9 port widget to dbus 2024-03-15 15:51:23 +02:00
0fcfb7d7e4 port library 2024-03-08 16:22:00 +02:00
5fd3a4a21a update to plasma 6 support 2024-03-07 12:09:46 +02:00
180 changed files with 1925 additions and 936 deletions

View File

@ -58,7 +58,7 @@ CFontDialog::CFontDialog(QWidget *parent, bool needWeight, bool needItalic)
setLayout(mainGrid);
colorBox = new QComboBox(this);
connect(colorBox, &QComboBox::currentTextChanged, this, &CFontDialog::updateColor);
connect(colorBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateColor(QString)));
QStringList colorNames = QColor::colorNames();
int index = 0;
for (int i=0; i<colorNames.count(); i++) {
@ -81,8 +81,8 @@ CFontDialog::CFontDialog(QWidget *parent, bool needWeight, bool needItalic)
buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
Qt::Horizontal, this);
QObject::connect(buttons, &QDialogButtonBox::accepted, this, &CFontDialog::accept);
QObject::connect(buttons, &QDialogButtonBox::rejected, this, &CFontDialog::reject);
QObject::connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
QObject::connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
mainGrid->addWidget(buttons, 1, 0, 1, 5);
italicBox->setHidden(!needItalic);

View File

@ -15,7 +15,8 @@
* License along with this library. *
***************************************************************************/
#pragma once
#ifndef FONTDIALOG_H
#define FONTDIALOG_H
#include <QComboBox>
#include <QDialog>
@ -71,3 +72,6 @@ private:
QSpinBox *sizeBox;
QSpinBox *weightBox;
};
#endif /* FONTDIALOG_H */

View File

@ -12,7 +12,7 @@ QReplyTimeout::QReplyTimeout(QNetworkReply *reply, const int timeout)
void QReplyTimeout::timeout()
{
auto reply = dynamic_cast<QNetworkReply *>(parent());
auto *reply = dynamic_cast<QNetworkReply *>(parent());
if (reply->isRunning())
reply->close();
}

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWDEBUG_H
#define AWDEBUG_H
#include <QLoggingCategory>
@ -40,3 +42,6 @@ Q_DECLARE_LOGGING_CATEGORY(LOG_DP)
Q_DECLARE_LOGGING_CATEGORY(LOG_ESM)
Q_DECLARE_LOGGING_CATEGORY(LOG_ESS)
Q_DECLARE_LOGGING_CATEGORY(LOG_LIB)
#endif /* AWDEBUG_H */

View File

@ -18,8 +18,7 @@
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
import org.kde.plasma.private.awesomewidget 1.0
KCM.SimpleKCM {

View File

@ -19,8 +19,7 @@ import QtQuick 2.15
import QtQuick.Controls
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
import org.kde.plasma.private.awesomewidget 1.0
KCM.SimpleKCM {

View File

@ -18,8 +18,8 @@
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
import org.kde.plasma.private.awesomewidget 1.0
import "."
KCM.SimpleKCM {

View File

@ -19,8 +19,7 @@ import QtQuick 2.15
import QtQuick.Controls
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
import org.kde.plasma.private.awesomewidget 1.0
KCM.SimpleKCM {
@ -191,6 +190,10 @@ KCM.SimpleKCM {
Component.onCompleted: {
// init submodule
awKeys.updateCache()
// update hdd model
hdd.model = awKeys.getHddDevices()
hdd.onCompleted
}
Component.onDestruction: {

View File

@ -22,8 +22,8 @@ import QtQuick.Layouts
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
import org.kde.plasma.private.awesomewidget 1.0
import "."
PlasmoidItem {

View File

@ -0,0 +1,27 @@
# Do not edit qmldir directly it will be overrided during compilation,
# edit qml/qmldir.in file instead.
# common QML constants
singleton General 1.0 file:///usr/share/awesomewidgets/qml/General.qml
# custom QML UI classes
AboutTab file:///usr/share/awesomewidgets/qml/AboutTab.qml
AWExtensions file:///usr/share/awesomewidgets/qml/AWExtensions.qml
AWInfoLabel file:///usr/share/awesomewidgets/qml/AWInfoLabel.qml
AWTagSelector file:///usr/share/awesomewidgets/qml/AWTagSelector.qml
AWTextEditor file:///usr/share/awesomewidgets/qml/AWTextEditor.qml
BugReport file:///usr/share/awesomewidgets/qml/BugReport.qml
ButtonSelector file:///usr/share/awesomewidgets/qml/ButtonSelector.qml
CheckBoxSelector file:///usr/share/awesomewidgets/qml/CheckBoxSelector.qml
ColorSelector file:///usr/share/awesomewidgets/qml/ColorSelector.qml
ComboBoxSelector file:///usr/share/awesomewidgets/qml/ComboBoxSelector.qml
ExportDialog file:///usr/share/awesomewidgets/qml/ExportDialog.qml
FontSelector file:///usr/share/awesomewidgets/qml/FontSelector.qml
HtmlDefaultFunctionsBar file:///usr/share/awesomewidgets/qml/HtmlDefaultFunctionsBar.qml
HtmlEditorButton file:///usr/share/awesomewidgets/qml/HtmlEditorButton.qml
HtmlEditorColor file:///usr/share/awesomewidgets/qml/HtmlEditorColor.qml
HtmlEditorFont file:///usr/share/awesomewidgets/qml/HtmlEditorFont.qml
ImportDialog file:///usr/share/awesomewidgets/qml/ImportDialog.qml
IntegerSelector file:///usr/share/awesomewidgets/qml/IntegerSelector.qml
LineSelector file:///usr/share/awesomewidgets/qml/LineSelector.qml

View File

@ -19,8 +19,7 @@ import QtQuick 2.15
import QtQuick.Controls
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
import org.kde.plasma.private.awesomewidget 1.0
KCM.SimpleKCM {

View File

@ -19,8 +19,8 @@ import QtQuick 2.15
import QtQuick.Controls
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
import org.kde.plasma.private.awesomewidget 1.0
import "."
KCM.SimpleKCM {

View File

@ -37,13 +37,13 @@ AWAbstractPairConfig::AWAbstractPairConfig(QWidget *_parent, const bool _hasEdit
ui->setupUi(this);
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &AWAbstractPairConfig::accept);
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &AWAbstractPairConfig::reject);
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
// edit feature
if (m_hasEdit) {
m_editButton = ui->buttonBox->addButton(i18n("Edit"), QDialogButtonBox::ActionRole);
connect(m_editButton, &QPushButton::clicked, [this]() { return edit(); });
connect(m_editButton, SIGNAL(clicked(bool)), this, SLOT(edit()));
}
}
@ -84,14 +84,14 @@ void AWAbstractPairConfig::edit()
void AWAbstractPairConfig::updateUi()
{
auto current = dynamic_cast<AWAbstractSelector *>(sender())->current();
auto index = m_selectors.indexOf(dynamic_cast<AWAbstractSelector *>(sender()));
QPair<QString, QString> current = dynamic_cast<AWAbstractSelector *>(sender())->current();
int index = m_selectors.indexOf(dynamic_cast<AWAbstractSelector *>(sender()));
if ((current.first.isEmpty()) && (current.second.isEmpty())) {
// remove current selector if it is empty and does not last
if (sender() == m_selectors.last())
return;
auto selector = m_selectors.takeAt(index);
AWAbstractSelector *selector = m_selectors.takeAt(index);
ui->verticalLayout->removeWidget(selector);
selector->deleteLater();
} else {
@ -109,10 +109,10 @@ void AWAbstractPairConfig::addSelector(const QStringList &_keys, const QStringLi
{
qCDebug(LOG_AW) << "Add selector with keys" << _keys << "values" << _values << "and current ones" << _current;
auto selector = new AWAbstractSelector(ui->scrollAreaWidgetContents, m_editable);
auto *selector = new AWAbstractSelector(ui->scrollAreaWidgetContents, m_editable);
selector->init(_keys, _values, _current);
ui->verticalLayout->insertWidget(ui->verticalLayout->count() - 1, selector);
connect(selector, &AWAbstractSelector::selectionChanged, this, &AWAbstractPairConfig::updateUi);
connect(selector, SIGNAL(selectionChanged()), this, SLOT(updateUi()));
m_selectors.append(selector);
}
@ -120,7 +120,7 @@ void AWAbstractPairConfig::addSelector(const QStringList &_keys, const QStringLi
void AWAbstractPairConfig::clearSelectors()
{
for (auto &selector : m_selectors) {
disconnect(selector, &AWAbstractSelector::selectionChanged, this, &AWAbstractPairConfig::updateUi);
disconnect(selector, SIGNAL(selectionChanged()), this, SLOT(updateUi()));
ui->verticalLayout->removeWidget(selector);
selector->deleteLater();
}
@ -164,7 +164,7 @@ QPair<QStringList, QStringList> AWAbstractPairConfig::initKeys() const
right.append(m_helper->rightKeys().isEmpty() ? m_keys : m_helper->rightKeys());
right.sort();
return {left, right};
return QPair<QStringList, QStringList>(left, right);
}
@ -175,7 +175,7 @@ void AWAbstractPairConfig::updateDialog()
auto keys = initKeys();
for (auto &key : m_helper->keys())
addSelector(keys.first, keys.second, QPair<QString, QString>(key, pairs[key]));
addSelector(keys.first, keys.second, QPair<QString, QString>(key, m_helper->pairs()[key]));
// empty one
addSelector(keys.first, keys.second, QPair<QString, QString>());
}

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWABSTRACTPAIRCONFIG_H
#define AWABSTRACTPAIRCONFIG_H
#include <QDialog>
@ -65,3 +67,6 @@ private:
[[nodiscard]] QPair<QStringList, QStringList> initKeys() const;
void updateDialog();
};
#endif /* AWABSTRACTPAIRCONFIG_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWABSTRACTPAIRHELPER_H
#define AWABSTRACTPAIRHELPER_H
#include <QHash>
@ -44,3 +46,6 @@ private:
QString m_filePath;
QString m_section;
};
#endif /* AWABSTRACTPAIRHELPER_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWABSTRACTSELECTOR_H
#define AWABSTRACTSELECTOR_H
#include <QWidget>
@ -41,3 +43,6 @@ signals:
private:
Ui::AWAbstractSelector *ui = nullptr;
};
#endif /* AWABSTRACTSELECTOR_H */

View File

@ -90,7 +90,7 @@ void AWActions::showReadme()
void AWActions::showLegacyInfo()
{
auto msgBox = new QMessageBox(nullptr);
auto *msgBox = new QMessageBox(nullptr);
msgBox->setAttribute(Qt::WA_DeleteOnClose);
msgBox->setModal(false);
msgBox->setWindowTitle(i18n("Not supported"));

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWACTIONS_H
#define AWACTIONS_H
#include <QMap>
#include <QObject>
@ -45,3 +47,6 @@ public slots:
private:
AWUpdateHelper *m_updateHelper = nullptr;
};
#endif /* AWACTIONS_H */

View File

@ -44,7 +44,7 @@ AWBugReporter::~AWBugReporter()
void AWBugReporter::doConnect()
{
// additional method for testing needs
connect(this, &AWBugReporter::replyReceived, this, &AWBugReporter::showInformation);
connect(this, SIGNAL(replyReceived(const int, const QString &)), this, SLOT(showInformation(int, const QString &)));
}
@ -71,26 +71,26 @@ void AWBugReporter::sendBugReport(const QString &_title, const QString &_body)
{
qCDebug(LOG_AW) << "Send bug report with title" << _title << "and body" << _body;
auto manager = new QNetworkAccessManager(nullptr);
connect(manager, &QNetworkAccessManager::finished, this, &AWBugReporter::issueReplyReceived);
auto *manager = new QNetworkAccessManager(nullptr);
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(issueReplyRecieved(QNetworkReply *)));
auto request = QNetworkRequest(QUrl(BUGTRACKER_API));
QNetworkRequest request = QNetworkRequest(QUrl(BUGTRACKER_API));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
// generate payload
QVariantMap payload;
payload["title"] = _title;
payload["body"] = _body;
payload["labels"] = QStringList({"from application"});
payload["labels"] = QStringList() << "from application";
// convert to QByteArray to send request
auto data = QJsonDocument::fromVariant(payload).toJson(QJsonDocument::Compact);
QByteArray data = QJsonDocument::fromVariant(payload).toJson(QJsonDocument::Compact);
qCInfo(LOG_AW) << "Send request with _body" << data.data() << "and size" << data.size();
manager->post(request, data);
}
void AWBugReporter::issueReplyReceived(QNetworkReply *_reply)
void AWBugReporter::issueReplyRecieved(QNetworkReply *_reply)
{
if (_reply->error() != QNetworkReply::NoError) {
qCWarning(LOG_AW) << "An error occurs" << _reply->error() << "with message" << _reply->errorString();
@ -98,7 +98,7 @@ void AWBugReporter::issueReplyReceived(QNetworkReply *_reply)
}
QJsonParseError error{};
auto jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error);
QJsonDocument jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(LOG_AW) << "Parse error" << error.errorString();
return emit(replyReceived(0, ""));
@ -106,9 +106,9 @@ void AWBugReporter::issueReplyReceived(QNetworkReply *_reply)
_reply->deleteLater();
// convert to map
auto response = jsonDoc.toVariant().toMap();
auto url = response["html_url"].toString();
auto number = response["number"].toInt();
QVariantMap response = jsonDoc.toVariant().toMap();
QString url = response["html_url"].toString();
int number = response["number"].toInt();
return emit(replyReceived(number, url));
}
@ -121,7 +121,7 @@ void AWBugReporter::showInformation(const int _number, const QString &_url)
// cache url first
m_lastBugUrl = _url;
auto msgBox = new QMessageBox(nullptr);
auto *msgBox = new QMessageBox(nullptr);
msgBox->setAttribute(Qt::WA_DeleteOnClose);
msgBox->setModal(false);
msgBox->setWindowTitle(i18n("Issue created"));
@ -135,7 +135,7 @@ void AWBugReporter::showInformation(const int _number, const QString &_url)
void AWBugReporter::userReplyOnBugReport(QAbstractButton *_button)
{
auto ret = dynamic_cast<QMessageBox *>(sender())->buttonRole(_button);
QMessageBox::ButtonRole ret = dynamic_cast<QMessageBox *>(sender())->buttonRole(_button);
qCInfo(LOG_AW) << "User select" << ret;
switch (ret) {

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWBUGREPORTER_H
#define AWBUGREPORTER_H
#include <QObject>
@ -39,10 +41,13 @@ signals:
void replyReceived(int _number, const QString &_url);
private slots:
void issueReplyReceived(QNetworkReply *_reply);
void issueReplyRecieved(QNetworkReply *_reply);
void showInformation(int _number, const QString &_url);
void userReplyOnBugReport(QAbstractButton *_button);
private:
QString m_lastBugUrl;
};
#endif /* AWBUGREPORTER_H */

View File

@ -72,7 +72,7 @@ bool AWConfigHelper::exportConfiguration(QObject *_nativeConfig, const QString &
QSettings settings(_fileName, QSettings::IniFormat);
// plasmoid configuration
auto configuration = dynamic_cast<const QQmlPropertyMap *>(_nativeConfig);
const auto *configuration = dynamic_cast<const QQmlPropertyMap *>(_nativeConfig);
settings.beginGroup("plasmoid");
for (auto &key : configuration->keys()) {
QVariant value = configuration->value(key);

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWCONFIGHELPER_H
#define AWCONFIGHELPER_H
#include <QObject>
#include <QVariant>
@ -50,3 +52,6 @@ private:
QString m_baseDir;
QStringList m_dirs = {"desktops", "quotes", "scripts", "upgrade", "weather", "formatters"};
};
#endif /* AWCONFIGHELPER_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWCUSTOMKEYSCONFIG_H
#define AWCUSTOMKEYSCONFIG_H
#include "awabstractpairconfig.h"
@ -28,3 +30,6 @@ public:
explicit AWCustomKeysConfig(QWidget *_parent = nullptr, const QStringList &_keys = QStringList());
~AWCustomKeysConfig() override;
};
#endif /* AWCUSTOMKEYSCONFIG_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWCUSTOMKEYSHELPER_H
#define AWCUSTOMKEYSHELPER_H
#include <QObject>
@ -40,3 +42,6 @@ public:
private:
};
#endif /* AWCUSTOMKEYSHELPER_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWTOOLTIP_H
#define AWTOOLTIP_H
#include <QObject>
#include <QVariant>
@ -66,3 +68,6 @@ private:
bool m_enablePopup = false;
QStringList requiredKeys;
};
#endif /* AWTOOLTIP_H */

View File

@ -139,7 +139,7 @@ void AWDataEngineAggregator::sensorRemoved(const QString &_sensor)
}
void AWDataEngineAggregator::updateData(const KSysGuard::SensorDataList &_data)
void AWDataEngineAggregator::updateData(KSysGuard::SensorDataList _data)
{
emit(dataUpdated(m_sensors, _data));
}
@ -147,9 +147,9 @@ void AWDataEngineAggregator::updateData(const KSysGuard::SensorDataList &_data)
void AWDataEngineAggregator::updateSensors(const QHash<QString, KSysGuard::SensorInfo> &_sensors)
{
for (auto [source, sensor] : _sensors.asKeyValueRange()) {
if (!isValidSensor(sensor))
for (auto sensor = _sensors.cbegin(); sensor != _sensors.cend(); ++sensor) {
if (!isValidSensor(sensor.value()))
continue;
m_sensors.insert(source, sensor);
m_sensors.insert(sensor.key(), sensor.value());
}
}

View File

@ -49,7 +49,7 @@ public slots:
void dropSource(const QString &_source);
void sensorAdded(const QString &_sensor);
void sensorRemoved(const QString &_sensor);
void updateData(const KSysGuard::SensorDataList &_data);
void updateData(KSysGuard::SensorDataList _data);
void updateSensors(const QHash<QString, KSysGuard::SensorInfo> &_sensors);
private:

View File

@ -153,7 +153,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
if (index > -1) {
QString key = QString("hddr%1").arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::MemKBFormat;
m_formatter[key] = AWKeysAggregator::FormatterType::Integer;
}
} else if (_source.contains(hddwRegExp)) {
// write speed
@ -163,7 +163,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
if (index > -1) {
QString key = QString("hddw%1").arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::MemKBFormat;
m_formatter[key] = AWKeysAggregator::FormatterType::Integer;
}
} else if (_source == "gpu/all/usage") {
// gpu load
@ -285,7 +285,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
// kb
auto key = QString("%1kb%2").arg(type).arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::MemKBFormat;
m_formatter[key] = AWKeysAggregator::FormatterType::Integer;
// smart
key = QString("%1%2").arg(type).arg(index);
m_map.insert(_source, key);
@ -303,7 +303,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
// kb
auto key = QString("%1totkb%2").arg(type).arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::MemKBFormat;
m_formatter[key] = AWKeysAggregator::FormatterType::Integer;
// mb
key = QString("%1tot%2").arg(type).arg(index);
m_map.insert(_source, key);

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWDATAENGINEMAPPER_H
#define AWDATAENGINEMAPPER_H
#include <ksysguard/formatter/Unit.h>
@ -48,3 +50,6 @@ private:
QHash<QString, AWKeysAggregator::FormatterType> m_formatter;
QMultiHash<QString, QString> m_map;
};
#endif /* AWDATAENGINEMAPPER_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWDBUSADAPTOR_H
#define AWDBUSADAPTOR_H
#include <QDBusAbstractAdaptor>
@ -48,3 +50,6 @@ private:
AWKeys *m_plugin = nullptr;
QStringList m_logLevels = {"debug", "info", "warning", "critical"};
};
#endif /* AWDBUSADAPTOR_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWPLUGIN_H
#define AWPLUGIN_H
#include <QQmlExtensionPlugin>
@ -28,3 +30,6 @@ class AWPlugin : public QQmlExtensionPlugin
public:
void registerTypes(const char *uri) override;
};
#endif /* AWPLUGIN_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWFORMATTERCONFIG_H
#define AWFORMATTERCONFIG_H
#include "awabstractpairconfig.h"
@ -28,3 +30,6 @@ public:
explicit AWFormatterConfig(QWidget *_parent = nullptr, const QStringList &_keys = QStringList());
~AWFormatterConfig() override;
};
#endif /* AWFORMATTERCONFIG_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWFORMATTERHELPER_H
#define AWFORMATTERHELPER_H
#include "abstractextitemaggregator.h"
#include "awabstractformatter.h"
@ -54,3 +56,6 @@ private:
QHash<QString, AWAbstractFormatter *> m_formatters;
QHash<QString, AWAbstractFormatter *> m_formattersClasses;
};
#endif /* AWFORMATTERHELPER_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWKEYCACHE_H
#define AWKEYCACHE_H
#include <QHash>
#include <QString>
@ -29,3 +31,6 @@ QStringList getRequiredKeys(const QStringList &_keys, const QStringList &_bars,
const QStringList &_userKeys, const QStringList &_allKeys);
QHash<QString, QStringList> loadKeysFromCache();
} // namespace AWKeyCache
#endif /* AWKEYCACHE_H */

View File

@ -210,11 +210,11 @@ QString AWKeyOperations::infoByKey(const QString &_key) const
QString output;
if (_key.startsWith("bar")) {
auto item = m_graphicalItems->itemByTag(_key, stripped);
auto *item = m_graphicalItems->itemByTag(_key, stripped);
if (item)
output = item->uniq();
} else if (_key.startsWith("custom")) {
auto item = m_extScripts->itemByTag(_key, stripped);
auto *item = m_extScripts->itemByTag(_key, stripped);
if (item)
output = item->uniq();
} else if (_key.contains(QRegularExpression("^hdd[rw]"))) {
@ -230,15 +230,15 @@ QString AWKeyOperations::infoByKey(const QString &_key) const
index.remove(QRegularExpression("^(down|up)"));
output = m_devices["net"][index.toInt()];
} else if (_key.startsWith("pkgcount")) {
auto item = m_extUpgrade->itemByTag(_key, stripped);
auto *item = m_extUpgrade->itemByTag(_key, stripped);
if (item)
output = item->uniq();
} else if (_key.contains(QRegularExpression("(^|perc)(ask|bid|price)(chg|)"))) {
auto item = m_extQuotes->itemByTag(_key, stripped);
auto *item = m_extQuotes->itemByTag(_key, stripped);
if (item)
output = item->uniq();
} else if (_key.contains(QRegularExpression("(weather|weatherId|humidity|pressure|temperature)"))) {
auto item = m_extWeather->itemByTag(_key, stripped);
auto *item = m_extWeather->itemByTag(_key, stripped);
if (item)
output = item->uniq();
} else if (_key.startsWith("temp")) {
@ -246,7 +246,7 @@ QString AWKeyOperations::infoByKey(const QString &_key) const
index.remove("temp");
output = m_devices["temp"][index.toInt()];
} else if (_key.startsWith("response")) {
auto item = m_extNetRequest->itemByTag(_key, stripped);
auto *item = m_extNetRequest->itemByTag(_key, stripped);
if (item)
output = item->uniq();
} else {

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWKEYOPERATIONS_H
#define AWKEYOPERATIONS_H
#include <QObject>
@ -76,3 +78,6 @@ private:
QHash<QString, QStringList> m_devices;
QString m_pattern;
};
#endif /* AWKEYOPERATIONS_H */

View File

@ -153,6 +153,26 @@ QStringList AWKeys::dictKeys(const bool _sorted, const QString &_regexp) const
}
QVariantList AWKeys::getHddDevices() const
{
QStringList hddDevices = m_keyOperator->devices("hdd");
// required by selector in the UI
hddDevices.insert(0, "disable");
hddDevices.insert(0, "auto");
// build model
QVariantList devices;
for (auto &device : hddDevices) {
QVariantMap model;
model["label"] = device;
model["name"] = device;
devices.append(model);
}
return devices;
}
QString AWKeys::infoByKey(const QString &_key) const
{
qCDebug(LOG_AW) << "Requested info for key" << _key;
@ -182,14 +202,12 @@ void AWKeys::editItem(const QString &_type)
void AWKeys::dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_sensors, const KSysGuard::SensorDataList &_data)
{
qCDebug(LOG_AW) << "Update data for" << _data.count() << "items";
// though it is better to use QtConcurrent::map here, but it might cause stack corruption
for (auto &data : _data) {
if (!_sensors.contains(data.sensorProperty))
continue;
auto sensor = _sensors[data.sensorProperty];
std::ignore = QtConcurrent::run(m_threadPool, &AWKeys::setDataBySource, this, data.sensorProperty, sensor, data.payload);
for (auto &single : _data) {
if (_sensors.contains(single.sensorProperty)) {
setDataBySource(single.sensorProperty, _sensors.value(single.sensorProperty), single);
}
// TODO use QtConcurrent::map or something like that
// QtConcurrent::run(m_threadPool, this, &AWKeys::setDataBySource, "ss", sensor);
}
}
@ -254,7 +272,7 @@ void AWKeys::calculateValues()
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();
m_values["mem"] = 100.0f * m_values["memmb"].toDouble() / m_values["memtotmb"].toDouble();
// up, down, upkb, downkb, upunits, downunits
int netIndex = m_keyOperator->devices("net").indexOf(m_values["netdev"].toString());
@ -273,7 +291,7 @@ void AWKeys::calculateValues()
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();
m_values["swap"] = 100.0f * m_values["swapmb"].toDouble() / m_values["swaptotmb"].toDouble();
// user defined keys
for (auto &key : m_keyOperator->userKeys())
@ -339,9 +357,10 @@ QString AWKeys::parsePattern(QString _pattern) const
}
void AWKeys::setDataBySource(const QString &_source, const KSysGuard::SensorInfo &_sensor, const QVariant &_value)
void AWKeys::setDataBySource(const QString &_source, const KSysGuard::SensorInfo &_sensor,
const KSysGuard::SensorData &_data)
{
qCDebug(LOG_AW) << "Source" << _source << _sensor.name << "with data" << _value;
qCDebug(LOG_AW) << "Source" << _source << _sensor.name << "with data" << _data.payload;
// first list init
auto tags = m_aggregator->keysFromSource(_source);
@ -355,6 +374,6 @@ void AWKeys::setDataBySource(const QString &_source, const KSysGuard::SensorInfo
}
m_mutex.lock();
std::for_each(tags.cbegin(), tags.cend(), [this, _value](const QString &tag) { m_values[tag] = _value; });
std::for_each(tags.cbegin(), tags.cend(), [this, &_data](const QString &tag) { m_values[tag] = _data.payload; });
m_mutex.unlock();
}

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWKEYS_H
#define AWKEYS_H
#include <QMutex>
#include <QObject>
@ -46,19 +48,22 @@ public:
Q_INVOKABLE void updateCache();
// keys
Q_INVOKABLE [[nodiscard]] QStringList dictKeys(bool _sorted = false, const QString &_regexp = "") const;
Q_INVOKABLE [[nodiscard]] QVariantList getHddDevices() const;
// values
Q_INVOKABLE [[nodiscard]] QString infoByKey(const QString &_key) const;
Q_INVOKABLE [[nodiscard]] QString valueByKey(const QString &_key) const;
// configuration
Q_INVOKABLE void editItem(const QString &_type);
public slots:
void dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_sensors, const KSysGuard::SensorDataList &_data);
signals:
void dropSourceFromDataengine(const QString &_source);
void needTextToBeUpdated(const QString &_newText) const;
void needToolTipToBeUpdated(const QString &_newText) const;
private slots:
void dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_sensors, const KSysGuard::SensorDataList &_data);
void reinitKeys(const QStringList &_currentKeys);
void updateTextData();
@ -67,7 +72,8 @@ private:
void calculateValues();
void createDBusInterface();
[[nodiscard]] QString parsePattern(QString _pattern) const;
void setDataBySource(const QString &_source, const KSysGuard::SensorInfo &_sensor, const QVariant &_value);
void setDataBySource(const QString &_source, const KSysGuard::SensorInfo &_sensor,
const KSysGuard::SensorData &_data);
// objects
AWDataAggregator *m_dataAggregator = nullptr;
AWDataEngineAggregator *m_dataEngineAggregator = nullptr;
@ -84,3 +90,6 @@ private:
QThreadPool *m_threadPool = nullptr;
QMutex m_mutex;
};
#endif /* AWKEYS_H */

View File

@ -85,24 +85,21 @@ QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key,
output = _data.toBool() ? m_acOnline : m_acOffline;
break;
case FormatterType::MemGBFormat:
output = QString("%1").arg(_data.toDouble() / GBinBytes, 5, 'f', 1);
output = QString("%1").arg(_data.toDouble() / (1024.0 * 1024.0), 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);
output = QString("%1").arg(_data.toDouble() / 1024.0, 5, 'f', 0);
break;
case FormatterType::NetSmartFormat:
output = [](const double value) {
if (value > MBinBytes)
return QString("%1").arg(value / MBinBytes, 4, 'f', 1);
output = [](const float value) {
if (value > 1024.0)
return QString("%1").arg(value / 1024.0, 4, 'f', 1);
else
return QString("%1").arg(value / KBinBytes, 4, 'f', 0);
return QString("%1").arg(value, 4, 'f', 0);
}(_data.toDouble());
break;
case FormatterType::NetSmartUnits:
if (_data.toDouble() > MBinBytes)
if (_data.toDouble() > 1024.0)
output = m_translate ? i18n("MB/s") : "MB/s";
else
output = m_translate ? i18n("KB/s") : "KB/s";
@ -237,7 +234,7 @@ void AWKeysAggregator::setTranslate(const bool _translate)
}
QStringList AWKeysAggregator::registerSource(const QString &_source, const KSysGuard::Unit _units,
QStringList AWKeysAggregator::registerSource(const QString &_source, const KSysGuard::Unit &_units,
const QStringList &_keys)
{
qCDebug(LOG_AW) << "Source" << _source << "with units" << _units;
@ -246,24 +243,24 @@ QStringList AWKeysAggregator::registerSource(const QString &_source, const KSysG
}
double AWKeysAggregator::temperature(const double temp) const
float AWKeysAggregator::temperature(const float temp) const
{
qCDebug(LOG_AW) << "Temperature value" << temp;
auto converted = temp;
float converted = temp;
if (m_tempUnits == "Celsius") {
} else if (m_tempUnits == "Fahrenheit") {
converted = temp * 9.0f / 5.0 + 32.0;
converted = temp * 9.0f / 5.0f + 32.0f;
} else if (m_tempUnits == "Kelvin") {
converted = temp + 273.15;
converted = temp + 273.15f;
} else if (m_tempUnits == "Reaumur") {
converted = temp * 0.8;
converted = temp * 0.8f;
} else if (m_tempUnits == "cm^-1") {
converted = (temp + 273.15) * 0.695;
converted = (temp + 273.15f) * 0.695f;
} else if (m_tempUnits == "kJ/mol") {
converted = (temp + 273.15) * 8.31;
converted = (temp + 273.15f) * 8.31f;
} else if (m_tempUnits == "kcal/mol") {
converted = (temp + 273.15) * 1.98;
converted = (temp + 273.15f) * 1.98f;
} else {
qCWarning(LOG_AW) << "Invalid units" << m_tempUnits;
}

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWKEYSAGGREGATOR_H
#define AWKEYSAGGREGATOR_H
#include <ksysguard/formatter/Unit.h>
@ -51,7 +53,6 @@ public:
ACFormat,
MemGBFormat,
MemMBFormat,
MemKBFormat,
NetSmartFormat,
NetSmartUnits,
Quotes,
@ -66,10 +67,6 @@ public:
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);
~AWKeysAggregator() override;
void initFormatters();
@ -86,10 +83,10 @@ public:
void setTranslate(bool _translate);
public slots:
QStringList registerSource(const QString &_source, const KSysGuard::Unit _units, const QStringList &_keys);
QStringList registerSource(const QString &_source, const KSysGuard::Unit &_units, const QStringList &_keys);
private:
[[nodiscard]] double temperature(double temp) const;
[[nodiscard]] float temperature(float temp) const;
AWFormatterHelper *m_customFormatters = nullptr;
AWDataEngineMapper *m_mapper = nullptr;
QStringList m_timeKeys;
@ -101,3 +98,6 @@ private:
QString m_tempUnits;
bool m_translate = false;
};
#endif /* AWKEYSAGGREGATOR_H */

View File

@ -37,7 +37,7 @@ AWPairConfigFactory::~AWPairConfigFactory()
void AWPairConfigFactory::showFormatterDialog(const QStringList &_keys)
{
auto config = new AWFormatterConfig(nullptr, _keys);
auto *config = new AWFormatterConfig(nullptr, _keys);
config->showDialog();
config->deleteLater();
}
@ -45,7 +45,7 @@ void AWPairConfigFactory::showFormatterDialog(const QStringList &_keys)
void AWPairConfigFactory::showKeysDialog(const QStringList &_keys)
{
auto config = new AWCustomKeysConfig(nullptr, _keys);
auto *config = new AWCustomKeysConfig(nullptr, _keys);
config->showDialog();
config->deleteLater();
}

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWPAIRCONFIGFACTORY_H
#define AWPAIRCONFIGFACTORY_H
#include <QObject>
@ -32,3 +34,6 @@ public:
private:
};
#endif /* AWPAIRCONFIGFACTORY_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWPATTERNFUNCTIONS_H
#define AWPATTERNFUNCTIONS_H
#include <QString>
#include <QVariant>
@ -45,3 +47,6 @@ QString insertMacros(QString _code);
QStringList findKeys(const QString &_code, const QStringList &_keys, bool _isBars);
QStringList findLambdas(const QString &_code);
} // namespace AWPatternFunctions
#endif /* AWPATTERNFUNCTIONS_H */

View File

@ -126,8 +126,8 @@ void AWTelemetryHandler::uploadTelemetry(const QString &_group, const QString &_
return;
}
auto manager = new QNetworkAccessManager(nullptr);
connect(manager, &QNetworkAccessManager::finished, this, &AWTelemetryHandler::telemetryReplyReceived);
auto *manager = new QNetworkAccessManager(nullptr);
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(telemetryReplyRecieved(QNetworkReply *)));
QUrl url(REMOTE_TELEMETRY_URL);
QNetworkRequest request(url);
@ -140,14 +140,14 @@ void AWTelemetryHandler::uploadTelemetry(const QString &_group, const QString &_
payload["metadata"] = _value;
payload["type"] = _group;
// convert to QByteArray to send request
auto data = QJsonDocument::fromVariant(payload).toJson(QJsonDocument::Compact);
QByteArray data = QJsonDocument::fromVariant(payload).toJson(QJsonDocument::Compact);
qCInfo(LOG_AW) << "Send request with body" << data.data() << "and size" << data.size();
manager->post(request, data);
}
void AWTelemetryHandler::telemetryReplyReceived(QNetworkReply *_reply)
void AWTelemetryHandler::telemetryReplyRecieved(QNetworkReply *_reply)
{
if (_reply->error() != QNetworkReply::NoError) {
qCWarning(LOG_AW) << "An error occurs" << _reply->error() << "with message" << _reply->errorString();
@ -155,7 +155,7 @@ void AWTelemetryHandler::telemetryReplyReceived(QNetworkReply *_reply)
}
QJsonParseError error{};
auto jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error);
QJsonDocument jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(LOG_AW) << "Parse error" << error.errorString();
return;
@ -163,8 +163,8 @@ void AWTelemetryHandler::telemetryReplyReceived(QNetworkReply *_reply)
_reply->deleteLater();
// convert to map
auto response = jsonDoc.toVariant().toMap();
auto message = response["message"].toString();
QVariantMap response = jsonDoc.toVariant().toMap();
QString message = response["message"].toString();
qCInfo(LOG_AW) << "Server reply on telemetry" << message;
return emit(replyReceived(message));

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWTELEMETRYHANDLER_H
#define AWTELEMETRYHANDLER_H
#include <QObject>
@ -41,7 +43,7 @@ signals:
void replyReceived(const QString &_message);
private slots:
void telemetryReplyReceived(QNetworkReply *_reply);
void telemetryReplyRecieved(QNetworkReply *_reply);
private:
static QString getKey(int _count);
@ -50,3 +52,6 @@ private:
int m_storeCount = 0;
bool m_uploadEnabled = false;
};
#endif /* AWTELEMETRYHANDLER_H */

View File

@ -52,9 +52,9 @@ void AWUpdateHelper::checkUpdates(const bool _showAnyway)
// showAnyway options requires to show message if no updates found on direct
// request. In case of automatic check no message will be shown
auto manager = new QNetworkAccessManager(nullptr);
auto *manager = new QNetworkAccessManager(nullptr);
connect(manager, &QNetworkAccessManager::finished,
[_showAnyway, this](QNetworkReply *reply) { return versionReplyReceived(reply, _showAnyway); });
[_showAnyway, this](QNetworkReply *reply) { return versionReplyRecieved(reply, _showAnyway); });
manager->get(QNetworkRequest(QUrl(VERSION_API)));
}
@ -63,7 +63,7 @@ void AWUpdateHelper::checkUpdates(const bool _showAnyway)
bool AWUpdateHelper::checkVersion()
{
QSettings settings(m_genericConfig, QSettings::IniFormat);
auto version = QVersionNumber::fromString(settings.value("Version", QString(VERSION)).toString());
QVersionNumber version = QVersionNumber::fromString(settings.value("Version", QString(VERSION)).toString());
// update version
settings.setValue("Version", QString(VERSION));
settings.sync();
@ -88,7 +88,7 @@ void AWUpdateHelper::showInfo(const QVersionNumber &_version)
{
qCDebug(LOG_AW) << "Version" << _version;
auto text = i18n("You are using the actual version %1", _version.toString());
QString text = i18n("You are using the actual version %1", _version.toString());
if (!QString(COMMIT_SHA).isEmpty())
text += QString(" (%1)").arg(QString(COMMIT_SHA));
return genMessageBox(i18n("No new version found"), text, QMessageBox::Ok)->open();
@ -112,7 +112,7 @@ void AWUpdateHelper::showUpdates(const QVersionNumber &_version)
void AWUpdateHelper::userReplyOnUpdates(QAbstractButton *_button)
{
auto ret = dynamic_cast<QMessageBox *>(sender())->buttonRole(_button);
QMessageBox::ButtonRole ret = dynamic_cast<QMessageBox *>(sender())->buttonRole(_button);
qCInfo(LOG_AW) << "User select" << ret;
switch (ret) {
@ -126,7 +126,7 @@ void AWUpdateHelper::userReplyOnUpdates(QAbstractButton *_button)
}
void AWUpdateHelper::versionReplyReceived(QNetworkReply *_reply, const bool _showAnyway)
void AWUpdateHelper::versionReplyRecieved(QNetworkReply *_reply, const bool _showAnyway)
{
qCDebug(LOG_AW) << "Show message anyway" << _showAnyway;
if (_reply->error() != QNetworkReply::NoError) {
@ -134,8 +134,8 @@ void AWUpdateHelper::versionReplyReceived(QNetworkReply *_reply, const bool _sho
return;
}
auto error = QJsonParseError();
auto jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error);
QJsonParseError error = QJsonParseError();
QJsonDocument jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(LOG_AW) << "Parse error" << error.errorString();
return;
@ -143,13 +143,13 @@ void AWUpdateHelper::versionReplyReceived(QNetworkReply *_reply, const bool _sho
_reply->deleteLater();
// convert to map
auto firstRelease = jsonDoc.toVariant().toList().first().toMap();
auto version = firstRelease["tag_name"].toString();
QVariantMap firstRelease = jsonDoc.toVariant().toList().first().toMap();
QString version = firstRelease["tag_name"].toString();
version.remove("V.");
m_foundVersion = QVersionNumber::fromString(version);
qCInfo(LOG_AW) << "Update found version to" << m_foundVersion;
auto oldVersion = QVersionNumber::fromString(VERSION);
QVersionNumber oldVersion = QVersionNumber::fromString(VERSION);
if (oldVersion < m_foundVersion)
return showUpdates(m_foundVersion);
else if (_showAnyway)
@ -163,7 +163,7 @@ QMessageBox *AWUpdateHelper::genMessageBox(const QString &_title, const QString
{
qCDebug(LOG_AW) << "Construct message box with title" << _title << "and body" << _body;
auto msgBox = new QMessageBox(nullptr);
auto *msgBox = new QMessageBox(nullptr);
msgBox->setAttribute(Qt::WA_DeleteOnClose);
msgBox->setModal(false);
msgBox->setWindowTitle(_title);

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWUPDATEHELPER_H
#define AWUPDATEHELPER_H
#include <QMessageBox>
#include <QObject>
@ -38,7 +40,7 @@ private slots:
static void showInfo(const QVersionNumber &_version);
void showUpdates(const QVersionNumber &_version);
void userReplyOnUpdates(QAbstractButton *_button);
void versionReplyReceived(QNetworkReply *_reply, bool _showAnyway);
void versionReplyRecieved(QNetworkReply *_reply, bool _showAnyway);
private:
static QMessageBox *genMessageBox(const QString &_title, const QString &_body,
@ -46,3 +48,6 @@ private:
QVersionNumber m_foundVersion;
QString m_genericConfig;
};
#endif /* AWUPDATEHELPER_H */

View File

@ -198,7 +198,7 @@ void AbstractExtItem::setCron(const QString &_cron)
qCDebug(LOG_LIB) << "Cron string" << _cron;
// deinit module first
if (m_scheduler) {
disconnect(m_scheduler, &QCronScheduler::activated, this, &AbstractExtItem::requestDataUpdate);
disconnect(m_scheduler, SIGNAL(activated()), this, SIGNAL(requestDataUpdate()));
delete m_scheduler;
}
@ -209,7 +209,7 @@ void AbstractExtItem::setCron(const QString &_cron)
// init scheduler
m_scheduler = new QCronScheduler(this);
m_scheduler->parse(cron());
connect(m_scheduler, &QCronScheduler::activated, this, &AbstractExtItem::requestDataUpdate);
connect(m_scheduler, SIGNAL(activated()), this, SIGNAL(requestDataUpdate()));
}
@ -234,7 +234,7 @@ void AbstractExtItem::setName(const QString &_name)
void AbstractExtItem::setNumber(int _number)
{
qCDebug(LOG_LIB) << "Number" << _number;
auto generateNumber = (_number == -1);
bool generateNumber = (_number == -1);
if (generateNumber) {
_number = []() {
qCWarning(LOG_LIB) << "Number is empty, generate new one";
@ -267,7 +267,7 @@ void AbstractExtItem::deinitSocket()
m_socket->close();
QLocalServer::removeServer(socket());
disconnect(m_socket, &QLocalServer::newConnection, this, &AbstractExtItem::newConnectionReceived);
disconnect(m_socket, SIGNAL(newConnection()), this, SLOT(newConnectionReceived()));
delete m_socket;
}
@ -278,9 +278,9 @@ void AbstractExtItem::initSocket()
deinitSocket();
m_socket = new QLocalServer(this);
auto listening = m_socket->listen(socket());
bool listening = m_socket->listen(socket());
qCInfo(LOG_LIB) << "Server listening on" << socket() << listening;
connect(m_socket, &QLocalServer::newConnection, this, &AbstractExtItem::newConnectionReceived);
connect(m_socket, SIGNAL(newConnection()), this, SLOT(newConnectionReceived()));
}
@ -303,7 +303,7 @@ void AbstractExtItem::readConfiguration()
bool AbstractExtItem::tryDelete() const
{
auto status = QFile::remove(m_fileName);
bool status = QFile::remove(m_fileName);
qCInfo(LOG_LIB) << "Remove file" << m_fileName << status;
return status;

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef ABSTRACTEXTITEM_H
#define ABSTRACTEXTITEM_H
#include <QVariant>
@ -101,3 +102,6 @@ private:
QLocalServer *m_socket = nullptr;
QString m_socketFile = "";
};
#endif /* ABSTRACTEXTITEM_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef ABSTRACTEXTITEMAGGREGATOR_H
#define ABSTRACTEXTITEMAGGREGATOR_H
#include <QStandardPaths>
@ -79,3 +80,6 @@ private:
// ui methods
virtual void doCreateItem(QListWidget *_widget) = 0;
};
#endif /* ABSTRACTEXTITEMAGGREGATOR_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef ABSTRACTQUOTESPROVIDER_H
#define ABSTRACTQUOTESPROVIDER_H
#include <QObject>
#include <QUrl>
@ -39,3 +40,6 @@ public:
};
[[nodiscard]] virtual QUrl url() const = 0;
};
#endif /* ABSTRACTQUOTESPROVIDER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef ABSTRACTWEATHERPROVIDER_H
#define ABSTRACTWEATHERPROVIDER_H
#include <QObject>
#include <QUrl>
@ -39,3 +40,6 @@ public:
};
[[nodiscard]] virtual QUrl url() const = 0;
};
#endif /* ABSTRACTWEATHERPROVIDER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWABSTRACTFORMATTER_H
#define AWABSTRACTFORMATTER_H
#include <QRegularExpression>
@ -51,3 +52,6 @@ private:
// properties
FormatterClass m_type = FormatterClass::NoFormat;
};
#endif /* AWABSTRACTFORMATTER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWDATETIMEFORMATTER_H
#define AWDATETIMEFORMATTER_H
#include <QLocale>
@ -51,3 +52,6 @@ private:
QString m_format = "";
bool m_translate = true;
};
#endif /* AWDATETIMEFORMATTER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWFLOATFORMATTER_H
#define AWFLOATFORMATTER_H
#include "awabstractformatter.h"
@ -67,3 +68,6 @@ private:
int m_precision = -1;
double m_summand = 0.0;
};
#endif /* AWFLOATFORMATTER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWJSONFORMATTER_H
#define AWJSONFORMATTER_H
#include "awabstractformatter.h"
@ -48,3 +49,6 @@ private:
QString m_path;
QVariantList m_splittedPath;
};
#endif /* AWJSONFORMATTER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWLISTFORMATTER_H
#define AWLISTFORMATTER_H
#include "awabstractformatter.h"
@ -52,3 +53,6 @@ private:
bool m_sorted = false;
QRegularExpression m_regex;
};
#endif /* AWLISTFORMATTER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWNOFORMATTER_H
#define AWNOFORMATTER_H
#include "awabstractformatter.h"
@ -36,3 +37,6 @@ private:
void translate(void *_ui) override;
// properties
};
#endif /* AWNOFORMATTER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWSCRIPTFORMATTER_H
#define AWSCRIPTFORMATTER_H
#include "awabstractformatter.h"
@ -55,3 +56,6 @@ private:
bool m_hasReturn = false;
QString m_program;
};
#endif /* AWSCRIPTFORMATTER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWSTRINGFORMATTER_H
#define AWSTRINGFORMATTER_H
#include "awabstractformatter.h"
@ -51,3 +52,6 @@ private:
QChar m_fillChar = QChar();
bool m_forceWidth = false;
};
#endif /* AWSTRINGFORMATTER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef EXTITEMAGGREGATOR_H
#define EXTITEMAGGREGATOR_H
#include <KI18n/KLocalizedString>
@ -65,7 +66,7 @@ public:
m_activeItems.clear();
m_items = getItems();
for (auto item : m_items) {
for (auto &item : m_items) {
if (!item->isActive())
continue;
m_activeItems.append(static_cast<T *>(item));
@ -77,7 +78,7 @@ public:
// HACK as soon as per one widget instance we have two objects each of
// them will try to control socket, whereas actually only one of them
// should be owner of the socket
for (auto item : m_items)
for (auto &item : m_items)
item->initSocket();
}
@ -86,7 +87,7 @@ public:
qCDebug(LOG_LIB) << "Tag" << _tag << "with used type" << _type;
T *found = nullptr;
for (auto item : m_items) {
for (auto &item : m_items) {
if (item->tag(_type) != _tag)
continue;
found = static_cast<T *>(item);
@ -103,7 +104,7 @@ public:
qCDebug(LOG_LIB) << "Number" << _number;
T *found = nullptr;
for (auto item : m_items) {
for (auto &item : m_items) {
if (item->number() != _number)
continue;
found = static_cast<T *>(item);
@ -129,7 +130,7 @@ private:
auto dirs = directories();
for (auto &dir : dirs) {
auto files = QDir(dir).entryList(QDir::Files, QDir::Name);
QStringList files = QDir(dir).entryList(QDir::Files, QDir::Name);
for (auto &file : files) {
// check filename
if (!file.endsWith(".desktop"))
@ -145,7 +146,10 @@ private:
}
// sort items
std::sort(items.begin(), items.end(), [](auto lhs, auto rhs) { return lhs->number() < rhs->number(); });
std::sort(items.begin(), items.end(), [](auto *lhs, auto *rhs) { return lhs->number() < rhs->number(); });
return items;
};
};
#endif /* EXTITEMAGGREGATOR_H */

View File

@ -40,8 +40,9 @@ ExtNetworkRequest::ExtNetworkRequest(QObject *_parent, const QString &_filePath)
// HACK declare as child of nullptr to avoid crash with plasmawindowed
// in the destructor
m_manager = new QNetworkAccessManager(nullptr);
connect(m_manager, &QNetworkAccessManager::finished, this, &ExtNetworkRequest::networkReplyReceived);
connect(this, &ExtNetworkRequest::requestDataUpdate, this, &ExtNetworkRequest::sendRequest);
connect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(networkReplyReceived(QNetworkReply *)));
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
}
@ -49,8 +50,8 @@ ExtNetworkRequest::~ExtNetworkRequest()
{
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
disconnect(m_manager, &QNetworkAccessManager::finished, this, &ExtNetworkRequest::networkReplyReceived);
disconnect(this, &ExtNetworkRequest::requestDataUpdate, this, &ExtNetworkRequest::sendRequest);
disconnect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(networkReplyReceived(QNetworkReply *)));
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
m_manager->deleteLater();
}

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef EXTNETWORKREQUEST_H
#define EXTNETWORKREQUEST_H
#include <QNetworkReply>
@ -58,3 +59,6 @@ private:
// values
QVariantHash m_values;
};
#endif /* EXTNETWORKREQUEST_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef EXTQUOTES_H
#define EXTQUOTES_H
#include <QNetworkReply>
@ -60,3 +61,6 @@ private:
// values
QVariantHash m_values;
};
#endif /* EXTQUOTES_H */

View File

@ -40,10 +40,10 @@ ExtScript::ExtScript(QObject *_parent, const QString &_filePath)
m_values[tag("custom")] = "";
m_process = new QProcess(nullptr);
connect(m_process, &QProcess::finished, [this]() { return updateValue(); });
connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(updateValue()));
m_process->waitForFinished(0);
connect(this, &ExtScript::requestDataUpdate, this, &ExtScript::startProcess);
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(startProcess()));
}
@ -51,9 +51,10 @@ ExtScript::~ExtScript()
{
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
disconnect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(updateValue()));
m_process->kill();
m_process->deleteLater();
disconnect(this, &ExtScript::requestDataUpdate, this, &ExtScript::startProcess);
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(startProcess()));
}
@ -226,11 +227,11 @@ void ExtScript::readJsonFilters()
qCWarning(LOG_LIB) << "Could not open" << fileName;
return;
}
auto jsonText = jsonFile.readAll();
QString jsonText = jsonFile.readAll();
jsonFile.close();
QJsonParseError error{};
auto jsonDoc = QJsonDocument::fromJson(jsonText, &error);
auto jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8(), &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
return;

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef EXTSCRIPT_H
#define EXTSCRIPT_H
#include <QProcess>
@ -75,3 +76,6 @@ private:
QVariantMap m_jsonFilters;
QVariantHash m_values;
};
#endif /* EXTSCRIPT_H */

View File

@ -36,10 +36,10 @@ ExtUpgrade::ExtUpgrade(QObject *_parent, const QString &_filePath)
m_values[tag("pkgcount")] = 0;
m_process = new QProcess(nullptr);
connect(m_process, &QProcess::finished, [this]() { return updateValue(); });
connect(m_process, SIGNAL(finished(int)), this, SLOT(updateValue()));
m_process->waitForFinished(0);
connect(this, &ExtUpgrade::requestDataUpdate, this, &ExtUpgrade::startProcess);
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(startProcess()));
}
@ -49,7 +49,7 @@ ExtUpgrade::~ExtUpgrade()
m_process->kill();
m_process->deleteLater();
disconnect(this, &ExtUpgrade::requestDataUpdate, this, &ExtUpgrade::startProcess);
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(startProcess()));
}

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef EXTUPGRADE_H
#define EXTUPGRADE_H
#include <QProcess>
@ -63,3 +64,6 @@ private:
// internal properties
QVariantHash m_values;
};
#endif /* EXTUPGRADE_H */

View File

@ -49,8 +49,9 @@ ExtWeather::ExtWeather(QObject *_parent, const QString &_filePath)
// HACK declare as child of nullptr to avoid crash with plasmawindowed
// in the destructor
m_manager = new QNetworkAccessManager(nullptr);
connect(m_manager, &QNetworkAccessManager::finished, this, &ExtWeather::weatherReplyReceived);
connect(this, &ExtWeather::requestDataUpdate, this, &ExtWeather::sendRequest);
connect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(weatherReplyReceived(QNetworkReply *)));
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
}
@ -58,8 +59,8 @@ ExtWeather::~ExtWeather()
{
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
disconnect(m_manager, &QNetworkAccessManager::finished, this, &ExtWeather::weatherReplyReceived);
disconnect(this, &ExtWeather::requestDataUpdate, this, &ExtWeather::sendRequest);
disconnect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(weatherReplyReceived(QNetworkReply *)));
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
m_manager->deleteLater();
}
@ -149,7 +150,7 @@ int ExtWeather::ts() const
QString ExtWeather::uniq() const
{
return QString("%1 (%2) at %3").arg(city(), country()).arg(ts());
return QString("%1 (%2) at %3").arg(city()).arg(country()).arg(ts());
}
@ -236,11 +237,11 @@ void ExtWeather::readJsonMap()
qCWarning(LOG_LIB) << "Could not open" << fileName;
return;
}
auto jsonText = jsonFile.readAll();
QString jsonText = jsonFile.readAll();
jsonFile.close();
QJsonParseError error{};
auto jsonDoc = QJsonDocument::fromJson(jsonText, &error);
auto jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8(), &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
return;

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef EXTWEATHER_H
#define EXTWEATHER_H
#include <QNetworkReply>
@ -89,3 +90,6 @@ private:
// values
QVariantHash m_values;
};
#endif /* EXTWEATHER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef GRAPHICALITEM_H
#define GRAPHICALITEM_H
#include <QColor>
@ -117,3 +118,6 @@ private:
QStringList m_usedKeys;
int m_width = 100;
};
#endif /* GRAPHICALITEM_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef GRAPHICALITEMHELPER_H
#define GRAPHICALITEMHELPER_H
#include <QColor>
#include <QObject>
@ -55,3 +56,6 @@ private:
// list of values which will be used to store data for graph type only
QList<float> m_values;
};
#endif /* GRAPHICALITEMHELPER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef OWMWEATHERPROVIDER_H
#define OWMWEATHERPROVIDER_H
#include "abstractweatherprovider.h"
@ -41,3 +42,6 @@ private:
int m_ts = 0;
QUrl m_url;
};
#endif /* OWMWEATHERPROVIDER_H */

View File

@ -33,7 +33,7 @@ QCronScheduler::QCronScheduler(QObject *_parent)
m_timer->setSingleShot(false);
m_timer->setInterval(60 * 1000);
connect(m_timer, &QTimer::timeout, this, &QCronScheduler::expired);
connect(m_timer, SIGNAL(timeout()), this, SLOT(expired()));
m_timer->start();
}

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef QCRONSCHEDULER_H
#define QCRONSCHEDULER_H
#include "QObject"
@ -57,3 +58,6 @@ private:
QTimer *m_timer = nullptr;
static QList<int> parseField(const QString &_value, int _min, int _max);
};
#endif /* QCRONSCHEDULER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef STOOQQUOTESPROVIDER_H
#define STOOQQUOTESPROVIDER_H
#include "abstractquotesprovider.h"
@ -36,3 +37,6 @@ public:
private:
QUrl m_url;
};
#endif /* STOOQQUOTESPROVIDER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef YAHOOQUOTESPROVIDER_H
#define YAHOOQUOTESPROVIDER_H
#include "abstractquotesprovider.h"
@ -37,3 +38,6 @@ public:
private:
QUrl m_url;
};
#endif /* YAHOOQUOTESPROVIDER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef YAHOOWEATHERPROVIDER_H
#define YAHOOWEATHERPROVIDER_H
#include "abstractweatherprovider.h"
@ -42,3 +43,6 @@ private:
int m_ts = 0;
QUrl m_url;
};
#endif /* YAHOOWEATHERPROVIDER_H */

View File

@ -18,8 +18,7 @@
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.desktoppanel
import org.kde.plasma.private.desktoppanel 1.0
KCM.SimpleKCM {

View File

@ -18,8 +18,8 @@
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.desktoppanel
import org.kde.plasma.private.desktoppanel 1.0
import "."
KCM.SimpleKCM {

View File

@ -19,8 +19,7 @@ import QtQuick 2.15
import QtQuick.Controls
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.desktoppanel
import org.kde.plasma.private.desktoppanel 1.0
KCM.SimpleKCM {

View File

@ -18,8 +18,8 @@
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.desktoppanel
import org.kde.plasma.private.desktoppanel 1.0
import "."
KCM.SimpleKCM {

View File

@ -21,8 +21,8 @@ import QtQuick.Layouts
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.desktoppanel
import org.kde.plasma.private.desktoppanel 1.0
import "."
PlasmoidItem {

View File

@ -0,0 +1,27 @@
# Do not edit qmldir directly it will be overrided during compilation,
# edit qml/qmldir.in file instead.
# common QML constants
singleton General 1.0 file:///usr/share/awesomewidgets/qml/General.qml
# custom QML UI classes
AboutTab file:///usr/share/awesomewidgets/qml/AboutTab.qml
AWExtensions file:///usr/share/awesomewidgets/qml/AWExtensions.qml
AWInfoLabel file:///usr/share/awesomewidgets/qml/AWInfoLabel.qml
AWTagSelector file:///usr/share/awesomewidgets/qml/AWTagSelector.qml
AWTextEditor file:///usr/share/awesomewidgets/qml/AWTextEditor.qml
BugReport file:///usr/share/awesomewidgets/qml/BugReport.qml
ButtonSelector file:///usr/share/awesomewidgets/qml/ButtonSelector.qml
CheckBoxSelector file:///usr/share/awesomewidgets/qml/CheckBoxSelector.qml
ColorSelector file:///usr/share/awesomewidgets/qml/ColorSelector.qml
ComboBoxSelector file:///usr/share/awesomewidgets/qml/ComboBoxSelector.qml
ExportDialog file:///usr/share/awesomewidgets/qml/ExportDialog.qml
FontSelector file:///usr/share/awesomewidgets/qml/FontSelector.qml
HtmlDefaultFunctionsBar file:///usr/share/awesomewidgets/qml/HtmlDefaultFunctionsBar.qml
HtmlEditorButton file:///usr/share/awesomewidgets/qml/HtmlEditorButton.qml
HtmlEditorColor file:///usr/share/awesomewidgets/qml/HtmlEditorColor.qml
HtmlEditorFont file:///usr/share/awesomewidgets/qml/HtmlEditorFont.qml
ImportDialog file:///usr/share/awesomewidgets/qml/ImportDialog.qml
IntegerSelector file:///usr/share/awesomewidgets/qml/IntegerSelector.qml
LineSelector file:///usr/share/awesomewidgets/qml/LineSelector.qml

View File

@ -18,8 +18,8 @@
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.desktoppanel
import org.kde.plasma.private.desktoppanel 1.0
import "."
KCM.SimpleKCM {

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef DPPLUGIN_H
#define DPPLUGIN_H
#include <QQmlExtensionPlugin>
@ -28,3 +30,6 @@ class DPPlugin : public QQmlExtensionPlugin
public:
void registerTypes(const char *uri) override;
};
#endif /* DPPLUGIN_H */

View File

@ -111,8 +111,8 @@ QString DPAdds::toolTipImage(const int _desktop) const
}
// init
auto toolTipScene = new QGraphicsScene();
auto toolTipView = new QGraphicsView(toolTipScene);
auto *toolTipScene = new QGraphicsScene();
auto *toolTipView = new QGraphicsView(toolTipScene);
toolTipView->setStyleSheet("background: transparent");
toolTipView->setContentsMargins(0, 0, 0, 0);
toolTipView->setFrameShape(QFrame::NoFrame);

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef DPADDS_H
#define DPADDS_H
// ui library required by WId definition
#include <QGuiApplication>
@ -76,3 +78,6 @@ private:
QString m_tooltipColor = "#000000";
QString m_tooltipType = "none";
};
#endif /* DPADDS_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef EXTSYSMON_H
#define EXTSYSMON_H
#include <ksysguard/systemstats/SensorPlugin.h>
@ -35,3 +36,6 @@ private:
void readConfiguration();
[[nodiscard]] static QHash<QString, QString> updateConfiguration(QHash<QString, QString> _rawConfig);
};
#endif /* EXTSYSMON_H */

View File

@ -57,33 +57,34 @@ void ExtSysMonAggregator::init(const QHash<QString, QString> &_config)
qCDebug(LOG_ESM) << "Configuration" << _config;
// battery
createSensor("battery", i18n("Battery"), new BatterySource(this, _config["ACPIPATH"]));
createSensor("battery", i18n("Battery"), new BatterySource(this, {_config["ACPIPATH"]}));
// custom
createSensor("custom", i18n("Scripts"), new CustomSource(this));
createSensor("custom", i18n("Scripts"), new CustomSource(this, {}));
// desktop
createSensor("desktop", i18n("Desktop"), new DesktopSource(this));
// FIXME causes segfault in kde libs
// createSensor("desktop", i18n("Desktop"), new DesktopSource(this, {}));
// network
createSensor("network", i18n("Network"), new NetworkSource(this));
createSensor("network", i18n("Network"), new NetworkSource(this, {}));
// player
createSensor("player", i18n("Music player"),
new PlayerSource(this, _config["PLAYER"], _config["MPDADDRESS"], _config["MPDPORT"].toInt(),
_config["MPRIS"], _config["PLAYERSYMBOLS"].toInt()));
new PlayerSource(this, {_config["PLAYER"], _config["MPDADDRESS"], _config["MPDPORT"], _config["MPRIS"],
_config["PLAYERSYMBOLS"]}));
// processes
createSensor("ps", i18n("Processes"), new ProcessesSource(this));
createSensor("ps", i18n("Processes"), new ProcessesSource(this, {}));
// network request
createSensor("requests", i18n("Network requests"), new RequestSource(this));
createSensor("requests", i18n("Network requests"), new RequestSource(this, {}));
// quotes
createSensor("quotes", i18n("Quotes"), new QuotesSource(this));
createSensor("quotes", i18n("Quotes"), new QuotesSource(this, {}));
// system
createSensor("system", i18n("System"), new SystemInfoSource(this));
createSensor("system", i18n("System"), new SystemInfoSource(this, {}));
// current time
createSensor("time", i18n("Time"), new TimeSource(this));
createSensor("time", i18n("Time"), new TimeSource(this, {}));
// upgrade
createSensor("upgrade", i18n("Upgrades"), new UpgradeSource(this));
createSensor("upgrade", i18n("Upgrades"), new UpgradeSource(this, {}));
// weather
createSensor("weather", i18n("Weather"), new WeatherSource(this));
createSensor("weather", i18n("Weather"), new WeatherSource(this, {}));
#ifdef BUILD_LOAD
// additional load source
createSensor("load", i18n("Load"), new LoadSource(this));
createSensor("load", i18n("Load"), new LoadSource(this, {}));
#endif /* BUILD_LOAD */
}

View File

@ -15,62 +15,41 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#include <ksysguard/systemstats/SensorInfo.h>
#ifndef ABSTRACTEXTSYSMONSOURCE_H
#define ABSTRACTEXTSYSMONSOURCE_H
#include <QObject>
#include <QRegularExpression>
#include <QVariant>
namespace KSysGuard
{
class SensorInfo;
}
class AbstractExtSysMonSource : public QObject
{
Q_OBJECT
public:
inline static QRegularExpression NUMBER_REGEX = QRegularExpression("\\d+$");
explicit AbstractExtSysMonSource(QObject *_parent)
explicit AbstractExtSysMonSource(QObject *_parent, const QStringList &)
: QObject(_parent){};
~AbstractExtSysMonSource() override = default;
virtual QVariant data(const QString &_source) = 0;
[[nodiscard]] virtual QHash<QString, KSysGuard::SensorInfo *> sources() const = 0;
[[nodiscard]] virtual KSysGuard::SensorInfo *initialData(const QString &_source) const = 0;
virtual void run() = 0;
[[nodiscard]] virtual QStringList sources() const = 0;
// used by extensions
// This method returns -1 in case of invalid source name (like if there is no number)
static int index(const QString &_source)
{
auto match = NUMBER_REGEX.match(_source);
return match.hasMatch() ? match.captured().toInt() : -1;
}
// safe value extractor
template <class T> static QVariantHash dataByItem(T *_extension, const QString &_source)
{
auto idx = index(_source);
if (idx == -1)
return {};
auto item = _extension->itemByTagNumber(idx);
return item ? item->run() : QVariantHash();
}
static KSysGuard::SensorInfo *makeSensorInfo(const QString &_name, const QVariant::Type type,
const KSysGuard::Unit unit = KSysGuard::UnitNone, const double min = 0,
const double max = 0)
{
auto info = new KSysGuard::SensorInfo();
info->name = _name;
info->variantType = type;
info->unit = unit;
info->min = min;
info->max = max;
return info;
QRegularExpression rx("\\d+");
return rx.match(_source).captured().toInt();
}
signals:
void dataReceived(const QVariantHash &);
};
#endif /* ABSTRACTEXTSYSMONSOURCE_H */

View File

@ -15,8 +15,12 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "batterysource.h"
#include <ksysguard/formatter/Unit.h>
#include <ksysguard/systemstats/SensorInfo.h>
#include <QDir>
#include <cmath>
@ -24,15 +28,51 @@
#include "awdebug.h"
BatterySource::BatterySource(QObject *_parent, QString _acpiPath)
: AbstractExtSysMonSource(_parent)
, m_acpiPath(std::move(_acpiPath))
BatterySource::BatterySource(QObject *_parent, const QStringList &_args)
: AbstractExtSysMonSource(_parent, _args)
{
Q_ASSERT(_args.count() == 1);
qCDebug(LOG_ESS) << __PRETTY_FUNCTION__;
m_acpiPath = _args.at(0);
m_sources = getSources();
}
BatterySource::~BatterySource()
{
qCDebug(LOG_ESS) << __PRETTY_FUNCTION__;
}
QStringList BatterySource::getSources()
{
QStringList sources;
sources.append("ac");
sources.append("bat");
sources.append("batleft");
sources.append("batnow");
sources.append("batrate");
sources.append("battotal");
auto directory = QDir(m_acpiPath);
m_batteriesCount = directory.entryList(QStringList({"BAT*"}), QDir::Dirs | QDir::NoDotAndDotDot).count();
qCInfo(LOG_ESS) << "Init batteries count as" << m_batteriesCount;
if (directory.exists()) {
m_batteriesCount
= directory.entryList(QStringList({"BAT*"}), QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name).count();
qCInfo(LOG_ESS) << "Init batteries count as" << m_batteriesCount;
for (int i = 0; i < m_batteriesCount; i++) {
sources.append(QString("bat%1").arg(i));
sources.append(QString("batleft%1").arg(i));
sources.append(QString("batnow%1").arg(i));
sources.append(QString("batrate%1").arg(i));
sources.append(QString("battotal%1").arg(i));
}
}
qCInfo(LOG_ESS) << "Sources list" << sources;
return sources;
}
@ -41,11 +81,86 @@ QVariant BatterySource::data(const QString &_source)
qCDebug(LOG_ESS) << "Source" << _source;
if (!m_values.contains(_source))
run(); // syncronous update of all values
run();
return m_values.take(_source);
}
KSysGuard::SensorInfo *BatterySource::initialData(const QString &_source) const
{
qCDebug(LOG_ESS) << "Source" << _source;
auto data = new KSysGuard::SensorInfo();
if (_source == "ac") {
data->name = "Is AC online or not";
data->variantType = QVariant::Bool;
data->unit = KSysGuard::UnitNone;
} else if (_source == "bat") {
data->min = 0;
data->max = 100;
data->name = "Average battery usage";
data->variantType = QVariant::Int;
data->unit = KSysGuard::UnitPercent;
} else if (_source == "batleft") {
data->min = 0;
data->max = 0;
data->name = "Battery discharge time";
data->variantType = QVariant::Int;
data->unit = KSysGuard::UnitSecond;
} else if (_source == "batnow") {
data->min = 0;
data->max = 0;
data->name = "Current battery capacity";
data->variantType = QVariant::Int;
data->unit = KSysGuard::UnitNone;
} else if (_source == "batrate") {
data->min = 0;
data->max = 0;
data->name = "Average battery discharge rate";
data->variantType = QVariant::Double;
data->unit = KSysGuard::UnitRate;
} else if (_source == "battotal") {
data->min = 0;
data->max = 0;
data->name = "Full battery capacity";
data->variantType = QVariant::Int;
data->unit = KSysGuard::UnitNone;
} else if (_source.startsWith("batleft")) {
data->min = 0;
data->max = 0;
data->name = QString("Battery %1 discharge time").arg(index(_source));
data->variantType = QVariant::Int;
data->unit = KSysGuard::UnitSecond;
} else if (_source.startsWith("batnow")) {
data->min = 0;
data->max = 0;
data->name = QString("Battery %1 capacity").arg(index(_source));
data->variantType = QVariant::Int;
data->unit = KSysGuard::UnitNone;
} else if (_source.startsWith("battotal")) {
data->min = 0;
data->max = 0;
data->name = QString("Battery %1 full capacity").arg(index(_source));
data->variantType = QVariant::Int;
data->unit = KSysGuard::UnitNone;
} else if (_source.startsWith("batrate")) {
data->min = 0;
data->max = 0;
data->name = QString("Battery %1 discharge rate").arg(index(_source));
data->variantType = QVariant::Double;
data->unit = KSysGuard::UnitRate;
} else if (_source.startsWith("bat")) {
data->min = 0;
data->max = 100;
data->name = QString("Battery %1 usage").arg(index(_source));
data->variantType = QVariant::Int;
data->unit = KSysGuard::UnitPercent;
}
return data;
}
void BatterySource::run()
{
// adaptor
@ -88,32 +203,9 @@ void BatterySource::run()
}
QHash<QString, KSysGuard::SensorInfo *> BatterySource::sources() const
QStringList BatterySource::sources() const
{
auto result = QHash<QString, KSysGuard::SensorInfo *>();
// fixed fields
result.insert("ac", makeSensorInfo("Is AC online or not", QVariant::Bool));
result.insert("bat", makeSensorInfo("Average battery usage", QVariant::Int, KSysGuard::UnitPercent, 0, 100));
result.insert("batleft", makeSensorInfo("Battery discharge time", QVariant::Int, KSysGuard::UnitSecond));
result.insert("batnow", makeSensorInfo("Current battery capacity", QVariant::Int));
result.insert("batrate", makeSensorInfo("Average battery discharge rate", QVariant::Double, KSysGuard::UnitRate));
result.insert("battotal", makeSensorInfo("Full battery capacity", QVariant::Int));
// generators
for (auto i = 0; i < m_batteriesCount; i++) {
result.insert(QString("bat%1").arg(i), makeSensorInfo(QString("Battery %1 usage").arg(i), QVariant::Int,
KSysGuard::UnitPercent, 0, 100));
result.insert(QString("batleft%1").arg(i), makeSensorInfo(QString("Battery %1 discharge time").arg(i),
QVariant::Int, KSysGuard::UnitSecond));
result.insert(QString("batnow%1").arg(i), makeSensorInfo(QString("Battery %1 capacity").arg(i), QVariant::Int));
result.insert(QString("batrate%1").arg(i), makeSensorInfo(QString("Battery %1 discharge rate").arg(i),
QVariant::Double, KSysGuard::UnitRate));
result.insert(QString("battotal%1").arg(i),
makeSensorInfo(QString("Battery %1 full capacity").arg(i), QVariant::Int));
}
return result;
return m_sources;
}

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef BATTERYSOURCE_H
#define BATTERYSOURCE_H
#include <QDateTime>
#include <QObject>
@ -30,11 +31,13 @@ class BatterySource : public AbstractExtSysMonSource
public:
const int TREND_LIMIT = 20;
explicit BatterySource(QObject *_parent, QString _acpiPath);
~BatterySource() override = default;
explicit BatterySource(QObject *_parent, const QStringList &_args);
~BatterySource() override;
QStringList getSources();
QVariant data(const QString &_source) override;
void run();
[[nodiscard]] QHash<QString, KSysGuard::SensorInfo *> sources() const override;
[[nodiscard]] KSysGuard::SensorInfo *initialData(const QString &_source) const override;
void run() override;
[[nodiscard]] QStringList sources() const override;
private:
static double approximate(const QList<int> &_trend);
@ -47,3 +50,6 @@ private:
QHash<int, QList<int>> m_trend;
QVariantHash m_values;
};
#endif /* BATTERYSOURCE_H */

View File

@ -17,17 +17,28 @@
#include "customsource.h"
#include <ksysguard/formatter/Unit.h>
#include <ksysguard/systemstats/SensorInfo.h>
#include "awdebug.h"
#include "extscript.h"
CustomSource::CustomSource(QObject *_parent)
: AbstractExtSysMonSource(_parent)
CustomSource::CustomSource(QObject *_parent, const QStringList &_args)
: AbstractExtSysMonSource(_parent, _args)
{
Q_ASSERT(_args.count() == 0);
qCDebug(LOG_ESS) << __PRETTY_FUNCTION__;
m_extScripts = new ExtItemAggregator<ExtScript>(this, "scripts");
m_extScripts = new ExtItemAggregator<ExtScript>(nullptr, "scripts");
m_extScripts->initSockets();
m_sources = getSources();
}
CustomSource::~CustomSource()
{
qCDebug(LOG_ESS) << __PRETTY_FUNCTION__;
}
@ -36,17 +47,34 @@ QVariant CustomSource::data(const QString &_source)
qCDebug(LOG_ESS) << "Source" << _source;
// there are only one value
return dataByItem(m_extScripts, _source).values().first();
return m_extScripts->itemByTagNumber(index(_source))->run().values().first();
}
QHash<QString, KSysGuard::SensorInfo *> CustomSource::sources() const
KSysGuard::SensorInfo *CustomSource::initialData(const QString &_source) const
{
auto result = QHash<QString, KSysGuard::SensorInfo *>();
qCDebug(LOG_ESS) << "Source" << _source;
for (auto &item : m_extScripts->activeItems())
result.insert(item->tag("custom"),
makeSensorInfo(QString("Custom command '%1' output").arg(item->uniq()), QVariant::String));
auto data = new KSysGuard::SensorInfo();
data->name = QString("Custom command '%1' output").arg(m_extScripts->itemByTagNumber(index(_source))->uniq());
data->variantType = QVariant::String;
data->unit = KSysGuard::UnitNone;
return result;
return data;
}
QStringList CustomSource::sources() const
{
return m_sources;
}
QStringList CustomSource::getSources()
{
QStringList sources;
for (auto &item : m_extScripts->activeItems())
sources.append(item->tag("custom"));
return sources;
}

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef CUSTOMSOURCE_H
#define CUSTOMSOURCE_H
#include <QObject>
@ -30,12 +31,19 @@ class CustomSource : public AbstractExtSysMonSource
Q_OBJECT
public:
explicit CustomSource(QObject *_parent);
~CustomSource() override = default;
explicit CustomSource(QObject *_parent, const QStringList &_args);
~CustomSource() override;
QVariant data(const QString &_source) override;
[[nodiscard]] QHash<QString, KSysGuard::SensorInfo *> sources() const override;
[[nodiscard]] KSysGuard::SensorInfo *initialData(const QString &_source) const override;
void run() override{};
[[nodiscard]] QStringList sources() const override;
private:
QStringList getSources();
// configuration and values
ExtItemAggregator<ExtScript> *m_extScripts = nullptr;
QStringList m_sources;
};
#endif /* CUSTOMSOURCE_H */

View File

@ -17,17 +17,29 @@
#include "desktopsource.h"
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusVariant>
#include <KWindowSystem/KWindowSystem>
#include <ksysguard/formatter/Unit.h>
#include <ksysguard/systemstats/SensorInfo.h>
#include <taskmanager/virtualdesktopinfo.h>
#include "awdebug.h"
DesktopSource::DesktopSource(QObject *_parent)
: AbstractExtSysMonSource(_parent)
DesktopSource::DesktopSource(QObject *_parent, const QStringList &_args)
: AbstractExtSysMonSource(_parent, _args)
{
Q_ASSERT(_args.count() == 0);
qCDebug(LOG_ESS) << __PRETTY_FUNCTION__;
m_vdi = new TaskManager::VirtualDesktopInfo(this);
}
DesktopSource::~DesktopSource()
{
qCDebug(LOG_ESS) << __PRETTY_FUNCTION__;
m_vdi->deleteLater();
}
@ -35,72 +47,60 @@ QVariant DesktopSource::data(const QString &_source)
{
qCDebug(LOG_ESS) << "Source" << _source;
auto current = getDBusProperty({"org.kde.KWin.VirtualDesktopManager", "current"}).toString();
auto desktops
= extractDesktops(getDBusProperty({"org.kde.KWin.VirtualDesktopManager", "desktops"}).value<QDBusArgument>());
auto nativeIndex = m_vdi->position(m_vdi->currentDesktop());
auto decrement = KWindowSystem::isPlatformX11() ? 1 : 0;
auto current = nativeIndex - decrement;
if (_source == "name") {
return desktops[current].second;
return m_vdi->desktopNames().at(current);
} else if (_source == "number") {
return desktops[current].first + 1;
return current + 1;
} else if (_source == "names") {
return m_vdi->desktopNames();
} else if (_source == "count") {
return desktops.count();
return m_vdi->numberOfDesktops();
}
return {};
}
QHash<QString, KSysGuard::SensorInfo *> DesktopSource::sources() const
KSysGuard::SensorInfo *DesktopSource::initialData(const QString &_source) const
{
auto result = QHash<QString, KSysGuard::SensorInfo *>();
qCDebug(LOG_ESS) << "Source" << _source;
result.insert("name", makeSensorInfo("Current desktop name", QVariant::String));
result.insert("number", makeSensorInfo("Current desktop number", QVariant::Int));
result.insert("count", makeSensorInfo("Desktops count", QVariant::Int));
return result;
}
QHash<QString, QPair<int, QString>> DesktopSource::extractDesktops(const QDBusArgument &_result)
{
QHash<QString, QPair<int, QString>> result;
_result.beginArray();
while (!_result.atEnd()) {
_result.beginStructure();
int index;
QString uuid, name;
_result >> index >> uuid >> name;
_result.endStructure();
result[uuid] = {index, name};
auto data = new KSysGuard::SensorInfo();
if (_source == "name") {
data->name = "Current desktop name";
data->variantType = QVariant::String;
data->unit = KSysGuard::UnitNone;
} else if (_source == "number") {
data->min = 0;
data->name = "Current desktop number";
data->variantType = QVariant::Int;
data->unit = KSysGuard::UnitNone;
} else if (_source == "names") {
data->name = "All desktops by name";
data->variantType = QVariant::StringList;
data->unit = KSysGuard::UnitNone;
} else if (_source == "count") {
data->min = 0;
data->name = "Desktops count";
data->variantType = QVariant::Int;
data->unit = KSysGuard::UnitNone;
}
_result.endArray();
return result;
return data;
}
QVariant DesktopSource::getDBusProperty(const QVariantList &_args)
QStringList DesktopSource::sources() const
{
qCDebug(LOG_ESS) << "Get VDI property" << _args;
QStringList sources;
sources.append("name");
sources.append("number");
sources.append("names");
sources.append("count");
auto bus = QDBusConnection::sessionBus();
auto request
= QDBusMessage::createMethodCall(KWinDBusAdapter, VDIDBusPath, PropertyDBusInterface, PropertyDBusMethod);
request.setArguments(_args);
auto response = bus.call(request, QDBus::BlockWithGui, REQUEST_TIMEOUT);
if ((response.type() != QDBusMessage::ReplyMessage) || (response.arguments().isEmpty())) {
qCWarning(LOG_ESS) << "Error message" << response.errorMessage();
return {};
} else {
auto value = response.arguments().first();
return value.value<QDBusVariant>().variant();
}
return sources;
}

View File

@ -15,30 +15,33 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef DESKTOPSOURCE_H
#define DESKTOPSOURCE_H
#include <QObject>
#include "abstractextsysmonsource.h"
namespace TaskManager
{
class VirtualDesktopInfo;
}
class DesktopSource : public AbstractExtSysMonSource
{
Q_OBJECT
public:
static constexpr auto KWinDBusAdapter = "org.kde.KWin";
static constexpr auto VDIDBusPath = "/VirtualDesktopManager";
static constexpr auto PropertyDBusInterface = "org.freedesktop.DBus.Properties";
static constexpr auto PropertyDBusMethod = "Get";
explicit DesktopSource(QObject *_parent);
~DesktopSource() override = default;
explicit DesktopSource(QObject *_parent, const QStringList &_args);
~DesktopSource() override;
QVariant data(const QString &_source) override;
[[nodiscard]] QHash<QString, KSysGuard::SensorInfo *> sources() const override;
[[nodiscard]] KSysGuard::SensorInfo *initialData(const QString &_source) const override;
void run() override{};
[[nodiscard]] QStringList sources() const override;
private:
static QHash<QString, QPair<int, QString>> extractDesktops(const QDBusArgument &_result);
static QVariant getDBusProperty(const QVariantList &_args);
TaskManager::VirtualDesktopInfo *m_vdi = nullptr;
};
#endif /* DESKTOPSOURCE_H */

View File

@ -33,8 +33,8 @@ ExtSysMonSensor::ExtSysMonSensor(KSysGuard::SensorContainer *_parent, const QStr
loadProperties();
connect(this, &SensorObject::subscribedChanged, this, &ExtSysMonSensor::changeSubscription);
connect(m_timer, &QTimer::timeout, this, &ExtSysMonSensor::update);
connect(this, &SensorObject::subscribedChanged, [this](bool _state) { changeSubscription(_state); });
connect(m_timer, &QTimer::timeout, [this]() { update(); });
}
@ -61,19 +61,21 @@ void ExtSysMonSensor::changeSubscription(bool _subscribed)
void ExtSysMonSensor::update()
{
for (auto sensor : sensors()) {
if (!sensor->isSubscribed())
for (auto &source : m_source->sources()) {
auto property = sensor(source);
if (!property->isSubscribed())
continue; // skip properties which are not explicitly subscribed
auto value = m_source->data(sensor->id());
sensor->setValue(value);
auto value = m_source->data(source);
property->setValue(value);
}
}
void ExtSysMonSensor::loadProperties()
{
for (auto [source, info] : m_source->sources().asKeyValueRange()) {
for (auto &source : m_source->sources()) {
auto info = m_source->initialData(source);
auto property = new KSysGuard::SensorProperty(source, info->name, this);
property->setUnit(info->unit);

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef EXTSYSMONSENSOR_H
#define EXTSYSMONSENSOR_H
#include <ksysguard/systemstats/SensorObject.h>
@ -31,8 +32,6 @@ public:
explicit ExtSysMonSensor(KSysGuard::SensorContainer *_parent, const QString &_id, const QString &_name,
AbstractExtSysMonSource *_source);
~ExtSysMonSensor() override;
public slots:
void changeSubscription(bool _subscribed);
void update();
@ -41,3 +40,6 @@ private:
AbstractExtSysMonSource *m_source = nullptr;
QTimer *m_timer = nullptr;
};
#endif /* EXTSYSMONSENSOR_H */

View File

@ -15,15 +15,26 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "loadsource.h"
#include <ksysguard/formatter/Unit.h>
#include <ksysguard/systemstats/SensorInfo.h>
#include <QRandomGenerator>
#include "awdebug.h"
LoadSource::LoadSource(QObject *_parent)
: AbstractExtSysMonSource(_parent)
LoadSource::LoadSource(QObject *_parent, const QStringList &_args)
: AbstractExtSysMonSource(_parent, _args)
{
Q_ASSERT(_args.count() == 0);
qCDebug(LOG_ESS) << __PRETTY_FUNCTION__;
}
LoadSource::~LoadSource()
{
qCDebug(LOG_ESS) << __PRETTY_FUNCTION__;
}
@ -37,12 +48,28 @@ QVariant LoadSource::data(const QString &_source)
}
QHash<QString, KSysGuard::SensorInfo *> LoadSource::sources() const
KSysGuard::SensorInfo *LoadSource::initialData(const QString &_source) const
{
auto result = QHash<QString, KSysGuard::SensorInfo *>();
qCDebug(LOG_ESS) << "Source" << _source;
for (auto i = 0; i < 1000; i++)
result.insert(QString("load%1").arg(i), makeSensorInfo("Simple sources for load tests", QVariant::Int));
auto data = new KSysGuard::SensorInfo();
if (_source.startsWith("load")) {
data->min = 0;
data->max = 0;
data->name = "Simple sources for load tests";
data->variantType = QVariant::Int;
data->unit = KSysGuard::UnitNone;
}
return result;
return data;
}
QStringList LoadSource::sources() const
{
QStringList sources;
for (int i = 0; i < 1000; i++)
sources.append(QString("load%1").arg(i));
return sources;
}

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