147 lines
3.9 KiB
C++
147 lines
3.9 KiB
C++
//
|
||
// 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>
|
||
#include <QList>
|
||
#include <QPair>
|
||
namespace UkuiNotification {
|
||
class PopupNotificationPrivate;
|
||
//TODO 可以增加通知基类,实现多种类型通知
|
||
typedef QList<QPair<QString, QString>> ActionList;
|
||
class UKUINOTIFICATION_EXPORT PopupNotification
|
||
{
|
||
Q_GADGET
|
||
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)
|
||
|
||
public:
|
||
/**
|
||
* The notification urgency.
|
||
*/
|
||
enum Urgency {
|
||
LowUrgency = 0,
|
||
NormalUrgency = 1,
|
||
CriticalUrgency = 2,
|
||
};
|
||
Q_ENUM(Urgency)
|
||
|
||
explicit PopupNotification(uint id = 0);
|
||
PopupNotification(const PopupNotification &other);
|
||
PopupNotification &operator=(const PopupNotification &other);
|
||
PopupNotification &operator=(PopupNotification &&other) Q_DECL_NOEXCEPT;
|
||
~PopupNotification();
|
||
|
||
uint id() const;
|
||
QString applicationName() const;
|
||
void setApplicationName(const QString &applicationName);
|
||
|
||
QString applicationIconName() const;
|
||
void setAplicationIconName(const QString &applicationIconName);
|
||
|
||
QString summary() const;
|
||
void setSummary(const QString &summary);
|
||
|
||
QString body() const;
|
||
void setBody(const QString &body);
|
||
|
||
bool hasDefaultAction() const;
|
||
QString defauleActionLable();
|
||
void setActions(const QStringList &actions);
|
||
ActionList actions() const;
|
||
|
||
QVariantMap hints() const;
|
||
void setHints(const QVariantMap &hints);
|
||
|
||
int timeout() const;
|
||
void setTimeout(int timeout);
|
||
|
||
QDateTime createdTime() const;
|
||
//m_hints
|
||
/**
|
||
* 使用图标显示action
|
||
* @return
|
||
*/
|
||
bool enableActionIcons() const;
|
||
/**
|
||
* 分类
|
||
* @return
|
||
*/
|
||
QString category() const;
|
||
/**
|
||
* desktop名称(不带.desktop后缀)
|
||
* @return
|
||
*/
|
||
QString desktopEntry() const;
|
||
/**
|
||
* 对应image-data字段
|
||
* @return
|
||
*/
|
||
QImage image() const;
|
||
/**
|
||
* 当加载image-data失败,或通过image-path加载image失败时(image-path不是URL),icon会被设置为image-path数据
|
||
* @return
|
||
*/
|
||
QString icon() const;
|
||
/**
|
||
* 是否持续显示,不会自动移除,直到被用户手动或发送者删除
|
||
* @return
|
||
*/
|
||
bool resident() const;
|
||
/**
|
||
* 声音
|
||
* @return
|
||
*/
|
||
QString soundFile() const;
|
||
/**
|
||
* 是否静音
|
||
* @return
|
||
*/
|
||
bool suppressSound() const;
|
||
/**
|
||
* 暂时通知(会自动移除)
|
||
* @return
|
||
*/
|
||
bool transient() const;
|
||
|
||
Urgency urgency() const;
|
||
void setUrgency(Urgency urgency);
|
||
/**
|
||
* 通知发送者所在的display
|
||
* @return
|
||
*/
|
||
QString display() const;
|
||
|
||
private:
|
||
PopupNotificationPrivate *d = nullptr;
|
||
};
|
||
}
|
||
|
||
#endif //UKUI_NOTIFICATION_POPUP_NOTIFICATION_H
|