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

          Line data    Source code
       1             : #include "NotificationManager.hpp"
       2             : 
       3           9 : NotificationManager* NotificationManager::instance()
       4             : {
       5           9 :         static NotificationManager instanceObj;
       6           9 :         return &instanceObj;
       7             : }
       8             : 
       9           1 : NotificationManager::NotificationManager(QObject* parent)
      10           1 :         : QObject(parent)
      11             : {
      12           1 : }
      13             : 
      14           8 : void NotificationManager::initialize(NotificationOverlay* overlay)
      15             : {
      16           8 :         m_overlay = overlay;
      17           8 : }
      18             : 
      19           4 : void NotificationManager::enqueueNotification(const QString& text, NotificationLevel level, int durationMs)
      20             : {
      21           4 :         if (!m_overlay) return;
      22             : 
      23             :         /* const int MAX_QUEUE_SIZE = 5;
      24             :         if (m_queue.size() >= MAX_QUEUE_SIZE) {
      25             :                 m_queue.dequeue();  // Drop oldest to make room
      26             :         }
      27             : 
      28             :         // Prevent duplicate text
      29             :         bool alreadyQueued = std::any_of(m_queue.begin(), m_queue.end(), [&](const auto& t) {
      30             :                 return std::get<0>(t) == text;
      31             :         });
      32             : 
      33             :         if (!alreadyQueued) {
      34             :                 m_queue.enqueue(std::make_tuple(text, level, durationMs));
      35             :         }
      36             : 
      37             :         m_queue.enqueue(std::make_tuple(text, level, durationMs));
      38             :         if (!m_busy) {
      39             :                 showNext();
      40             :         } */
      41             : 
      42           2 :         m_overlay->showNotification(text, level, durationMs);
      43             : }
      44             : 
      45           4 : void NotificationManager::showPersistentNotification(const QString& text, NotificationLevel level) {
      46           4 :         if (!m_overlay) return;
      47           2 :         m_overlay->showNotification(text, level, 0);  // 0 = persistent
      48           2 :         m_persistentActive = true;
      49             : }
      50             : 
      51           2 : void NotificationManager::clearNotification() {
      52           2 :         if (!m_overlay || !m_persistentActive) return;
      53           1 :         m_overlay->hideNotification();
      54           1 :         m_persistentActive = false;
      55             : }
      56             : 
      57             : /* void NotificationManager::showNext()
      58             : {
      59             :         if (m_queue.isEmpty()) {
      60             :                 m_busy = false;
      61             :                 return;
      62             :         }
      63             : 
      64             :         m_busy = true;
      65             :         auto [text, level, duration] = m_queue.dequeue();
      66             : 
      67             :         m_overlay->showNotification(text, level, duration); // Show for 2 seconds
      68             : 
      69             :         QTimer::singleShot(duration, this, [this]() {
      70             :                 showNext();
      71             :         });
      72             : } */

Generated by: LCOV version 1.14