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 全局通知设置 notification-global-settings.h 全局通知设置
application-settings.h 应用通知行为设置 applications-settings.h 应用通知行为设置
single-application-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}) set(UKUI_NOTIFICATION_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO})
find_package(KF5WindowSystem) 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) find_package(PkgConfig REQUIRED)
set(UKUI_NOTIFICATION_EXTERNAL_LIBS "") set(UKUI_NOTIFICATION_EXTERNAL_LIBS "")
set(UKUI_NOTIFICATION_PC_PKGS ukui-search) 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}) list(APPEND UKUI_NOTIFICATION_EXTERNAL_LIBS ${${PC_LIB}_LIBRARIES})
endif() endif()
endforeach() endforeach()
include_directories(notification-settings) include_directories(notification-settings)
set(ukui-notification_LIB_SRCS set(ukui-notification_LIB_SRCS
notification-client.cpp notification-client.cpp
@ -74,6 +83,32 @@ set(HEADERS_INSTALL_DIR /usr/include/ukui-notification)
set(PC_INSTALL_DIR "/usr/lib/pkgconfig") set(PC_INSTALL_DIR "/usr/lib/pkgconfig")
target_include_directories(ukui-notification PUBLIC $<INSTALL_INTERFACE:${HEADERS_INSTALL_DIR}>) 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( configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/ukui-notification-config.cmake.in" "${CMAKE_CURRENT_SOURCE_DIR}/ukui-notification-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/ukui-notification-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/ukui-notification-config.cmake"

View File

@ -25,6 +25,10 @@
#include "notification-close-reason.h" #include "notification-close-reason.h"
namespace UkuiNotification { namespace UkuiNotification {
class NotificationClientPrivate; class NotificationClientPrivate;
/**
* @short .
* @author iaom
*/
class UKUINOTIFICATION_EXPORT NotificationClient : public QObject class UKUINOTIFICATION_EXPORT NotificationClient : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -32,15 +36,41 @@ public:
explicit NotificationClient(QObject *parent = nullptr); explicit NotificationClient(QObject *parent = nullptr);
~NotificationClient(); ~NotificationClient();
/** /**
* * @brief &
* @return ture- false * @return
* @retval truefalse
*/ */
bool registerClient(); bool registerClient();
/**
* @brief
* @return
* @retval truefalse
*/
void unregisterClient(); void unregisterClient();
/**
* @brief
* @param idid
* @param reason
* @return
* @retval truefalse
*/
bool closeNotification(uint id, NotificationCloseReason::CloseReason reason); 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); bool invokeAction(uint id, const QString &action_key);
Q_SIGNALS: Q_SIGNALS:
/**
* .
*/
void newNotification(const UkuiNotification::PopupNotification &notification); void newNotification(const UkuiNotification::PopupNotification &notification);
/**
* .
*/
void notificationClosed(uint id, UkuiNotification::NotificationCloseReason::CloseReason closeReason); void notificationClosed(uint id, UkuiNotification::NotificationCloseReason::CloseReason closeReason);
private: private:
NotificationClientPrivate *d = nullptr; NotificationClientPrivate *d = nullptr;

View File

@ -23,8 +23,11 @@
#include <QObject> #include <QObject>
#include "ukui-notification_global.h" #include "ukui-notification_global.h"
namespace UkuiNotification { namespace UkuiNotification {
/**
* @short .
* @author iaom
*/
class UKUINOTIFICATION_EXPORT NotificationCloseReason class UKUINOTIFICATION_EXPORT NotificationCloseReason
{ {
Q_GADGET Q_GADGET
@ -33,10 +36,22 @@ public:
* The reason a notification was closed * The reason a notification was closed
*/ */
enum CloseReason { 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) Q_ENUM(CloseReason)
}; };

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,7 +4,6 @@ set(notificationClientTest_SRCS
main.cpp notification-settings-test.cpp notification-settings-test.h) main.cpp notification-settings-test.cpp notification-settings-test.h)
include_directories(${CMAKE_SOURCE_DIR}/libukui-notification ${CMAKE_SOURCE_DIR}/libukui-notification/notification-settings) 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}) add_executable(ukui-notification-test ${notificationClientTest_SRCS})
target_link_libraries(ukui-notification-test PRIVATE target_link_libraries(ukui-notification-test PRIVATE