dashboard

This commit is contained in:
Zacharias-Brohn
2026-02-14 00:14:18 +01:00
parent 6be4b382b7
commit 53fe85c455
48 changed files with 2754 additions and 54 deletions
+36
View File
@@ -0,0 +1,36 @@
#include "requests.hpp"
#include <qnetworkaccessmanager.h>
#include <qnetworkreply.h>
#include <qnetworkrequest.h>
namespace ZShell {
Requests::Requests(QObject* parent)
: QObject(parent)
, m_manager(new QNetworkAccessManager(this)) {
}
void Requests::get(const QUrl& url, QJSValue onSuccess, QJSValue onError) const {
if (!onSuccess.isCallable()) {
qWarning() << "Requests::get: onSuccess is not callable";
return;
}
QNetworkRequest request(url);
auto reply = m_manager->get(request);
QObject::connect(reply, &QNetworkReply::finished, [reply, onSuccess, onError]() {
if (reply->error() == QNetworkReply::NoError) {
onSuccess.call({ QString(reply->readAll()) });
} else if (onError.isCallable()) {
onError.call({ reply->errorString() });
} else {
qWarning() << "Requests::get: request failed with error" << reply->errorString();
}
reply->deleteLater();
});
}
} // namespace ZShell