Changeset View
Changeset View
Standalone View
Standalone View
applets/taskmanager/package/contents/ui/Task.qml
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 31 | MouseArea { | |||
---|---|---|---|---|---|
55 | property QtObject contextMenu: null | 55 | property QtObject contextMenu: null | ||
56 | property int wheelDelta: 0 | 56 | property int wheelDelta: 0 | ||
57 | readonly property bool smartLauncherEnabled: plasmoid.configuration.smartLaunchersEnabled && !inPopup && model.IsStartup !== true | 57 | readonly property bool smartLauncherEnabled: plasmoid.configuration.smartLaunchersEnabled && !inPopup && model.IsStartup !== true | ||
58 | property QtObject smartLauncherItem: null | 58 | property QtObject smartLauncherItem: null | ||
59 | property alias toolTipAreaItem: toolTipArea | 59 | property alias toolTipAreaItem: toolTipArea | ||
60 | 60 | | |||
61 | property Item audioStreamOverlay | 61 | property Item audioStreamOverlay | ||
62 | property var audioStreams: [] | 62 | property var audioStreams: [] | ||
63 | property bool delayAudioStreamIndicator: false | ||||
63 | readonly property bool hasAudioStream: plasmoid.configuration.indicateAudioStreams && audioStreams.length > 0 | 64 | readonly property bool hasAudioStream: plasmoid.configuration.indicateAudioStreams && audioStreams.length > 0 | ||
64 | readonly property bool playingAudio: hasAudioStream && audioStreams.some(function (item) { | 65 | readonly property bool playingAudio: hasAudioStream && audioStreams.some(function (item) { | ||
65 | return !item.corked | 66 | return !item.corked | ||
66 | }) | 67 | }) | ||
67 | readonly property bool muted: hasAudioStream && audioStreams.every(function (item) { | 68 | readonly property bool muted: hasAudioStream && audioStreams.every(function (item) { | ||
68 | return item.muted | 69 | return item.muted | ||
69 | }) | 70 | }) | ||
70 | 71 | | |||
71 | readonly property bool highlighted: (inPopup && activeFocus) || (!inPopup && containsMouse) | 72 | readonly property bool highlighted: (inPopup && activeFocus) || (!inPopup && containsMouse) | ||
72 | || (task.contextMenu && task.contextMenu.status === PlasmaComponents.DialogStatus.Open) | 73 | || (task.contextMenu && task.contextMenu.status === PlasmaComponents.DialogStatus.Open) | ||
73 | || (groupDialog.visible && groupDialog.visualParent === task) | 74 | || (groupDialog.visible && groupDialog.visualParent === task) | ||
74 | 75 | | |||
75 | function hideToolTipTemporarily() { | 76 | function hideToolTipTemporarily() { | ||
76 | toolTipArea.hideToolTip(); | 77 | toolTipArea.hideToolTip(); | ||
77 | } | 78 | } | ||
78 | 79 | | |||
79 | acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton | Qt.BackButton | Qt.ForwardButton | 80 | acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton | Qt.BackButton | Qt.ForwardButton | ||
80 | 81 | | |||
81 | onPidChanged: updateAudioStreams() | 82 | onPidChanged: updateAudioStreams({delay: false}) | ||
82 | onAppNameChanged: updateAudioStreams() | 83 | onAppNameChanged: updateAudioStreams({delay: false}) | ||
83 | 84 | | |||
84 | onIsWindowChanged: { | 85 | onIsWindowChanged: { | ||
85 | if (isWindow) { | 86 | if (isWindow) { | ||
86 | taskInitComponent.createObject(task); | 87 | taskInitComponent.createObject(task); | ||
87 | } | 88 | } | ||
88 | } | 89 | } | ||
89 | 90 | | |||
90 | onChildCountChanged: { | 91 | onChildCountChanged: { | ||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Line(s) | 230 | return (inPopup ? tasksModel.makeModelIndex(groupDialog.visualParent.itemIndex, index) | |||
230 | : tasksModel.makeModelIndex(index)); | 231 | : tasksModel.makeModelIndex(index)); | ||
231 | } | 232 | } | ||
232 | 233 | | |||
233 | function showContextMenu(args) { | 234 | function showContextMenu(args) { | ||
234 | contextMenu = tasks.createContextMenu(task, modelIndex(), args); | 235 | contextMenu = tasks.createContextMenu(task, modelIndex(), args); | ||
235 | contextMenu.show(); | 236 | contextMenu.show(); | ||
236 | } | 237 | } | ||
237 | 238 | | |||
238 | function updateAudioStreams() { | 239 | function updateAudioStreams(args) { | ||
240 | if (args) { | ||||
241 | // When the task just appeared (e.g. virtual desktop switch), show the audio indicator | ||||
242 | // right away. Only when audio streams change during the lifetime of this task, delay | ||||
243 | // showing that to avoid distraction. | ||||
244 | delayAudioStreamIndicator = !!args.delay; | ||||
245 | } | ||||
246 | | ||||
239 | var pa = pulseAudio.item; | 247 | var pa = pulseAudio.item; | ||
240 | if (!pa) { | 248 | if (!pa) { | ||
241 | task.audioStreams = []; | 249 | task.audioStreams = []; | ||
242 | return; | 250 | return; | ||
243 | } | 251 | } | ||
244 | 252 | | |||
245 | var streams = pa.streamsForPid(task.pid); | 253 | var streams = pa.streamsForPid(task.pid); | ||
246 | if (streams.length) { | 254 | if (streams.length) { | ||
Show All 17 Lines | 269 | function toggleMuted() { | |||
264 | } else { | 272 | } else { | ||
265 | task.audioStreams.forEach(function (item) { item.mute(); }); | 273 | task.audioStreams.forEach(function (item) { item.mute(); }); | ||
266 | } | 274 | } | ||
267 | } | 275 | } | ||
268 | 276 | | |||
269 | Connections { | 277 | Connections { | ||
270 | target: pulseAudio.item | 278 | target: pulseAudio.item | ||
271 | ignoreUnknownSignals: true // Plasma-PA might not be available | 279 | ignoreUnknownSignals: true // Plasma-PA might not be available | ||
272 | onStreamsChanged: task.updateAudioStreams() | 280 | onStreamsChanged: task.updateAudioStreams({delay: true}) | ||
273 | } | 281 | } | ||
274 | 282 | | |||
275 | Component { | 283 | Component { | ||
276 | id: taskInitComponent | 284 | id: taskInitComponent | ||
277 | 285 | | |||
278 | Timer { | 286 | Timer { | ||
279 | id: timer | 287 | id: timer | ||
280 | 288 | | |||
▲ Show 20 Lines • Show All 286 Lines • ▼ Show 20 Line(s) | 574 | if (!inPopup && model.IsWindow === true) { | |||
567 | var component = Qt.createComponent("GroupExpanderOverlay.qml"); | 575 | var component = Qt.createComponent("GroupExpanderOverlay.qml"); | ||
568 | component.createObject(task); | 576 | component.createObject(task); | ||
569 | } | 577 | } | ||
570 | 578 | | |||
571 | if (!inPopup && model.IsWindow !== true) { | 579 | if (!inPopup && model.IsWindow !== true) { | ||
572 | taskInitComponent.createObject(task); | 580 | taskInitComponent.createObject(task); | ||
573 | } | 581 | } | ||
574 | 582 | | |||
575 | updateAudioStreams() | 583 | updateAudioStreams({delay: false}) | ||
576 | } | 584 | } | ||
577 | } | 585 | } |