Commit 1ba15da0 authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Move SensorFaceController::Private class outside of SensorFaceController

This allows us to access it from autotests.
parent 6f3e6031
......@@ -133,51 +133,17 @@ QHash<int, QByteArray> PresetsModel::roleNames() const
}
SensorFaceControllerPrivate::SensorFaceControllerPrivate()
{
}
class SensorFaceController::Private
{
public:
Private();
QJsonArray resolveSensors(const QJsonArray &partialEntries);
SensorFace *createGui(const QString &qmlPath);
QQuickItem *createConfigUi(const QString &file, const QVariantMap &initialProperties);
SensorFaceController *q;
QString title;
QQmlEngine *engine;
KConfigGroup faceProperties;
KDeclarative::ConfigPropertyMap *faceConfiguration = nullptr;
KConfigLoader *faceConfigLoader = nullptr;
bool configNeedsSave = false;
KPackage::Package facePackage;
QString faceId;
KLocalizedContext *contextObj = nullptr;
KConfigGroup configGroup;
KConfigGroup appearanceGroup;
KConfigGroup sensorsGroup;
KConfigGroup colorsGroup;
QPointer <SensorFace> fullRepresentation;
QPointer <SensorFace> compactRepresentation;
QPointer <QQuickItem> faceConfigUi;
QPointer <QQuickItem> appearanceConfigUi;
QPointer <QQuickItem> sensorsConfigUi;
QJsonArray totalSensors;
QJsonArray highPrioritySensorIds;
QJsonArray lowPrioritySensorIds;
QTimer *syncTimer;
bool shouldSync = true;
FacesModel *availableFacesModel = nullptr;
PresetsModel *availablePresetsModel = nullptr;
};
SensorFaceController::Private::Private()
{}
QJsonArray SensorFaceController::Private::resolveSensors(const QJsonArray &partialEntries)
QJsonArray SensorFaceControllerPrivate::resolveSensors(const QJsonArray &partialEntries)
{
QJsonArray sensors;
......@@ -194,7 +160,7 @@ QJsonArray SensorFaceController::Private::resolveSensors(const QJsonArray &parti
return sensors;
};
SensorFace *SensorFaceController::Private::createGui(const QString &qmlPath)
SensorFace *SensorFaceControllerPrivate::createGui(const QString &qmlPath)
{
QQmlComponent *component = new QQmlComponent(engine, qmlPath, nullptr);
// TODO: eventually support async components? (only useful for qml files from http, we probably don't want that)
......@@ -227,7 +193,7 @@ SensorFace *SensorFaceController::Private::createGui(const QString &qmlPath)
return gui;
}
QQuickItem *SensorFaceController::Private::createConfigUi(const QString &file, const QVariantMap &initialProperties)
QQuickItem *SensorFaceControllerPrivate::createConfigUi(const QString &file, const QVariantMap &initialProperties)
{
QQmlComponent *component = new QQmlComponent(engine, file, nullptr);
// TODO: eventually support async components? (only useful for qml files from http, we probably don't want that)
......@@ -254,12 +220,9 @@ QQuickItem *SensorFaceController::Private::createConfigUi(const QString &file, c
}
SensorFaceController::SensorFaceController(KConfigGroup &config, QQmlEngine *engine)
: QObject(engine),
d(std::make_unique<Private>())
d(std::make_unique<SensorFaceControllerPrivate>())
{
d->q = this;
d->configGroup = config;
......
......@@ -39,6 +39,7 @@ class KConfigLoader;
namespace KSysGuard {
class SensorFace;
class SensorFaceControllerPrivate;
class SENSORFACES_EXPORT SensorFaceController : public QObject
{
......@@ -130,7 +131,6 @@ Q_SIGNALS:
void sensorColorsChanged();
private:
class Private;
const std::unique_ptr<Private> d;
const std::unique_ptr<SensorFaceControllerPrivate> d;
};
}
......@@ -21,13 +21,21 @@
#include <QQuickItem>
#include <QStandardItemModel>
#include <QJsonArray>
#include <KLocalizedContext>
#include <KPackage/PackageLoader>
#include <KConfigGroup>
#include <KConfigLoader>
#include <KDeclarative/ConfigPropertyMap>
#include "sensorfaces_export.h"
class QQmlEngine;
namespace KSysGuard {
class SensorFaceController;
class SensorFace;
class FacesModel : public QStandardItemModel
{
......@@ -65,4 +73,47 @@ public:
QHash<int, QByteArray> roleNames() const override;
};
// This is exported so we can use it in autotests
class SENSORFACES_EXPORT SensorFaceControllerPrivate
{
public:
SensorFaceControllerPrivate();
QJsonArray resolveSensors(const QJsonArray &partialEntries);
SensorFace *createGui(const QString &qmlPath);
QQuickItem *createConfigUi(const QString &file, const QVariantMap &initialProperties);
SensorFaceController *q;
QString title;
QQmlEngine *engine;
KConfigGroup faceProperties;
KDeclarative::ConfigPropertyMap *faceConfiguration = nullptr;
KConfigLoader *faceConfigLoader = nullptr;
bool configNeedsSave = false;
KPackage::Package facePackage;
QString faceId;
KLocalizedContext *contextObj = nullptr;
KConfigGroup configGroup;
KConfigGroup appearanceGroup;
KConfigGroup sensorsGroup;
KConfigGroup colorsGroup;
QPointer <SensorFace> fullRepresentation;
QPointer <SensorFace> compactRepresentation;
QPointer <QQuickItem> faceConfigUi;
QPointer <QQuickItem> appearanceConfigUi;
QPointer <QQuickItem> sensorsConfigUi;
QJsonArray totalSensors;
QJsonArray highPrioritySensorIds;
QJsonArray lowPrioritySensorIds;
QTimer *syncTimer;
bool shouldSync = true;
FacesModel *availableFacesModel = nullptr;
PresetsModel *availablePresetsModel = nullptr;
};
}
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