Commit ffb79de7 authored by Volker Krause's avatar Volker Krause
Browse files

Fix Qt4 build

parent 59801e32
......@@ -163,7 +163,9 @@ if(Qt5Charts_FOUND AND KF5WidgetsAddons_FOUND AND NOT CMAKE_VERSION VERSION_LESS
add_subdirectory(analyzer)
add_subdirectory(tests/manual)
endif()
add_subdirectory(tests/auto)
if(Qt5Core_FOUND)
add_subdirectory(tests/auto)
endif()
#
# CMake package config file generation
......
......@@ -2,12 +2,15 @@ set(userfeedback_core_srcs
abstractdatasource.cpp
applicationversionsource.cpp
platforminfosource.cpp
propertyratiosource.cpp
provider.cpp
screeninfosource.cpp
surveyinfo.cpp
)
if(Qt5Core_FOUND)
list(APPEND userfeedback_core_srcs propertyratiosource.cpp)
endif()
add_library(UserFeedbackCore SHARED ${userfeedback_core_srcs})
set_target_properties(UserFeedbackCore PROPERTIES
SOVERSION ${USERFEEDBACK_VERSION}
......
......@@ -30,6 +30,7 @@ PlatformInfoSource::PlatformInfoSource() :
QVariant PlatformInfoSource::data()
{
QVariantMap m;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
// on Linux productType() is the distro name
m.insert(QStringLiteral("os"), QStringLiteral("linux"));
......@@ -37,6 +38,7 @@ QVariant PlatformInfoSource::data()
#else
m.insert(QStringLiteral("os"), QSysInfo::productType());
m.insert(QStringLiteral("version"), QSysInfo::productVersion());
#endif
#endif
return m;
}
......@@ -24,9 +24,11 @@
#include <QCoreApplication>
#include <QDateTime>
#include <QDebug>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#endif
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
......@@ -108,7 +110,7 @@ ProviderPrivate::ProviderPrivate(Provider *qq)
{
auto domain = QCoreApplication::organizationDomain().split(QLatin1Char('.'));
std::reverse(domain.begin(), domain.end());
productId = domain.join(QLatin1Char('.')) + QLatin1Char('.') + QCoreApplication::applicationName();
productId = domain.join(QLatin1String(".")) + QLatin1Char('.') + QCoreApplication::applicationName();
submissionTimer.setSingleShot(true);
QObject::connect(&submissionTimer, SIGNAL(timeout()), q, SLOT(submit()));
......@@ -177,6 +179,7 @@ void ProviderPrivate::aboutToQuit()
QByteArray ProviderPrivate::jsonData() const
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QJsonObject obj;
if (statisticsMode != Provider::NoStatistics) {
QJsonObject valueObj;
......@@ -197,6 +200,10 @@ QByteArray ProviderPrivate::jsonData() const
QJsonDocument doc(obj);
return doc.toJson();
#else
qCritical("NOT IMPLEMENTED YET");
return QByteArray();
#endif
}
void ProviderPrivate::scheduleNextSubmission()
......@@ -224,12 +231,14 @@ void ProviderPrivate::submitFinished()
lastSubmitTime = QDateTime::currentDateTime();
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
const auto obj = QJsonDocument::fromJson(reply->readAll()).object();
if (obj.contains(QStringLiteral("survey"))) {
const auto surveyObj = obj.value(QStringLiteral("survey")).toObject();
const auto survey = SurveyInfo::fromJson(surveyObj);
selectSurvey(survey);
}
#endif
scheduleNextSubmission();
}
......@@ -381,7 +390,9 @@ void Provider::submit()
url.setPath(url.path() + QStringLiteral("/receiver/submit/") + d->productId);
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/json"));
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
request.setHeader(QNetworkRequest::UserAgentHeader, QStringLiteral("UserFeedback/") + QStringLiteral(USERFEEDBACK_VERSION));
#endif
auto reply = d->networkAccessManager->post(request, d->jsonData());
connect(reply, SIGNAL(finished()), this, SLOT(submitFinished()));
}
......
......@@ -17,16 +17,14 @@
#include "screeninfosource.h"
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QGuiApplication>
#endif
#include <QScreen>
#include <QVariant>
using namespace UserFeedback;
QString screenToString(QScreen *screen)
{
return QStringLiteral("%1x%2 %3dpi").arg(screen->size().width()).arg(screen->size().height()).arg((int)screen->physicalDotsPerInch());
}
ScreenInfoSource::ScreenInfoSource() :
AbstractDataSource(QStringLiteral("screens"))
{
......@@ -35,11 +33,13 @@ ScreenInfoSource::ScreenInfoSource() :
QVariant ScreenInfoSource::data()
{
QVariantList l;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
foreach (auto screen, QGuiApplication::screens()) {
QVariantMap m;
m.insert(QStringLiteral("width"), screen->size().width());
m.insert(QStringLiteral("height"), screen->size().height());
l.push_back(m);
}
#endif
return l;
}
......@@ -17,7 +17,9 @@
#include "surveyinfo.h"
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QJsonObject>
#endif
#include <QSharedData>
#include <QUrl>
......@@ -68,7 +70,9 @@ void SurveyInfo::setUrl(const QUrl& url)
SurveyInfo SurveyInfo::fromJson(const QJsonObject& obj)
{
SurveyInfo s;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
s.setId(obj.value(QStringLiteral("id")).toInt());
s.setUrl(QUrl(obj.value(QStringLiteral("url")).toString()));
#endif
return s;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment