diff --git a/sources/awesome-widget/package/contents/ui/main.qml b/sources/awesome-widget/package/contents/ui/main.qml index 8e66f1e..e66688d 100644 --- a/sources/awesome-widget/package/contents/ui/main.qml +++ b/sources/awesome-widget/package/contents/ui/main.qml @@ -183,10 +183,8 @@ PlasmoidItem { plasmoid.configuration.telemetryId = generateUuid() // save telemetry awTelemetryHandler.init(plasmoid.configuration.telemetryCount, - plasmoid.configuration.telemetryRemote, plasmoid.configuration.telemetryId) - if (awTelemetryHandler.put("awwidgetconfig", plasmoid.configuration.text)) - awTelemetryHandler.uploadTelemetry("awwidgetconfig", plasmoid.configuration.text) + awTelemetryHandler.put("awwidgetconfig", plasmoid.configuration.text) } // code from http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript diff --git a/sources/awesome-widget/plugin/awabstractpairconfig.cpp b/sources/awesome-widget/plugin/awabstractpairconfig.cpp index 61ef729..8f971f4 100644 --- a/sources/awesome-widget/plugin/awabstractpairconfig.cpp +++ b/sources/awesome-widget/plugin/awabstractpairconfig.cpp @@ -58,6 +58,12 @@ AWAbstractPairConfig::~AWAbstractPairConfig() } +void AWAbstractPairConfig::setHelper(std::unique_ptr _helper) +{ + m_helper = std::move(_helper); +} + + void AWAbstractPairConfig::showDialog() { // update dialog @@ -133,7 +139,7 @@ void AWAbstractPairConfig::execDialog() auto ret = exec(); QHash data; for (auto selector : m_selectors) { - QPair select = selector->current(); + auto select = selector->current(); if (select.first.isEmpty()) continue; data[select.first] = select.second; diff --git a/sources/awesome-widget/plugin/awabstractpairconfig.h b/sources/awesome-widget/plugin/awabstractpairconfig.h index 9a027ac..ee07585 100644 --- a/sources/awesome-widget/plugin/awabstractpairconfig.h +++ b/sources/awesome-widget/plugin/awabstractpairconfig.h @@ -35,12 +35,7 @@ class AWAbstractPairConfig : public QDialog public: explicit AWAbstractPairConfig(QWidget *_parent = nullptr, bool _hasEdit = false, QStringList _keys = {}); ~AWAbstractPairConfig() override; - template void initHelper() - { - - delete m_helper; - m_helper = new T(this); - } + void setHelper(std::unique_ptr _helper); void showDialog(); // properties void setEditable(bool _first, bool _second); @@ -52,7 +47,7 @@ private slots: private: QPushButton *m_editButton = nullptr; Ui::AWAbstractPairConfig *ui = nullptr; - AWAbstractPairHelper *m_helper = nullptr; + std::unique_ptr m_helper; QList m_selectors; // properties QPair m_editable = {false, false}; diff --git a/sources/awesome-widget/plugin/awbugreporter.cpp b/sources/awesome-widget/plugin/awbugreporter.cpp index 5c0e3dc..4f8ce5b 100644 --- a/sources/awesome-widget/plugin/awbugreporter.cpp +++ b/sources/awesome-widget/plugin/awbugreporter.cpp @@ -33,12 +33,17 @@ AWBugReporter::AWBugReporter(QObject *_parent) : QObject(_parent) { qCDebug(LOG_AW) << __PRETTY_FUNCTION__; + + m_manager = new QNetworkAccessManager(nullptr); + connect(m_manager, &QNetworkAccessManager::finished, this, &AWBugReporter::issueReplyReceived); } AWBugReporter::~AWBugReporter() { qCDebug(LOG_AW) << __PRETTY_FUNCTION__; + + m_manager->deleteLater(); } @@ -72,8 +77,6 @@ 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 request = QNetworkRequest(QUrl(BUGTRACKER_API)); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); @@ -87,7 +90,7 @@ void AWBugReporter::sendBugReport(const QString &_title, const QString &_body) auto data = QJsonDocument::fromVariant(payload).toJson(QJsonDocument::Compact); qCInfo(LOG_AW) << "Send request with _body" << data.data() << "and size" << data.size(); - manager->post(request, data); + m_manager->post(request, data); } diff --git a/sources/awesome-widget/plugin/awbugreporter.h b/sources/awesome-widget/plugin/awbugreporter.h index 5ff845b..14b1dca 100644 --- a/sources/awesome-widget/plugin/awbugreporter.h +++ b/sources/awesome-widget/plugin/awbugreporter.h @@ -20,6 +20,7 @@ #include +class QNetworkAccessManager; class QNetworkReply; class AWBugReporter : public QObject @@ -44,4 +45,5 @@ private slots: private: QString m_lastBugUrl; + QNetworkAccessManager *m_manager = nullptr; }; diff --git a/sources/awesome-widget/plugin/awcustomkeysconfig.cpp b/sources/awesome-widget/plugin/awcustomkeysconfig.cpp index 4871b66..743e6b3 100644 --- a/sources/awesome-widget/plugin/awcustomkeysconfig.cpp +++ b/sources/awesome-widget/plugin/awcustomkeysconfig.cpp @@ -27,5 +27,5 @@ AWCustomKeysConfig::AWCustomKeysConfig(QWidget *_parent, const QStringList &_key qCDebug(LOG_AW) << __PRETTY_FUNCTION__; setEditable(true, false); - initHelper(); + setHelper(std::make_unique()); } diff --git a/sources/awesome-widget/plugin/awdataaggregator.cpp b/sources/awesome-widget/plugin/awdataaggregator.cpp index 74e7d2b..c2f9109 100644 --- a/sources/awesome-widget/plugin/awdataaggregator.cpp +++ b/sources/awesome-widget/plugin/awdataaggregator.cpp @@ -50,7 +50,8 @@ AWDataAggregator::~AWDataAggregator() { qCDebug(LOG_AW) << __PRETTY_FUNCTION__; - delete m_toolTipScene; + m_toolTipView->deleteLater(); + m_toolTipScene->deleteLater(); } diff --git a/sources/awesome-widget/plugin/awformatterconfig.cpp b/sources/awesome-widget/plugin/awformatterconfig.cpp index d4eedda..fa8f3b7 100644 --- a/sources/awesome-widget/plugin/awformatterconfig.cpp +++ b/sources/awesome-widget/plugin/awformatterconfig.cpp @@ -27,5 +27,5 @@ AWFormatterConfig::AWFormatterConfig(QWidget *_parent, const QStringList &_keys) qCDebug(LOG_AW) << __PRETTY_FUNCTION__; setEditable(false, false); - initHelper(); + setHelper(std::make_unique()); } diff --git a/sources/awesome-widget/plugin/awformatterhelper.cpp b/sources/awesome-widget/plugin/awformatterhelper.cpp index cfe628a..61cf73d 100644 --- a/sources/awesome-widget/plugin/awformatterhelper.cpp +++ b/sources/awesome-widget/plugin/awformatterhelper.cpp @@ -33,7 +33,7 @@ #include "awstringformatter.h" -AWFormatterHelper::AWFormatterHelper(QWidget *_parent) +AWFormatterHelper::AWFormatterHelper(QObject *_parent) : AbstractExtItemAggregator(_parent, "formatters") , AWAbstractPairHelper("awesomewidgets/formatters/formatters.ini", "Formatters") { diff --git a/sources/awesome-widget/plugin/awformatterhelper.h b/sources/awesome-widget/plugin/awformatterhelper.h index cf8523c..ed68791 100644 --- a/sources/awesome-widget/plugin/awformatterhelper.h +++ b/sources/awesome-widget/plugin/awformatterhelper.h @@ -27,7 +27,7 @@ class AWFormatterHelper : public AbstractExtItemAggregator, public AWAbstractPai Q_OBJECT public: - explicit AWFormatterHelper(QWidget *_parent = nullptr); + explicit AWFormatterHelper(QObject *_parent = nullptr); ~AWFormatterHelper() override; // read-write methods void initItems() override; diff --git a/sources/awesome-widget/plugin/awkeyoperations.cpp b/sources/awesome-widget/plugin/awkeyoperations.cpp index 5d78e07..bb60147 100644 --- a/sources/awesome-widget/plugin/awkeyoperations.cpp +++ b/sources/awesome-widget/plugin/awkeyoperations.cpp @@ -40,12 +40,12 @@ AWKeyOperations::AWKeyOperations(QObject *_parent) qCDebug(LOG_AW) << __PRETTY_FUNCTION__; m_customKeys = new AWCustomKeysHelper(this); - m_graphicalItems = new ExtItemAggregator(nullptr, "desktops"); - m_extNetRequest = new ExtItemAggregator(nullptr, "requests"); - m_extQuotes = new ExtItemAggregator(nullptr, "quotes"); - m_extScripts = new ExtItemAggregator(nullptr, "scripts"); - m_extUpgrade = new ExtItemAggregator(nullptr, "upgrade"); - m_extWeather = new ExtItemAggregator(nullptr, "weather"); + m_graphicalItems = new ExtItemAggregator(this, "desktops"); + m_extNetRequest = new ExtItemAggregator(this, "requests"); + m_extQuotes = new ExtItemAggregator(this, "quotes"); + m_extScripts = new ExtItemAggregator(this, "scripts"); + m_extUpgrade = new ExtItemAggregator(this, "upgrade"); + m_extWeather = new ExtItemAggregator(this, "weather"); } diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp index a2b47e9..2042966 100644 --- a/sources/awesome-widget/plugin/awkeys.cpp +++ b/sources/awesome-widget/plugin/awkeys.cpp @@ -189,8 +189,10 @@ void AWKeys::dataUpdated(const QHash &_sensors, 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); + setDataBySource(data.sensorProperty, sensor, data.payload); + // std::ignore = QtConcurrent::run(m_threadPool, &AWKeys::setDataBySource, this, data.sensorProperty, + // sensor, + // data.payload); } } diff --git a/sources/awesome-widget/plugin/awkeysaggregator.cpp b/sources/awesome-widget/plugin/awkeysaggregator.cpp index 34422de..9562993 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.cpp +++ b/sources/awesome-widget/plugin/awkeysaggregator.cpp @@ -33,7 +33,7 @@ AWKeysAggregator::AWKeysAggregator(QObject *_parent) { qCDebug(LOG_AW) << __PRETTY_FUNCTION__; - m_customFormatters = new AWFormatterHelper(nullptr); + m_customFormatters = new AWFormatterHelper(this); m_mapper = new AWDataEngineMapper(this, m_customFormatters); // sort time keys diff --git a/sources/awesome-widget/plugin/awtelemetryhandler.cpp b/sources/awesome-widget/plugin/awtelemetryhandler.cpp index a98cf2b..cb899e0 100644 --- a/sources/awesome-widget/plugin/awtelemetryhandler.cpp +++ b/sources/awesome-widget/plugin/awtelemetryhandler.cpp @@ -18,8 +18,6 @@ #include "awtelemetryhandler.h" #include -#include -#include #include #include #include @@ -65,13 +63,11 @@ QString AWTelemetryHandler::getLast(const QString &_group) const } -void AWTelemetryHandler::init(const int _count, const bool _enableRemote, const QString &_clientId) +void AWTelemetryHandler::init(const int _count, const QString &_clientId) { - qCDebug(LOG_AW) << "Init telemetry with count" << _count << "enable remote" << _enableRemote << "client ID" - << _clientId; + qCDebug(LOG_AW) << "Init telemetry with count" << _count << "client ID" << _clientId; m_storeCount = _count; - m_uploadEnabled = _enableRemote; m_clientId = _clientId; } @@ -112,59 +108,6 @@ bool AWTelemetryHandler::put(const QString &_group, const QString &_value) const } -void AWTelemetryHandler::uploadTelemetry(const QString &_group, const QString &_value) -{ - qCDebug(LOG_AW) << "Upload data with group" << _group << "and value" << _value; - if (!m_uploadEnabled) { - qCInfo(LOG_AW) << "Upload disabled by configuration"; - return; - } - - auto manager = new QNetworkAccessManager(nullptr); - connect(manager, &QNetworkAccessManager::finished, this, &AWTelemetryHandler::telemetryReplyReceived); - - QUrl url(REMOTE_TELEMETRY_URL); - QNetworkRequest request(url); - request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); - - // generate payload - QVariantMap payload; - payload["api"] = AW_TELEMETRY_API; - payload["client_id"] = m_clientId; - payload["metadata"] = _value; - payload["type"] = _group; - // convert to QByteArray to send request - auto 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) -{ - if (_reply->error() != QNetworkReply::NoError) { - qCWarning(LOG_AW) << "An error occurs" << _reply->error() << "with message" << _reply->errorString(); - return; - } - - QJsonParseError error{}; - auto jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error); - if (error.error != QJsonParseError::NoError) { - qCWarning(LOG_AW) << "Parse error" << error.errorString(); - return; - } - _reply->deleteLater(); - - // convert to map - auto response = jsonDoc.toVariant().toMap(); - auto message = response["message"].toString(); - qCInfo(LOG_AW) << "Server reply on telemetry" << message; - - return emit(replyReceived(message)); -} - - QString AWTelemetryHandler::getKey(const int _count) { qCDebug(LOG_AW) << "Get key for keys count" << _count; diff --git a/sources/awesome-widget/plugin/awtelemetryhandler.h b/sources/awesome-widget/plugin/awtelemetryhandler.h index 5f3253f..f9b14cf 100644 --- a/sources/awesome-widget/plugin/awtelemetryhandler.h +++ b/sources/awesome-widget/plugin/awtelemetryhandler.h @@ -20,33 +20,21 @@ #include -class QNetworkReply; - class AWTelemetryHandler : public QObject { Q_OBJECT public: - const char *REMOTE_TELEMETRY_URL = "https://arcanis.me/telemetry"; - explicit AWTelemetryHandler(QObject *_parent = nullptr, const QString &_clientId = ""); ~AWTelemetryHandler() override = default; Q_INVOKABLE [[nodiscard]] QStringList get(const QString &_group) const; Q_INVOKABLE [[nodiscard]] QString getLast(const QString &_group) const; - Q_INVOKABLE void init(int _count, bool _enableRemote, const QString &_clientId); + Q_INVOKABLE void init(int _count, const QString &_clientId); Q_INVOKABLE [[nodiscard]] bool put(const QString &_group, const QString &_value) const; - Q_INVOKABLE void uploadTelemetry(const QString &_group, const QString &_value); - -signals: - void replyReceived(const QString &_message); - -private slots: - void telemetryReplyReceived(QNetworkReply *_reply); private: static QString getKey(int _count); QString m_clientId; QString m_localFile; int m_storeCount = 0; - bool m_uploadEnabled = false; }; diff --git a/sources/awesome-widget/plugin/awupdatehelper.cpp b/sources/awesome-widget/plugin/awupdatehelper.cpp index 622f8d2..3ac092f 100644 --- a/sources/awesome-widget/plugin/awupdatehelper.cpp +++ b/sources/awesome-widget/plugin/awupdatehelper.cpp @@ -45,7 +45,7 @@ void AWUpdateHelper::checkUpdates(const bool _showAnyway) { qCDebug(LOG_AW) << "Show anyway" << _showAnyway; - // showAnyway options requires to show message if no updates found on direct + // showAnyway options required 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); connect(manager, &QNetworkAccessManager::finished, @@ -126,6 +126,7 @@ void AWUpdateHelper::versionReplyReceived(QNetworkReply *_reply, const bool _sho return; } _reply->deleteLater(); + _reply->manager()->deleteLater(); // remember to delete manager too // convert to map auto firstRelease = jsonDoc.toVariant().toList().first().toMap(); diff --git a/sources/awesomewidgets/abstractextitem.cpp b/sources/awesomewidgets/abstractextitem.cpp index c2a0184..7c046c8 100644 --- a/sources/awesomewidgets/abstractextitem.cpp +++ b/sources/awesomewidgets/abstractextitem.cpp @@ -36,6 +36,12 @@ AbstractExtItem::AbstractExtItem(QObject *_parent, const QString &_filePath) qCDebug(LOG_LIB) << "Desktop name" << _filePath; m_name = m_filePath; + + m_scheduler = new QCronScheduler(this); + connect(m_scheduler, &QCronScheduler::activated, this, &AbstractExtItem::requestDataUpdate); + + m_socket = new QLocalServer(this); + connect(m_socket, &QLocalServer::newConnection, this, &AbstractExtItem::requestDataUpdate); } @@ -43,11 +49,11 @@ AbstractExtItem::~AbstractExtItem() { qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; - if (m_socket) { - m_socket->close(); - QLocalServer::removeServer(socket()); - m_socket->deleteLater(); - } + m_scheduler->stop(); + m_scheduler->deleteLater(); + + m_socket->close(); + m_socket->deleteLater(); } @@ -203,20 +209,14 @@ void AbstractExtItem::setComment(const QString &_comment) 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); - delete m_scheduler; - } m_cron = _cron; - if (cron().isEmpty()) - return; - - // init scheduler - m_scheduler = new QCronScheduler(this); - m_scheduler->parse(cron()); - connect(m_scheduler, &QCronScheduler::activated, this, &AbstractExtItem::requestDataUpdate); + if (m_cron.isEmpty()) { // disable cron timer + m_scheduler->stop(); + } else { + m_scheduler->parse(m_cron); + m_scheduler->start(); + } } @@ -260,34 +260,18 @@ void AbstractExtItem::setNumber(int _number) void AbstractExtItem::setSocket(const QString &_socket) { qCDebug(LOG_LIB) << "Socket" << _socket; - // remove old socket first - deinitSocket(); m_socketFile = _socket; } -void AbstractExtItem::deinitSocket() -{ - if (!m_socket) - return; - - m_socket->close(); - QLocalServer::removeServer(socket()); - disconnect(m_socket, &QLocalServer::newConnection, this, &AbstractExtItem::requestDataUpdate); - delete m_socket; -} - - void AbstractExtItem::initSocket() { - // remove old socket first - deinitSocket(); + // reload local socket + m_socket->close(); - m_socket = new QLocalServer(this); - auto listening = m_socket->listen(socket()); - qCInfo(LOG_LIB) << "Server listening on" << socket() << listening; - connect(m_socket, &QLocalServer::newConnection, this, &AbstractExtItem::requestDataUpdate); + auto listening = m_socket->listen(m_socketFile); + qCInfo(LOG_LIB) << "Server listening on" << m_socketFile << listening; } diff --git a/sources/awesomewidgets/abstractextitem.h b/sources/awesomewidgets/abstractextitem.h index c11ce1d..e4537c0 100644 --- a/sources/awesomewidgets/abstractextitem.h +++ b/sources/awesomewidgets/abstractextitem.h @@ -75,7 +75,6 @@ signals: void requestDataUpdate(); public slots: - virtual void deinitSocket(); virtual void initSocket(); virtual void readConfiguration(); virtual QVariantHash run() = 0; diff --git a/sources/awesomewidgets/abstractquotesprovider.h b/sources/awesomewidgets/abstractquotesprovider.h index 409051f..bf13fa4 100644 --- a/sources/awesomewidgets/abstractquotesprovider.h +++ b/sources/awesomewidgets/abstractquotesprovider.h @@ -17,25 +17,15 @@ #pragma once -#include #include - -#include "abstractextitem.h" +#include -class AbstractQuotesProvider : public QObject +class AbstractQuotesProvider { - Q_OBJECT - public: - explicit AbstractQuotesProvider(QObject *_parent) - : QObject(_parent){}; - ~AbstractQuotesProvider() override = default; + virtual ~AbstractQuotesProvider() = default; virtual void initUrl(const QString &_asset) = 0; - [[nodiscard]] virtual QVariantHash parse(const QByteArray &_source, const QVariantHash &_oldValues) const = 0; - [[nodiscard]] QString tag(const QString &_type) const - { - return dynamic_cast(parent())->tag(_type); - }; + [[nodiscard]] virtual QVariantHash parse(const QByteArray &_source) = 0; [[nodiscard]] virtual QUrl url() const = 0; }; diff --git a/sources/awesomewidgets/abstractweatherprovider.h b/sources/awesomewidgets/abstractweatherprovider.h index 817c711..1e437f1 100644 --- a/sources/awesomewidgets/abstractweatherprovider.h +++ b/sources/awesomewidgets/abstractweatherprovider.h @@ -17,25 +17,15 @@ #pragma once -#include #include - -#include "abstractextitem.h" +#include -class AbstractWeatherProvider : public QObject +class AbstractWeatherProvider { - Q_OBJECT - public: - explicit AbstractWeatherProvider(QObject *_parent) - : QObject(_parent){}; - ~AbstractWeatherProvider() override = default; + virtual ~AbstractWeatherProvider() = default; virtual void initUrl(const QString &_city, const QString &_country, int _ts) = 0; [[nodiscard]] virtual QVariantHash parse(const QVariantMap &_json) const = 0; - [[nodiscard]] QString tag(const QString &_type) const - { - return dynamic_cast(parent())->tag(_type); - }; [[nodiscard]] virtual QUrl url() const = 0; }; diff --git a/sources/awesomewidgets/extnetworkrequest.cpp b/sources/awesomewidgets/extnetworkrequest.cpp index 8839666..c13ecd0 100644 --- a/sources/awesomewidgets/extnetworkrequest.cpp +++ b/sources/awesomewidgets/extnetworkrequest.cpp @@ -49,9 +49,6 @@ ExtNetworkRequest::~ExtNetworkRequest() { qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; - disconnect(m_manager, &QNetworkAccessManager::finished, this, &ExtNetworkRequest::networkReplyReceived); - disconnect(this, &ExtNetworkRequest::requestDataUpdate, this, &ExtNetworkRequest::sendRequest); - m_manager->deleteLater(); } diff --git a/sources/awesomewidgets/extquotes.cpp b/sources/awesomewidgets/extquotes.cpp index 8515e88..bf2ce82 100644 --- a/sources/awesomewidgets/extquotes.cpp +++ b/sources/awesomewidgets/extquotes.cpp @@ -55,9 +55,6 @@ ExtQuotes::~ExtQuotes() { qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; - disconnect(m_manager, &QNetworkAccessManager::finished, this, &ExtQuotes::quotesReplyReceived); - disconnect(this, &ExtQuotes::requestDataUpdate, this, &ExtQuotes::sendRequest); - m_manager->deleteLater(); } @@ -186,10 +183,9 @@ void ExtQuotes::quotesReplyReceived(QNetworkReply *_reply) auto text = _reply->readAll(); _reply->deleteLater(); - auto data = m_providerObject->parse(text, m_values); - if (data.isEmpty()) - return; - m_values = data; + auto data = m_providerObject->parse(text); + for (auto [key, value] : data.asKeyValueRange()) + m_values[tag(key)] = value; emit(dataReceived(m_values)); } @@ -205,10 +201,8 @@ void ExtQuotes::sendRequest() void ExtQuotes::initProvider() { - delete m_providerObject; - // in the future release it is possible to change provider here - m_providerObject = new StooqQuotesProvider(this); + m_providerObject = std::make_unique(); return m_providerObject->initUrl(ticker()); } diff --git a/sources/awesomewidgets/extquotes.h b/sources/awesomewidgets/extquotes.h index d6d7b02..d10288f 100644 --- a/sources/awesomewidgets/extquotes.h +++ b/sources/awesomewidgets/extquotes.h @@ -50,7 +50,7 @@ private slots: void sendRequest(); private: - AbstractQuotesProvider *m_providerObject = nullptr; + std::unique_ptr m_providerObject; QNetworkAccessManager *m_manager = nullptr; bool m_isRunning = false; void initProvider(); diff --git a/sources/awesomewidgets/extscript.cpp b/sources/awesomewidgets/extscript.cpp index 9c940ca..697e124 100644 --- a/sources/awesomewidgets/extscript.cpp +++ b/sources/awesomewidgets/extscript.cpp @@ -53,7 +53,6 @@ ExtScript::~ExtScript() m_process->kill(); m_process->deleteLater(); - disconnect(this, &ExtScript::requestDataUpdate, this, &ExtScript::startProcess); } diff --git a/sources/awesomewidgets/extupgrade.cpp b/sources/awesomewidgets/extupgrade.cpp index e15085f..a113f86 100644 --- a/sources/awesomewidgets/extupgrade.cpp +++ b/sources/awesomewidgets/extupgrade.cpp @@ -36,7 +36,7 @@ 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, &QProcess::finished, this, &ExtUpgrade::updateValue); m_process->waitForFinished(0); connect(this, &ExtUpgrade::requestDataUpdate, this, &ExtUpgrade::startProcess); @@ -49,7 +49,6 @@ ExtUpgrade::~ExtUpgrade() m_process->kill(); m_process->deleteLater(); - disconnect(this, &ExtUpgrade::requestDataUpdate, this, &ExtUpgrade::startProcess); } diff --git a/sources/awesomewidgets/extweather.cpp b/sources/awesomewidgets/extweather.cpp index 454eba3..b9fd3d8 100644 --- a/sources/awesomewidgets/extweather.cpp +++ b/sources/awesomewidgets/extweather.cpp @@ -58,9 +58,6 @@ ExtWeather::~ExtWeather() { qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; - disconnect(m_manager, &QNetworkAccessManager::finished, this, &ExtWeather::weatherReplyReceived); - disconnect(this, &ExtWeather::requestDataUpdate, this, &ExtWeather::sendRequest); - m_manager->deleteLater(); } @@ -354,9 +351,8 @@ void ExtWeather::weatherReplyReceived(QNetworkReply *_reply) } auto data = m_providerObject->parse(jsonDoc.toVariant().toMap()); - if (data.isEmpty()) - return; - m_values = data; + for (auto [key, value] : data.asKeyValueRange()) + m_values[tag(key)] = value; m_values[tag("weather")] = weatherFromInt(m_values[tag("weatherId")].toInt()); emit(dataReceived(m_values)); @@ -365,10 +361,8 @@ void ExtWeather::weatherReplyReceived(QNetworkReply *_reply) void ExtWeather::initProvider() { - delete m_providerObject; - // in the future release it is possible to change provider here - m_providerObject = new OWMWeatherProvider(this); + m_providerObject = std::make_unique(); return m_providerObject->initUrl(city(), country(), ts()); } diff --git a/sources/awesomewidgets/extweather.h b/sources/awesomewidgets/extweather.h index 40574d4..7231853 100644 --- a/sources/awesomewidgets/extweather.h +++ b/sources/awesomewidgets/extweather.h @@ -74,7 +74,7 @@ private slots: void weatherReplyReceived(QNetworkReply *_reply); private: - AbstractWeatherProvider *m_providerObject = nullptr; + std::unique_ptr m_providerObject; QNetworkAccessManager *m_manager = nullptr; bool m_isRunning = false; void initProvider(); diff --git a/sources/awesomewidgets/graphicalitem.cpp b/sources/awesomewidgets/graphicalitem.cpp index 2595c44..4f1081d 100644 --- a/sources/awesomewidgets/graphicalitem.cpp +++ b/sources/awesomewidgets/graphicalitem.cpp @@ -55,6 +55,15 @@ GraphicalItem::GraphicalItem(QObject *_parent, const QString &_filePath) } +GraphicalItem::~GraphicalItem() +{ + qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; + + m_view->deleteLater(); + m_scene->deleteLater(); +} + + GraphicalItem *GraphicalItem::copy(const QString &_fileName, const int _number) { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; diff --git a/sources/awesomewidgets/graphicalitem.h b/sources/awesomewidgets/graphicalitem.h index ccbdf8f..93890af 100644 --- a/sources/awesomewidgets/graphicalitem.h +++ b/sources/awesomewidgets/graphicalitem.h @@ -52,6 +52,7 @@ public: enum class Type { Horizontal = 0, Vertical = 1, Circle = 2, Graph = 3, Bars = 4 }; explicit GraphicalItem(QObject *_parent = nullptr, const QString &_filePath = ""); + ~GraphicalItem() override; GraphicalItem *copy(const QString &_fileName, int _number) override; QString image(const QVariant &value); void initScene(); diff --git a/sources/awesomewidgets/owmweatherprovider.cpp b/sources/awesomewidgets/owmweatherprovider.cpp index 9b54a84..4556c72 100644 --- a/sources/awesomewidgets/owmweatherprovider.cpp +++ b/sources/awesomewidgets/owmweatherprovider.cpp @@ -23,14 +23,8 @@ #include "awdebug.h" -OWMWeatherProvider::OWMWeatherProvider(QObject *_parent) - : AbstractWeatherProvider(_parent) -{ - qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; -} - - -OWMWeatherProvider::~OWMWeatherProvider() +OWMWeatherProvider::OWMWeatherProvider() + : AbstractWeatherProvider() { qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; } @@ -66,7 +60,7 @@ QVariantHash OWMWeatherProvider::parse(const QVariantMap &_json) const if (m_ts == 0) { return parseSingleJson(_json); } else { - QVariantList list = _json["list"].toList(); + auto list = _json["list"].toList(); return parseSingleJson(list.count() <= m_ts ? list.at(m_ts - 1).toMap() : list.last().toMap()); } } @@ -78,7 +72,7 @@ QUrl OWMWeatherProvider::url() const } -QVariantHash OWMWeatherProvider::parseSingleJson(const QVariantMap &_json) const +QVariantHash OWMWeatherProvider::parseSingleJson(const QVariantMap &_json) { qCDebug(LOG_LIB) << "Single json data" << _json; @@ -88,19 +82,19 @@ QVariantHash OWMWeatherProvider::parseSingleJson(const QVariantMap &_json) const auto weather = _json["weather"].toList(); if (!weather.isEmpty()) { int id = weather.first().toMap()["id"].toInt(); - output[tag("weatherId")] = id; + output["weatherId"] = id; } // main data auto mainWeather = _json["main"].toMap(); if (!weather.isEmpty()) { - output[tag("humidity")] = mainWeather["humidity"].toDouble(); - output[tag("pressure")] = mainWeather["pressure"].toDouble(); - output[tag("temperature")] = mainWeather["temp"].toDouble(); + output["humidity"] = mainWeather["humidity"].toDouble(); + output["pressure"] = mainWeather["pressure"].toDouble(); + output["temperature"] = mainWeather["temp"].toDouble(); } // timestamp - output[tag("timestamp")] = QDateTime::fromSecsSinceEpoch(_json["dt"].toUInt()).toUTC(); + output["timestamp"] = QDateTime::fromSecsSinceEpoch(_json["dt"].toUInt()).toUTC(); return output; } diff --git a/sources/awesomewidgets/owmweatherprovider.h b/sources/awesomewidgets/owmweatherprovider.h index af49e63..10e577b 100644 --- a/sources/awesomewidgets/owmweatherprovider.h +++ b/sources/awesomewidgets/owmweatherprovider.h @@ -22,22 +22,20 @@ class OWMWeatherProvider : public AbstractWeatherProvider { - Q_OBJECT - public: // we are using own server to pass requests to OpenWeatherMap because it // requires specific APPID which belongs to developer not user const char *OWM_WEATHER_URL = "https://arcanis.me/weather"; const char *OWM_FORECAST_URL = "https://arcanis.me/forecast"; - explicit OWMWeatherProvider(QObject *_parent); - ~OWMWeatherProvider() override; + explicit OWMWeatherProvider(); + ~OWMWeatherProvider() override = default; void initUrl(const QString &_city, const QString &_country, int) override; [[nodiscard]] QVariantHash parse(const QVariantMap &_json) const override; [[nodiscard]] QUrl url() const override; private: - [[nodiscard]] QVariantHash parseSingleJson(const QVariantMap &_json) const; + [[nodiscard]] static QVariantHash parseSingleJson(const QVariantMap &_json); int m_ts = 0; QUrl m_url; }; diff --git a/sources/awesomewidgets/qcronscheduler.cpp b/sources/awesomewidgets/qcronscheduler.cpp index f8f6215..400d366 100644 --- a/sources/awesomewidgets/qcronscheduler.cpp +++ b/sources/awesomewidgets/qcronscheduler.cpp @@ -34,8 +34,6 @@ QCronScheduler::QCronScheduler(QObject *_parent) m_timer->setInterval(60 * 1000); connect(m_timer, &QTimer::timeout, this, &QCronScheduler::expired); - - m_timer->start(); } @@ -44,6 +42,7 @@ QCronScheduler::~QCronScheduler() qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; m_timer->stop(); + m_timer->deleteLater(); } @@ -63,6 +62,22 @@ void QCronScheduler::parse(const QString &_timer) } +void QCronScheduler::start() +{ + qCDebug(LOG_LIB) << "Start cron timer"; + + m_timer->start(); +} + + +void QCronScheduler::stop() +{ + qCDebug(LOG_LIB) << "Stop cron timer"; + + m_timer->stop(); +} + + void QCronScheduler::expired() { auto now = QDateTime::currentDateTime(); diff --git a/sources/awesomewidgets/qcronscheduler.h b/sources/awesomewidgets/qcronscheduler.h index 72a1599..a740087 100644 --- a/sources/awesomewidgets/qcronscheduler.h +++ b/sources/awesomewidgets/qcronscheduler.h @@ -39,12 +39,14 @@ public: int maxValue = -1; int div = 1; void fromRange(const QString &_range, int _min, int _max); - QList toList() const; + [[nodiscard]] QList toList() const; }; explicit QCronScheduler(QObject *_parent = nullptr); ~QCronScheduler() override; void parse(const QString &_timer); + void start(); + void stop(); signals: void activated(); diff --git a/sources/awesomewidgets/stooqquotesprovider.cpp b/sources/awesomewidgets/stooqquotesprovider.cpp index fc66b1e..a1156c1 100644 --- a/sources/awesomewidgets/stooqquotesprovider.cpp +++ b/sources/awesomewidgets/stooqquotesprovider.cpp @@ -22,14 +22,8 @@ #include "awdebug.h" -StooqQuotesProvider::StooqQuotesProvider(QObject *_parent) - : AbstractQuotesProvider(_parent) -{ - qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; -} - - -StooqQuotesProvider::~StooqQuotesProvider() +StooqQuotesProvider::StooqQuotesProvider() + : AbstractQuotesProvider() { qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; } @@ -49,7 +43,7 @@ void StooqQuotesProvider::initUrl(const QString &_asset) } -QVariantHash StooqQuotesProvider::parse(const QByteArray &_source, const QVariantHash &_oldValues) const +QVariantHash StooqQuotesProvider::parse(const QByteArray &_source) { qCDebug(LOG_LIB) << "Parse csv" << _source; @@ -61,20 +55,18 @@ QVariantHash StooqQuotesProvider::parse(const QByteArray &_source, const QVarian return values; } - // extract old data - auto oldPrice = _oldValues[tag("price")].toDouble(); - auto oldVolume = _oldValues[tag("volume")].toInt(); - // last trade auto price = sourceValues.at(0).toDouble(); - values[tag("pricechg")] = oldPrice == 0.0 ? 0.0 : price - oldPrice; - values[tag("percpricechg")] = 100.0 * values[tag("pricechg")].toDouble() / oldPrice; - values[tag("price")] = price; + values["pricechg"] = m_price == 0.0 ? 0.0 : price - m_price; + values["percpricechg"] = 100.0 * values["pricechg"].toDouble() / m_price; + values["price"] = price; + m_price = price; // volume auto volume = sourceValues.at(1).toInt(); - values[tag("volumechg")] = oldVolume == 0 ? 0 : volume - oldVolume; - values[tag("percvolumechg")] = 100.0 * values[tag("volumechg")].toDouble() / oldVolume; - values[tag("volume")] = volume; + values["volumechg"] = m_volume == 0 ? 0 : volume - m_volume; + values["percvolumechg"] = 100.0 * values["volumechg"].toDouble() / m_volume; + values["volume"] = volume; + m_volume = volume; return values; } diff --git a/sources/awesomewidgets/stooqquotesprovider.h b/sources/awesomewidgets/stooqquotesprovider.h index 19c1b81..fa3f034 100644 --- a/sources/awesomewidgets/stooqquotesprovider.h +++ b/sources/awesomewidgets/stooqquotesprovider.h @@ -22,17 +22,17 @@ class StooqQuotesProvider : public AbstractQuotesProvider { - Q_OBJECT - public: const char *STOOQ_QUOTES_URL = "https://stooq.com/q/l/"; - explicit StooqQuotesProvider(QObject *_parent); - ~StooqQuotesProvider() override; + explicit StooqQuotesProvider(); + ~StooqQuotesProvider() override = default; void initUrl(const QString &_asset) override; - [[nodiscard]] QVariantHash parse(const QByteArray &_source, const QVariantHash &_oldValues) const override; + [[nodiscard]] QVariantHash parse(const QByteArray &_source) override; [[nodiscard]] QUrl url() const override; private: + double m_price = 0.0; QUrl m_url; + int m_volume = 0; }; diff --git a/sources/awesomewidgets/yahooquotesprovider.cpp b/sources/awesomewidgets/yahooquotesprovider.cpp index 16b1aaf..35a4fbe 100644 --- a/sources/awesomewidgets/yahooquotesprovider.cpp +++ b/sources/awesomewidgets/yahooquotesprovider.cpp @@ -23,14 +23,8 @@ #include "awdebug.h" -YahooQuotesProvider::YahooQuotesProvider(QObject *_parent) - : AbstractQuotesProvider(_parent) -{ - qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; -} - - -YahooQuotesProvider::~YahooQuotesProvider() +YahooQuotesProvider::YahooQuotesProvider() + : AbstractQuotesProvider() { qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; } @@ -50,7 +44,7 @@ void YahooQuotesProvider::initUrl(const QString &_asset) } -QVariantHash YahooQuotesProvider::parse(const QByteArray &_source, const QVariantHash &_oldValues) const +QVariantHash YahooQuotesProvider::parse(const QByteArray &_source) { qCDebug(LOG_LIB) << "Parse json" << _source; @@ -65,18 +59,16 @@ QVariantHash YahooQuotesProvider::parse(const QByteArray &_source, const QVarian auto jsonQuotes = jsonDoc.toVariant().toMap()["query"].toMap(); jsonQuotes = jsonQuotes["results"].toMap()["quote"].toMap(); - // extract old data - auto oldPrice = _oldValues[tag("price")].toDouble(); - // last trade - auto value = jsonQuotes["LastTradePriceOnly"].toString().toDouble(); - values[tag("pricechg")] = oldPrice == 0.0 ? 0.0 : value - oldPrice; - values[tag("percpricechg")] = 100.0 * values[tag("pricechg")].toDouble() / value; - values[tag("price")] = value; + auto price = jsonQuotes["LastTradePriceOnly"].toString().toDouble(); + values["pricechg"] = m_price == 0.0 ? 0.0 : price - m_price; + values["percpricechg"] = 100.0 * values["pricechg"].toDouble() / price; + values["price"] = price; + m_price = price; // volume - values[tag("volume")] = 0; - values[tag("volumechg")] = 0; - values[tag("percvolumechg")] = 0.0; + values["volume"] = 0; + values["volumechg"] = 0; + values["percvolumechg"] = 0.0; return values; } diff --git a/sources/awesomewidgets/yahooquotesprovider.h b/sources/awesomewidgets/yahooquotesprovider.h index 32bf518..ddef0de 100644 --- a/sources/awesomewidgets/yahooquotesprovider.h +++ b/sources/awesomewidgets/yahooquotesprovider.h @@ -22,18 +22,17 @@ class YahooQuotesProvider : public AbstractQuotesProvider { - Q_OBJECT - public: const char *YAHOO_QUOTES_URL = "https://query.yahooapis.com/v1/public/yql"; const char *YAHOO_QUOTES_QUERY = "select * from yahoo.finance.quotes where symbol='%1'"; - explicit YahooQuotesProvider(QObject *_parent); - ~YahooQuotesProvider() override; + explicit YahooQuotesProvider(); + ~YahooQuotesProvider() override = default; void initUrl(const QString &_asset) override; - [[nodiscard]] QVariantHash parse(const QByteArray &_source, const QVariantHash &_oldValues) const override; + [[nodiscard]] QVariantHash parse(const QByteArray &_source) override; [[nodiscard]] QUrl url() const override; private: + double m_price = 0.0; QUrl m_url; }; diff --git a/sources/awesomewidgets/yahooweatherprovider.cpp b/sources/awesomewidgets/yahooweatherprovider.cpp index 3e81a96..1e54cc7 100644 --- a/sources/awesomewidgets/yahooweatherprovider.cpp +++ b/sources/awesomewidgets/yahooweatherprovider.cpp @@ -22,14 +22,8 @@ #include "awdebug.h" -YahooWeatherProvider::YahooWeatherProvider(QObject *_parent) - : AbstractWeatherProvider(_parent) -{ - qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; -} - - -YahooWeatherProvider::~YahooWeatherProvider() +YahooWeatherProvider::YahooWeatherProvider() + : AbstractWeatherProvider() { qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; } @@ -74,7 +68,7 @@ QUrl YahooWeatherProvider::url() const } -QVariantHash YahooWeatherProvider::parseCurrent(const QVariantMap &_json, const QVariantMap &_atmosphere) const +QVariantHash YahooWeatherProvider::parseCurrent(const QVariantMap &_json, const QVariantMap &_atmosphere) { qCDebug(LOG_LIB) << "Parse current weather from" << _json; @@ -82,12 +76,12 @@ QVariantHash YahooWeatherProvider::parseCurrent(const QVariantMap &_json, const QVariantHash values; auto id = _json["condition"].toMap()["code"].toInt(); - values[tag("weatherId")] = id; - values[tag("temperature")] = condition["temp"].toInt(); - values[tag("timestamp")] = condition["date"].toString(); - values[tag("humidity")] = _atmosphere["humidity"].toInt(); + values["weatherId"] = id; + values["temperature"] = condition["temp"].toInt(); + values["timestamp"] = condition["date"].toString(); + values["humidity"] = _atmosphere["humidity"].toInt(); // HACK temporary fix of invalid values on Yahoo! side - values[tag("pressure")] = static_cast(_atmosphere["pressure"].toDouble() / 33.863753); + values["pressure"] = static_cast(_atmosphere["pressure"].toDouble() / 33.863753); return values; } @@ -101,13 +95,13 @@ QVariantHash YahooWeatherProvider::parseForecast(const QVariantMap &_json) const auto weatherList = _json["forecast"].toList(); auto weatherMap = weatherList.count() < m_ts ? weatherList.last().toMap() : weatherList.at(m_ts).toMap(); auto id = weatherMap["code"].toInt(); - values[tag("weatherId")] = id; - values[tag("timestamp")] = weatherMap["date"].toString(); + values["weatherId"] = id; + values["timestamp"] = weatherMap["date"].toString(); // yahoo provides high and low temperatures. Lets calculate average one - values[tag("temperature")] = (weatherMap["high"].toDouble() + weatherMap["low"].toDouble()) / 2.0; + values["temperature"] = (weatherMap["high"].toDouble() + weatherMap["low"].toDouble()) / 2.0; // ... and no forecast data for humidity and pressure - values[tag("humidity")] = 0; - values[tag("pressure")] = 0.0; + values["humidity"] = 0; + values["pressure"] = 0.0; return values; } diff --git a/sources/awesomewidgets/yahooweatherprovider.h b/sources/awesomewidgets/yahooweatherprovider.h index 0da4330..9849544 100644 --- a/sources/awesomewidgets/yahooweatherprovider.h +++ b/sources/awesomewidgets/yahooweatherprovider.h @@ -22,22 +22,20 @@ class YahooWeatherProvider : public AbstractWeatherProvider { - Q_OBJECT - public: const char *YAHOO_WEATHER_URL = "https://query.yahooapis.com/v1/public/yql"; const char *YAHOO_WEATHER_QUERY = "select * from weather.forecast where " "u='c' and woeid in (select woeid from " "geo.places(1) where text='%1, %2')"; - explicit YahooWeatherProvider(QObject *_parent); - ~YahooWeatherProvider() override; + explicit YahooWeatherProvider(); + ~YahooWeatherProvider() override = default; void initUrl(const QString &_city, const QString &_country, int) override; [[nodiscard]] QVariantHash parse(const QVariantMap &_json) const override; [[nodiscard]] QUrl url() const override; private: - [[nodiscard]] QVariantHash parseCurrent(const QVariantMap &_json, const QVariantMap &_atmosphere) const; + [[nodiscard]] static QVariantHash parseCurrent(const QVariantMap &_json, const QVariantMap &_atmosphere); [[nodiscard]] QVariantHash parseForecast(const QVariantMap &_json) const; int m_ts = 0; QUrl m_url; diff --git a/sources/desktop-panel/plugin/dpadds.cpp b/sources/desktop-panel/plugin/dpadds.cpp index 772648e..9ca3948 100644 --- a/sources/desktop-panel/plugin/dpadds.cpp +++ b/sources/desktop-panel/plugin/dpadds.cpp @@ -136,7 +136,7 @@ QString DPAdds::toolTipImage(const int _desktop) const toolTipScene->addLine(width + 2.0 * margin, height + 2.0 * margin, width + 2.0 * margin, 0); toolTipScene->addLine(width + 2.0 * margin, 0, 0, 0); - // with wayland countours only are supported + // with wayland contours only are supported auto pen = QPen(); pen.setWidthF(2.0 * width / 400.0); pen.setColor(QColor(m_tooltipColor)); @@ -159,8 +159,8 @@ QString DPAdds::toolTipImage(const int _desktop) const QBuffer buffer(&byteArray); image.save(&buffer, "PNG"); - delete toolTipView; - delete toolTipScene; + toolTipView->deleteLater(); + toolTipScene->deleteLater(); return QString("").arg(QString(byteArray.toBase64())); } diff --git a/sources/extsysmonsources/quotessource.cpp b/sources/extsysmonsources/quotessource.cpp index 21dc4b3..41b4ca1 100644 --- a/sources/extsysmonsources/quotessource.cpp +++ b/sources/extsysmonsources/quotessource.cpp @@ -26,7 +26,7 @@ QuotesSource::QuotesSource(QObject *_parent) { qCDebug(LOG_ESS) << __PRETTY_FUNCTION__; - m_extQuotes = new ExtItemAggregator(nullptr, "quotes"); + m_extQuotes = new ExtItemAggregator(this, "quotes"); m_extQuotes->initSockets(); } diff --git a/sources/extsysmonsources/requestsource.cpp b/sources/extsysmonsources/requestsource.cpp index 24417e8..29b3cf3 100644 --- a/sources/extsysmonsources/requestsource.cpp +++ b/sources/extsysmonsources/requestsource.cpp @@ -26,7 +26,7 @@ RequestSource::RequestSource(QObject *_parent) { qCDebug(LOG_ESS) << __PRETTY_FUNCTION__; - m_extNetRequest = new ExtItemAggregator(nullptr, "requests"); + m_extNetRequest = new ExtItemAggregator(this, "requests"); m_extNetRequest->initSockets(); } diff --git a/sources/extsysmonsources/upgradesource.cpp b/sources/extsysmonsources/upgradesource.cpp index 5103137..7c2b3e1 100644 --- a/sources/extsysmonsources/upgradesource.cpp +++ b/sources/extsysmonsources/upgradesource.cpp @@ -26,7 +26,7 @@ UpgradeSource::UpgradeSource(QObject *_parent) { qCDebug(LOG_ESS) << __PRETTY_FUNCTION__; - m_extUpgrade = new ExtItemAggregator(nullptr, "upgrade"); + m_extUpgrade = new ExtItemAggregator(this, "upgrade"); m_extUpgrade->initSockets(); } diff --git a/sources/extsysmonsources/weathersource.cpp b/sources/extsysmonsources/weathersource.cpp index 5004246..709d36e 100644 --- a/sources/extsysmonsources/weathersource.cpp +++ b/sources/extsysmonsources/weathersource.cpp @@ -26,7 +26,7 @@ WeatherSource::WeatherSource(QObject *_parent) { qCDebug(LOG_ESS) << __PRETTY_FUNCTION__; - m_extWeather = new ExtItemAggregator(nullptr, "weather"); + m_extWeather = new ExtItemAggregator(this, "weather"); m_extWeather->initSockets(); } diff --git a/sources/test/testawtelemetryhandler.cpp b/sources/test/testawtelemetryhandler.cpp index 3b53312..d0ef441 100644 --- a/sources/test/testawtelemetryhandler.cpp +++ b/sources/test/testawtelemetryhandler.cpp @@ -27,7 +27,7 @@ void TestAWTelemetryHandler::initTestCase() { AWTestLibrary::init(); plugin = new AWTelemetryHandler(this); - plugin->init(1, true, telemetryId); + plugin->init(1, telemetryId); telemetryData = AWTestLibrary::randomString(); telemetryGroup = AWTestLibrary::randomString(); } @@ -61,18 +61,4 @@ void TestAWTelemetryHandler::test_getLast() } -void TestAWTelemetryHandler::test_uploadTelemetry() -{ - QSKIP("Remote telemetry is disabled at the moment"); - - QSignalSpy spy(plugin, SIGNAL(replyReceived(const QString &))); - plugin->uploadTelemetry(telemetryValidGroup, telemetryData); - - QVERIFY(spy.wait(5000)); - auto arguments = spy.takeFirst(); - - QCOMPARE(arguments.at(0).toString(), telemetryStatus); -} - - QTEST_MAIN(TestAWTelemetryHandler); diff --git a/sources/test/testawtelemetryhandler.h b/sources/test/testawtelemetryhandler.h index 7e0f488..defecfa 100644 --- a/sources/test/testawtelemetryhandler.h +++ b/sources/test/testawtelemetryhandler.h @@ -34,7 +34,6 @@ private slots: void test_put(); void test_get(); void test_getLast(); - void test_uploadTelemetry(); private: AWTelemetryHandler *plugin = nullptr;