[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 {
id: dndRow
spacing: units.smallSpacing
enabled: NotificationManager.Server.valid
PlasmaComponents3.CheckBox {
id: dndCheck
@ -590,7 +591,37 @@ ColumnLayout{
level: 3
opacity: 0.6
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() {
var inhibited = false;
if (!NotificationManager.Server.valid) {
return false;
}
var inhibitedUntil = notificationSettings.notificationsInhibitedUntil;
if (!isNaN(inhibitedUntil.getTime())) {
inhibited |= (new Date().getTime() < inhibitedUntil.getTime());

@ -46,24 +46,28 @@ Item {
lines.push(i18np("%1 running job", "%1 running jobs", historyModel.activeJobsCount));
}
// Any notification that is newer than "lastRead" is "unread"
// 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) {
lines.push(i18np("%1 unread notification", "%1 unread notifications", actualUnread));
}
if (Globals.inhibited) {
var inhibitedUntil = notificationSettings.notificationsInhibitedUntil
var inhibitedUntilValid = !isNaN(inhibitedUntil.getTime());
if (!NotificationManager.Server.valid) {
lines.push(i18n("Notification service not available"));
} else {
// Any notification that is newer than "lastRead" is "unread"
// 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) {
lines.push(i18np("%1 unread notification", "%1 unread notifications", actualUnread));
}
// TODO check app inhibition, too
if (inhibitedUntilValid) {
lines.push(i18n("Do not disturb until %1",
KCoreAddons.Format.formatRelativeDateTime(inhibitedUntil, Locale.ShortFormat)));
if (Globals.inhibited) {
var inhibitedUntil = notificationSettings.notificationsInhibitedUntil
var inhibitedUntilValid = !isNaN(inhibitedUntil.getTime());
// 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");
@ -92,7 +96,7 @@ Item {
jobsCount: historyModel.activeJobsCount
jobsPercentage: historyModel.jobsPercentage
inhibited: Globals.inhibited
inhibited: Globals.inhibited || !NotificationManager.Server.valid
}
Plasmoid.fullRepresentation: FullRepresentation {

Loading…
Cancel
Save