dtknotifications
notification development tool kit
dnotificationappconfig.h
浏览该文件的文档.
1// SPDX-FileCopyrightText: 2022 Uniontech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#pragma once
6
7#include <QObject>
8#include <dexpected.h>
9
10#include "dtknotification_global.h"
11
12DNOTIFICATIONS_BEGIN_NAMESPACE
13DCORE_USE_NAMESPACE
14
15class DNotificationAppConfigPrivate;
16
17class DNotificationAppConfig : public QObject
18{
19 Q_OBJECT
20 Q_PROPERTY(QString appName READ appName)
21 Q_PROPERTY(QString appIcon READ appIcon)
22 Q_PROPERTY(bool notificationEnabled READ notificationEnabled WRITE setNotificationEnabled NOTIFY notificationEnabledChanged)
23 Q_PROPERTY(bool previewEnabled READ previewEnabled WRITE setPreviewEnabled NOTIFY previewEnabledChanged)
24 Q_PROPERTY(bool soundEnabled READ soundEnabled WRITE setSoundEnabled NOTIFY soundEnabledChanged)
25 Q_PROPERTY(bool showInNotificationCenterEnabled READ showInNotificationCenterEnabled WRITE setShowInNotificationCenterEnabled NOTIFY showInNotificationCenterEnabledChanged)
26 Q_PROPERTY(bool showInLockScreenEnabled READ showInLockScreenEnabled WRITE setShowInLockScreenEnabled NOTIFY showInLockScreenEnabledChanged)
27
28public:
29 explicit DNotificationAppConfig(const QString &id, QObject *parent = nullptr);
31
32 QString appName() const;
33 QString appIcon() const;
34
35 bool notificationEnabled() const;
36 DExpected<void> setNotificationEnabled(bool enabled);
37
38 // show message preview
39 bool previewEnabled() const;
40 DExpected<void> setPreviewEnabled(const bool enabled);
41
42 // play a sound
43 bool soundEnabled() const;
44 DExpected<void> setSoundEnabled(const bool enabled);
45
47 DExpected<void> setShowInNotificationCenterEnabled(const bool enabled);
48
50 DExpected<void> setShowInLockScreenEnabled(const bool enabled);
51
52Q_SIGNALS:
53 void notificationEnabledChanged(const QString &id, const bool enabled);
54 void previewEnabledChanged(const QString &id, const bool enabled);
55 void soundEnabledChanged(const QString &id, const bool enabled);
56 void showInNotificationCenterEnabledChanged(const QString &id, const bool enabled);
57 void showInLockScreenEnabledChanged(const QString &id, const bool enabled);
58
59private:
60 QScopedPointer<DNotificationAppConfigPrivate> d_ptr;
61 Q_DECLARE_PRIVATE(DNotificationAppConfig)
62};
63typedef QSharedPointer<DNotificationAppConfig> DNotificationAppConfigPtr;
64
65DNOTIFICATIONS_END_NAMESPACE
DAppNotificationConfig类
Definition: dnotificationappconfig.h:18
QString appIcon() const
应用图标名称
void notificationEnabledChanged(const QString &id, const bool enabled)
是否打开通知的配置发生变化后发出的信号
DExpected< void > setNotificationEnabled(bool enabled)
设置是否打开通知
DExpected< void > setPreviewEnabled(const bool enabled)
设置是否打开预览
DExpected< void > setShowInLockScreenEnabled(const bool enabled)
设置是否在锁屏界面显示
bool soundEnabled() const
判断是否打开声音
bool notificationEnabled() const
判断是否打开通知
bool showInNotificationCenterEnabled() const
判断是否在通知中心显示
void soundEnabledChanged(const QString &id, const bool enabled)
是否打开声音的配置发生变化后发出的信号
void previewEnabledChanged(const QString &id, const bool enabled)
是否打开预览的配置发生变化后发出的信号
void showInLockScreenEnabledChanged(const QString &id, const bool enabled)
是否在锁屏界面展示的配置发生变化后发出的信号
DExpected< void > setSoundEnabled(const bool enabled)
设置是否打开声音
void showInNotificationCenterEnabledChanged(const QString &id, const bool enabled)
是否在通知中心展示的配置发生变化后发出的信号
QString appName() const
应用名称
bool showInLockScreenEnabled() const
判断是否在锁屏界面显示
DExpected< void > setShowInNotificationCenterEnabled(const bool enabled)
设置是否在通知中心显示
bool previewEnabled() const
判断是否打开预览
DNotificationAppConfig(const QString &id, QObject *parent=nullptr)
构造通知应用配置对象