LCOV - code coverage report
Current view: top level - data - ClusterSettingsManager.cpp (source / functions) Hit Total Coverage
Test: filtered.info Lines: 36 36 100.0 %
Date: 2025-07-25 11:48:17 Functions: 9 9 100.0 %

          Line data    Source code
       1             : /*!
       2             :  * @file ClusterSettingsManager.cpp
       3             :  * @brief Implementation of the ClusterSettingsManager class.
       4             :  * @version 0.1
       5             :  * @date 2025-02-12
       6             :  * @details This file contains the implementation of the ClusterSettingsManager
       7             :  * class, which manages the settings of the cluster.
       8             :  * @author Félix LE BIHAN (@Fle-bihh)
       9             :  * @author Tiago Pereira (@t-pereira06)
      10             :  * @author Ricardo Melo (@reomelo)
      11             :  * @author Michel Batista (@MicchelFAB)
      12             :  *
      13             :  * @copyright Copyright (c) 2025
      14             :  */
      15             : 
      16             : #include "ClusterSettingsManager.hpp"
      17             : 
      18             : /*!
      19             :  * @brief Construct a new ClusterSettingsManager::ClusterSettingsManager object
      20             :  * @param parent The parent QObject.
      21             :  * @details This constructor initializes the ClusterSettingsManager object.
      22             :  */
      23           3 : ClusterSettingsManager::ClusterSettingsManager(QObject *parent)
      24           3 :         : QObject(parent)
      25           3 : {}
      26             : 
      27             : /*!
      28             :  * @brief Destroy the ClusterSettingsManager::ClusterSettingsManager object
      29             :  * @details This destructor cleans up the resources used by the
      30             :  * ClusterSettingsManager.
      31             :  */
      32           6 : ClusterSettingsManager::~ClusterSettingsManager() {}
      33             : 
      34             : /*!
      35             :  * @brief Get the driving mode.
      36             :  * @returns The driving mode.
      37             :  * @details This function returns the current driving mode.
      38             :  */
      39           2 : void ClusterSettingsManager::setDrivingMode(DrivingMode newMode)
      40             : {
      41           2 :         if (m_drivingMode != newMode) {
      42           2 :                 m_drivingMode = newMode;
      43           2 :                 emit drivingModeUpdated(newMode);
      44             :         }
      45           2 : }
      46             : 
      47             : /*!
      48             :  * @brief Toggle the driving mode.
      49             :  * @details This function toggles the driving mode between manual and automatic.
      50             :  */
      51           2 : void ClusterSettingsManager::toggleDrivingMode()
      52             : {
      53           2 :         if (m_drivingMode == DrivingMode::Manual) {
      54           1 :                 setDrivingMode(DrivingMode::Automatic);
      55             :         } else {
      56           1 :                 setDrivingMode(DrivingMode::Manual);
      57             :         }
      58           2 : }
      59             : 
      60             : /*!
      61             :  * @brief Get the cluster theme.
      62             :  * @returns The cluster theme.
      63             :  * @details This function returns the current cluster theme.
      64             :  */
      65           2 : void ClusterSettingsManager::setClusterTheme(ClusterTheme newTheme)
      66             : {
      67           2 :         if (m_clusterTheme != newTheme) {
      68           2 :                 m_clusterTheme = newTheme;
      69           2 :                 emit clusterThemeUpdated(newTheme);
      70             :         }
      71           2 : }
      72             : 
      73             : /*!
      74             :  * @brief Toggle the cluster theme.
      75             :  * @details This function toggles the cluster theme between light and dark.
      76             :  */
      77           2 : void ClusterSettingsManager::toggleClusterTheme()
      78             : {
      79           2 :         if (m_clusterTheme == ClusterTheme::Dark) {
      80           1 :                 setClusterTheme(ClusterTheme::Light);
      81             :         } else {
      82           1 :                 setClusterTheme(ClusterTheme::Dark);
      83             :         }
      84           2 : }
      85             : 
      86             : /*!
      87             :  * @brief Get the cluster metrics.
      88             :  * @returns The cluster metrics.
      89             :  * @details This function returns the current cluster metrics.
      90             :  */
      91           2 : void ClusterSettingsManager::setClusterMetrics(ClusterMetrics newMetrics)
      92             : {
      93           2 :         if (m_clusterMetrics != newMetrics) {
      94           2 :                 m_clusterMetrics = newMetrics;
      95           2 :                 emit clusterMetricsUpdated(newMetrics);
      96             :         }
      97           2 : }
      98             : 
      99             : /*!
     100             :  * @brief Toggle the cluster metrics.
     101             :  * @details This function toggles the cluster metrics between kilometers and miles.
     102             :  */
     103           2 : void ClusterSettingsManager::toggleClusterMetrics()
     104             : {
     105           2 :         if (m_clusterMetrics == ClusterMetrics::Kilometers) {
     106           1 :                 setClusterMetrics(ClusterMetrics::Miles);
     107           1 :                 NotificationManager::instance()->enqueueNotification("Metrics set to MPH", NotificationLevel::Info, 2000);
     108             :         } else {
     109           1 :                 setClusterMetrics(ClusterMetrics::Kilometers);
     110           1 :                 NotificationManager::instance()->enqueueNotification("Metrics set to KMH", NotificationLevel::Info, 2000);
     111             :         }
     112           2 : }

Generated by: LCOV version 1.14