Commits

Anonymous committed 396c71e

added a function to CameraWindow called setConfigurationFromMap_Lenient that allows parts of the configuration to not be specified in the loaded file. If any section is unspecified, it uses the old configuration

Comments (0)

Files changed (3)

src/gui/basic_http_server.cpp

     QVariantMap BasicHttpServer::handleLoadConfiguration(QString fileName)
     {
         QVariantMap cmdMap;
+
         RtnStatus status = cameraWindowPtr_ -> loadConfiguration(fileName,false);
         cmdMap.insert("success", status.success);
         cmdMap.insert("message", status.message);

src/gui/camera_window.cpp

 
         QVariantMap oldConfigMap = getConfigurationMap(rtnStatus);
 
-        rtnStatus = setConfigurationFromMap(configMap,showErrorDlg);
+        //rtnStatus = setConfigurationFromMap(configMap,showErrorDlg);
+	rtnStatus = setConfigurationFromMap_Lenient(configMap,oldConfigMap,showErrorDlg);
         if (!rtnStatus.success)
         {
             QString origErrMsg = rtnStatus.message;
         return rtnStatus;
     }
 
+    // same as setConfigurationFromMap, but uses the old configuration if 
+    // fields are missing from the new one
+    RtnStatus CameraWindow::setConfigurationFromMap_Lenient(
+            QVariantMap configMap, 
+	    QVariantMap oldConfigMap,
+            bool showErrorDlg
+            )
+    {
+
+        RtnStatus rtnStatus;
+        QString errMsgTitle("Load Configuration Error");
+
+        // Check if camera is capturing
+        // ----------------------------
+        if (capturing_)
+        {
+            QString errMsgText("unable to set configuration - capturing");
+            return onError(errMsgText, errMsgTitle, showErrorDlg);
+        }
+
+        // Set camera properties, videomode, etc.
+        // --------------------------------------
+        QVariantMap cameraMap = configMap["camera"].toMap();
+        if (cameraMap.isEmpty())
+        {
+	  cameraMap = oldConfigMap["camera"].toMap();
+        }
+	rtnStatus = setCameraFromMap(cameraMap,showErrorDlg);
+        if (!rtnStatus.success)
+        {
+            return rtnStatus;
+        }
+
+        // Set logging configuration
+        // --------------------------
+        QVariantMap loggingMap = configMap["logging"].toMap();
+        if (loggingMap.isEmpty())
+        {
+	  loggingMap = oldConfigMap["logging"].toMap();
+        }
+        rtnStatus = setLoggingFromMap(loggingMap,showErrorDlg);
+        if (!rtnStatus.success)
+        {
+            return rtnStatus;
+        }
+
+        // Set timer configuration
+        // ------------------------
+        QVariantMap timerMap = configMap["timer"].toMap();
+        if (timerMap.isEmpty())
+        {
+	  timerMap = oldConfigMap["timer"].toMap();
+        }
+        rtnStatus = setTimerFromMap(timerMap,showErrorDlg);
+        if (!rtnStatus.success)
+        {
+            return rtnStatus;
+        }
+
+        // Set display configuration
+        // --------------------------
+        QVariantMap displayMap = configMap["display"].toMap();
+        if (displayMap.isEmpty())
+        {
+	  displayMap = oldConfigMap["display"].toMap();
+        }
+        rtnStatus = setDisplayFromMap(displayMap,showErrorDlg);
+        if (!rtnStatus.success)
+        {
+            return rtnStatus;
+        }
+
+        // Set external control server configuration
+        // -----------------------------------------
+        QVariantMap serverMap = configMap["server"].toMap();
+        if (serverMap.isEmpty())
+        {
+	  serverMap = oldConfigMap["server"].toMap();
+        }
+        rtnStatus = setServerFromMap(serverMap,showErrorDlg);
+        if (!rtnStatus.success)
+        {
+            return rtnStatus;
+        }
+
+        // Set configuration file configuraiton 
+        // -------------------------------------
+        QVariantMap configFileMap = configMap["configuration"].toMap();
+        if (configFileMap.isEmpty())
+        {
+	  configFileMap = oldConfigMap["configuration"].toMap();
+        }
+        rtnStatus = setConfigFileFromMap(configFileMap,showErrorDlg);
+        if (!rtnStatus.success)
+        {
+            return rtnStatus;
+        }
+
+        rtnStatus.success = true;
+        rtnStatus.message = QString("");
+
+        return rtnStatus;
+    }
 
     RtnStatus CameraWindow::enableLogging(bool showErrorDlg)
     {

src/gui/camera_window.hpp

                     QVariantMap configMap, 
                     bool showErrorDlg=true
                     );
+            RtnStatus setConfigurationFromMap_Lenient(
+                    QVariantMap configMap, 
+		    QVariantMap oldConfigMap, 
+                    bool showErrorDlg=true
+                    );
 
             QByteArray getConfigurationJson(
                     RtnStatus &rtnStatus,