diff --git a/applets/notifications/contents/ui/main.qml b/applets/notifications/contents/ui/main.qml index af27ee5..0057a30 100644 --- a/applets/notifications/contents/ui/main.qml +++ b/applets/notifications/contents/ui/main.qml @@ -1,238 +1,239 @@ /* * Copyright 2014 Aaron Seigo * Copyright 2015 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.1 import QtQuick.Layouts 1.1 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.plasmoid 2.0 Item { id: root property int notificationId: 0 Layout.maximumHeight: notificationView.contentHeight + units.gridUnit //todo: size of first item Layout.minimumHeight: units.gridUnit * 4 + property var pendingRemovals: []; Plasmoid.switchWidth: 500 Plasmoid.switchHeight: 500 function addNotification(source, data, actions) { // Do not show duplicated notifications // Remove notifications that are sent again (odd, but true) for (var i = 0; i < notificationsModel.count; ++i) { var tmp = notificationsModel.get(i); var matches = (tmp.appName == data.appName && tmp.summary == data.summary && tmp.body == data.body); var sameSource = tmp.source == source; if (sameSource && matches) { return; } if (sameSource || matches) { notificationsModel.remove(i) break; } } data["id"] = ++notificationId; data["source"] = source; if (data["summary"].length < 1) { data["summary"] = data["body"]; data["body"] = ''; } data["actions"] = actions; notificationsModel.insert(0, data); if (!data["isPersistent"]) { pendingRemovals.push(notificationId); pendingTimer.start(); } } function executeAction(source, id) { //try to use the service if (source.indexOf("notification") !== -1) { var service = notificationsSource.serviceForSource(source) var op = service.operationDescription("invokeAction") op["actionId"] = id service.startOperationCall(op) //try to open the id as url } else if (source.indexOf("Job") !== -1) { Qt.openUrlExternally(id) } } PlasmaCore.DataSource { id: notificationsSource engine: "notifications" interval: 0 onSourceAdded: { connectSource(source); } onSourceRemoved: { for (var i = 0; i < notificationsModel.count; ++i) { if (notificationsModel.get(i) == source) { notificationsModel.remove(i); break; } } } onNewData: { var actions = new Array() if (data["actions"] && data["actions"].length % 2 == 0) { for (var i = 0; i < data["actions"].length; i += 2) { var action = new Object(); action["id"] = data["actions"][i]; action["text"] = data["actions"][i+1]; actions.push(action); } } root.addNotification( sourceName, data, actions); } } PlasmaComponents.Label { anchors.centerIn: parent opacity: 0.4 visible: notificationsModel.count == 0 text: i18n("No recent notifications") } Plasmoid.compactRepresentation: PlasmaCore.SvgItem { id: notificationSvgItem anchors.centerIn: parent width: units.roundToIconSize(Math.min(parent.width, parent.height)) height: width svg: PlasmaCore.Svg { imagePath: "icons/notification" colorGroup: PlasmaCore.ColorScope.colorGroup } elementId: { if (notificationsModel.count > 0) { return "notification-empty" } return "notification-disabled" } PlasmaComponents.Label { anchors.fill: parent horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter visible: notificationsModel.count > 0 text: notificationsModel.count } } ListModel { id: notificationsModel /* ListElement { source: "call1Source" appIcon: "call-start" summary: "Missed call from Joe" appName: "Phone" body: "Called at 8:42 from +41 56 373 37 31" actions: [] } ListElement { source: "im1Source" appIcon: "im-google" appName: "Message" summary: "July: Hey! Are you around?" actions: [] } ListElement { source: "im2Source" appIcon: "im-google" appName: "Message" summary: "July: Hello?" actions: [] }*/ } ListView { id: notificationView spacing: units.largeSpacing anchors { fill: parent leftMargin: units.largeSpacing rightMargin: units.largeSpacing } interactive: false cacheBuffer: 200000 z: 1 verticalLayoutDirection: ListView.BottomToTop model: notificationsModel add: Transition { NumberAnimation { properties: "x" from: notificationView.width duration: units.shortDuration easing.type: Easing.InOutQuad } } remove: Transition { NumberAnimation { properties: "x" to: notificationView.width duration: units.longDuration easing.type: Easing.InOutQuad } NumberAnimation { properties: "opacity" to: 0 duration: units.longDuration easing.type: Easing.InOutQuad } } removeDisplaced: Transition { SequentialAnimation { PauseAnimation { duration: units.longDuration } NumberAnimation { properties: "x,y" duration: units.shortDuration easing.type: Easing.InOutQuad } } } delegate: NotificationStripe {} } } diff --git a/shell/contents/views/Desktop.qml b/shell/contents/views/Desktop.qml index 096f519..bd77d72 100644 --- a/shell/contents/views/Desktop.qml +++ b/shell/contents/views/Desktop.qml @@ -1,216 +1,215 @@ /* * Copyright 2014 Aaron Seigo * Copyright 2012 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.6 import QtGraphicalEffects 1.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.shell 2.0 as Shell import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.workspace.components 2.0 as PlasmaWorkspace import org.kde.kquickcontrolsaddons 2.0 import org.kde.activities 0.1 as Activities import "../components" Item { id: root width: 1080 height: 1920 property Item containment; property Item wallpaper; - property var pendingRemovals: []; property int notificationId: 0; property int buttonHeight: width/4 property bool containmentsEnterFromRight: true //NOTE: this PathView { id: activitiesRepresentation model: Activities.ActivityModel { id: activityModel } width: 10 height: 10 cacheItemCount: 999//count delegate: Item { Connections { target: activitiesRepresentation onCurrentIndexChanged: { if (index == activitiesRepresentation.currentIndex) { activityModel.setCurrentActivity(model.id, function(){}); } } } } } ActivityHandle { mirrored: true } ActivityHandle { mirrored: false } function toggleWidgetExplorer(containment) { console.log("Widget Explorer toggled"); if (widgetExplorerStack.source != "") { widgetExplorerStack.source = ""; } else { widgetExplorerStack.setSource(Qt.resolvedUrl("../explorer/WidgetExplorer.qml"), {"containment": containment}) } } Loader { id: widgetExplorerStack z: 99 asynchronous: true y: containment ? containment.availableScreenRect.y : 0 height: containment ? containment.availableScreenRect.height : parent.height width: parent.width onLoaded: { if (widgetExplorerStack.item) { item.closed.connect(function() { widgetExplorerStack.source = "" }); } } } onContainmentChanged: { if (containment == null) { return; } if (switchAnim.running) { //If the animation was still running, stop it and reset //everything so that a consistent state can be kept switchAnim.running = false; internal.newContainment.visible = false; internal.oldContainment.visible = false; internal.oldContainment = null; } internal.newContainment = containment; containment.visible = true; if (internal.oldContainment != null && internal.oldContainment != containment) { switchAnim.running = true; } else { containment.anchors.left = root.left; containment.anchors.top = root.top; containment.anchors.right = root.right; containment.anchors.bottom = root.bottom; if (internal.oldContainment) { internal.oldContainment.visible = false; } internal.oldContainment = containment; } } //some properties that shouldn't be accessible from elsewhere QtObject { id: internal; property Item oldContainment: null; property Item newContainment: null; } SequentialAnimation { id: switchAnim ScriptAction { script: { if (containment) { containment.anchors.left = undefined; containment.anchors.top = undefined; containment.anchors.right = undefined; containment.anchors.bottom = undefined; containment.z = 1; containment.x = root.containmentsEnterFromRight ? root.width : -root.width; } if (internal.oldContainment) { internal.oldContainment.anchors.left = undefined; internal.oldContainment.anchors.top = undefined; internal.oldContainment.anchors.right = undefined; internal.oldContainment.anchors.bottom = undefined; internal.oldContainment.z = 0; internal.oldContainment.x = 0; } } } ParallelAnimation { NumberAnimation { target: internal.oldContainment properties: "x" to: internal.newContainment != null ? (root.containmentsEnterFromRight ? -root.width : root.width) : 0 duration: 400 easing.type: Easing.InOutQuad } NumberAnimation { target: internal.newContainment properties: "x" to: 0 duration: units.longDuration easing.type: Easing.InOutQuad } } ScriptAction { script: { if (internal.oldContainment) { internal.oldContainment.visible = false; } if (containment) { containment.anchors.left = root.left; containment.anchors.top = root.top; containment.anchors.right = root.right; containment.anchors.bottom = root.bottom; internal.oldContainment = containment; } } } } //pass the focus to the containment, so it can react to homescreen activate/inactivate Connections { target: desktop onActiveChanged: { containment.focus = desktop.active; } } Loader { id: pinOverlay anchors { fill: parent topMargin: containment.availableScreenRect.y bottomMargin: parent.height - containment.availableScreenRect.height - containment.availableScreenRect.y } z: 222 source: Qt.resolvedUrl("Pin.qml") } Component.onCompleted: { //configure the view behavior if (desktop) { desktop.width = width; desktop.height = height; } } }