mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
make actions work
This commit is contained in:
parent
f1ce156ce9
commit
34434ff367
2 changed files with 51 additions and 6 deletions
|
|
@ -24,16 +24,18 @@ import org.kde.plasma.core 2.0 as PlasmaCore
|
|||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||
|
||||
MouseArea {
|
||||
id: root
|
||||
id: notificationItem
|
||||
|
||||
|
||||
height: units.gridUnit * (expanded ? 4 : 2) + background.margins.top + background.margins.bottom
|
||||
height: units.gridUnit * (expanded ? (actionsLayout.visible ? 6 : 4) : 2) + background.margins.top + background.margins.bottom
|
||||
width: parent.width
|
||||
anchors.bottomMargin: 10
|
||||
drag.axis: Drag.XAxis
|
||||
drag.target: root
|
||||
drag.target: notificationItem
|
||||
|
||||
property bool expanded: false
|
||||
property string source: model.source
|
||||
property var actions: model.actions
|
||||
|
||||
Behavior on x {
|
||||
SpringAnimation { spring: 2; damping: 0.2 }
|
||||
|
|
@ -61,7 +63,7 @@ MouseArea {
|
|||
imagePath: "widgets/background"
|
||||
anchors {
|
||||
fill: parent
|
||||
rightMargin: -root.width
|
||||
rightMargin: -notificationItem.width
|
||||
leftMargin: units.gridUnit
|
||||
}
|
||||
colorGroup: PlasmaCore.ColorScope.colorGroup
|
||||
|
|
@ -95,22 +97,45 @@ MouseArea {
|
|||
anchors {
|
||||
right: icon.left
|
||||
verticalCenter: parent.verticalCenter
|
||||
rightMargin: units.smallSpacing
|
||||
}
|
||||
horizontalAlignment: Qt.AlignRight
|
||||
verticalAlignment: Qt.AlignVCenter
|
||||
color: PlasmaCore.ColorScope.textColor
|
||||
text: summary + (root.expanded ? (body ? "\n" + body : '') :
|
||||
text: summary + (notificationItem.expanded ? (body ? "\n" + body : '') :
|
||||
(body ? '...' : ''))
|
||||
}
|
||||
|
||||
PlasmaCore.IconItem {
|
||||
id: icon
|
||||
anchors {
|
||||
right: root.right
|
||||
right: notificationItem.right
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
width: units.iconSizes.medium
|
||||
height: width
|
||||
source: appIcon && appIcon.length > 0 ? appIcon : "im-user"
|
||||
}
|
||||
RowLayout {
|
||||
id: actionsLayout
|
||||
anchors {
|
||||
right: summaryText.right
|
||||
top: summaryText.bottom
|
||||
topMargin: units.smallSpacing
|
||||
}
|
||||
opacity: notificationItem.expanded && notificationItem.actions && notificationItem.actions.count > 0 ? 1 : 0
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: units.shortDuration
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
}
|
||||
Repeater {
|
||||
model: notificationItem.actions
|
||||
delegate: PlasmaComponents.Button {
|
||||
text: model.text
|
||||
onClicked: root.executeAction(notificationItem.source, model.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,20 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
|
@ -106,20 +120,26 @@ Item {
|
|||
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: []
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue