2023-04-17 11:15:11 +08:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2023, KylinSoft Co., Ltd.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
*
|
|
|
|
|
* Authors: iaom <zhangpengfei@kylinos.cn>
|
|
|
|
|
*/
|
2023-02-03 18:01:06 +08:00
|
|
|
|
|
|
|
|
|
#ifndef UKUI_NOTIFICATION_NOTIFICATION_CLIENT_H
|
|
|
|
|
#define UKUI_NOTIFICATION_NOTIFICATION_CLIENT_H
|
|
|
|
|
#include "ukui-notification_global.h"
|
|
|
|
|
#include <QObject>
|
2023-02-06 17:03:12 +08:00
|
|
|
|
#include "popup-notification.h"
|
2023-03-08 16:57:51 +08:00
|
|
|
|
#include "notification-close-reason.h"
|
2023-02-03 18:01:06 +08:00
|
|
|
|
namespace UkuiNotification {
|
|
|
|
|
class NotificationClientPrivate;
|
2023-11-24 14:44:17 +08:00
|
|
|
|
/**
|
|
|
|
|
* @short 通知中心客户端接口.
|
|
|
|
|
* @author iaom
|
|
|
|
|
*/
|
2023-02-03 18:01:06 +08:00
|
|
|
|
class UKUINOTIFICATION_EXPORT NotificationClient : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2023-02-16 09:28:41 +08:00
|
|
|
|
explicit NotificationClient(QObject *parent = nullptr);
|
2023-02-06 17:03:12 +08:00
|
|
|
|
~NotificationClient();
|
2023-11-24 14:44:17 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief 客户端注册,注册后可监听通知发送&关闭信号或调用通知动作执行以及主动关闭通知的接口。
|
|
|
|
|
* @return 是否成功操作
|
|
|
|
|
* @retval 成功:true;失败:false
|
|
|
|
|
*/
|
|
|
|
|
bool registerClient();
|
2023-02-06 17:03:12 +08:00
|
|
|
|
/**
|
2023-11-24 14:44:17 +08:00
|
|
|
|
* @brief 注销当前客户端,注销后将不能再接收到新通知或通知关闭信号。
|
|
|
|
|
* @return 是否成功操作
|
|
|
|
|
* @retval 成功:true;失败:false
|
2023-02-06 17:03:12 +08:00
|
|
|
|
*/
|
2023-02-17 16:54:45 +08:00
|
|
|
|
void unregisterClient();
|
2023-11-24 14:44:17 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief 关闭一条通知
|
|
|
|
|
* @param id:通知id
|
|
|
|
|
* @param reason:通知关闭原因
|
|
|
|
|
* @return 是否成功操作
|
|
|
|
|
* @retval 成功:true;失败:false
|
|
|
|
|
*/
|
2023-03-08 16:57:51 +08:00
|
|
|
|
bool closeNotification(uint id, NotificationCloseReason::CloseReason reason);
|
2023-11-24 14:44:17 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief 执行动作
|
|
|
|
|
* @param id: 通知id
|
|
|
|
|
* @param action_key: action的唯一标识
|
|
|
|
|
* @return 是否成功操作
|
|
|
|
|
* @retval 成功:true;失败:false
|
|
|
|
|
*/
|
2023-02-17 16:54:45 +08:00
|
|
|
|
bool invokeAction(uint id, const QString &action_key);
|
2023-02-06 17:03:12 +08:00
|
|
|
|
Q_SIGNALS:
|
2023-11-24 14:44:17 +08:00
|
|
|
|
/**
|
|
|
|
|
* 通知服务收到新通知时发送.
|
|
|
|
|
*/
|
2023-03-08 16:57:51 +08:00
|
|
|
|
void newNotification(const UkuiNotification::PopupNotification ¬ification);
|
2023-11-24 14:44:17 +08:00
|
|
|
|
/**
|
|
|
|
|
* 通知被关闭时发送.
|
|
|
|
|
*/
|
2023-03-08 16:57:51 +08:00
|
|
|
|
void notificationClosed(uint id, UkuiNotification::NotificationCloseReason::CloseReason closeReason);
|
2023-02-03 18:01:06 +08:00
|
|
|
|
private:
|
|
|
|
|
NotificationClientPrivate *d = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // UkuiNotification
|
|
|
|
|
|
|
|
|
|
#endif //UKUI_NOTIFICATION_NOTIFICATION_CLIENT_H
|