mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
refactor: review delete and new operators
This commit is contained in:
parent
397b523180
commit
95d5bb99c0
@ -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
|
||||
|
@ -58,6 +58,12 @@ AWAbstractPairConfig::~AWAbstractPairConfig()
|
||||
}
|
||||
|
||||
|
||||
void AWAbstractPairConfig::setHelper(std::unique_ptr<AWAbstractPairHelper> _helper)
|
||||
{
|
||||
m_helper = std::move(_helper);
|
||||
}
|
||||
|
||||
|
||||
void AWAbstractPairConfig::showDialog()
|
||||
{
|
||||
// update dialog
|
||||
@ -133,7 +139,7 @@ void AWAbstractPairConfig::execDialog()
|
||||
auto ret = exec();
|
||||
QHash<QString, QString> data;
|
||||
for (auto selector : m_selectors) {
|
||||
QPair<QString, QString> select = selector->current();
|
||||
auto select = selector->current();
|
||||
if (select.first.isEmpty())
|
||||
continue;
|
||||
data[select.first] = select.second;
|
||||
|
@ -35,12 +35,7 @@ class AWAbstractPairConfig : public QDialog
|
||||
public:
|
||||
explicit AWAbstractPairConfig(QWidget *_parent = nullptr, bool _hasEdit = false, QStringList _keys = {});
|
||||
~AWAbstractPairConfig() override;
|
||||
template <class T> void initHelper()
|
||||
{
|
||||
|
||||
delete m_helper;
|
||||
m_helper = new T(this);
|
||||
}
|
||||
void setHelper(std::unique_ptr<AWAbstractPairHelper> _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<AWAbstractPairHelper> m_helper;
|
||||
QList<AWAbstractSelector *> m_selectors;
|
||||
// properties
|
||||
QPair<bool, bool> m_editable = {false, false};
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class QNetworkAccessManager;
|
||||
class QNetworkReply;
|
||||
|
||||
class AWBugReporter : public QObject
|
||||
@ -44,4 +45,5 @@ private slots:
|
||||
|
||||
private:
|
||||
QString m_lastBugUrl;
|
||||
QNetworkAccessManager *m_manager = nullptr;
|
||||
};
|
||||
|
@ -27,5 +27,5 @@ AWCustomKeysConfig::AWCustomKeysConfig(QWidget *_parent, const QStringList &_key
|
||||
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
||||
|
||||
setEditable(true, false);
|
||||
initHelper<AWCustomKeysHelper>();
|
||||
setHelper(std::make_unique<AWCustomKeysHelper>());
|
||||
}
|
||||
|
@ -50,7 +50,8 @@ AWDataAggregator::~AWDataAggregator()
|
||||
{
|
||||
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
||||
|
||||
delete m_toolTipScene;
|
||||
m_toolTipView->deleteLater();
|
||||
m_toolTipScene->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,5 +27,5 @@ AWFormatterConfig::AWFormatterConfig(QWidget *_parent, const QStringList &_keys)
|
||||
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
||||
|
||||
setEditable(false, false);
|
||||
initHelper<AWFormatterHelper>();
|
||||
setHelper(std::make_unique<AWFormatterHelper>());
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "awstringformatter.h"
|
||||
|
||||
|
||||
AWFormatterHelper::AWFormatterHelper(QWidget *_parent)
|
||||
AWFormatterHelper::AWFormatterHelper(QObject *_parent)
|
||||
: AbstractExtItemAggregator(_parent, "formatters")
|
||||
, AWAbstractPairHelper("awesomewidgets/formatters/formatters.ini", "Formatters")
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -40,12 +40,12 @@ AWKeyOperations::AWKeyOperations(QObject *_parent)
|
||||
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
||||
|
||||
m_customKeys = new AWCustomKeysHelper(this);
|
||||
m_graphicalItems = new ExtItemAggregator<GraphicalItem>(nullptr, "desktops");
|
||||
m_extNetRequest = new ExtItemAggregator<ExtNetworkRequest>(nullptr, "requests");
|
||||
m_extQuotes = new ExtItemAggregator<ExtQuotes>(nullptr, "quotes");
|
||||
m_extScripts = new ExtItemAggregator<ExtScript>(nullptr, "scripts");
|
||||
m_extUpgrade = new ExtItemAggregator<ExtUpgrade>(nullptr, "upgrade");
|
||||
m_extWeather = new ExtItemAggregator<ExtWeather>(nullptr, "weather");
|
||||
m_graphicalItems = new ExtItemAggregator<GraphicalItem>(this, "desktops");
|
||||
m_extNetRequest = new ExtItemAggregator<ExtNetworkRequest>(this, "requests");
|
||||
m_extQuotes = new ExtItemAggregator<ExtQuotes>(this, "quotes");
|
||||
m_extScripts = new ExtItemAggregator<ExtScript>(this, "scripts");
|
||||
m_extUpgrade = new ExtItemAggregator<ExtUpgrade>(this, "upgrade");
|
||||
m_extWeather = new ExtItemAggregator<ExtWeather>(this, "weather");
|
||||
}
|
||||
|
||||
|
||||
|
@ -189,8 +189,10 @@ void AWKeys::dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -18,8 +18,6 @@
|
||||
#include "awtelemetryhandler.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
#include <QUuid>
|
||||
@ -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;
|
||||
|
@ -20,33 +20,21 @@
|
||||
#include <QObject>
|
||||
|
||||
|
||||
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;
|
||||
};
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -75,7 +75,6 @@ signals:
|
||||
void requestDataUpdate();
|
||||
|
||||
public slots:
|
||||
virtual void deinitSocket();
|
||||
virtual void initSocket();
|
||||
virtual void readConfiguration();
|
||||
virtual QVariantHash run() = 0;
|
||||
|
@ -17,25 +17,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
|
||||
#include "abstractextitem.h"
|
||||
#include <QVariant>
|
||||
|
||||
|
||||
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<AbstractExtItem *>(parent())->tag(_type);
|
||||
};
|
||||
[[nodiscard]] virtual QVariantHash parse(const QByteArray &_source) = 0;
|
||||
[[nodiscard]] virtual QUrl url() const = 0;
|
||||
};
|
||||
|
@ -17,25 +17,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
|
||||
#include "abstractextitem.h"
|
||||
#include <QVariant>
|
||||
|
||||
|
||||
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<AbstractExtItem *>(parent())->tag(_type);
|
||||
};
|
||||
[[nodiscard]] virtual QUrl url() const = 0;
|
||||
};
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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<StooqQuotesProvider>();
|
||||
|
||||
return m_providerObject->initUrl(ticker());
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ private slots:
|
||||
void sendRequest();
|
||||
|
||||
private:
|
||||
AbstractQuotesProvider *m_providerObject = nullptr;
|
||||
std::unique_ptr<AbstractQuotesProvider> m_providerObject;
|
||||
QNetworkAccessManager *m_manager = nullptr;
|
||||
bool m_isRunning = false;
|
||||
void initProvider();
|
||||
|
@ -53,7 +53,6 @@ ExtScript::~ExtScript()
|
||||
|
||||
m_process->kill();
|
||||
m_process->deleteLater();
|
||||
disconnect(this, &ExtScript::requestDataUpdate, this, &ExtScript::startProcess);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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<OWMWeatherProvider>();
|
||||
|
||||
return m_providerObject->initUrl(city(), country(), ts());
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ private slots:
|
||||
void weatherReplyReceived(QNetworkReply *_reply);
|
||||
|
||||
private:
|
||||
AbstractWeatherProvider *m_providerObject = nullptr;
|
||||
std::unique_ptr<AbstractWeatherProvider> m_providerObject;
|
||||
QNetworkAccessManager *m_manager = nullptr;
|
||||
bool m_isRunning = false;
|
||||
void initProvider();
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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();
|
||||
|
@ -39,12 +39,14 @@ public:
|
||||
int maxValue = -1;
|
||||
int div = 1;
|
||||
void fromRange(const QString &_range, int _min, int _max);
|
||||
QList<int> toList() const;
|
||||
[[nodiscard]] QList<int> toList() const;
|
||||
};
|
||||
|
||||
explicit QCronScheduler(QObject *_parent = nullptr);
|
||||
~QCronScheduler() override;
|
||||
void parse(const QString &_timer);
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
signals:
|
||||
void activated();
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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<int>(_atmosphere["pressure"].toDouble() / 33.863753);
|
||||
values["pressure"] = static_cast<int>(_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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ QuotesSource::QuotesSource(QObject *_parent)
|
||||
{
|
||||
qCDebug(LOG_ESS) << __PRETTY_FUNCTION__;
|
||||
|
||||
m_extQuotes = new ExtItemAggregator<ExtQuotes>(nullptr, "quotes");
|
||||
m_extQuotes = new ExtItemAggregator<ExtQuotes>(this, "quotes");
|
||||
m_extQuotes->initSockets();
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ RequestSource::RequestSource(QObject *_parent)
|
||||
{
|
||||
qCDebug(LOG_ESS) << __PRETTY_FUNCTION__;
|
||||
|
||||
m_extNetRequest = new ExtItemAggregator<ExtNetworkRequest>(nullptr, "requests");
|
||||
m_extNetRequest = new ExtItemAggregator<ExtNetworkRequest>(this, "requests");
|
||||
m_extNetRequest->initSockets();
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ UpgradeSource::UpgradeSource(QObject *_parent)
|
||||
{
|
||||
qCDebug(LOG_ESS) << __PRETTY_FUNCTION__;
|
||||
|
||||
m_extUpgrade = new ExtItemAggregator<ExtUpgrade>(nullptr, "upgrade");
|
||||
m_extUpgrade = new ExtItemAggregator<ExtUpgrade>(this, "upgrade");
|
||||
m_extUpgrade->initSockets();
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ WeatherSource::WeatherSource(QObject *_parent)
|
||||
{
|
||||
qCDebug(LOG_ESS) << __PRETTY_FUNCTION__;
|
||||
|
||||
m_extWeather = new ExtItemAggregator<ExtWeather>(nullptr, "weather");
|
||||
m_extWeather = new ExtItemAggregator<ExtWeather>(this, "weather");
|
||||
m_extWeather->initSockets();
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -34,7 +34,6 @@ private slots:
|
||||
void test_put();
|
||||
void test_get();
|
||||
void test_getLast();
|
||||
void test_uploadTelemetry();
|
||||
|
||||
private:
|
||||
AWTelemetryHandler *plugin = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user