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

286 lines
8.2 KiB
C
Raw Normal View History

2023-07-31 18:01:44 +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>
*/
#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;
typedef QList<QPair<QString, QString>> ActionList;
/**
* @short
* @author iaom
*/
2023-07-31 18:01:44 +08:00
class UKUINOTIFICATION_EXPORT PopupNotification
{
friend class NotificationSettingsTest;
Q_GADGET
/**
* ID
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(uint id READ id)
/**
*
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(QString applicationName READ applicationName WRITE setApplicationName)
/**
*
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(QString applicationIconName READ applicationIconName WRITE setApplicationIconName)
/**
*
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(QString summary READ summary WRITE setSummary)
/**
*
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(QString body READ body WRITE setBody)
/**
*
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(QDateTime createdTime READ createdTime)
/**
* action,
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(bool hasDefaultAction READ hasDefaultAction)
/**
* action列表actions及执行动作信息0action的唯一标识
* action为defaultaction拼成一组action则会在通知弹窗里以按钮形式展示
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(ActionList actions READ actions)
/**
* NotificationClosed信号-10 >0
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(int timeout READ timeout WRITE setTimeout)
/**
* hints中的action-icon功能
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(bool enableActionIcons READ enableActionIcons)
/**
* hints中的image-data字段
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(QImage image READ image)
/**
* image-data失败image-path加载image失败时image-path不是URL,icon会被设置为image-path数据
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(QString icon READ icon)
/**
* true时action按钮后自动移除消息
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(bool resident READ resident)
/**
* true后
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(bool transient READ transient)
/**
*
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(QString soundFile READ soundFile)
/**
*
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(QString soundName READ soundName)
/**
*
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(bool suppressSound READ suppressSound)
/**
*
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(QString category READ category)
/**
*
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(Urgency urgency READ urgency WRITE setUrgency)
/**
* DISPLAY上
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(QString display READ display)
/**
* action对应action的状态(default action)
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(QStringList actionState READ actionState)
/**
* true后
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(bool noFold READ noFold)
/**
* -1,0>0:
*/
2023-07-31 18:01:44 +08:00
Q_PROPERTY(int popupTimeout READ popupTimeout)
public:
/**
* The notification urgency.
*/
enum Urgency {
/**
*
*/
2023-07-31 18:01:44 +08:00
LowUrgency = 0,
/**
* 6s后关闭
*/
2023-07-31 18:01:44 +08:00
NormalUrgency = 1,
/**
*
*/
2023-07-31 18:01:44 +08:00
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();
/**
* ID
*/
2023-07-31 18:01:44 +08:00
uint id() const;
/**
*
*/
2023-07-31 18:01:44 +08:00
QString applicationName() const;
void setApplicationName(const QString &applicationName);
/**
*
*/
2023-07-31 18:01:44 +08:00
QString applicationIconName() const;
void setApplicationIconName(const QString &applicationIconName);
/**
*
*/
2023-07-31 18:01:44 +08:00
QString summary() const;
void setSummary(const QString &summary);
/**
*
*/
2023-07-31 18:01:44 +08:00
QString body() const;
void setBody(const QString &body);
/**
* action,
*/
2023-07-31 18:01:44 +08:00
bool hasDefaultAction() const;
/**
* action的label名称
*/
2023-07-31 18:01:44 +08:00
QString defaultActionLabel();
void setActions(const QStringList &actions);
ActionList actions() const;
QStringList actionState() 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
*/
QString soundName() const;
/**
*
* @return
*/
bool suppressSound() const;
/**
*
* @return
*/
bool transient() const;
Urgency urgency() const;
void setUrgency(Urgency urgency);
/**
* display
* @return
*/
QString display() const;
/**
*
* @return
*/
bool noFold() const;
/**
*
* @return
*/
int popupTimeout() const;
private:
PopupNotificationPrivate *d = nullptr;
};
}
#endif //UKUI_NOTIFICATION_POPUP_NOTIFICATION_H