diff --git a/applets/notifications/package/contents/config/main.xml b/applets/notifications/package/contents/config/main.xml
--- a/applets/notifications/package/contents/config/main.xml
+++ b/applets/notifications/package/contents/config/main.xml
@@ -14,6 +14,10 @@
true
+
+
+ true
+
diff --git a/applets/notifications/package/contents/ui/NotificationDelegate.qml b/applets/notifications/package/contents/ui/NotificationDelegate.qml
--- a/applets/notifications/package/contents/ui/NotificationDelegate.qml
+++ b/applets/notifications/package/contents/ui/NotificationDelegate.qml
@@ -27,6 +27,8 @@
PlasmaComponents.ListItem {
id: notificationItem
width: popupFlickable.width
+
+ property ListModel listModel;
opacity: 1-Math.abs(x)/width
@@ -38,8 +40,8 @@
repeat: false
running: !idleTimeSource.idle
onTriggered: {
- if (!notificationsModel.inserting)
- notificationsModel.remove(index)
+ if (!listModel.inserting)
+ listModel.remove(index)
}
}
@@ -87,7 +89,7 @@
ScriptAction {
script: {
closeNotification(model.source);
- notificationsModel.remove(index);
+ listModel.remove(index);
}
}
}
@@ -133,11 +135,11 @@
}
onClose: {
- if (notificationsModel.count > 1) {
+ if (listModel.count > 1) {
removeAnimation.running = true
} else {
closeNotification(model.source)
- notificationsModel.remove(index)
+ listModel.remove(index)
}
}
onConfigure: {
diff --git a/applets/notifications/package/contents/ui/NotificationIcon.qml b/applets/notifications/package/contents/ui/NotificationIcon.qml
--- a/applets/notifications/package/contents/ui/NotificationIcon.qml
+++ b/applets/notifications/package/contents/ui/NotificationIcon.qml
@@ -75,28 +75,28 @@
PlasmaComponents.Label {
id: notificationCountLabel
- property int oldTotalCount: 0
+ property int oldActiveItemsCount: 0
// anchors.fill: parent breaks at small sizes for some reason
anchors.centerIn: parent
width: parent.width - (units.smallSpacing * 2.5 * text.length)
height: width
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
- text: notificationsApplet.totalCount
+ text: notificationsApplet.activeItemsCount
font.pointSize: 100
fontSizeMode: Text.Fit
minimumPointSize: theme.smallestFont.pointSize
visible: false
Connections {
target: notificationsApplet
- onTotalCountChanged: {
- if (notificationsApplet.totalCount > notificationCountLabel.oldTotalCount) {
+ onActiveItemsCountChanged: {
+ if (notificationsApplet.activeItemsCount > notificationCountLabel.oldActiveItemsCount) {
notificationAnimation.running = true
}
- notificationCountLabel.oldTotalCount = notificationsApplet.totalCount
+ notificationCountLabel.oldActiveItemsCount = notificationsApplet.activeItemsCount
}
}
diff --git a/applets/notifications/package/contents/ui/Notifications.qml b/applets/notifications/package/contents/ui/Notifications.qml
--- a/applets/notifications/package/contents/ui/Notifications.qml
+++ b/applets/notifications/package/contents/ui/Notifications.qml
@@ -20,6 +20,7 @@
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
+import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.private.notifications 1.0
@@ -32,7 +33,16 @@
}
property alias count: notificationsRepeater.count
+ property alias historyCount: notificationsHistoryRepeater.count
+
+ property bool showHistory
+
signal popupShown(var popup)
+
+ onShowHistoryChanged: {
+ if(!showHistory)
+ clearHistory()
+ }
Component.onCompleted: {
// Create the popup components and pass them to the C++ plugin
@@ -74,6 +84,28 @@
notificationsModel.insert(0, notification);
notificationsModel.inserting = false;
}
+ else if (showHistory) {
+
+ notificationsHistoryModel.inserting = true;
+
+ //create a copy of the notification.
+ //Disable actions in this copy as they will stop working once the original notification ist closed.
+ notificationsHistoryModel.insert(0, {
+ "compact" : notification.compact,
+ "icon" : notification.icon,
+ "image" : notification.image,
+ "summary" : notification.summary,
+ "body" : notification.body,
+ "configurable" : false,
+ "created" : new Date(),
+ "urls" : notification.urls,
+ "maximumTextHeight" : notification.maximumTextHeight,
+ "actions" : null,
+ "hasDefaultAction" : false,
+ "hasConfigureAction" : false,
+ });
+ notificationsHistoryModel.inserting = false;
+ }
notificationPositioner.displayNotification(notification);
}
@@ -129,6 +161,11 @@
}
notificationsModel.clear()
+ clearHistory()
+ }
+
+ function clearHistory() {
+ notificationsHistoryModel.clear()
}
Component {
@@ -140,6 +177,11 @@
id: notificationsModel
property bool inserting: false
}
+
+ ListModel {
+ id: notificationsHistoryModel
+ property bool inserting: false
+ }
PlasmaCore.DataSource {
id: idleTimeSource
@@ -220,6 +262,20 @@
Repeater {
id: notificationsRepeater
model: notificationsModel
- delegate: NotificationDelegate {}
+ delegate: NotificationDelegate { listModel: notificationsModel }
+ }
+
+ PlasmaExtras.Heading {
+ width: parent.width
+ level: 3
+ opacity: 0.6
+ visible: historyCount > 0
+ text: i18n("History")
+ }
+
+ Repeater {
+ id: notificationsHistoryRepeater
+ model: notificationsHistoryModel
+ delegate: NotificationDelegate { listModel: notificationsHistoryModel }
}
}
diff --git a/applets/notifications/package/contents/ui/configNotifications.qml b/applets/notifications/package/contents/ui/configNotifications.qml
--- a/applets/notifications/package/contents/ui/configNotifications.qml
+++ b/applets/notifications/package/contents/ui/configNotifications.qml
@@ -35,6 +35,7 @@
property alias cfg_showNotifications: showNotificationsCheckBox.checked
property alias cfg_showJobs: showJobsCheckBox.checked
+ property alias cfg_showHistory: showHistoryCheckBox.checked
QtLayouts.ColumnLayout {
anchors.left: parent.left
@@ -47,6 +48,12 @@
id: showJobsCheckBox
text: i18n("Track file transfers and other jobs")
}
+
+ QtControls.CheckBox {
+ id: showHistoryCheckBox
+ text: i18n("Show a history of notifications")
+ }
+
QtControls.CheckBox {
id: useCustomPopupPositionCheckBox
text: i18n("Use custom position for the notification popup")
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
@@ -51,26 +51,27 @@
property Item notifications: notificationsLoader.item
property Item jobs: jobsLoader.item
-
+
//notifications + jobs
- property int totalCount: (notifications ? notifications.count : 0) + (jobs ? jobs.count : 0)
+ property int activeItemsCount: (notifications ? notifications.count : 0) + (jobs ? jobs.count : 0)
+ property int totalCount: activeItemsCount + (notifications ? notifications.historyCount : 0)
property Item notificationIcon
Plasmoid.switchWidth: units.gridUnit * 20
Plasmoid.switchHeight: units.gridUnit * 30
- Plasmoid.status: totalCount > 0 ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.PassiveStatus
+ Plasmoid.status: activeItemsCount > 0 ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.PassiveStatus
Plasmoid.icon: {
if (jobs && jobs.count) {
return "notification-active"
}
- return totalCount ? "notification-inactive" : "notification-disabled"
+ return activeItemsCount ? "notification-inactive" : "notification-disabled"
}
Plasmoid.toolTipSubText: {
- if (totalCount == 0) {
+ if (activeItemsCount == 0) {
return i18n("No notifications or jobs")
} else if (!notifications || !notifications.count) {
return i18np("%1 running job", "%1 running jobs", jobs.count)
@@ -91,9 +92,9 @@
state: "default"
hoverEnabled: !UiProperties.touchInput
- onTotalCountChanged: {
- print(" totalCountChanged " + totalCount)
- if (totalCount > 0) {
+ onActiveItemsCountChanged: {
+ print(" activeItemsCountChanged " + activeItemsCount)
+ if (activeItemsCount > 0) {
state = "new-notifications"
} else {
state = "default"
@@ -147,6 +148,9 @@
width: parent.width
source: "Notifications.qml"
active: notificationsApplet.Plasmoid.configuration.showNotifications
+ onLoaded: {
+ notificationsLoader.item.showHistory = Qt.binding(function(){ return notificationsApplet.Plasmoid.configuration.showHistory })
+ }
}
}
}