LCOV - code coverage report
Current view: top level - shared-main-lib - notification.h (source / functions) Coverage Total Hit
Test: QtApplicationManager Lines: 0.0 % 1 0
Test Date: 2024-06-22 10:03:32 Functions: - 0 0
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0.0 % 2 0

             Branch data     Line data    Source code
       1                 :             : // Copyright (C) 2021 The Qt Company Ltd.
       2                 :             : // Copyright (C) 2019 Luxoft Sweden AB
       3                 :             : // Copyright (C) 2018 Pelagicore AG
       4                 :             : // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
       5                 :             : 
       6                 :             : #ifndef NOTIFICATION_H
       7                 :             : #define NOTIFICATION_H
       8                 :             : 
       9                 :             : #include <QtCore/QObject>
      10                 :             : #include <QtCore/QUrl>
      11                 :             : #include <QtCore/QVariantMap>
      12                 :             : #include <QtQml/QQmlParserStatus>
      13                 :             : #include <QtAppManCommon/global.h>
      14                 :             : 
      15                 :             : QT_BEGIN_NAMESPACE_AM
      16                 :             : 
      17                 :             : class NotificationImpl;
      18                 :             : 
      19                 :             : 
      20                 :             : class Notification : public QObject, public QQmlParserStatus
      21                 :             : {
      22                 :             :     Q_OBJECT
      23                 :             :     Q_INTERFACES(QQmlParserStatus)
      24                 :             : 
      25                 :             :     Q_PROPERTY(uint notificationId READ notificationId NOTIFY notificationIdChanged FINAL)
      26                 :             :     Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
      27                 :             : 
      28                 :             :     Q_PROPERTY(QString summary READ summary WRITE setSummary NOTIFY summaryChanged FINAL)
      29                 :             :     Q_PROPERTY(QString body READ body WRITE setBody NOTIFY bodyChanged FINAL)
      30                 :             :     Q_PROPERTY(QUrl icon READ icon WRITE setIcon NOTIFY iconChanged FINAL)
      31                 :             :     Q_PROPERTY(QUrl image READ image WRITE setImage NOTIFY imageChanged FINAL)
      32                 :             :     Q_PROPERTY(QString category READ category WRITE setCategory NOTIFY categoryChanged FINAL)
      33                 :             :     Q_PROPERTY(int priority READ priority WRITE setPriority NOTIFY priorityChanged FINAL)
      34                 :             :     Q_PROPERTY(bool acknowledgeable READ isAcknowledgeable WRITE setAcknowledgeable NOTIFY acknowledgeableChanged FINAL)
      35                 :             :     Q_PROPERTY(int timeout READ timeout WRITE setTimeout NOTIFY timeoutChanged FINAL)
      36                 :             :     Q_PROPERTY(bool sticky READ isSticky WRITE setSticky NOTIFY stickyChanged FINAL)
      37                 :             :     Q_PROPERTY(bool showProgress READ isShowingProgress WRITE setShowProgress NOTIFY showProgressChanged FINAL)
      38                 :             :     Q_PROPERTY(qreal progress READ progress WRITE setProgress NOTIFY progressChanged FINAL)
      39                 :             :     Q_PROPERTY(QVariantList actions READ actions WRITE setActions NOTIFY actionsChanged FINAL)
      40                 :             :     Q_PROPERTY(bool showActionsAsIcons READ showActionsAsIcons WRITE setShowActionsAsIcons NOTIFY showActionsAsIconsChanged FINAL)
      41                 :             :     Q_PROPERTY(bool dismissOnAction READ dismissOnAction WRITE setDismissOnAction NOTIFY dismissOnActionChanged FINAL)
      42                 :             :     Q_PROPERTY(QVariantMap extended READ extended WRITE setExtended NOTIFY extendedChanged FINAL)
      43                 :             : 
      44                 :             : public:
      45                 :             :     enum Priority { Low, Normal, Critical };
      46         [ #  # ]:           0 :     Q_ENUM(Priority)
      47                 :             : 
      48                 :             :     Notification(QObject *parent = nullptr, const QString &applicationId = { });
      49                 :             :     ~Notification() override;
      50                 :             : 
      51                 :             :     uint notificationId() const;
      52                 :             :     QString summary() const;
      53                 :             :     QString body() const;
      54                 :             :     QUrl icon() const;
      55                 :             :     QUrl image() const;
      56                 :             :     QString category() const;
      57                 :             :     int priority() const;
      58                 :             :     bool isAcknowledgeable() const;
      59                 :             :     int timeout() const;
      60                 :             :     bool isSticky() const;
      61                 :             :     bool isShowingProgress() const;
      62                 :             :     qreal progress() const;
      63                 :             :     QVariantList actions() const;
      64                 :             :     bool showActionsAsIcons() const;
      65                 :             :     bool dismissOnAction() const;
      66                 :             :     QVariantMap extended() const;
      67                 :             :     bool isVisible() const;
      68                 :             : 
      69                 :             :     Q_INVOKABLE void show();
      70                 :             :     Q_INVOKABLE void update();
      71                 :             :     Q_INVOKABLE void hide();
      72                 :             : 
      73                 :             : public Q_SLOTS:
      74                 :             :     void setSummary(const QString &summary);
      75                 :             :     void setBody(const QString &boy);
      76                 :             :     void setIcon(const QUrl &icon);
      77                 :             :     void setImage(const QUrl &image);
      78                 :             :     void setCategory(const QString &category);
      79                 :             :     void setPriority(int priority);
      80                 :             :     void setAcknowledgeable(bool acknowledgeable);
      81                 :             :     void setTimeout(int timeout);
      82                 :             :     void setSticky(bool sticky);
      83                 :             :     void setShowProgress(bool showProgress);
      84                 :             :     void setProgress(qreal progress);
      85                 :             :     void setActions(const QVariantList &actions);
      86                 :             :     void setShowActionsAsIcons(bool showActionsAsIcons);
      87                 :             :     void setDismissOnAction(bool dismissOnAction);
      88                 :             :     void setExtended(const QVariantMap &extended);
      89                 :             :     void setVisible(bool visible);
      90                 :             : 
      91                 :             : Q_SIGNALS:
      92                 :             :     void notificationIdChanged(uint notificationId);
      93                 :             :     void summaryChanged(const QString &summary);
      94                 :             :     void bodyChanged(const QString &body);
      95                 :             :     void iconChanged(const QUrl &icon);
      96                 :             :     void imageChanged(const QUrl &image);
      97                 :             :     void categoryChanged(const QString &category);
      98                 :             :     void priorityChanged(int priority);
      99                 :             :     void acknowledgeableChanged(bool acknowledgeable);
     100                 :             :     void timeoutChanged(int timeout);
     101                 :             :     void stickyChanged(bool sticky);
     102                 :             :     void showProgressChanged(bool showProgress);
     103                 :             :     void progressChanged(qreal progress);
     104                 :             :     void actionsChanged(const QVariantList &actions);
     105                 :             :     void showActionsAsIconsChanged(bool showActionsAsIcons);
     106                 :             :     void dismissOnActionChanged(bool dismissOnAction);
     107                 :             :     void extendedChanged(QVariantMap extended);
     108                 :             :     void visibleChanged(bool visible);
     109                 :             : 
     110                 :             :     void acknowledged();
     111                 :             :     void actionTriggered(const QString &actionId);
     112                 :             : 
     113                 :             : public:
     114                 :             :     // not public API, but QQmlParserStatus pure-virtual overrides
     115                 :             :     void classBegin() override;
     116                 :             :     void componentComplete() override;
     117                 :             : 
     118                 :             :     void setId(uint notificationId);
     119                 :             :     void close();
     120                 :             :     void triggerAction(const QString &actionId);
     121                 :             : 
     122                 :             :     QVariantMap libnotifyHints() const;
     123                 :             :     QStringList libnotifyActionList() const;
     124                 :             : 
     125                 :             : private:
     126                 :             :     void updateNotification();
     127                 :             : 
     128                 :             : private:
     129                 :             :     uint m_id = 0;
     130                 :             :     QString m_summary;
     131                 :             :     QString m_body;
     132                 :             :     QUrl m_icon;
     133                 :             :     QUrl m_image;
     134                 :             :     QString m_category;
     135                 :             :     int m_priority = Normal;
     136                 :             :     bool m_acknowledgeable = false;
     137                 :             :     int m_timeout = defaultTimeout;
     138                 :             :     bool m_showProgress = false;
     139                 :             :     qreal m_progress = -1;
     140                 :             :     QVariantList m_actions;
     141                 :             :     bool m_showActionsAsIcons = false;
     142                 :             :     bool m_dismissOnAction = false;
     143                 :             :     QVariantMap m_extended;
     144                 :             :     bool m_visible = false;
     145                 :             : 
     146                 :             :     bool m_usedByQml = false;
     147                 :             :     bool m_componentComplete = false;
     148                 :             : 
     149                 :             :     static const int defaultTimeout = 2000;
     150                 :             : 
     151                 :             : private:
     152                 :             :     Q_DISABLE_COPY_MOVE(Notification)
     153                 :             : 
     154                 :             :     std::unique_ptr<NotificationImpl> m_impl;
     155                 :             :     friend class NotificationImpl;
     156                 :             :     friend class ApplicationMain;
     157                 :             : };
     158                 :             : 
     159                 :             : QT_END_NAMESPACE_AM
     160                 :             : 
     161                 :             : #endif // NOTIFICATION_H
        

Generated by: LCOV version 2.0-1