mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
use the new containment
This commit is contained in:
parent
4b77fe4647
commit
fe6332b1d2
4 changed files with 18 additions and 283 deletions
|
|
@ -206,6 +206,7 @@ Item {
|
|||
Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.minimumHeight: root.height
|
||||
Layout.maximumHeight: root.height
|
||||
Clock {
|
||||
anchors {
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
LookAndFeelPackage=org.kde.satellite.phone
|
||||
|
||||
[Desktop]
|
||||
Containment=org.kde.desktopcontainment
|
||||
Containment=org.kde.phone.homescreen
|
||||
ToolBox=
|
||||
|
||||
[Desktop][ContainmentActions]
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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 (containment != null) {
|
||||
containment.visible = true;
|
||||
}
|
||||
|
||||
if (sameSource || matches) {
|
||||
notificationsModel.remove(i)
|
||||
break;
|
||||
if (containment != null) {
|
||||
containment.anchors.left = homescreen.left;
|
||||
containment.anchors.top = homescreen.top;
|
||||
containment.anchors.right = homescreen.right;
|
||||
containment.anchors.bottom = homescreen.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue