完善Action执行处理逻辑
This commit is contained in:
parent
39bd53a95a
commit
57cc6a3324
|
@ -10,8 +10,6 @@
|
|||
<method name="InvokedAction">
|
||||
<arg name="id" type="u" direction="in"/>
|
||||
<arg name="action_key" type="s" direction="in"/>
|
||||
<arg name="action" type="s" direction="in"/>
|
||||
<arg name="display" type="s" direction="in"/>
|
||||
</method>
|
||||
</interface>
|
||||
</node>
|
|
@ -34,7 +34,7 @@ target_link_libraries(ukui-notification
|
|||
)
|
||||
target_compile_definitions(ukui-notification PRIVATE UKUINOTIFICATION_LIBRARY)
|
||||
include(CMakePackageConfigHelpers)
|
||||
set(CMAKECONFIG_INSTALL_DIR "/usr/lib/ukui-notification")
|
||||
set(CMAKECONFIG_INSTALL_DIR "/usr/include/ukui-notification")
|
||||
configure_package_config_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/ukui-notification-config.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/ukui-notification-config.cmake"
|
||||
|
@ -42,7 +42,7 @@ configure_package_config_file(
|
|||
set(PC_INSTALL_DIR "/usr/lib/pkgconfig")
|
||||
configure_package_config_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/ukui-notification.pc.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/ukui-notification.pc.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/ukui-notification.pc"
|
||||
INSTALL_DESTINATION ${PC_INSTALL_DIR})
|
||||
set_target_properties(ukui-notification PROPERTIES
|
||||
VERSION ${UKUI_NOTIFICATION_VERSION}
|
||||
|
@ -50,4 +50,6 @@ set_target_properties(ukui-notification PROPERTIES
|
|||
OUTPUT_NAME ukui-notification
|
||||
)
|
||||
install(TARGETS ukui-notification DESTINATION /usr/lib)
|
||||
install(FILES ${HEADERS} DESTINATION /usr/include/ukui-notification)
|
||||
install(FILES ${HEADERS} DESTINATION /usr/include/ukui-notification)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ukui-notification.pc DESTINATION ${PC_INSTALL_DIR})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ukui-notification-config.cmake DESTINATION ${CMAKECONFIG_INSTALL_DIR})
|
|
@ -28,7 +28,7 @@ public:
|
|||
const QVariantMap &hints,
|
||||
int timeout);
|
||||
void closeNotification(uint id, NotificationClient::CloseReason reason);
|
||||
void invokeAction(uint id, const QString &action_key, const QString &action, const QString &display);
|
||||
void invokeAction(uint id, const QString &action_key);
|
||||
|
||||
private Q_SLOTS:
|
||||
void notificationClosed(uint id, uint reason);
|
||||
|
|
|
@ -147,15 +147,14 @@ void NotificationClientPrivate::serviceChange(const QString &service, const QStr
|
|||
}
|
||||
}
|
||||
|
||||
void NotificationClientPrivate::invokeAction(uint id, const QString &action_key, const QString &action,
|
||||
const QString &display)
|
||||
void NotificationClientPrivate::invokeAction(uint id, const QString &action_key)
|
||||
{
|
||||
if(!m_notificationsInterface) {
|
||||
return;
|
||||
}
|
||||
QDBusMessage reply = m_notificationsInterface->callWithArgumentList(QDBus::NoBlock,
|
||||
QStringLiteral("InvokedAction"),
|
||||
{id, action_key, action, display});
|
||||
{id, action_key});
|
||||
if (reply.type() == QDBusMessage::ErrorMessage) {
|
||||
qWarning() << "Failed to call InvokedAction!" << QDBusConnection::sessionBus().lastError();
|
||||
}
|
||||
|
@ -178,7 +177,7 @@ void NotificationClient::closeNotification(uint id, NotificationClient::CloseRea
|
|||
d->closeNotification(id, reason);
|
||||
}
|
||||
|
||||
void NotificationClient::invokeAction(uint id, const QString &action_key, const QString &action, const QString &display)
|
||||
void NotificationClient::invokeAction(uint id, const QString &action_key)
|
||||
{
|
||||
d->invokeAction(id, action_key, action, display);
|
||||
d->invokeAction(id, action_key);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
*/
|
||||
bool registerClient();
|
||||
void closeNotification(uint id, CloseReason reason);
|
||||
void invokeAction(uint id, const QString &action_key, const QString &action, const QString &display);
|
||||
void invokeAction(uint id, const QString &action_key);
|
||||
Q_SIGNALS:
|
||||
void newNotification(const PopupNotification ¬ification);
|
||||
void notificationClosed(uint id, CloseReason closeReason);
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
QString m_body;
|
||||
QList<QPair<QString, QString>> m_actions;
|
||||
bool m_hasDefaultAction = false;
|
||||
QString m_defaultActionInfo;
|
||||
QString m_defaultActionLabel;
|
||||
QVariantMap m_hints = QVariantMap();
|
||||
QString m_category;
|
||||
QImage m_image;
|
||||
|
@ -171,6 +171,11 @@ PopupNotification::~PopupNotification()
|
|||
}
|
||||
}
|
||||
|
||||
uint PopupNotification::id() const
|
||||
{
|
||||
return d->m_id;
|
||||
}
|
||||
|
||||
QString PopupNotification::applicationName() const
|
||||
{
|
||||
return d->m_applicationName;
|
||||
|
@ -218,7 +223,7 @@ bool PopupNotification::hasDefaultAction() const
|
|||
|
||||
QString PopupNotification::defauleActionLable()
|
||||
{
|
||||
return d->m_defaultActionInfo;
|
||||
return d->m_defaultActionLabel;
|
||||
}
|
||||
|
||||
void PopupNotification::setActions(const QStringList &actions)
|
||||
|
@ -231,15 +236,15 @@ void PopupNotification::setActions(const QStringList &actions)
|
|||
d->m_hasDefaultAction = false;
|
||||
|
||||
for (int i = 0; i < actions.count(); i += 2) {
|
||||
const QString &name = actions.at(i);
|
||||
const QString &info = actions.at(i + 1);
|
||||
const QString &key = actions.at(i);
|
||||
const QString &label = actions.at(i + 1);
|
||||
|
||||
if (!d->m_hasDefaultAction && name == QLatin1String("default")) {
|
||||
if (!d->m_hasDefaultAction && key == QLatin1String("default")) {
|
||||
d->m_hasDefaultAction = true;
|
||||
d->m_defaultActionInfo = info;
|
||||
d->m_defaultActionLabel = label;
|
||||
continue;
|
||||
}
|
||||
d->m_actions.append({name, info});
|
||||
d->m_actions.append({key, label});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -370,4 +375,9 @@ QString PopupNotification::display() const
|
|||
void PopupNotification::setUrgency(PopupNotification::Urgency urgency)
|
||||
{
|
||||
d->m_urgency = urgency;
|
||||
}
|
||||
}
|
||||
|
||||
PopupNotification::Urgency PopupNotification::urgency() const
|
||||
{
|
||||
return d->m_urgency;
|
||||
}
|
||||
|
|
|
@ -17,9 +17,30 @@
|
|||
namespace UkuiNotification {
|
||||
class PopupNotificationPrivate;
|
||||
//TODO 可以增加通知基类,实现多种类型通知
|
||||
typedef QList<QPair<QString, QString>> ActionList;
|
||||
class UKUINOTIFICATION_EXPORT PopupNotification : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
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.
|
||||
|
@ -37,6 +58,7 @@ public:
|
|||
PopupNotification &operator=(PopupNotification &&other) Q_DECL_NOEXCEPT;
|
||||
~PopupNotification();
|
||||
|
||||
uint id() const;
|
||||
QString applicationName() const;
|
||||
void setApplicationName(const QString &applicationName);
|
||||
|
||||
|
@ -52,7 +74,7 @@ public:
|
|||
bool hasDefaultAction() const;
|
||||
QString defauleActionLable();
|
||||
void setActions(const QStringList &actions);
|
||||
QList<QPair<QString, QString>> actions() const;
|
||||
ActionList actions() const;
|
||||
|
||||
QVariantMap hints() const;
|
||||
void setHints(const QVariantMap &hints);
|
||||
|
@ -107,6 +129,8 @@ public:
|
|||
* @return
|
||||
*/
|
||||
bool transient() const;
|
||||
|
||||
Urgency urgency() const;
|
||||
void setUrgency(Urgency urgency);
|
||||
/**
|
||||
* 通知发送者所在的display
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
prefix=/usr
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
|
||||
includedir=${prefix}/include/ukui-notification
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
* @param reason 关闭原因
|
||||
*/
|
||||
void CloseNotification(uint id, uint);
|
||||
void InvokedAction(uint id, const QString &action_key, const QString &action, const QString &display);
|
||||
void InvokedAction(uint id, const QString &action_key);
|
||||
Q_SIGNALS:
|
||||
void NotificationClosed(uint id, uint reason);
|
||||
void ActionInvoked(uint id, const QString &actionKey);
|
||||
|
|
|
@ -133,9 +133,8 @@ void ServerPrivate::CloseNotification(uint id, uint reason)
|
|||
Q_EMIT NotificationClosed(id, reason);
|
||||
}
|
||||
|
||||
void ServerPrivate::InvokedAction(uint id, const QString &action_key, const QString &action, const QString &display)
|
||||
void ServerPrivate::InvokedAction(uint id, const QString &action_key)
|
||||
{
|
||||
//TODO: 异步执行action
|
||||
Q_EMIT ActionInvoked(id, action_key);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue