[Notifications] Show hint if notifications aren't available or provided by someone else

When Plasma notification service isn't available or provided by someone else, disable the plasmoid.
Do not disturb controls are disabled and the applet stays in the popup crossed out.
Effectively D25097 of plasma-desktop for the applet itself.

Differential Revision: https://phabricator.kde.org/D25917
wilder-5.18
Kai Uwe Broulik 6 years ago
parent 553b427c7b
commit 943ca2072a
  1. 33
      applets/notifications/package/contents/ui/FullRepresentation.qml
  2. 4
      applets/notifications/package/contents/ui/global/Globals.qml
  3. 38
      applets/notifications/package/contents/ui/main.qml

@ -79,6 +79,7 @@ ColumnLayout{
RowLayout { RowLayout {
id: dndRow id: dndRow
spacing: units.smallSpacing spacing: units.smallSpacing
enabled: NotificationManager.Server.valid
PlasmaComponents3.CheckBox { PlasmaComponents3.CheckBox {
id: dndCheck id: dndCheck
@ -590,7 +591,37 @@ ColumnLayout{
level: 3 level: 3
opacity: 0.6 opacity: 0.6
text: i18n("No unread notifications.") text: i18n("No unread notifications.")
visible: list.count === 0 visible: list.count === 0 && NotificationManager.Server.valid
}
ColumnLayout {
id: serverUnavailableColumn
width: list.width
visible: list.count === 0 && !NotificationManager.Server.valid
PlasmaExtras.Heading {
Layout.fillWidth: true
level: 3
opacity: 0.6
text: i18n("Notification service not available")
wrapMode: Text.WordWrap
}
PlasmaComponents.Label {
// Checking valid to avoid creating ServerInfo object if everything is alright
readonly property NotificationManager.ServerInfo currentOwner: !NotificationManager.Server.valid ? NotificationManager.Server.currentOwner
: null
Layout.fillWidth: true
wrapMode: Text.WordWrap
text: currentOwner ? i18nc("Vendor and product name",
"Notifications are currently provided by '%1 %2'",
currentOwner.vendor,
currentOwner.name)
: ""
visible: currentOwner && currentOwner.vendor && currentOwner.name
}
} }
} }
} }

@ -200,6 +200,10 @@ QtObject {
globals.inhibited = Qt.binding(function() { globals.inhibited = Qt.binding(function() {
var inhibited = false; var inhibited = false;
if (!NotificationManager.Server.valid) {
return false;
}
var inhibitedUntil = notificationSettings.notificationsInhibitedUntil; var inhibitedUntil = notificationSettings.notificationsInhibitedUntil;
if (!isNaN(inhibitedUntil.getTime())) { if (!isNaN(inhibitedUntil.getTime())) {
inhibited |= (new Date().getTime() < inhibitedUntil.getTime()); inhibited |= (new Date().getTime() < inhibitedUntil.getTime());

@ -46,24 +46,28 @@ Item {
lines.push(i18np("%1 running job", "%1 running jobs", historyModel.activeJobsCount)); lines.push(i18np("%1 running job", "%1 running jobs", historyModel.activeJobsCount));
} }
// Any notification that is newer than "lastRead" is "unread" if (!NotificationManager.Server.valid) {
// since it doesn't know the popup is on screen which makes the user see it lines.push(i18n("Notification service not available"));
var actualUnread = historyModel.unreadNotificationsCount - Globals.popupNotificationsModel.activeNotificationsCount; } else {
if (actualUnread > 0) { // Any notification that is newer than "lastRead" is "unread"
lines.push(i18np("%1 unread notification", "%1 unread notifications", actualUnread)); // since it doesn't know the popup is on screen which makes the user see it
} var actualUnread = historyModel.unreadNotificationsCount - Globals.popupNotificationsModel.activeNotificationsCount;
if (actualUnread > 0) {
if (Globals.inhibited) { lines.push(i18np("%1 unread notification", "%1 unread notifications", actualUnread));
var inhibitedUntil = notificationSettings.notificationsInhibitedUntil }
var inhibitedUntilValid = !isNaN(inhibitedUntil.getTime());
// TODO check app inhibition, too if (Globals.inhibited) {
if (inhibitedUntilValid) { var inhibitedUntil = notificationSettings.notificationsInhibitedUntil
lines.push(i18n("Do not disturb until %1", var inhibitedUntilValid = !isNaN(inhibitedUntil.getTime());
KCoreAddons.Format.formatRelativeDateTime(inhibitedUntil, Locale.ShortFormat)));
// TODO check app inhibition, too
if (inhibitedUntilValid) {
lines.push(i18n("Do not disturb until %1",
KCoreAddons.Format.formatRelativeDateTime(inhibitedUntil, Locale.ShortFormat)));
}
} else if (lines.length === 0) {
lines.push(i18n("No unread notifications"));
} }
} else if (lines.length === 0) {
lines.push(i18n("No unread notifications"));
} }
return lines.join("\n"); return lines.join("\n");
@ -92,7 +96,7 @@ Item {
jobsCount: historyModel.activeJobsCount jobsCount: historyModel.activeJobsCount
jobsPercentage: historyModel.jobsPercentage jobsPercentage: historyModel.jobsPercentage
inhibited: Globals.inhibited inhibited: Globals.inhibited || !NotificationManager.Server.valid
} }
Plasmoid.fullRepresentation: FullRepresentation { Plasmoid.fullRepresentation: FullRepresentation {

Loading…
Cancel
Save