feat(doc):Add qch docment for libukui-notification.

This commit is contained in:
iaom 2023-11-24 14:44:17 +08:00
parent e5c674bcde
commit b6c9d2e209
10 changed files with 220 additions and 15 deletions

View File

@ -45,7 +45,7 @@ popup-notification.h 单条通知的所有信息
notification-global-settings.h 全局通知设置
application-settings.h 应用通知行为设置
applications-settings.h 应用通知行为设置
single-application-settings.h 单个应用的通知设置
#### 代码编译:

View File

@ -4,6 +4,14 @@ set(VERSION_MICRO 0)
set(UKUI_NOTIFICATION_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO})
find_package(KF5WindowSystem)
include(FeatureSummary)
find_package(ECM)
option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" TRUE)
add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)")
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
include(ECMAddQch)
find_package(PkgConfig REQUIRED)
set(UKUI_NOTIFICATION_EXTERNAL_LIBS "")
set(UKUI_NOTIFICATION_PC_PKGS ukui-search)
@ -16,6 +24,7 @@ foreach(PC_LIB IN ITEMS ${UKUI_NOTIFICATION_PC_PKGS})
list(APPEND UKUI_NOTIFICATION_EXTERNAL_LIBS ${${PC_LIB}_LIBRARIES})
endif()
endforeach()
include_directories(notification-settings)
set(ukui-notification_LIB_SRCS
notification-client.cpp
@ -74,6 +83,32 @@ set(HEADERS_INSTALL_DIR /usr/include/ukui-notification)
set(PC_INSTALL_DIR "/usr/lib/pkgconfig")
target_include_directories(ukui-notification PUBLIC $<INSTALL_INTERFACE:${HEADERS_INSTALL_DIR}>)
if (BUILD_QCH)
set(QCH_INSTALL_DIR "/usr/share/qt5/doc/")
ecm_add_qch(
ukui-notification-qch
NAME ukui-notification
BASE_NAME ukui-notification
VERSION "${UKUI_NOTIFICATION_VERSION}"
ORG_DOMAIN org.ukui
SOURCES ${HEADERS}
MD_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md"
LINK_QCHS
INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}
TAGFILE_INSTALL_DESTINATION ${QCH_INSTALL_DIR}
QCH_INSTALL_DESTINATION ${QCH_INSTALL_DIR}
COMPONENT Devel
)
ecm_install_qch_export(
TARGETS ukui-notification-qch
FILE ukui-notification-qch-targets.cmake
DESTINATION "${CMAKE_CONFIG_INSTALL_DIR}"
COMPONENT Devel
)
set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/ukui-notification-qch-targets.cmake\")")
endif()
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/ukui-notification-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/ukui-notification-config.cmake"

View File

@ -25,22 +25,52 @@
#include "notification-close-reason.h"
namespace UkuiNotification {
class NotificationClientPrivate;
/**
* @short .
* @author iaom
*/
class UKUINOTIFICATION_EXPORT NotificationClient : public QObject
{
Q_OBJECT
public:
explicit NotificationClient(QObject *parent = nullptr);
~NotificationClient();
/**
*
* @return ture- false
*/
/**
* @brief &
* @return
* @retval truefalse
*/
bool registerClient();
/**
* @brief
* @return
* @retval truefalse
*/
void unregisterClient();
/**
* @brief
* @param idid
* @param reason
* @return
* @retval truefalse
*/
bool closeNotification(uint id, NotificationCloseReason::CloseReason reason);
/**
* @brief
* @param id id
* @param action_key action的唯一标识
* @return
* @retval truefalse
*/
bool invokeAction(uint id, const QString &action_key);
Q_SIGNALS:
/**
* .
*/
void newNotification(const UkuiNotification::PopupNotification &notification);
/**
* .
*/
void notificationClosed(uint id, UkuiNotification::NotificationCloseReason::CloseReason closeReason);
private:
NotificationClientPrivate *d = nullptr;

View File

@ -23,20 +23,35 @@
#include <QObject>
#include "ukui-notification_global.h"
namespace UkuiNotification {
/**
* @short .
* @author iaom
*/
class UKUINOTIFICATION_EXPORT NotificationCloseReason
{
Q_GADGET
public:
/**
* The reason a notification was closed
*/
* The reason a notification was closed
*/
enum CloseReason {
Expired = 1, // The notification expired(timed out).
DismissedByUser = 2, // The notification was dismissed by the user.
Revoked = 3, //< The notification was closed by sender by a call to CloseNotification.
Undefined = 4, //Undefined/reserved reasons.
/**
* .
*/
Expired = 1,
/**
* .
*/
DismissedByUser = 2,
/**
* CloseNotification接口关闭
*/
Revoked = 3,
/**
* /
*/
Undefined = 4,
};
Q_ENUM(CloseReason)
};

View File

@ -27,7 +27,8 @@ namespace UkuiNotification{
typedef QMap<QString, SingleApplicationSettings*> ApplicationsSettingsMap;
class ApplicationsSettingsPrivate;
/**
* SingleApplicationSettings
* @short .
* @author iaom
*/
class ApplicationsSettings : public QObject
{

View File

@ -24,6 +24,10 @@
#include "settings-properties.h"
namespace UkuiNotification {
class NotificationGlobalSettingsPrivate;
/**
* @short .
* @author iaom
*/
class NotificationGlobalSettings : public QObject
{
Q_OBJECT

View File

@ -25,7 +25,8 @@
namespace UkuiNotification {
class SingleApplicationSettingsPrivate;
/**
*
* @short .
* @author iaom
*/
class SingleApplicationSettings : public QObject
{

View File

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

View File

@ -21,9 +21,25 @@
#define UKUI_NOTIFICATION_UTILS_H
#include <QString>
namespace UkuiNotification {
/**
* @short 便.
* @author iaom
*/
namespace Utils {
/**
* @brief @p pid desktop文件
* @return desktop文件全路径
*/
QString desktopEntryFromPid(uint pid);
/**
* @brief @p pid DISPLAY
* @return DISPLAY的值
*/
QString displayFromPid(uint pid);
/**
* @brief desktop文件名
* @return desktop文件全路径
*/
QString desktopEntryFromName(const QString& desktopFileName);
}
}

View File

@ -4,7 +4,6 @@ set(notificationClientTest_SRCS
main.cpp notification-settings-test.cpp notification-settings-test.h)
include_directories(${CMAKE_SOURCE_DIR}/libukui-notification ${CMAKE_SOURCE_DIR}/libukui-notification/notification-settings)
message(${notificationClientTest_SRCS}, "123123")
add_executable(ukui-notification-test ${notificationClientTest_SRCS})
target_link_libraries(ukui-notification-test PRIVATE