Changeset View
Changeset View
Standalone View
Standalone View
applets/taskmanager/package/contents/ui/Task.qml
Show All 35 Lines | 31 | MouseArea { | |||
---|---|---|---|---|---|
36 | 36 | | |||
37 | visible: false | 37 | visible: false | ||
38 | 38 | | |||
39 | LayoutMirroring.enabled: (Qt.application.layoutDirection == Qt.RightToLeft) | 39 | LayoutMirroring.enabled: (Qt.application.layoutDirection == Qt.RightToLeft) | ||
40 | LayoutMirroring.childrenInherit: (Qt.application.layoutDirection == Qt.RightToLeft) | 40 | LayoutMirroring.childrenInherit: (Qt.application.layoutDirection == Qt.RightToLeft) | ||
41 | 41 | | |||
42 | readonly property var m: model | 42 | readonly property var m: model | ||
43 | 43 | | |||
44 | readonly property int pid: model.AppPid | ||||
44 | property int itemIndex: index | 45 | property int itemIndex: index | ||
45 | property bool inPopup: false | 46 | property bool inPopup: false | ||
46 | property bool isWindow: model.IsWindow === true | 47 | property bool isWindow: model.IsWindow === true | ||
47 | property int childCount: model.ChildCount != undefined ? model.ChildCount : 0 | 48 | property int childCount: model.ChildCount != undefined ? model.ChildCount : 0 | ||
48 | property int previousChildCount: 0 | 49 | property int previousChildCount: 0 | ||
49 | property alias textWidth: label.implicitWidth | 50 | property alias textWidth: label.implicitWidth | ||
50 | property bool pressed: false | 51 | property bool pressed: false | ||
51 | property int pressX: -1 | 52 | property int pressX: -1 | ||
52 | property int pressY: -1 | 53 | property int pressY: -1 | ||
53 | property QtObject contextMenu: null | 54 | property QtObject contextMenu: null | ||
54 | property int wheelDelta: 0 | 55 | property int wheelDelta: 0 | ||
55 | readonly property bool smartLauncherEnabled: plasmoid.configuration.smartLaunchersEnabled && !inPopup && model.IsStartup !== true | 56 | readonly property bool smartLauncherEnabled: plasmoid.configuration.smartLaunchersEnabled && !inPopup && model.IsStartup !== true | ||
56 | property QtObject smartLauncherItem: null | 57 | property QtObject smartLauncherItem: null | ||
57 | 58 | | |||
59 | property Item audioStreamOverlay | ||||
60 | property var audioStreams: [] | ||||
61 | readonly property bool hasAudioStream: plasmoid.configuration.indicateAudioStreams && audioStreams.length > 0 | ||||
62 | readonly property bool playingAudio: hasAudioStream && audioStreams.some(function (item) { | ||||
63 | return !item.corked | ||||
64 | }) | ||||
65 | readonly property bool muted: hasAudioStream && audioStreams.every(function (item) { | ||||
66 | return item.muted | ||||
67 | }) | ||||
68 | | ||||
58 | readonly property bool highlighted: (inPopup && activeFocus) || (!inPopup && containsMouse) | 69 | readonly property bool highlighted: (inPopup && activeFocus) || (!inPopup && containsMouse) | ||
59 | 70 | | |||
60 | function hideToolTipTemporarily() { | 71 | function hideToolTipTemporarily() { | ||
61 | toolTipArea.hideToolTip(); | 72 | toolTipArea.hideToolTip(); | ||
62 | } | 73 | } | ||
63 | 74 | | |||
64 | acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton | 75 | acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton | ||
65 | 76 | | |||
77 | onPidChanged: updateAudioStreams() | ||||
78 | | ||||
66 | onIsWindowChanged: { | 79 | onIsWindowChanged: { | ||
67 | if (isWindow) { | 80 | if (isWindow) { | ||
68 | taskInitComponent.createObject(task); | 81 | taskInitComponent.createObject(task); | ||
69 | } | 82 | } | ||
70 | } | 83 | } | ||
71 | 84 | | |||
72 | onChildCountChanged: { | 85 | onChildCountChanged: { | ||
73 | if (childCount > previousChildCount) { | 86 | if (childCount > previousChildCount) { | ||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Line(s) | |||||
162 | TaskManagerApplet.SmartLauncherItem { }", task); | 175 | TaskManagerApplet.SmartLauncherItem { }", task); | ||
163 | 176 | | |||
164 | smartLauncher.launcherUrl = Qt.binding(function() { return model.LauncherUrlWithoutIcon; }); | 177 | smartLauncher.launcherUrl = Qt.binding(function() { return model.LauncherUrlWithoutIcon; }); | ||
165 | 178 | | |||
166 | smartLauncherItem = smartLauncher; | 179 | smartLauncherItem = smartLauncher; | ||
167 | } | 180 | } | ||
168 | } | 181 | } | ||
169 | 182 | | |||
183 | onHasAudioStreamChanged: { | ||||
184 | if (hasAudioStream) { | ||||
185 | audioStreamIconLoader.active = true | ||||
186 | } | ||||
187 | } | ||||
188 | | ||||
170 | Keys.onReturnPressed: TaskTools.activateTask(modelIndex(), model, event.modifiers, task) | 189 | Keys.onReturnPressed: TaskTools.activateTask(modelIndex(), model, event.modifiers, task) | ||
171 | Keys.onEnterPressed: Keys.onReturnPressed(event); | 190 | Keys.onEnterPressed: Keys.onReturnPressed(event); | ||
172 | 191 | | |||
173 | function modelIndex() { | 192 | function modelIndex() { | ||
174 | return (inPopup ? tasksModel.makeModelIndex(groupDialog.visualParent.itemIndex, index) | 193 | return (inPopup ? tasksModel.makeModelIndex(groupDialog.visualParent.itemIndex, index) | ||
175 | : tasksModel.makeModelIndex(index)); | 194 | : tasksModel.makeModelIndex(index)); | ||
176 | } | 195 | } | ||
177 | 196 | | |||
197 | function updateAudioStreams() { | ||||
198 | if (!pid) { | ||||
199 | task.audioStreams = []; | ||||
200 | return; | ||||
201 | } | ||||
202 | | ||||
203 | var pa = pulseAudio.item; | ||||
204 | if (!pa) { | ||||
205 | task.audioStreams = []; | ||||
206 | return; | ||||
207 | } | ||||
208 | | ||||
209 | task.audioStreams = pa.streamsForPid(pid); | ||||
210 | } | ||||
211 | | ||||
212 | function toggleMuted() { | ||||
213 | if (muted) { | ||||
214 | task.audioStreams.forEach(function (item) { item.unmute(); }); | ||||
215 | } else { | ||||
216 | task.audioStreams.forEach(function (item) { item.mute(); }); | ||||
217 | } | ||||
218 | } | ||||
219 | | ||||
220 | Connections { | ||||
221 | target: pulseAudio.item | ||||
222 | ignoreUnknownSignals: true // Plasma-PA might not be available | ||||
223 | onStreamsChanged: task.updateAudioStreams() | ||||
224 | } | ||||
225 | | ||||
178 | Component { | 226 | Component { | ||
179 | id: taskInitComponent | 227 | id: taskInitComponent | ||
180 | 228 | | |||
181 | Timer { | 229 | Timer { | ||
182 | id: timer | 230 | id: timer | ||
183 | 231 | | |||
184 | interval: units.longDuration * 2 | 232 | interval: units.longDuration * 2 | ||
185 | repeat: false | 233 | repeat: false | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 274 | PlasmaCore.ToolTipArea { | |||
232 | active: !inPopup && !groupDialog.visible && plasmoid.configuration.showToolTips | 280 | active: !inPopup && !groupDialog.visible && plasmoid.configuration.showToolTips | ||
233 | interactive: true | 281 | interactive: true | ||
234 | 282 | | |||
235 | mainItem: toolTipDelegate | 283 | mainItem: toolTipDelegate | ||
236 | 284 | | |||
237 | onContainsMouseChanged: { | 285 | onContainsMouseChanged: { | ||
238 | if (containsMouse) { | 286 | if (containsMouse) { | ||
239 | toolTipDelegate.parentTask = task; | 287 | toolTipDelegate.parentTask = task; | ||
240 | toolTipDelegate.parentIndex = itemIndex; | 288 | toolTipDelegate.parentIndex = itemIndex; | ||
hein: ? | |||||
241 | 289 | | |||
242 | toolTipDelegate.appName = Qt.binding(function() { | 290 | toolTipDelegate.appName = Qt.binding(function() { | ||
243 | return model.AppName; | 291 | return model.AppName; | ||
244 | }); | 292 | }); | ||
245 | toolTipDelegate.pidParent = Qt.binding(function() { | 293 | toolTipDelegate.pidParent = Qt.binding(function() { | ||
246 | return model.AppPid; | 294 | return model.AppPid; | ||
247 | }); | 295 | }); | ||
248 | toolTipDelegate.windows = Qt.binding(function() { | 296 | toolTipDelegate.windows = Qt.binding(function() { | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 341 | Item { | |||
295 | 343 | | |||
296 | anchors { | 344 | anchors { | ||
297 | left: parent.left | 345 | left: parent.left | ||
298 | leftMargin: adjustMargin(true, parent.width, taskFrame.margins.left) | 346 | leftMargin: adjustMargin(true, parent.width, taskFrame.margins.left) | ||
299 | top: parent.top | 347 | top: parent.top | ||
300 | topMargin: adjustMargin(false, parent.height, taskFrame.margins.top) | 348 | topMargin: adjustMargin(false, parent.height, taskFrame.margins.top) | ||
301 | } | 349 | } | ||
302 | 350 | | |||
303 | width: (label.visible ? height | 351 | width: height | ||
304 | : parent.width - adjustMargin(true, parent.width, taskFrame.margins.left) | | |||
305 | - adjustMargin(true, parent.width, taskFrame.margins.right)) | | |||
306 | height: (parent.height - adjustMargin(false, parent.height, taskFrame.margins.top) | 352 | height: (parent.height - adjustMargin(false, parent.height, taskFrame.margins.top) | ||
307 | - adjustMargin(false, parent.height, taskFrame.margins.bottom)) | 353 | - adjustMargin(false, parent.height, taskFrame.margins.bottom)) | ||
308 | 354 | | |||
309 | function adjustMargin(vert, size, margin) { | 355 | function adjustMargin(vert, size, margin) { | ||
310 | if (!size) { | 356 | if (!size) { | ||
311 | return margin; | 357 | return margin; | ||
312 | } | 358 | } | ||
313 | 359 | | |||
314 | var margins = vert ? LayoutManager.horizontalMargins() : LayoutManager.verticalMargins(); | 360 | var margins = vert ? LayoutManager.horizontalMargins() : LayoutManager.verticalMargins(); | ||
315 | 361 | | |||
316 | if ((size - margins) < units.iconSizes.small) { | 362 | if ((size - margins) < units.iconSizes.small) { | ||
317 | return Math.ceil((margin * (units.iconSizes.small / size)) / 2); | 363 | return Math.ceil((margin * (units.iconSizes.small / size)) / 2); | ||
318 | } | 364 | } | ||
hein: Do we need "This application" or can we simplify to "Currently muted."? | |||||
319 | 365 | | |||
320 | return margin; | 366 | return margin; | ||
321 | } | 367 | } | ||
322 | 368 | | |||
323 | //width: inPopup ? units.iconSizes.small : Math.min(height, parent.width - LayoutManager.horizontalMargins()) | 369 | //width: inPopup ? units.iconSizes.small : Math.min(height, parent.width - LayoutManager.horizontalMargins()) | ||
324 | 370 | | |||
325 | PlasmaCore.IconItem { | 371 | PlasmaCore.IconItem { | ||
326 | id: icon | 372 | id: icon | ||
Show All 19 Lines | 391 | active: plasmoid.configuration.smartLaunchersEnabled && height >= units.iconSizes.small | |||
346 | && task.smartLauncherItem && task.smartLauncherItem.countVisible | 392 | && task.smartLauncherItem && task.smartLauncherItem.countVisible | ||
347 | } | 393 | } | ||
348 | 394 | | |||
349 | states: [ | 395 | states: [ | ||
350 | // Using a state transition avoids a binding loop between label.visible and | 396 | // Using a state transition avoids a binding loop between label.visible and | ||
351 | // the text label margin, which derives from the icon width. | 397 | // the text label margin, which derives from the icon width. | ||
352 | State { | 398 | State { | ||
353 | name: "standalone" | 399 | name: "standalone" | ||
354 | when: !label.visible | 400 | when: !label.visible && !audioStreamIconLoader.shown | ||
355 | 401 | | |||
356 | AnchorChanges { | 402 | AnchorChanges { | ||
357 | target: iconBox | 403 | target: iconBox | ||
358 | anchors.left: undefined | 404 | anchors.left: undefined | ||
359 | anchors.horizontalCenter: parent.horizontalCenter | 405 | anchors.horizontalCenter: parent.horizontalCenter | ||
360 | } | 406 | } | ||
361 | 407 | | |||
362 | PropertyChanges { | 408 | PropertyChanges { | ||
363 | target: iconBox | 409 | target: iconBox | ||
364 | anchors.leftMargin: 0 | 410 | anchors.leftMargin: 0 | ||
411 | width: parent.width - adjustMargin(true, task.width, taskFrame.margins.left) | ||||
412 | - adjustMargin(true, task.width, taskFrame.margins.right) | ||||
365 | } | 413 | } | ||
366 | } | 414 | } | ||
367 | ] | 415 | ] | ||
368 | 416 | | |||
369 | Loader { | 417 | Loader { | ||
370 | anchors.fill: parent | 418 | anchors.fill: parent | ||
371 | 419 | | |||
372 | active: model.IsStartup === true | 420 | active: model.IsStartup === true | ||
373 | sourceComponent: busyIndicator | 421 | sourceComponent: busyIndicator | ||
374 | } | 422 | } | ||
375 | 423 | | |||
376 | Component { | 424 | Component { | ||
377 | id: busyIndicator | 425 | id: busyIndicator | ||
378 | 426 | | |||
379 | PlasmaComponents.BusyIndicator { anchors.fill: parent } | 427 | PlasmaComponents.BusyIndicator { anchors.fill: parent } | ||
380 | } | 428 | } | ||
381 | } | 429 | } | ||
382 | 430 | | |||
431 | Loader { | ||||
432 | id: audioStreamIconLoader | ||||
433 | | ||||
434 | readonly property bool shown: item && item.visible | ||||
435 | | ||||
436 | source: "AudioStream.qml" | ||||
437 | width: Math.min(units.iconSizes.medium, iconBox.width) | ||||
438 | height: Math.min(units.iconSizes.medium, iconBox.height) | ||||
439 | | ||||
440 | anchors { | ||||
441 | right: parent.right | ||||
442 | rightMargin: iconBox.adjustMargin(true, parent.width, taskFrame.margins.right) | ||||
443 | top: parent.top | ||||
444 | topMargin: iconBox.adjustMargin(false, parent.height, taskFrame.margins.top) | ||||
445 | } | ||||
446 | } | ||||
447 | | ||||
383 | PlasmaComponents.Label { | 448 | PlasmaComponents.Label { | ||
384 | id: label | 449 | id: label | ||
385 | 450 | | |||
386 | visible: (inPopup || !iconsOnly && model.IsLauncher !== true | 451 | visible: (inPopup || !iconsOnly && model.IsLauncher !== true | ||
387 | && (parent.width - iconBox.height - units.smallSpacing) >= (theme.mSize(theme.defaultFont).width * 7)) | 452 | && (parent.width - iconBox.height - units.smallSpacing) >= (theme.mSize(theme.defaultFont).width * 7)) | ||
388 | 453 | | |||
389 | anchors { | 454 | anchors { | ||
390 | fill: parent | 455 | fill: parent | ||
391 | leftMargin: taskFrame.margins.left + iconBox.width + units.smallSpacing | 456 | leftMargin: taskFrame.margins.left + iconBox.width + units.smallSpacing | ||
392 | topMargin: taskFrame.margins.top | 457 | topMargin: taskFrame.margins.top | ||
393 | rightMargin: taskFrame.margins.right | 458 | rightMargin: taskFrame.margins.right + (audioStreamIconLoader.shown ? (audioStreamIconLoader.width + units.smallSpacing) : 0) | ||
394 | bottomMargin: taskFrame.margins.bottom | 459 | bottomMargin: taskFrame.margins.bottom | ||
395 | } | 460 | } | ||
396 | 461 | | |||
397 | text: model.display | 462 | text: model.display | ||
398 | wrapMode: Text.Wrap | 463 | wrapMode: Text.Wrap | ||
399 | elide: Text.ElideRight | 464 | elide: Text.ElideRight | ||
400 | textFormat: Text.PlainText | 465 | textFormat: Text.PlainText | ||
401 | verticalAlignment: Text.AlignVCenter | 466 | verticalAlignment: Text.AlignVCenter | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 517 | Component.onCompleted: { | |||
453 | if (!inPopup && model.IsWindow === true) { | 518 | if (!inPopup && model.IsWindow === true) { | ||
454 | var component = Qt.createComponent("GroupExpanderOverlay.qml"); | 519 | var component = Qt.createComponent("GroupExpanderOverlay.qml"); | ||
455 | component.createObject(task); | 520 | component.createObject(task); | ||
456 | } | 521 | } | ||
457 | 522 | | |||
458 | if (!inPopup && model.IsWindow !== true) { | 523 | if (!inPopup && model.IsWindow !== true) { | ||
459 | taskInitComponent.createObject(task); | 524 | taskInitComponent.createObject(task); | ||
460 | } | 525 | } | ||
526 | | ||||
527 | updateAudioStreams() | ||||
461 | } | 528 | } | ||
462 | } | 529 | } | ||
hein: Coding style: Missing trailing semicolon. |
?