增加三个自定义hint

This commit is contained in:
iaom 2023-04-28 11:16:14 +08:00
parent 6b355e273c
commit e23ed46856
3 changed files with 40 additions and 8 deletions

View File

@ -52,6 +52,9 @@ public:
QString m_soundFile;
bool m_suppressSound = false;
QString m_display;
QStringList m_actionState;
bool m_noFold = false;
int m_popupTimeout = 6;
};
}
using namespace UkuiNotification;
@ -205,7 +208,7 @@ QString PopupNotification::applicationIconName() const
return d->m_applicationIconName;
}
void PopupNotification::setAplicationIconName(const QString &applicationIconName)
void PopupNotification::setApplicationIconName(const QString &applicationIconName)
{
d->m_applicationIconName = applicationIconName;
}
@ -235,7 +238,7 @@ bool PopupNotification::hasDefaultAction() const
return d->m_hasDefaultAction;
}
QString PopupNotification::defauleActionLable()
QString PopupNotification::defaultActionLabel()
{
return d->m_defaultActionLabel;
}
@ -291,7 +294,7 @@ void PopupNotification::setHints(const QVariantMap &hints)
break;
}
}
d->m_createdTime = hints.value(QStringLiteral("x-ukui-createdTime")).toDateTime();
d->m_createdTime = QDateTime::fromString(hints.value(QStringLiteral("x-ukui-createdTime")).toString());
d->m_resident = hints.value(QStringLiteral("resident")).toBool();
d->m_resident = hints.value(QStringLiteral("transient")).toBool();
d->m_category = hints.value(QStringLiteral("category")).toString();
@ -318,6 +321,9 @@ void PopupNotification::setHints(const QVariantMap &hints)
d->m_soundFile = hints.value(QStringLiteral("sound-file")).toString();
d->m_suppressSound = hints.value(QStringLiteral("suppress-sound")).toBool();
d->m_display = hints.value(QStringLiteral("x-ukui-display")).toString();
d->m_actionState = hints.value(QStringLiteral("x-ukui-action-state")).toStringList();
d->m_noFold = hints.value(QStringLiteral("x-ukui-no-fold")).toBool();
d->m_popupTimeout = hints.value(QStringLiteral("x-ukui-popup-timeout")).toInt();
}
int PopupNotification::timeout() const
@ -395,3 +401,15 @@ PopupNotification::Urgency PopupNotification::urgency() const
{
return d->m_urgency;
}
QStringList PopupNotification::actionState() const {
return d->m_actionState;
}
bool PopupNotification::noFold() const {
return d->m_noFold;
}
int PopupNotification::popupTimeout() const {
return d->m_popupTimeout;
}

View File

@ -38,13 +38,13 @@ class UKUINOTIFICATION_EXPORT PopupNotification
Q_GADGET
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 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)
Q_PROPERTY(bool hasDefaultAction READ hasDefaultAction)
Q_PROPERTY(ActionList actions READ actions)
Q_PROPERTY(uint timeout READ timeout WRITE setTimeout)
Q_PROPERTY(int timeout READ timeout WRITE setTimeout)
Q_PROPERTY(bool enableActionIcons READ enableActionIcons)
Q_PROPERTY(QImage image READ image)
Q_PROPERTY(QString icon READ icon)
@ -55,6 +55,9 @@ class UKUINOTIFICATION_EXPORT PopupNotification
Q_PROPERTY(QString category READ category)
Q_PROPERTY(Urgency urgency READ urgency WRITE setUrgency)
Q_PROPERTY(QString display READ display)
Q_PROPERTY(QStringList actionState READ actionState)
Q_PROPERTY(bool noFold READ noFold)
Q_PROPERTY(int popupTimeout READ popupTimeout)
public:
/**
@ -78,7 +81,7 @@ public:
void setApplicationName(const QString &applicationName);
QString applicationIconName() const;
void setAplicationIconName(const QString &applicationIconName);
void setApplicationIconName(const QString &applicationIconName);
QString summary() const;
void setSummary(const QString &summary);
@ -87,9 +90,10 @@ public:
void setBody(const QString &body);
bool hasDefaultAction() const;
QString defauleActionLable();
QString defaultActionLabel();
void setActions(const QStringList &actions);
ActionList actions() const;
QStringList actionState() const;
QVariantMap hints() const;
void setHints(const QVariantMap &hints);
@ -152,6 +156,16 @@ public:
* @return
*/
QString display() const;
/**
*
* @return
*/
bool noFold() const;
/**
*
* @return
*/
int popupTimeout() const;
private:
PopupNotificationPrivate *d = nullptr;

View File

@ -56,7 +56,7 @@ uint ServerPrivate::Notify(const QString &app_name, uint replaces_id, const QStr
}
QVariantMap newHints = hints;
newHints.insert(QStringLiteral("x-ukui-createdTime"), QDateTime::currentDateTimeUtc());
newHints.insert(QStringLiteral("x-ukui-createdTime"), QDateTime::currentDateTime().toString());
uint pid = 0;
QDBusReply<uint> pidReply = connection().interface()->servicePid(message().service());