Merge branch 'Plasma/5.18'

wilder-portage-prov
Kai Uwe Broulik 6 years ago
commit 2afa524c4a
  1. 75
      applets/notifications/package/contents/ui/NotificationItem.qml
  2. 11
      applets/notifications/package/contents/ui/NotificationReplyField.qml
  3. 10
      libnotificationmanager/notification.cpp
  4. 3
      libnotificationmanager/notification.h
  5. 2
      libnotificationmanager/notification_p.h
  6. 2
      libnotificationmanager/notificationsmodel.cpp
  7. 4
      libnotificationmanager/server.cpp
  8. 3
      libnotificationmanager/server.h
  9. 31
      libnotificationmanager/server_p.cpp
  10. 4
      libnotificationmanager/server_p.h

@ -297,42 +297,20 @@ ColumnLayout {
Layout.preferredHeight: Math.max(actionFlow.implicitHeight, replyLoader.height)
visible: actionRepeater.count > 0
states: [
State {
when: notificationItem.replying
PropertyChanges {
target: actionFlow
enabled: false
opacity: 0
}
PropertyChanges {
target: replyLoader
active: true
visible: true
opacity: 1
x: 0
}
}
]
transitions: [
Transition {
to: "*" // any state
NumberAnimation {
targets: [actionFlow, replyLoader]
properties: "opacity,scale,x"
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}
]
// Notification actions
Flow { // it's a Flow so it can wrap if too long
id: actionFlow
width: parent.width
spacing: units.smallSpacing
layoutDirection: Qt.RightToLeft
enabled: !replyLoader.active
opacity: replyLoader.active ? 0 : 1
Behavior on opacity {
NumberAnimation {
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}
Repeater {
id: actionRepeater
@ -367,10 +345,7 @@ ColumnLayout {
onClicked: {
if (modelData.actionName === "inline-reply") {
notificationItem.replying = true;
plasmoid.nativeInterface.forceActivateWindow(notificationItem.Window.window);
replyLoader.item.activate();
replyLoader.beginReply();
return;
}
@ -385,15 +360,39 @@ ColumnLayout {
id: replyLoader
width: parent.width
height: active ? item.implicitHeight : 0
active: false
visible: false
opacity: 0
x: parent.width
// When there is only one action and it is a reply action, show text field right away
active: notificationItem.replying || (notificationItem.hasReplyAction && (notificationItem.actionNames || []).length === 0)
visible: active
opacity: active ? 1 : 0
x: active ? 0 : parent.width
Behavior on x {
NumberAnimation {
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}
Behavior on opacity {
NumberAnimation {
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}
function beginReply() {
notificationItem.replying = true;
plasmoid.nativeInterface.forceActivateWindow(notificationItem.Window.window);
replyLoader.item.activate();
}
sourceComponent: NotificationReplyField {
placeholderText: notificationItem.replyPlaceholderText
buttonIconName: notificationItem.replySubmitButtonIconName
buttonText: notificationItem.replySubmitButtonText
onReplied: notificationItem.replied(text)
replying: notificationItem.replying
onBeginReplyRequested: replyLoader.beginReply()
}
}
}

@ -26,8 +26,11 @@ import org.kde.plasma.components 2.0 as PlasmaComponents
RowLayout {
id: replyRow
signal beginReplyRequested
signal replied(string text)
property bool replying: false
property alias text: replyTextField.text
property string placeholderText
property string buttonIconName
@ -49,6 +52,14 @@ RowLayout {
replyRow.replied(text);
}
}
// Catches mouse click when reply field is already shown to start a reply
MouseArea {
anchors.fill: parent
cursorShape: Qt.IBeamCursor
visible: !replyRow.replying
onPressed: replyRow.beginReplyRequested()
}
}
PlasmaComponents.Button {

@ -479,6 +479,16 @@ uint Notification::id() const
return d->id;
}
QString Notification::dBusService() const
{
return d->dBusService;
}
void Notification::setDBusService(const QString &dBusService)
{
d->dBusService = dBusService;
}
QDateTime Notification::created() const
{
return d->created;

@ -53,6 +53,9 @@ public:
uint id() const;
QString dBusService() const;
void setDBusService(const QString &dBusService);
QDateTime created() const;
QDateTime updated() const;

@ -58,6 +58,8 @@ public:
void setUrgency(Notifications::Urgency urgency);
uint id = 0;
// Bus name of the creator/sender
QString dBusService;
QDateTime created;
QDateTime updated;
bool read = false;

@ -458,7 +458,7 @@ void NotificationsModel::reply(uint notificationId, const QString &text)
return;
}
Server::self().reply(notificationId, text);
Server::self().reply(notification.dBusService(), notificationId, text);
}
void NotificationsModel::startTimeout(uint notificationId)

@ -80,9 +80,9 @@ void Server::invokeAction(uint notificationId, const QString &actionName)
emit d->ActionInvoked(notificationId, actionName);
}
void Server::reply(uint notificationId, const QString &text)
void Server::reply(const QString &dbusService, uint notificationId, const QString &text)
{
emit d->NotificationReplied(notificationId, text);
d->sendReplyText(dbusService, notificationId, text);
}
uint Server::add(const Notification &notification)

@ -151,11 +151,12 @@ public:
/**
* Sends a notification reply text
*
* @param dbusService The bus name of the receiving application
* @param id The notification ID
* @param text The reply message text
* @since 5.18
*/
void reply(uint id, const QString &text);
void reply(const QString &dbusService, uint id, const QString &text);
/**
* Adds a notification

@ -58,6 +58,16 @@ QString ServerPrivate::notificationServiceName()
return QStringLiteral("org.freedesktop.Notifications");
}
QString ServerPrivate::notificationServicePath()
{
return QStringLiteral("/org/freedesktop/Notifications");
}
QString ServerPrivate::notificationServiceInterface()
{
return notificationServiceName();
}
ServerInfo *ServerPrivate::currentOwner() const
{
if (!m_currentOwner) {
@ -76,7 +86,7 @@ bool ServerPrivate::init()
new NotificationsAdaptor(this);
if (!m_dbusObjectValid) { // if already registered, don't fail here
m_dbusObjectValid = QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/freedesktop/Notifications"), this);
m_dbusObjectValid = QDBusConnection::sessionBus().registerObject(notificationServicePath(), this);
}
if (!m_dbusObjectValid) {
@ -142,6 +152,7 @@ uint ServerPrivate::Notify(const QString &app_name, uint replaces_id, const QStr
}
Notification notification(notificationId);
notification.setDBusService(message().service());
notification.setSummary(summary);
notification.setBody(body);
notification.setApplicationName(app_name);
@ -303,6 +314,20 @@ uint ServerPrivate::add(const Notification &notification)
return notification.id();
}
void ServerPrivate::sendReplyText(const QString &dbusService, uint notificationId, const QString &text)
{
if (dbusService.isEmpty()) {
qCWarning(NOTIFICATIONMANAGER) << "Sending notification reply text for notification" << notificationId << "untargeted";
}
QDBusMessage msg = QDBusMessage::createTargetedSignal(dbusService,
notificationServicePath(),
notificationServiceName(),
QStringLiteral("NotificationReplied"));
msg.setArguments({notificationId, text});
QDBusConnection::sessionBus().send(msg);
}
uint ServerPrivate::Inhibit(const QString &desktop_entry, const QString &reason, const QVariantMap &hints)
{
const QString dbusService = message().service();
@ -384,13 +409,13 @@ void ServerPrivate::onInhibitedChanged()
{
// emit DBus change signal...
QDBusMessage signal = QDBusMessage::createSignal(
QStringLiteral("/org/freedesktop/Notifications"),
notificationServicePath(),
QStringLiteral("org.freedesktop.DBus.Properties"),
QStringLiteral("PropertiesChanged")
);
signal.setArguments({
QStringLiteral("org.freedesktop.Notifications"),
notificationServiceInterface(),
QVariantMap{ // updated
{QStringLiteral("Inhibited"), inhibited()},
},

@ -73,6 +73,7 @@ Q_SIGNALS:
void NotificationClosed(uint id, uint reason);
void ActionInvoked(uint id, const QString &actionKey);
// non-standard
// This is manually emitted as targeted signal in sendReplyText()
void NotificationReplied(uint id, const QString &text);
void validChanged();
@ -87,9 +88,12 @@ Q_SIGNALS:
public: // stuff used by public class
friend class ServerInfo;
static QString notificationServiceName();
static QString notificationServicePath();
static QString notificationServiceInterface();
bool init();
uint add(const Notification &notification);
void sendReplyText(const QString &dbusService, uint notificationId, const QString &text);
ServerInfo *currentOwner() const;

Loading…
Cancel
Save