mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-06-11 00:47:22 +00:00
Add activity actions to dock menu
Expose activity placement controls for running tasks in convergence mode. The dock menu can now move a window to the current activity, all activities, or a specific activity.
This commit is contained in:
parent
6ee9cb62a3
commit
3c2d8fb602
1 changed files with 55 additions and 0 deletions
|
|
@ -177,6 +177,33 @@ MouseArea {
|
|||
return result
|
||||
}
|
||||
|
||||
function taskActivities(taskModel) {
|
||||
let activities = taskModel.Activities
|
||||
return activities ? activities : []
|
||||
}
|
||||
|
||||
function activityName(activityId) {
|
||||
let name = activityInfo.activityName(activityId)
|
||||
return name && name.length > 0 ? name : i18n("Activity")
|
||||
}
|
||||
|
||||
function menuActivityIds(taskActivities) {
|
||||
let runningActivities = activityInfo.runningActivities()
|
||||
if (!runningActivities || runningActivities.length <= 1) {
|
||||
return []
|
||||
}
|
||||
|
||||
let result = []
|
||||
for (let i = 0; i < runningActivities.length; ++i) {
|
||||
let activityId = runningActivities[i]
|
||||
if (taskActivities.length === 1 && String(taskActivities[0]) === String(activityId)) {
|
||||
continue
|
||||
}
|
||||
result.push(activityId)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Returns the desktop ID of the pager button under screen-space x, or ""
|
||||
function pagerButtonDesktopAt(x) {
|
||||
if (!showPager) return ""
|
||||
|
|
@ -1623,6 +1650,7 @@ MouseArea {
|
|||
readonly property bool dynamicTilingActive: root.convergenceMode && ShellSettings.Settings.dynamicTilingEnabled
|
||||
readonly property bool showFreeGeometryActions: !taskDelegate.isGroupParent && !taskDelegate.dynamicTilingActive
|
||||
readonly property bool canChangeVirtualDesktops: taskDelegate.model.IsVirtualDesktopsChangeable === true
|
||||
readonly property bool canChangeActivities: activityInfo.numberOfRunningActivities > 1 && !taskDelegate.isGroupParent
|
||||
|
||||
Accessible.role: Accessible.Button
|
||||
Accessible.name: taskDelegate.model.display || ""
|
||||
|
|
@ -1942,6 +1970,33 @@ MouseArea {
|
|||
height: visible ? implicitHeight : 0
|
||||
onClicked: tasksModel.requestNewVirtualDesktop(tasksModel.makeModelIndex(taskDelegate.index))
|
||||
}
|
||||
|
||||
Controls.MenuSeparator {
|
||||
visible: taskDelegate.canChangeActivities
|
||||
height: visible ? implicitHeight : 0
|
||||
}
|
||||
|
||||
PC3.MenuItem {
|
||||
icon.name: "activities"
|
||||
text: root.taskActivities(taskDelegate.model).length === 0 ? i18n("Show Only on Current Activity") : i18n("Show on All Activities")
|
||||
visible: taskDelegate.canChangeActivities
|
||||
height: visible ? implicitHeight : 0
|
||||
onClicked: tasksModel.requestActivities(tasksModel.makeModelIndex(taskDelegate.index),
|
||||
root.taskActivities(taskDelegate.model).length === 0 ? [activityInfo.currentActivity] : [])
|
||||
}
|
||||
|
||||
Instantiator {
|
||||
model: taskDelegate.canChangeActivities ? root.menuActivityIds(root.taskActivities(taskDelegate.model)) : []
|
||||
delegate: PC3.MenuItem {
|
||||
required property var modelData
|
||||
icon.name: activityInfo.activityIcon(modelData)
|
||||
text: i18n("Move to %1", root.activityName(modelData))
|
||||
onTriggered: tasksModel.requestActivities(
|
||||
tasksModel.makeModelIndex(taskDelegate.index), [modelData])
|
||||
}
|
||||
onObjectAdded: (idx, obj) => taskContextMenu.insertItem(taskContextMenu.count, obj)
|
||||
onObjectRemoved: (idx, obj) => taskContextMenu.removeItem(obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue