diff --git a/applets/notifications/package/contents/ui/FullRepresentation.qml b/applets/notifications/package/contents/ui/FullRepresentation.qml --- a/applets/notifications/package/contents/ui/FullRepresentation.qml +++ b/applets/notifications/package/contents/ui/FullRepresentation.qml @@ -79,6 +79,7 @@ RowLayout { id: dndRow spacing: units.smallSpacing + enabled: NotificationManager.Server.valid PlasmaComponents3.CheckBox { id: dndCheck @@ -590,7 +591,37 @@ 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 + } } } } diff --git a/applets/notifications/package/contents/ui/global/Globals.qml b/applets/notifications/package/contents/ui/global/Globals.qml --- a/applets/notifications/package/contents/ui/global/Globals.qml +++ b/applets/notifications/package/contents/ui/global/Globals.qml @@ -200,6 +200,10 @@ 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()); diff --git a/applets/notifications/package/contents/ui/main.qml b/applets/notifications/package/contents/ui/main.qml --- a/applets/notifications/package/contents/ui/main.qml +++ b/applets/notifications/package/contents/ui/main.qml @@ -46,24 +46,28 @@ 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 @@ jobsCount: historyModel.activeJobsCount jobsPercentage: historyModel.jobsPercentage - inhibited: Globals.inhibited + inhibited: Globals.inhibited || !NotificationManager.Server.valid } Plasmoid.fullRepresentation: FullRepresentation {