ukui-notification/libukui-notification/popup-notification.h

148 lines
4.0 KiB
C
Raw Normal View History

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;
class UKUINOTIFICATION_EXPORT PopupNotification
2023-02-03 18:01:06 +08:00
{
friend class NotificationSettingsTest;
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)
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-06 17:03:12 +08:00
* @return
*/
bool suppressSound() const;
/**
*
* @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);
/**
* 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