diff --git a/containments/homescreen/contents/ui/main.qml b/containments/homescreen/contents/ui/main.qml index bc808af8..d52dfdf0 100644 --- a/containments/homescreen/contents/ui/main.qml +++ b/containments/homescreen/contents/ui/main.qml @@ -206,6 +206,7 @@ Item { Item { Layout.fillWidth: true Layout.minimumHeight: root.height + Layout.maximumHeight: root.height Clock { anchors { horizontalCenter: parent.horizontalCenter diff --git a/shell/contents/defaults b/shell/contents/defaults index c5458f35..8dc05ec7 100644 --- a/shell/contents/defaults +++ b/shell/contents/defaults @@ -2,7 +2,7 @@ LookAndFeelPackage=org.kde.satellite.phone [Desktop] -Containment=org.kde.desktopcontainment +Containment=org.kde.phone.homescreen ToolBox= [Desktop][ContainmentActions] diff --git a/shell/contents/layout.js b/shell/contents/layout.js index 5f3eace0..49acf7a7 100644 --- a/shell/contents/layout.js +++ b/shell/contents/layout.js @@ -14,3 +14,4 @@ for (var j = 0; j < desktopsArray.length; j++) { desktopsArray[j].writeConfig("Image", "org.kde.satellite.lockers"); } +desktopsForActivity(id)[0].addWidget("org.kde.phone.notifications"); diff --git a/shell/contents/views/Desktop.qml b/shell/contents/views/Desktop.qml index b6e914e4..24b11409 100644 --- a/shell/contents/views/Desktop.qml +++ b/shell/contents/views/Desktop.qml @@ -41,52 +41,25 @@ Item { property int notificationId: 0; property int buttonHeight: width/4 - /* - Notificadtion data object has the following properties: - appIcon - image - appName - summary - body - isPersistent - expireTimeout - urgency - appRealName - configurable - */ - 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; + onContainmentChanged: { + containment.parent = homescreen; - if (sameSource && matches) { - return; - } - - if (sameSource || matches) { - notificationsModel.remove(i) - break; - } + if (containment != null) { + containment.visible = true; } - - data["id"] = ++notificationId; - data["source"] = source; - if (data["summary"].length < 1) { - data["summary"] = data["body"]; - data["body"] = ''; + if (containment != null) { + containment.anchors.left = homescreen.left; + containment.anchors.top = homescreen.top; + containment.anchors.right = homescreen.right; + containment.anchors.bottom = homescreen.bottom; } - data["actions"] = actions; + } - notificationsModel.insert(0, data); - if (!data["isPersistent"]) { - pendingRemovals.push(notificationId); - pendingTimer.start(); - } + PlasmaCore.DataSource { + id: timeSource + engine: "time" + connectedSources: ["Local"] + interval: 60 * 1000 } OfonoManager { @@ -190,91 +163,6 @@ Item { } } - Timer { - id: pendingTimer - interval: 5000 - repeat: false - onTriggered: { - for (var i = 0; i < pendingRemovals.length; ++i) { - var id = pendingRemovals[i]; - for (var j = 0; j < notificationsModel.count; ++j) { - if (notificationsModel.get(j).id == id) { - notificationsModel.remove(j); - } - } - } - pendingRemovals = []; - } - } - - Rectangle { - z: 1 - color: Qt.rgba(0, 0, 0, 0.9 * (Math.min(applications.contentY + homescreen.height, homescreen.height) / homescreen.height)) - anchors.fill: parent - } - - PlasmaCore.DataSource { - id: timeSource - engine: "time" - connectedSources: ["Local"] - interval: 60 * 1000 - } - 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); - } - } - - homescreen.addNotification( - sourceName, - data, - actions); - } - - } - - ListModel { - id: notificationsModel - - ListElement { - appIcon: "call-start" - summary: "Missed call from Joe" - body: "Called at 8:42 from +41 56 373 37 31" - } - ListElement { - appIcon: "im-google" - summary: "July: Hey! Are you around?" - } - ListElement { - appIcon: "im-google" - summary: "July: Hello?" - } - } - Loader { id: dialerOverlay function open() { @@ -398,161 +286,6 @@ Item { height: homescreen.height } - - PlasmaCore.ColorScope { - z: 1 - anchors { - fill: parent - } - - colorGroup: PlasmaCore.Theme.ComplementaryColorGroup - - SatelliteComponents.ApplicationListModel { - id: appListModel - } - - GridView { - id: applications - anchors { - top: parent.top - bottom: parent.bottom - left: parent.left - right: parent.right - } - z: 1 - cellWidth: homescreen.buttonHeight - cellHeight: cellWidth - model: appListModel - snapMode: GridView.SnapToRow - clip: true - header: MouseArea { - z: 999 - width: homescreen.width - height: homescreen.height - units.iconSizes.medium - - onPressAndHold: { - containment.action("configure").trigger(); - } - - PlasmaComponents.Label { - id: bigClock - anchors { - horizontalCenter: parent.horizontalCenter - top: parent.top - bottom: notificationView.top - } - text: Qt.formatTime(timeSource.data.Local.DateTime, "hh:mm") - color: PlasmaCore.ColorScope.textColor - horizontalAlignment: Qt.AlignHCenter - verticalAlignment: Qt.AlignVCenter - font.pointSize: 40 - style: Text.Raised - styleColor: "black" - } - - ListView { - id: notificationView - spacing: units.smallSpacing - anchors { - bottom: parent.bottom - left: parent.left - right: parent.right - bottomMargin: stripe.height * 2 - } - height: parent.height / 3 - interactive: false - - z: 1 - verticalLayoutDirection: ListView.BottomToTop - model: notificationsModel - - add: Transition { - NumberAnimation { - properties: "x" - from: notificationView.width - duration: 100 - } - } - - remove: Transition { - NumberAnimation { - properties: "x" - to: notificationView.width - duration: 500 - } - NumberAnimation { - properties: "opacity" - to: 0 - duration: 500 - } - } - - removeDisplaced: Transition { - SequentialAnimation { - PauseAnimation { duration: 600 } - NumberAnimation { properties: "x,y"; duration: 100 } - } - } - - delegate: NotificationStripe {} - - } - SatelliteStripe { - id: stripe - z: 99 - y: Math.max(applications.contentY + parent.height, parent.height - height) - - PlasmaCore.Svg { - id: stripeIcons - imagePath: Qt.resolvedUrl("../images/homescreenicons.svg") - } - - Row { - anchors.fill: parent - property int columns: 4 - property alias buttonHeight: stripe.height - - HomeLauncherSvg { - id: phoneIcon - svg: stripeIcons - elementId: "phone" - callback: function() { - dialerOverlay.open() - } - } - - HomeLauncherSvg { - id: messagingIcon - svg: stripeIcons - elementId: "messaging" - callback: function() { console.log("Start messaging") } - } - - - HomeLauncherSvg { - id: emailIcon - svg: stripeIcons - elementId: "email" - callback: function() { console.log("Start email") } - } - - - HomeLauncherSvg { - id: webIcon - svg: stripeIcons - elementId: "web" - callback: function() { console.log("Start web") } - } - } - } - } - delegate: HomeLauncher {} - Component.onCompleted : { console.log("WTF " + width) } - - - } - } - Component.onCompleted: { //configure the view behavior if (desktop) {