diff --git a/plugins/MosaicCamera/src/MosaicCamera.cpp b/plugins/MosaicCamera/src/MosaicCamera.cpp index 17fff0b43555d..bd67ae1b4380b 100644 --- a/plugins/MosaicCamera/src/MosaicCamera.cpp +++ b/plugins/MosaicCamera/src/MosaicCamera.cpp @@ -67,6 +67,7 @@ MosaicCamera::MosaicCamera() setObjectName("MosaicCamera"); configDialog = new MosaicCameraDialog(); tcpServer = new MosaicTcpServer(); + conf = StelApp::getInstance().getSettings(); } /************************************************************************* @@ -78,6 +79,36 @@ MosaicCamera::~MosaicCamera() delete tcpServer; } +void MosaicCamera::loadSettings() +{ + conf->beginGroup("MosaicCamera"); + int size = conf->beginReadArray("cameraVisibility"); + for (int i = 0; i < size; ++i) { + conf->setArrayIndex(i); + QString name = conf->value("name").toString(); + bool visible = conf->value("visible").toBool(); + if (cameras.contains(name)) { + cameras[name].visible = visible; + } + } + conf->endArray(); + conf->endGroup(); +} + +void MosaicCamera::saveSettings() const +{ + conf->beginGroup("MosaicCamera"); + conf->beginWriteArray("cameraVisibility"); + int i = 0; + for (auto it = cameras.constBegin(); it != cameras.constEnd(); ++it) { + conf->setArrayIndex(i++); + conf->setValue("name", it.key()); + conf->setValue("visible", it.value().visible); + } + conf->endArray(); + conf->endGroup(); +} + /************************************************************************* Reimplementation of the getCallOrder method *************************************************************************/ @@ -104,6 +135,8 @@ void MosaicCamera::init() qDebug() << "[MosaicCamera] Loading built-in cameras"; loadBuiltInCameras(); + + loadSettings(); } void MosaicCamera::initializeUserData() @@ -277,6 +310,7 @@ void MosaicCamera::setVisibility(const QString& cameraName, bool visible) if (cameras.contains(cameraName)) { cameras[cameraName].visible = visible; + saveSettings(); if(configDialog->visible()) { if (configDialog->getCurrentCameraName() == cameraName) { configDialog->setVisibility(visible); diff --git a/plugins/MosaicCamera/src/MosaicCamera.hpp b/plugins/MosaicCamera/src/MosaicCamera.hpp index a1fa6f19d0b32..da7eab226440e 100644 --- a/plugins/MosaicCamera/src/MosaicCamera.hpp +++ b/plugins/MosaicCamera/src/MosaicCamera.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include class MosaicCameraDialog; @@ -69,6 +70,9 @@ class MosaicCamera : public StelModule double getRotation(const QString& cameraName) const; bool getVisibility(const QString& cameraName) const; + void loadSettings(); + void saveSettings() const; + QStringList getCameraNames() const; void readPolygonSetsFromJson(const QString& cameraName, const QString& filename); @@ -80,6 +84,7 @@ public slots: QStringList cameraOrder; QString currentCamera; QString userDirectory; + QSettings* conf; void loadBuiltInCameras(); void loadCameraOrder();