2023-02-03 18:01:06 +08:00
|
|
|
|
//
|
|
|
|
|
// Created by zpf on 23-2-2.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#ifndef UKUI_NOTIFICATION_POPUP_NOTIFICATION_H
|
|
|
|
|
#define UKUI_NOTIFICATION_POPUP_NOTIFICATION_H
|
|
|
|
|
#include "ukui-notification_global.h"
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QDateTime>
|
|
|
|
|
#include <QList>
|
|
|
|
|
#include <QString>
|
|
|
|
|
#include <QUrl>
|
|
|
|
|
#include <QVariantMap>
|
|
|
|
|
#include <QImage>
|
2023-02-06 17:03:12 +08:00
|
|
|
|
#include <QList>
|
|
|
|
|
#include <QPair>
|
|
|
|
|
namespace UkuiNotification {
|
|
|
|
|
class PopupNotificationPrivate;
|
|
|
|
|
//TODO 可以增加通知基类,实现多种类型通知
|
2023-02-14 17:21:09 +08:00
|
|
|
|
typedef QList<QPair<QString, QString>> ActionList;
|
2023-02-17 16:54:45 +08:00
|
|
|
|
class UKUINOTIFICATION_EXPORT PopupNotification
|
2023-02-03 18:01:06 +08:00
|
|
|
|
{
|
2023-03-17 15:01:29 +08:00
|
|
|
|
friend class NotificationSettingsTest;
|
2023-02-17 16:54:45 +08:00
|
|
|
|
Q_GADGET
|
2023-02-14 17:21:09 +08:00
|
|
|
|
Q_PROPERTY(uint id READ id)
|
|
|
|
|
Q_PROPERTY(QString applicationName READ applicationName WRITE setApplicationName)
|
|
|
|
|
Q_PROPERTY(QString applicationIconName READ applicationIconName WRITE setAplicationIconName)
|
|
|
|
|
Q_PROPERTY(QString summary READ summary WRITE setSummary)
|
|
|
|
|
Q_PROPERTY(QString body READ body WRITE setBody)
|
|
|
|
|
Q_PROPERTY(QDateTime createdTime READ createdTime)
|
|
|
|
|
Q_PROPERTY(bool hasDefaultAction READ hasDefaultAction)
|
|
|
|
|
Q_PROPERTY(ActionList actions READ actions)
|
|
|
|
|
Q_PROPERTY(uint timeout READ timeout WRITE setTimeout)
|
|
|
|
|
Q_PROPERTY(bool enableActionIcons READ enableActionIcons)
|
|
|
|
|
Q_PROPERTY(QImage image READ image)
|
|
|
|
|
Q_PROPERTY(QString icon READ icon)
|
|
|
|
|
Q_PROPERTY(bool resident READ resident)
|
|
|
|
|
Q_PROPERTY(bool transient READ transient)
|
|
|
|
|
Q_PROPERTY(QString soundFile READ soundFile)
|
|
|
|
|
Q_PROPERTY(bool suppressSound READ suppressSound)
|
|
|
|
|
Q_PROPERTY(QString category READ category)
|
|
|
|
|
Q_PROPERTY(Urgency urgency READ urgency WRITE setUrgency)
|
|
|
|
|
Q_PROPERTY(QString display READ display)
|
|
|
|
|
|
2023-02-03 18:01:06 +08:00
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* The notification urgency.
|
|
|
|
|
*/
|
|
|
|
|
enum Urgency {
|
2023-02-06 17:03:12 +08:00
|
|
|
|
LowUrgency = 0,
|
|
|
|
|
NormalUrgency = 1,
|
|
|
|
|
CriticalUrgency = 2,
|
2023-02-03 18:01:06 +08:00
|
|
|
|
};
|
|
|
|
|
Q_ENUM(Urgency)
|
|
|
|
|
|
2023-02-17 16:54:45 +08:00
|
|
|
|
explicit PopupNotification(uint id = 0);
|
2023-02-03 18:01:06 +08:00
|
|
|
|
PopupNotification(const PopupNotification &other);
|
|
|
|
|
PopupNotification &operator=(const PopupNotification &other);
|
|
|
|
|
PopupNotification &operator=(PopupNotification &&other) Q_DECL_NOEXCEPT;
|
|
|
|
|
~PopupNotification();
|
|
|
|
|
|
2023-02-14 17:21:09 +08:00
|
|
|
|
uint id() const;
|
2023-02-03 18:01:06 +08:00
|
|
|
|
QString applicationName() const;
|
|
|
|
|
void setApplicationName(const QString &applicationName);
|
|
|
|
|
|
2023-02-06 17:03:12 +08:00
|
|
|
|
QString applicationIconName() const;
|
|
|
|
|
void setAplicationIconName(const QString &applicationIconName);
|
2023-02-03 18:01:06 +08:00
|
|
|
|
|
|
|
|
|
QString summary() const;
|
|
|
|
|
void setSummary(const QString &summary);
|
|
|
|
|
|
|
|
|
|
QString body() const;
|
|
|
|
|
void setBody(const QString &body);
|
|
|
|
|
|
|
|
|
|
bool hasDefaultAction() const;
|
2023-02-06 17:03:12 +08:00
|
|
|
|
QString defauleActionLable();
|
2023-02-03 18:01:06 +08:00
|
|
|
|
void setActions(const QStringList &actions);
|
2023-02-14 17:21:09 +08:00
|
|
|
|
ActionList actions() const;
|
2023-02-03 18:01:06 +08:00
|
|
|
|
|
|
|
|
|
QVariantMap hints() const;
|
|
|
|
|
void setHints(const QVariantMap &hints);
|
|
|
|
|
|
|
|
|
|
int timeout() const;
|
|
|
|
|
void setTimeout(int timeout);
|
|
|
|
|
|
2023-02-06 17:03:12 +08:00
|
|
|
|
QDateTime createdTime() const;
|
|
|
|
|
//m_hints
|
|
|
|
|
/**
|
|
|
|
|
* 使用图标显示action
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-02-03 18:01:06 +08:00
|
|
|
|
bool enableActionIcons() const;
|
2023-02-06 17:03:12 +08:00
|
|
|
|
/**
|
|
|
|
|
* 分类
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-02-03 18:01:06 +08:00
|
|
|
|
QString category() const;
|
2023-02-06 17:03:12 +08:00
|
|
|
|
/**
|
|
|
|
|
* desktop名称(不带.desktop后缀)
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-02-03 18:01:06 +08:00
|
|
|
|
QString desktopEntry() const;
|
2023-02-06 17:03:12 +08:00
|
|
|
|
/**
|
|
|
|
|
* 对应image-data字段
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-02-03 18:01:06 +08:00
|
|
|
|
QImage image() const;
|
2023-02-06 17:03:12 +08:00
|
|
|
|
/**
|
|
|
|
|
* 当加载image-data失败,或通过image-path加载image失败时(image-path不是URL),icon会被设置为image-path数据
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
QString icon() const;
|
|
|
|
|
/**
|
|
|
|
|
* 是否持续显示,不会自动移除,直到被用户手动或发送者删除
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-02-03 18:01:06 +08:00
|
|
|
|
bool resident() const;
|
2023-02-06 17:03:12 +08:00
|
|
|
|
/**
|
|
|
|
|
* 声音
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-02-03 18:01:06 +08:00
|
|
|
|
QString soundFile() const;
|
2023-02-06 17:03:12 +08:00
|
|
|
|
/**
|
2023-02-09 13:54:53 +08:00
|
|
|
|
* 是否静音
|
2023-02-06 17:03:12 +08:00
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
bool suppressSound() const;
|
2023-02-09 13:54:53 +08:00
|
|
|
|
/**
|
|
|
|
|
* 暂时通知(会自动移除)
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-02-03 18:01:06 +08:00
|
|
|
|
bool transient() const;
|
2023-02-14 17:21:09 +08:00
|
|
|
|
|
|
|
|
|
Urgency urgency() const;
|
2023-02-03 18:01:06 +08:00
|
|
|
|
void setUrgency(Urgency urgency);
|
2023-02-09 13:54:53 +08:00
|
|
|
|
/**
|
|
|
|
|
* 通知发送者所在的display
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-02-06 17:03:12 +08:00
|
|
|
|
QString display() const;
|
2023-02-03 18:01:06 +08:00
|
|
|
|
|
|
|
|
|
private:
|
2023-02-06 17:03:12 +08:00
|
|
|
|
PopupNotificationPrivate *d = nullptr;
|
2023-02-03 18:01:06 +08:00
|
|
|
|
};
|
2023-02-06 17:03:12 +08:00
|
|
|
|
}
|
2023-02-03 18:01:06 +08:00
|
|
|
|
|
|
|
|
|
#endif //UKUI_NOTIFICATION_POPUP_NOTIFICATION_H
|