Initial commit: Icon Task Manager with Zoom - Enhanced KDE Plasma task manager with macOS dock-like zoom effects, custom launch animations, performance optimizations, and comprehensive documentation
This commit is contained in:
commit
e337191734
32 files changed
+6680
No files matched your search
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2017 Kai Uwe Broulik <kde@privat.broulik.de>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
import QtQuick
|
||||
|
||||
import org.kde.plasma.plasmoid
|
||||
import org.kde.plasma.extras as PlasmaExtras
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.ksvg as KSvg
|
||||
|
||||
Item {
|
||||
id: audioStreamIconBox
|
||||
|
||||
width: Math.round(Math.min(Math.min(iconBox.width, iconBox.height) * 0.4, Kirigami.Units.iconSizes.smallMedium))
|
||||
height: width
|
||||
anchors {
|
||||
top: frame.top
|
||||
right: frame.right
|
||||
rightMargin: taskFrame.margins.right
|
||||
topMargin: Math.round(taskFrame.margins.top * indicatorScale)
|
||||
}
|
||||
|
||||
readonly property real indicatorScale: 1.2
|
||||
|
||||
activeFocusOnTab: true
|
||||
|
||||
// Using States rather than a simple Behavior we can apply different transitions,
|
||||
// which allows us to delay showing the icon but hide it instantly still.
|
||||
states: [
|
||||
State {
|
||||
name: "playing"
|
||||
when: task.playingAudio && !task.muted
|
||||
PropertyChanges {
|
||||
target: audioStreamIconBox
|
||||
opacity: 1
|
||||
}
|
||||
PropertyChanges {
|
||||
target: audioStreamIcon
|
||||
source: "audio-volume-high-symbolic"
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "muted"
|
||||
when: task.muted
|
||||
PropertyChanges {
|
||||
target: audioStreamIconBox
|
||||
opacity: 1
|
||||
}
|
||||
PropertyChanges {
|
||||
target: audioStreamIcon
|
||||
source: "audio-volume-muted-symbolic"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
transitions: [
|
||||
Transition {
|
||||
from: ""
|
||||
to: "playing"
|
||||
SequentialAnimation {
|
||||
// Delay showing the play indicator so we don't flash it for brief sounds.
|
||||
PauseAnimation {
|
||||
duration: !task.delayAudioStreamIndicator || inPopup ? 0 : 2000
|
||||
}
|
||||
NumberAnimation {
|
||||
property: "opacity"
|
||||
duration: Kirigami.Units.longDuration
|
||||
}
|
||||
}
|
||||
},
|
||||
Transition {
|
||||
from: ""
|
||||
to: "muted"
|
||||
SequentialAnimation {
|
||||
NumberAnimation {
|
||||
property: "opacity"
|
||||
duration: Kirigami.Units.longDuration
|
||||
}
|
||||
}
|
||||
},
|
||||
Transition {
|
||||
to: ""
|
||||
NumberAnimation {
|
||||
property: "opacity"
|
||||
duration: Kirigami.Units.longDuration
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
opacity: 0
|
||||
visible: opacity > 0
|
||||
|
||||
Keys.onReturnPressed: event => toggleMuted()
|
||||
Keys.onEnterPressed: event => Keys.returnPressed(event);
|
||||
Keys.onSpacePressed: event => Keys.returnPressed(event);
|
||||
|
||||
Accessible.checkable: true
|
||||
Accessible.checked: task.muted
|
||||
Accessible.name: task.muted ? i18nc("@action:button", "Unmute") : i18nc("@action:button", "Mute")
|
||||
Accessible.description: task.muted ? i18nc("@info:tooltip %1 is the window title", "Unmute %1", model.display) : i18nc("@info:tooltip %1 is the window title", "Mute %1", model.display)
|
||||
Accessible.role: Accessible.Button
|
||||
|
||||
HoverHandler {
|
||||
id: hoverHandler
|
||||
enabled: Plasmoid.configuration.interactiveMute
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
id: tapHandler
|
||||
gesturePolicy: TapHandler.ReleaseWithinBounds // Exclusive grab
|
||||
enabled: Plasmoid.configuration.interactiveMute
|
||||
onTapped: (eventPoint, button) => toggleMuted()
|
||||
}
|
||||
|
||||
PlasmaExtras.Highlight {
|
||||
anchors.fill: audioStreamIcon
|
||||
hovered: hoverHandler.hovered || parent.activeFocus
|
||||
pressed: tapHandler.pressed
|
||||
}
|
||||
|
||||
Kirigami.Icon {
|
||||
id: audioStreamIcon
|
||||
|
||||
// Need audio indicator twice, to keep iconBox in the center.
|
||||
readonly property real requiredSpace: Math.min(iconBox.width, iconBox.height)
|
||||
+ Math.min(Math.min(iconBox.width, iconBox.height), Kirigami.Units.iconSizes.smallMedium) * 2
|
||||
|
||||
source: "audio-volume-high-symbolic"
|
||||
selected: tapHandler.pressed
|
||||
|
||||
height: Math.round(Math.min(parent.height * indicatorScale, Kirigami.Units.iconSizes.smallMedium))
|
||||
width: height
|
||||
|
||||
anchors {
|
||||
verticalCenter: parent.verticalCenter
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "verticalIconsOnly"
|
||||
when: tasks.vertical && frame.width < audioStreamIcon.requiredSpace
|
||||
|
||||
PropertyChanges {
|
||||
target: audioStreamIconBox
|
||||
anchors.rightMargin: Math.round(taskFrame.margins.right * indicatorScale)
|
||||
}
|
||||
},
|
||||
|
||||
State {
|
||||
name: "horizontal"
|
||||
when: frame.width > audioStreamIcon.requiredSpace
|
||||
|
||||
AnchorChanges {
|
||||
target: audioStreamIconBox
|
||||
|
||||
anchors.top: undefined
|
||||
anchors.verticalCenter: frame.verticalCenter
|
||||
}
|
||||
|
||||
PropertyChanges {
|
||||
target: audioStreamIconBox
|
||||
width: Kirigami.Units.iconSizes.roundedIconSize(Math.min(Math.min(iconBox.width, iconBox.height), Kirigami.Units.iconSizes.smallMedium))
|
||||
}
|
||||
|
||||
PropertyChanges {
|
||||
target: audioStreamIcon
|
||||
|
||||
height: parent.height
|
||||
width: parent.width
|
||||
}
|
||||
},
|
||||
|
||||
State {
|
||||
name: "vertical"
|
||||
when: frame.height > audioStreamIcon.requiredSpace
|
||||
|
||||
AnchorChanges {
|
||||
target: audioStreamIconBox
|
||||
|
||||
anchors.right: undefined
|
||||
anchors.horizontalCenter: frame.horizontalCenter
|
||||
}
|
||||
|
||||
PropertyChanges {
|
||||
target: audioStreamIconBox
|
||||
|
||||
anchors.topMargin: taskFrame.margins.top
|
||||
width: Kirigami.Units.iconSizes.roundedIconSize(Math.min(Math.min(iconBox.width, iconBox.height), Kirigami.Units.iconSizes.smallMedium))
|
||||
}
|
||||
|
||||
PropertyChanges {
|
||||
target: audioStreamIcon
|
||||
|
||||
height: parent.height
|
||||
width: parent.width
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@privat.broulik.de>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
import QtQuick
|
||||
|
||||
import org.kde.plasma.components as PlasmaComponents3
|
||||
import org.kde.kirigami as Kirigami
|
||||
|
||||
// This top-level item is an opaque background that goes behind the colored
|
||||
// background, for contrast. It's not an Item since that it would be square,
|
||||
// and not round, as required here
|
||||
Rectangle {
|
||||
id: badgeRect
|
||||
|
||||
property alias text: label.text
|
||||
property alias textColor: label.color
|
||||
property int number: 0
|
||||
|
||||
implicitWidth: Math.max(height, Math.round(label.contentWidth + radius / 2)) // Add some padding around.
|
||||
implicitHeight: implicitWidth
|
||||
|
||||
radius: height / 2
|
||||
|
||||
color: Kirigami.Theme.backgroundColor
|
||||
|
||||
// Colored background
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: height / 2
|
||||
|
||||
color: Qt.alpha(Kirigami.Theme.highlightColor, 0.3)
|
||||
border.color: Kirigami.Theme.highlightColor
|
||||
border.width: 1
|
||||
}
|
||||
|
||||
// Number
|
||||
PlasmaComponents3.Label {
|
||||
id: label
|
||||
anchors.centerIn: parent
|
||||
width: height
|
||||
height: Math.min(Kirigami.Units.gridUnit * 2, Math.round(parent.height))
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
fontSizeMode: Text.VerticalFit
|
||||
font.pointSize: 1024
|
||||
minimumPointSize: 5
|
||||
text: {
|
||||
if (badgeRect.number < 0) {
|
||||
return i18nc("Invalid number of new messages, overlay, keep short", "—");
|
||||
} else if (badgeRect.number > 9999) {
|
||||
return i18nc("Over 9999 new messages, overlay, keep short", "9,999+");
|
||||
} else {
|
||||
return badgeRect.number.toLocaleString(Qt.locale(), 'f', 0);
|
||||
}
|
||||
}
|
||||
textFormat: Text.PlainText
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,410 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2013 Eike Hein <hein@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.kcmutils as KCMUtils
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.plasma.core as PlasmaCore
|
||||
import org.kde.plasma.plasmoid
|
||||
|
||||
KCMUtils.SimpleKCM {
|
||||
readonly property bool plasmaPaAvailable: Qt.createComponent("PulseAudio.qml").status === Component.Ready
|
||||
readonly property bool plasmoidVertical: Plasmoid.formFactor === PlasmaCore.Types.Vertical
|
||||
readonly property bool iconOnly: Plasmoid.pluginName === "org.kde.plasma.icontasks" || Plasmoid.pluginName === "org.kde.plasma.icontasks.zoom"
|
||||
|
||||
property alias cfg_showToolTips: showToolTips.checked
|
||||
property alias cfg_highlightWindows: highlightWindows.checked
|
||||
property alias cfg_interactiveMute: interactiveMute.checked
|
||||
property alias cfg_fill: fill.checked
|
||||
property alias cfg_maxStripes: maxStripes.value
|
||||
property alias cfg_forceStripes: forceStripes.checked
|
||||
property alias cfg_taskMaxWidth: taskMaxWidth.currentIndex
|
||||
property int cfg_iconSpacing: 0
|
||||
property alias cfg_magnifyFactor: magnifyFactor.value
|
||||
property alias cfg_zoomDuration: zoomDuration.value
|
||||
property alias cfg_zoomEasing: zoomEasing.currentIndex
|
||||
property alias cfg_hoverDelay: hoverDelay.value
|
||||
property alias cfg_resetDelay: resetDelay.value
|
||||
property alias cfg_zoomAnchor: zoomAnchor.currentIndex
|
||||
property alias cfg_launchAnimationType: launchAnimationType.currentIndex
|
||||
property alias cfg_launchAnimationDuration: launchAnimationDuration.value
|
||||
property alias cfg_launchAnimationIntensity: launchAnimationIntensity.value
|
||||
|
||||
Component.onCompleted: {
|
||||
/* Don't rely on bindings for checking the radiobuttons
|
||||
When checking forceStripes, the condition for the checked value for the allow stripes button
|
||||
became true and that one got checked instead, stealing the checked state for the just clicked checkbox
|
||||
*/
|
||||
if (maxStripes.value === 1) {
|
||||
forbidStripes.checked = true;
|
||||
} else if (!Plasmoid.configuration.forceStripes && maxStripes.value > 1) {
|
||||
allowStripes.checked = true;
|
||||
} else if (Plasmoid.configuration.forceStripes && maxStripes.value > 1) {
|
||||
forceStripes.checked = true;
|
||||
}
|
||||
}
|
||||
Kirigami.FormLayout {
|
||||
QQC2.CheckBox {
|
||||
id: showToolTips
|
||||
Kirigami.FormData.label: i18nc("@label for several checkboxes", "General:")
|
||||
text: i18nc("@option:check section General", "Show small window previews when hovering over tasks")
|
||||
}
|
||||
|
||||
QQC2.CheckBox {
|
||||
id: highlightWindows
|
||||
text: i18nc("@option:check section General", "Hide other windows when hovering over previews")
|
||||
}
|
||||
|
||||
QQC2.CheckBox {
|
||||
id: interactiveMute
|
||||
text: i18nc("@option:check section General", "Use audio indicators to mute tasks")
|
||||
enabled: plasmaPaAvailable
|
||||
}
|
||||
|
||||
QQC2.CheckBox {
|
||||
id: fill
|
||||
text: i18nc("@option:check section General", "Fill free space on panel")
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
visible: !iconOnly
|
||||
}
|
||||
|
||||
QQC2.ComboBox {
|
||||
id: taskMaxWidth
|
||||
visible: !iconOnly && !plasmoidVertical
|
||||
|
||||
Kirigami.FormData.label: i18nc("@label:listbox", "Maximum task width:")
|
||||
|
||||
model: [
|
||||
i18nc("@item:inlistbox how wide a task item should be", "Narrow"),
|
||||
i18nc("@item:inlistbox how wide a task item should be", "Medium"),
|
||||
i18nc("@item:inlistbox how wide a task item should be", "Wide")
|
||||
]
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
}
|
||||
|
||||
QQC2.RadioButton {
|
||||
id: forbidStripes
|
||||
Kirigami.FormData.label: plasmoidVertical
|
||||
? i18nc("@label for radio button group, completes sentence: … when panel is low on space etc.", "Use multi-column view:")
|
||||
: i18nc("@label for radio button group, completes sentence: … when panel is low on space etc.", "Use multi-row view:")
|
||||
onToggled: {
|
||||
if (checked) {
|
||||
maxStripes.value = 1
|
||||
}
|
||||
}
|
||||
text: i18nc("@option:radio Never use multi-column view for Task Manager", "Never")
|
||||
}
|
||||
|
||||
QQC2.RadioButton {
|
||||
id: allowStripes
|
||||
onToggled: {
|
||||
if (checked) {
|
||||
maxStripes.value = Math.max(2, maxStripes.value)
|
||||
}
|
||||
}
|
||||
text: i18nc("@option:radio completes sentence: Use multi-column/row view", "When panel is low on space and thick enough")
|
||||
}
|
||||
|
||||
QQC2.RadioButton {
|
||||
id: forceStripes
|
||||
onToggled: {
|
||||
if (checked) {
|
||||
maxStripes.value = Math.max(2, maxStripes.value)
|
||||
}
|
||||
}
|
||||
text: i18nc("@option:radio completes sentence: Use multi-column/row view", "Always when panel is thick enough")
|
||||
}
|
||||
|
||||
QQC2.SpinBox {
|
||||
id: maxStripes
|
||||
enabled: maxStripes.value > 1
|
||||
Kirigami.FormData.label: plasmoidVertical
|
||||
? i18nc("@label:spinbox maximum number of columns for tasks", "Maximum columns:")
|
||||
: i18nc("@label:spinbox maximum number of rows for tasks", "Maximum rows:")
|
||||
from: 1
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
}
|
||||
|
||||
QQC2.ComboBox {
|
||||
visible: iconOnly
|
||||
Kirigami.FormData.label: i18nc("@label:listbox", "Spacing between icons:")
|
||||
|
||||
model: [
|
||||
{
|
||||
"label": i18nc("@item:inlistbox Icon spacing", "Small"),
|
||||
"spacing": 0
|
||||
},
|
||||
{
|
||||
"label": i18nc("@item:inlistbox Icon spacing", "Normal"),
|
||||
"spacing": 1
|
||||
},
|
||||
{
|
||||
"label": i18nc("@item:inlistbox Icon spacing", "Large"),
|
||||
"spacing": 3
|
||||
},
|
||||
]
|
||||
|
||||
textRole: "label"
|
||||
enabled: !Kirigami.Settings.tabletMode
|
||||
|
||||
currentIndex: {
|
||||
if (Kirigami.Settings.tabletMode) {
|
||||
return 2; // Large
|
||||
}
|
||||
|
||||
switch (cfg_iconSpacing) {
|
||||
case 0: return 0; // Small
|
||||
case 1: return 1; // Normal
|
||||
case 3: return 2; // Large
|
||||
}
|
||||
}
|
||||
onActivated: index => {
|
||||
cfg_iconSpacing = model[currentIndex]["spacing"];
|
||||
}
|
||||
}
|
||||
|
||||
QQC2.Label {
|
||||
visible: Kirigami.Settings.tabletMode
|
||||
text: i18nc("@info:usagetip under a set of radio buttons when Touch Mode is on", "Automatically set to Large when in Touch mode")
|
||||
font: Kirigami.Theme.smallFont
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
visible: iconOnly
|
||||
}
|
||||
|
||||
QQC2.CheckBox {
|
||||
id: enableZoomEffect
|
||||
visible: iconOnly
|
||||
Kirigami.FormData.label: i18nc("@label for zoom effect section", "Zoom Effect:")
|
||||
text: i18nc("@option:check", "Enable icon zoom on hover")
|
||||
checked: cfg_magnifyFactor > 0
|
||||
onToggled: {
|
||||
if (checked) {
|
||||
cfg_magnifyFactor = 0.3;
|
||||
} else {
|
||||
cfg_magnifyFactor = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QQC2.Label {
|
||||
visible: iconOnly && enableZoomEffect.checked
|
||||
text: i18nc("@info:usagetip", "Icons will smoothly zoom with configurable animation when you hover over them. Adjust the settings below to customize the zoom behavior.")
|
||||
font: Kirigami.Theme.smallFont
|
||||
wrapMode: Text.Wrap
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
visible: iconOnly && enableZoomEffect.checked
|
||||
Kirigami.FormData.label: i18nc("@label:slider", "Zoom intensity:")
|
||||
|
||||
QQC2.Slider {
|
||||
id: magnifyFactor
|
||||
Layout.fillWidth: true
|
||||
from: 0.1
|
||||
to: 1.0
|
||||
stepSize: 0.05
|
||||
value: cfg_magnifyFactor
|
||||
onValueChanged: cfg_magnifyFactor = value
|
||||
}
|
||||
|
||||
QQC2.Label {
|
||||
text: Math.round(magnifyFactor.value * 100) + "%"
|
||||
font: Kirigami.Theme.smallFont
|
||||
Layout.minimumWidth: Kirigami.Units.gridUnit * 2
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
visible: iconOnly && enableZoomEffect.checked
|
||||
Kirigami.FormData.label: i18nc("@label:slider", "Animation duration:")
|
||||
|
||||
QQC2.Slider {
|
||||
id: zoomDuration
|
||||
Layout.fillWidth: true
|
||||
from: 50
|
||||
to: 500
|
||||
stepSize: 25
|
||||
value: cfg_zoomDuration
|
||||
onValueChanged: cfg_zoomDuration = value
|
||||
}
|
||||
|
||||
QQC2.Label {
|
||||
text: Math.round(zoomDuration.value) + "ms"
|
||||
font: Kirigami.Theme.smallFont
|
||||
Layout.minimumWidth: Kirigami.Units.gridUnit * 2
|
||||
}
|
||||
}
|
||||
|
||||
QQC2.ComboBox {
|
||||
id: zoomEasing
|
||||
visible: iconOnly && enableZoomEffect.checked
|
||||
Kirigami.FormData.label: i18nc("@label:listbox", "Animation style:")
|
||||
|
||||
model: [
|
||||
i18nc("@item:inlistbox animation easing", "Linear"),
|
||||
i18nc("@item:inlistbox animation easing", "Smooth (Quad)"),
|
||||
i18nc("@item:inlistbox animation easing", "Smooth (Cubic)"),
|
||||
i18nc("@item:inlistbox animation easing", "Smooth (Quart)"),
|
||||
i18nc("@item:inlistbox animation easing", "Bouncy (Back)"),
|
||||
i18nc("@item:inlistbox animation easing", "Elastic"),
|
||||
i18nc("@item:inlistbox animation easing", "Bounce")
|
||||
]
|
||||
|
||||
currentIndex: cfg_zoomEasing
|
||||
onActivated: cfg_zoomEasing = currentIndex
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
visible: iconOnly && enableZoomEffect.checked
|
||||
Kirigami.FormData.label: i18nc("@label:slider", "Hover delay:")
|
||||
|
||||
QQC2.Slider {
|
||||
id: hoverDelay
|
||||
Layout.fillWidth: true
|
||||
from: 0
|
||||
to: 300
|
||||
stepSize: 25
|
||||
value: cfg_hoverDelay
|
||||
onValueChanged: cfg_hoverDelay = value
|
||||
}
|
||||
|
||||
QQC2.Label {
|
||||
text: Math.round(hoverDelay.value) + "ms"
|
||||
font: Kirigami.Theme.smallFont
|
||||
Layout.minimumWidth: Kirigami.Units.gridUnit * 2
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
visible: iconOnly && enableZoomEffect.checked
|
||||
Kirigami.FormData.label: i18nc("@label:slider", "Reset delay:")
|
||||
|
||||
QQC2.Slider {
|
||||
id: resetDelay
|
||||
Layout.fillWidth: true
|
||||
from: 0
|
||||
to: 300
|
||||
stepSize: 25
|
||||
value: cfg_resetDelay
|
||||
onValueChanged: cfg_resetDelay = value
|
||||
}
|
||||
|
||||
QQC2.Label {
|
||||
text: Math.round(resetDelay.value) + "ms"
|
||||
font: Kirigami.Theme.smallFont
|
||||
Layout.minimumWidth: Kirigami.Units.gridUnit * 2
|
||||
}
|
||||
}
|
||||
|
||||
QQC2.ComboBox {
|
||||
id: zoomAnchor
|
||||
visible: iconOnly && enableZoomEffect.checked
|
||||
Kirigami.FormData.label: i18nc("@label:listbox", "Zoom anchor:")
|
||||
|
||||
model: [
|
||||
i18nc("@item:inlistbox zoom anchor", "Center"),
|
||||
i18nc("@item:inlistbox zoom anchor", "Bottom (macOS style)"),
|
||||
i18nc("@item:inlistbox zoom anchor", "Top"),
|
||||
i18nc("@item:inlistbox zoom anchor", "Left"),
|
||||
i18nc("@item:inlistbox zoom anchor", "Right"),
|
||||
i18nc("@item:inlistbox zoom anchor", "Bottom Left"),
|
||||
i18nc("@item:inlistbox zoom anchor", "Bottom Right"),
|
||||
i18nc("@item:inlistbox zoom anchor", "Top Left"),
|
||||
i18nc("@item:inlistbox zoom anchor", "Top Right")
|
||||
]
|
||||
|
||||
currentIndex: cfg_zoomAnchor
|
||||
onActivated: cfg_zoomAnchor = currentIndex
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
}
|
||||
|
||||
QQC2.ComboBox {
|
||||
id: launchAnimationType
|
||||
Kirigami.FormData.label: i18nc("@label for launch animation section", "Launch Animation:")
|
||||
|
||||
model: [
|
||||
i18nc("@item:inlistbox launch animation type", "Classic Busy Indicator"),
|
||||
i18nc("@item:inlistbox launch animation type", "Pulsing Icon"),
|
||||
i18nc("@item:inlistbox launch animation type", "Bouncing Icon"),
|
||||
i18nc("@item:inlistbox launch animation type", "Rotating Icon"),
|
||||
i18nc("@item:inlistbox launch animation type", "Scaling Icon"),
|
||||
i18nc("@item:inlistbox launch animation type", "Fading Icon"),
|
||||
i18nc("@item:inlistbox launch animation type", "Glow Effect")
|
||||
]
|
||||
|
||||
currentIndex: cfg_launchAnimationType
|
||||
onActivated: cfg_launchAnimationType = currentIndex
|
||||
}
|
||||
|
||||
QQC2.Label {
|
||||
text: i18nc("@info:usagetip", "Choose how launching applications are visually indicated. Each animation type provides a different visual feedback when starting apps.")
|
||||
font: Kirigami.Theme.smallFont
|
||||
wrapMode: Text.Wrap
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
visible: cfg_launchAnimationType !== 0 // Hide for classic busy indicator
|
||||
Kirigami.FormData.label: i18nc("@label:slider", "Animation duration:")
|
||||
|
||||
QQC2.Slider {
|
||||
id: launchAnimationDuration
|
||||
Layout.fillWidth: true
|
||||
from: 500
|
||||
to: 3000
|
||||
stepSize: 100
|
||||
value: cfg_launchAnimationDuration
|
||||
onValueChanged: cfg_launchAnimationDuration = value
|
||||
}
|
||||
|
||||
QQC2.Label {
|
||||
text: Math.round(launchAnimationDuration.value) + "ms"
|
||||
font: Kirigami.Theme.smallFont
|
||||
Layout.minimumWidth: Kirigami.Units.gridUnit * 2.5
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
visible: cfg_launchAnimationType !== 0 // Hide for classic busy indicator
|
||||
Kirigami.FormData.label: i18nc("@label:slider", "Animation intensity:")
|
||||
|
||||
QQC2.Slider {
|
||||
id: launchAnimationIntensity
|
||||
Layout.fillWidth: true
|
||||
from: 0.1
|
||||
to: 1.0
|
||||
stepSize: 0.05
|
||||
value: cfg_launchAnimationIntensity
|
||||
onValueChanged: cfg_launchAnimationIntensity = value
|
||||
}
|
||||
|
||||
QQC2.Label {
|
||||
text: Math.round(launchAnimationIntensity.value * 100) + "%"
|
||||
font: Kirigami.Theme.smallFont
|
||||
Layout.minimumWidth: Kirigami.Units.gridUnit * 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2013 Eike Hein <hein@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.kcmutils as KCMUtils
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.plasma.core as PlasmaCore
|
||||
import org.kde.plasma.plasmoid
|
||||
|
||||
import org.kde.plasma.workspace.dbus as DBus
|
||||
|
||||
KCMUtils.SimpleKCM {
|
||||
property alias cfg_groupingStrategy: groupingStrategy.currentIndex
|
||||
property alias cfg_groupedTaskVisualization: groupedTaskVisualization.currentIndex
|
||||
property alias cfg_groupPopups: groupPopups.checked
|
||||
property alias cfg_onlyGroupWhenFull: onlyGroupWhenFull.checked
|
||||
property alias cfg_sortingStrategy: sortingStrategy.currentIndex
|
||||
property alias cfg_separateLaunchers: separateLaunchers.checked
|
||||
property alias cfg_hideLauncherOnStart: hideLauncherOnStart.checked
|
||||
property alias cfg_middleClickAction: middleClickAction.currentIndex
|
||||
property alias cfg_wheelEnabled: wheelEnabled.checked
|
||||
property alias cfg_wheelSkipMinimized: wheelSkipMinimized.checked
|
||||
property alias cfg_showOnlyCurrentScreen: showOnlyCurrentScreen.checked
|
||||
property alias cfg_showOnlyCurrentDesktop: showOnlyCurrentDesktop.checked
|
||||
property alias cfg_showOnlyCurrentActivity: showOnlyCurrentActivity.checked
|
||||
property alias cfg_showOnlyMinimized: showOnlyMinimized.checked
|
||||
property alias cfg_minimizeActiveTaskOnClick: minimizeActive.checked
|
||||
property alias cfg_unhideOnAttention: unhideOnAttention.checked
|
||||
property alias cfg_reverseMode: reverseMode.checked
|
||||
|
||||
DBus.DBusServiceWatcher {
|
||||
id: effectWatcher
|
||||
busType: DBus.BusType.Session
|
||||
watchedService: "org.kde.KWin.Effect.WindowView1"
|
||||
}
|
||||
|
||||
Kirigami.FormLayout {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
QQC2.ComboBox {
|
||||
id: groupingStrategy
|
||||
Kirigami.FormData.label: i18nc("@label:listbox how to group tasks", "Group:")
|
||||
Layout.fillWidth: true
|
||||
Layout.minimumWidth: Kirigami.Units.gridUnit * 14
|
||||
model: [
|
||||
i18nc("@item:inlistbox how to group tasks", "Do not group"),
|
||||
i18nc("@item:inlistbox how to group tasks", "By program name")
|
||||
]
|
||||
}
|
||||
|
||||
QQC2.ComboBox {
|
||||
id: groupedTaskVisualization
|
||||
Kirigami.FormData.label: i18nc("@label:listbox completes sentence like: … cycles through tasks", "Clicking grouped task:")
|
||||
Layout.fillWidth: true
|
||||
Layout.minimumWidth: Kirigami.Units.gridUnit * 14
|
||||
|
||||
enabled: groupingStrategy.currentIndex !== 0
|
||||
|
||||
model: [
|
||||
i18nc("@item:inlistbox Completes the sentence 'Clicking grouped task cycles through tasks' ", "Cycles through tasks"),
|
||||
i18nc("@item:inlistbox Completes the sentence 'Clicking grouped task shows small window previews' ", "Shows small window previews"),
|
||||
i18nc("@item:inlistbox Completes the sentence 'Clicking grouped task shows large window previews' ", "Shows large window previews"),
|
||||
i18nc("@item:inlistbox Completes the sentence 'Clicking grouped task shows textual list' ", "Shows textual list"),
|
||||
]
|
||||
|
||||
Accessible.name: currentText
|
||||
Accessible.onPressAction: currentIndex = currentIndex === count - 1 ? 0 : (currentIndex + 1)
|
||||
}
|
||||
// "You asked for Window View but Window View is not available" message
|
||||
Kirigami.InlineMessage {
|
||||
Layout.fillWidth: true
|
||||
visible: groupedTaskVisualization.currentIndex === 2 && !effectWatcher.registered
|
||||
type: Kirigami.MessageType.Warning
|
||||
text: i18nc("@info displayed as InlineMessage", "The compositor does not support displaying windows side by side, so a textual list will be displayed instead.")
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
}
|
||||
|
||||
QQC2.CheckBox {
|
||||
id: groupPopups
|
||||
visible: (Plasmoid.pluginName !== "org.kde.plasma.icontasks" && Plasmoid.pluginName !== "org.kde.plasma.icontasks.zoom")
|
||||
text: i18nc("@option:check grouped task", "Combine into single button")
|
||||
enabled: groupingStrategy.currentIndex > 0
|
||||
}
|
||||
|
||||
QQC2.CheckBox {
|
||||
id: onlyGroupWhenFull
|
||||
visible: (Plasmoid.pluginName !== "org.kde.plasma.icontasks" && Plasmoid.pluginName !== "org.kde.plasma.icontasks.zoom")
|
||||
text: i18nc("@option:check grouped task","Group only when the Task Manager is full")
|
||||
enabled: groupingStrategy.currentIndex > 0 && groupPopups.checked
|
||||
Accessible.onPressAction: toggle()
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
visible: (Plasmoid.pluginName !== "org.kde.plasma.icontasks" && Plasmoid.pluginName !== "org.kde.plasma.icontasks.zoom")
|
||||
}
|
||||
|
||||
QQC2.ComboBox {
|
||||
id: sortingStrategy
|
||||
Kirigami.FormData.label: i18nc("@label:listbox sort tasks in grouped task", "Sort:")
|
||||
Layout.fillWidth: true
|
||||
Layout.minimumWidth: Kirigami.Units.gridUnit * 14
|
||||
model: [
|
||||
i18nc("@item:inlistbox sort tasks in grouped task", "Do not sort"),
|
||||
i18nc("@item:inlistbox sort tasks in grouped task", "Manually"),
|
||||
i18nc("@item:inlistbox sort tasks in grouped task", "Alphabetically"),
|
||||
i18nc("@item:inlistbox sort tasks in grouped task", "By desktop"),
|
||||
i18nc("@item:inlistbox sort tasks in grouped task", "By activity")
|
||||
]
|
||||
}
|
||||
|
||||
QQC2.CheckBox {
|
||||
id: separateLaunchers
|
||||
visible: (Plasmoid.pluginName !== "org.kde.plasma.icontasks" && Plasmoid.pluginName !== "org.kde.plasma.icontasks.zoom")
|
||||
text: i18nc("@option:check configure task sorting", "Keep launchers separate")
|
||||
enabled: sortingStrategy.currentIndex === 1
|
||||
}
|
||||
|
||||
QQC2.CheckBox {
|
||||
id: hideLauncherOnStart
|
||||
visible: (Plasmoid.pluginName !== "org.kde.plasma.icontasks" && Plasmoid.pluginName !== "org.kde.plasma.icontasks.zoom")
|
||||
text: i18nc("@option:check for icons-and-text task manager", "Hide launchers after application startup")
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
visible: (Plasmoid.pluginName !== "org.kde.plasma.icontasks" && Plasmoid.pluginName !== "org.kde.plasma.icontasks.zoom")
|
||||
}
|
||||
|
||||
QQC2.CheckBox {
|
||||
id: minimizeActive
|
||||
Kirigami.FormData.label: i18nc("@label for checkbox Part of a sentence: 'Clicking active task minimizes the task'", "Clicking active task:")
|
||||
text: i18nc("@option:check Part of a sentence: 'Clicking active task minimizes the task'", "Minimizes the task")
|
||||
}
|
||||
|
||||
QQC2.ComboBox {
|
||||
id: middleClickAction
|
||||
Kirigami.FormData.label: i18nc("@label:listbox completes sentence like: … does nothing", "Middle-clicking any task:")
|
||||
Layout.fillWidth: true
|
||||
Layout.minimumWidth: Kirigami.Units.gridUnit * 14
|
||||
model: [
|
||||
i18nc("@item:inlistbox Part of a sentence: 'Middle-clicking any task does nothing'", "Does nothing"),
|
||||
i18nc("@item:inlistbox Part of a sentence: 'Middle-clicking any task closes window or group'", "Closes window or group"),
|
||||
i18nc("@item:inlistbox Part of a sentence: 'Middle-clicking any task opens a new window'", "Opens a new window"),
|
||||
i18nc("@item:inlistbox Part of a sentence: 'Middle-clicking any task minimizes/restores window or group'", "Minimizes/Restores window or group"),
|
||||
i18nc("@item:inlistbox Part of a sentence: 'Middle-clicking any task toggles grouping'", "Toggles grouping"),
|
||||
i18nc("@item:inlistbox Part of a sentence: 'Middle-clicking any task brings it to the current virtual desktop'", "Brings it to the current virtual desktop")
|
||||
]
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
}
|
||||
|
||||
QQC2.CheckBox {
|
||||
id: wheelEnabled
|
||||
Kirigami.FormData.label: i18nc("@label for checkbox Part of a sentence: 'Mouse wheel cycles through tasks'", "Mouse wheel:")
|
||||
text: i18nc("@option:check Part of a sentence: 'Mouse wheel cycles through tasks'", "Cycles through tasks")
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
// HACK: Workaround for Kirigami bug 434625
|
||||
// due to which a simple Layout.leftMargin on QQC2.CheckBox doesn't work
|
||||
Item { implicitWidth: Kirigami.Units.gridUnit }
|
||||
QQC2.CheckBox {
|
||||
id: wheelSkipMinimized
|
||||
text: i18nc("@option:check mouse wheel task cycling", "Skip minimized tasks")
|
||||
enabled: wheelEnabled.checked
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
}
|
||||
|
||||
QQC2.CheckBox {
|
||||
id: showOnlyCurrentScreen
|
||||
Kirigami.FormData.label: i18nc("@label for checkbox group, completes sentence like: … from current screen", "Show only tasks:")
|
||||
text: i18nc("@option:check completes sentence: show only tasks", "From current screen")
|
||||
}
|
||||
|
||||
QQC2.CheckBox {
|
||||
id: showOnlyCurrentDesktop
|
||||
text: i18nc("@option:check completes sentence: show only tasks", "From current desktop")
|
||||
}
|
||||
|
||||
QQC2.CheckBox {
|
||||
id: showOnlyCurrentActivity
|
||||
text: i18nc("@option:check completes sentence: show only tasks", "From current activity")
|
||||
}
|
||||
|
||||
QQC2.CheckBox {
|
||||
id: showOnlyMinimized
|
||||
text: i18nc("@option:check completes sentence: show only tasks", "That are minimized")
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
}
|
||||
|
||||
QQC2.CheckBox {
|
||||
id: unhideOnAttention
|
||||
Kirigami.FormData.label: i18nc("@label for checkbox, completes sentence: … unhide if window wants attention", "When panel is hidden:")
|
||||
text: i18nc("@option:check completes sentence: When panel is hidden", "Unhide when a window wants attention")
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
}
|
||||
|
||||
QQC2.ButtonGroup {
|
||||
id: reverseModeRadioButtonGroup
|
||||
}
|
||||
|
||||
QQC2.RadioButton {
|
||||
Kirigami.FormData.label: i18nc("@label for radiobutton group completes sentence like: … on the bottom", "New tasks appear:")
|
||||
checked: !reverseMode.checked
|
||||
text: {
|
||||
if (Plasmoid.formFactor === PlasmaCore.Types.Vertical) {
|
||||
return i18nc("@option:check completes sentence: New tasks appear", "On the bottom")
|
||||
}
|
||||
// horizontal
|
||||
if (Qt.application.layoutDirection === Qt.LeftToRight) {
|
||||
return i18nc("@option:check completes sentence: New tasks appear", "To the right");
|
||||
} else {
|
||||
return i18nc("@option:check completes sentence: New tasks appear", "To the left")
|
||||
}
|
||||
}
|
||||
QQC2.ButtonGroup.group: reverseModeRadioButtonGroup
|
||||
}
|
||||
|
||||
QQC2.RadioButton {
|
||||
id: reverseMode
|
||||
checked: Plasmoid.configuration.reverseMode === true
|
||||
text: {
|
||||
if (Plasmoid.formFactor === PlasmaCore.Types.Vertical) {
|
||||
return i18nc("@option:check completes sentence: New tasks appear", "On the top")
|
||||
}
|
||||
// horizontal
|
||||
if (Qt.application.layoutDirection === Qt.LeftToRight) {
|
||||
return i18nc("@option:check completes sentence: New tasks appear", "To the left");
|
||||
} else {
|
||||
return i18nc("@option:check completes sentence: New tasks appear", "To the right");
|
||||
}
|
||||
}
|
||||
QQC2.ButtonGroup.group: reverseModeRadioButtonGroup
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,774 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2012-2016 Eike Hein <hein@kde.org>
|
||||
SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
import QtQuick
|
||||
|
||||
import org.kde.plasma.plasmoid
|
||||
|
||||
import org.kde.plasma.core as PlasmaCore
|
||||
import org.kde.plasma.extras as PlasmaExtras
|
||||
|
||||
import org.kde.taskmanager as TaskManager
|
||||
import org.kde.plasma.private.mpris as Mpris
|
||||
import org.kde.plasma.private.taskmanager as TaskManagerApplet
|
||||
|
||||
import "code/layoutmetrics.js" as LayoutMetrics
|
||||
|
||||
PlasmaExtras.Menu {
|
||||
id: menu
|
||||
|
||||
required property TaskManagerApplet.Backend backend
|
||||
required property Mpris.Mpris2Model mpris2Source
|
||||
required property /*QModelIndex*/var modelIndex
|
||||
|
||||
readonly property var atm: TaskManager.AbstractTasksModel
|
||||
|
||||
property bool showAllPlaces: false
|
||||
|
||||
placement: {
|
||||
if (Plasmoid.location === PlasmaCore.Types.LeftEdge) {
|
||||
return PlasmaExtras.Menu.RightPosedTopAlignedPopup;
|
||||
} else if (Plasmoid.location === PlasmaCore.Types.TopEdge) {
|
||||
return PlasmaExtras.Menu.BottomPosedLeftAlignedPopup;
|
||||
} else if (Plasmoid.location === PlasmaCore.Types.RightEdge) {
|
||||
return PlasmaExtras.Menu.LeftPosedTopAlignedPopup;
|
||||
} else {
|
||||
return PlasmaExtras.Menu.TopPosedLeftAlignedPopup;
|
||||
}
|
||||
}
|
||||
|
||||
minimumWidth: visualParent.width
|
||||
|
||||
onStatusChanged: {
|
||||
if (visualParent && get(atm.LauncherUrlWithoutIcon).toString() !== "" && status === PlasmaExtras.Menu.Open) {
|
||||
activitiesDesktopsMenu.refresh();
|
||||
|
||||
} else if (status === PlasmaExtras.Menu.Closed) {
|
||||
menu.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
// Cannot have "Connections" as child of PlasmaExtras.Menu.
|
||||
backend.showAllPlaces.connect(showContextMenuWithAllPlaces);
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
backend.showAllPlaces.disconnect(showContextMenuWithAllPlaces);
|
||||
}
|
||||
|
||||
function showContextMenuWithAllPlaces(): void {
|
||||
visualParent.showContextMenu({showAllPlaces: true});
|
||||
}
|
||||
|
||||
function get(modelProp: int): var {
|
||||
return tasksModel.data(modelIndex, modelProp)
|
||||
}
|
||||
|
||||
function show(): void {
|
||||
Plasmoid.contextualActionsAboutToShow();
|
||||
|
||||
loadDynamicLaunchActions(get(atm.LauncherUrlWithoutIcon));
|
||||
openRelative();
|
||||
}
|
||||
|
||||
function newMenuItem(parent: QtObject): PlasmaExtras.MenuItem {
|
||||
return Qt.createQmlObject(`
|
||||
import org.kde.plasma.extras as PlasmaExtras
|
||||
|
||||
PlasmaExtras.MenuItem {}
|
||||
`, parent);
|
||||
}
|
||||
|
||||
function newSeparator(parent: QtObject): PlasmaExtras.MenuItem {
|
||||
return Qt.createQmlObject(`
|
||||
import org.kde.plasma.extras as PlasmaExtras
|
||||
|
||||
PlasmaExtras.MenuItem { separator: true }
|
||||
`, parent);
|
||||
}
|
||||
|
||||
function loadDynamicLaunchActions(launcherUrl: url): void {
|
||||
const sections = [];
|
||||
|
||||
const placesActions = backend.placesActions(launcherUrl, showAllPlaces, menu);
|
||||
|
||||
if (placesActions.length > 0) {
|
||||
sections.push({
|
||||
title: i18n("Places"),
|
||||
group: "places",
|
||||
actions: placesActions
|
||||
});
|
||||
} else {
|
||||
sections.push({
|
||||
title: i18n("Recent Files"),
|
||||
group: "recents",
|
||||
actions: backend.recentDocumentActions(launcherUrl, menu)
|
||||
});
|
||||
}
|
||||
|
||||
sections.push({
|
||||
title: i18n("Actions"),
|
||||
group: "actions",
|
||||
actions: backend.jumpListActions(launcherUrl, menu)
|
||||
});
|
||||
|
||||
// C++ can override section heading by returning a QString as first action
|
||||
sections.forEach((section) => {
|
||||
if (typeof section.actions[0] === "string") {
|
||||
section.title = section.actions.shift(); // take first
|
||||
}
|
||||
});
|
||||
|
||||
// QMenu does not limit its width automatically. Even if we set a maximumWidth
|
||||
// it would just cut off text rather than eliding. So we do this manually.
|
||||
const textMetrics = Qt.createQmlObject("import QtQuick; TextMetrics {}", menu);
|
||||
textMetrics.elide = Qt.ElideRight;
|
||||
textMetrics.elideWidth = LayoutMetrics.maximumContextMenuTextWidth();
|
||||
|
||||
sections.forEach(section => {
|
||||
if (section["actions"].length > 0 || section["group"] === "actions") {
|
||||
// Don't add the "Actions" header if the menu has nothing but actions
|
||||
// in it, because then it's redundant (all menus have actions)
|
||||
if (
|
||||
(section["group"] !== "actions") ||
|
||||
(section["group"] === "actions" && (sections[0]["actions"].length > 0 || sections[1]["actions"].length > 0))
|
||||
) {
|
||||
var sectionHeader = newMenuItem(menu);
|
||||
sectionHeader.text = section["title"];
|
||||
sectionHeader.section = true;
|
||||
menu.addMenuItem(sectionHeader, startNewInstanceItem);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < section["actions"].length; ++i) {
|
||||
var item = newMenuItem(menu);
|
||||
item.action = section["actions"][i];
|
||||
|
||||
textMetrics.text = item.action.text;
|
||||
item.action.text = textMetrics.elidedText;
|
||||
|
||||
menu.addMenuItem(item, startNewInstanceItem);
|
||||
}
|
||||
});
|
||||
|
||||
// Add Media Player control actions
|
||||
const playerData = mpris2Source.playerForLauncherUrl(launcherUrl, get(atm.AppPid));
|
||||
|
||||
if (playerData && playerData.canControl && !(get(atm.WinIdList) !== undefined && get(atm.WinIdList).length > 1)) {
|
||||
const playing = playerData.playbackStatus === Mpris.PlaybackStatus.Playing;
|
||||
let menuItem = menu.newMenuItem(menu);
|
||||
menuItem.text = i18nc("Play previous track", "Previous Track");
|
||||
menuItem.icon = "media-skip-backward";
|
||||
menuItem.enabled = Qt.binding(() => {
|
||||
return playerData.canGoPrevious;
|
||||
});
|
||||
menuItem.clicked.connect(() => {
|
||||
playerData.Previous();
|
||||
});
|
||||
menu.addMenuItem(menuItem, startNewInstanceItem);
|
||||
|
||||
menuItem = menu.newMenuItem(menu);
|
||||
// PlasmaCore Menu doesn't actually handle icons or labels changing at runtime...
|
||||
menuItem.text = Qt.binding(() => {
|
||||
// if CanPause, toggle the menu entry between Play & Pause, otherwise always use Play
|
||||
return playing && playerData.canPause ? i18nc("Pause playback", "Pause") : i18nc("Start playback", "Play");
|
||||
});
|
||||
menuItem.icon = Qt.binding(() => {
|
||||
return playing && playerData.canPause ? "media-playback-pause" : "media-playback-start";
|
||||
});
|
||||
menuItem.enabled = Qt.binding(() => {
|
||||
return playing ? playerData.canPause : playerData.canPlay;
|
||||
});
|
||||
menuItem.clicked.connect(() => {
|
||||
if (playing) {
|
||||
playerData.Pause();
|
||||
} else {
|
||||
playerData.Play();
|
||||
}
|
||||
});
|
||||
menu.addMenuItem(menuItem, startNewInstanceItem);
|
||||
|
||||
menuItem = menu.newMenuItem(menu);
|
||||
menuItem.text = i18nc("Play next track", "Next Track");
|
||||
menuItem.icon = "media-skip-forward";
|
||||
menuItem.enabled = Qt.binding(() => {
|
||||
return playerData.canGoNext;
|
||||
});
|
||||
menuItem.clicked.connect(() => {
|
||||
playerData.Next();
|
||||
});
|
||||
menu.addMenuItem(menuItem, startNewInstanceItem);
|
||||
|
||||
menuItem = menu.newMenuItem(menu);
|
||||
menuItem.text = i18nc("Stop playback", "Stop");
|
||||
menuItem.icon = "media-playback-stop";
|
||||
menuItem.enabled = Qt.binding(() => {
|
||||
return playerData.canStop;
|
||||
});
|
||||
menuItem.clicked.connect(() => {
|
||||
playerData.Stop();
|
||||
});
|
||||
menu.addMenuItem(menuItem, startNewInstanceItem);
|
||||
|
||||
// Technically media controls and audio streams are separate but for the user they're
|
||||
// semantically related, don't add a separator inbetween.
|
||||
if (!menu.visualParent.hasAudioStream) {
|
||||
menu.addMenuItem(newSeparator(menu), startNewInstanceItem);
|
||||
}
|
||||
|
||||
// If we don't have a window associated with the player but we can quit
|
||||
// it through MPRIS we'll offer a "Quit" option instead of "Close"
|
||||
if (!closeWindowItem.visible && playerData.canQuit) {
|
||||
menuItem = menu.newMenuItem(menu);
|
||||
menuItem.text = i18nc("Quit media player app", "Quit");
|
||||
menuItem.icon = "application-exit";
|
||||
menuItem.visible = Qt.binding(() => {
|
||||
return !closeWindowItem.visible;
|
||||
});
|
||||
menuItem.clicked.connect(() => {
|
||||
playerData.Quit();
|
||||
});
|
||||
menu.addMenuItem(menuItem);
|
||||
}
|
||||
|
||||
// If we don't have a window associated with the player but we can raise
|
||||
// it through MPRIS we'll offer a "Restore" option
|
||||
if (get(atm.IsLauncher) && !startNewInstanceItem.visible && playerData.canRaise) {
|
||||
menuItem = menu.newMenuItem(menu);
|
||||
menuItem.text = i18nc("Open or bring to the front window of media player app", "Restore");
|
||||
menuItem.icon = playerData.iconName;
|
||||
menuItem.visible = Qt.binding(() => {
|
||||
return !startNewInstanceItem.visible;
|
||||
});
|
||||
menuItem.clicked.connect(() => {
|
||||
playerData.Raise();
|
||||
});
|
||||
menu.addMenuItem(menuItem, startNewInstanceItem);
|
||||
}
|
||||
}
|
||||
|
||||
// We allow mute/unmute whenever an application has a stream, regardless of whether it
|
||||
// is actually playing sound.
|
||||
// This way you can unmute, e.g. a telephony app, even after the conversation has ended,
|
||||
// so you still have it ringing later on.
|
||||
if (menu.visualParent.hasAudioStream) {
|
||||
const muteItem = menu.newMenuItem(menu);
|
||||
muteItem.checkable = true;
|
||||
muteItem.checked = Qt.binding(() => {
|
||||
return menu.visualParent && menu.visualParent.muted;
|
||||
});
|
||||
muteItem.clicked.connect(() => {
|
||||
menu.visualParent.toggleMuted();
|
||||
});
|
||||
muteItem.text = i18n("Mute");
|
||||
muteItem.icon = "audio-volume-muted";
|
||||
menu.addMenuItem(muteItem, startNewInstanceItem);
|
||||
|
||||
menu.addMenuItem(newSeparator(menu), startNewInstanceItem);
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
id: startNewInstanceItem
|
||||
visible: get(atm.CanLaunchNewInstance)
|
||||
text: i18n("Open New Window")
|
||||
icon: "window-new"
|
||||
|
||||
onClicked: tasksModel.requestNewInstance(modelIndex)
|
||||
}
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
id: virtualDesktopsMenuItem
|
||||
|
||||
visible: virtualDesktopInfo.numberOfDesktops > 1
|
||||
&& (visualParent && !get(atm.IsLauncher)
|
||||
&& !get(atm.IsStartup)
|
||||
&& get(atm.IsVirtualDesktopsChangeable))
|
||||
|
||||
enabled: visible
|
||||
|
||||
text: i18n("Move to &Desktop")
|
||||
icon: "virtual-desktops"
|
||||
|
||||
readonly property Connections virtualDesktopsMenuConnections: Connections {
|
||||
target: virtualDesktopInfo
|
||||
|
||||
function onNumberOfDesktopsChanged(): void {
|
||||
Qt.callLater(virtualDesktopsMenu.refresh);
|
||||
}
|
||||
function onDesktopIdsChanged(): void {
|
||||
Qt.callLater(virtualDesktopsMenu.refresh);
|
||||
}
|
||||
function onDesktopNamesChanged(): void {
|
||||
Qt.callLater(virtualDesktopsMenu.refresh);
|
||||
}
|
||||
}
|
||||
|
||||
readonly property PlasmaExtras.Menu _virtualDesktopsMenu: PlasmaExtras.Menu {
|
||||
id: virtualDesktopsMenu
|
||||
|
||||
visualParent: virtualDesktopsMenuItem.action
|
||||
|
||||
function refresh(): void {
|
||||
clearMenuItems();
|
||||
|
||||
if (virtualDesktopInfo.numberOfDesktops <= 1 || !virtualDesktopsMenuItem.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
let menuItem = menu.newMenuItem(virtualDesktopsMenu);
|
||||
menuItem.text = i18n("Move &To Current Desktop");
|
||||
menuItem.enabled = Qt.binding(() => {
|
||||
return menu.visualParent && menu.get(atm.VirtualDesktops).indexOf(virtualDesktopInfo.currentDesktop) === -1;
|
||||
});
|
||||
menuItem.clicked.connect(() => {
|
||||
tasksModel.requestVirtualDesktops(menu.modelIndex, [virtualDesktopInfo.currentDesktop]);
|
||||
});
|
||||
|
||||
menuItem = menu.newMenuItem(virtualDesktopsMenu);
|
||||
menuItem.text = i18n("&All Desktops");
|
||||
menuItem.checkable = true;
|
||||
menuItem.checked = Qt.binding(() => {
|
||||
return menu.visualParent && menu.get(atm.IsOnAllVirtualDesktops);
|
||||
});
|
||||
menuItem.clicked.connect(() => {
|
||||
tasksModel.requestVirtualDesktops(menu.modelIndex, []);
|
||||
});
|
||||
backend.setActionGroup(menuItem.action);
|
||||
|
||||
menu.newSeparator(virtualDesktopsMenu);
|
||||
|
||||
for (let i = 0; i < virtualDesktopInfo.desktopNames.length; ++i) {
|
||||
menuItem = menu.newMenuItem(virtualDesktopsMenu);
|
||||
menuItem.text = virtualDesktopInfo.desktopNames[i];
|
||||
menuItem.checkable = true;
|
||||
menuItem.checked = Qt.binding((i => {
|
||||
return () => menu.visualParent && menu.get(atm.VirtualDesktops).indexOf(virtualDesktopInfo.desktopIds[i]) > -1;
|
||||
})(i));
|
||||
menuItem.clicked.connect((i => {
|
||||
return () => tasksModel.requestVirtualDesktops(menu.modelIndex, [virtualDesktopInfo.desktopIds[i]]);
|
||||
})(i));
|
||||
backend.setActionGroup(menuItem.action);
|
||||
}
|
||||
|
||||
menu.newSeparator(virtualDesktopsMenu);
|
||||
|
||||
menuItem = menu.newMenuItem(virtualDesktopsMenu);
|
||||
menuItem.text = i18n("&New Desktop");
|
||||
menuItem.icon = "list-add";
|
||||
menuItem.clicked.connect(() => {
|
||||
tasksModel.requestNewVirtualDesktop(menu.modelIndex);
|
||||
});
|
||||
}
|
||||
|
||||
Component.onCompleted: refresh()
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
id: activitiesDesktopsMenuItem
|
||||
|
||||
visible: activityInfo.numberOfRunningActivities > 1
|
||||
&& (visualParent && !get(atm.IsLauncher)
|
||||
&& !get(atm.IsStartup))
|
||||
|
||||
enabled: visible
|
||||
|
||||
text: i18n("Show in &Activities")
|
||||
icon: "activities"
|
||||
|
||||
readonly property Connections activityInfoConnections: Connections {
|
||||
target: activityInfo
|
||||
|
||||
function onNumberOfRunningActivitiesChanged(): void {
|
||||
activitiesDesktopsMenu.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
readonly property PlasmaExtras.Menu _activitiesDesktopsMenu: PlasmaExtras.Menu {
|
||||
id: activitiesDesktopsMenu
|
||||
|
||||
visualParent: activitiesDesktopsMenuItem.action
|
||||
|
||||
function refresh(): void {
|
||||
clearMenuItems();
|
||||
|
||||
if (activityInfo.numberOfRunningActivities <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
let menuItem = menu.newMenuItem(activitiesDesktopsMenu);
|
||||
menuItem.text = i18n("Add To Current Activity");
|
||||
menuItem.enabled = Qt.binding(() => {
|
||||
return menu.visualParent && menu.get(atm.Activities).length > 0 &&
|
||||
menu.get(atm.Activities).indexOf(activityInfo.currentActivity) < 0;
|
||||
});
|
||||
menuItem.clicked.connect(() => {
|
||||
tasksModel.requestActivities(menu.modelIndex, menu.get(atm.Activities).concat(activityInfo.currentActivity));
|
||||
});
|
||||
|
||||
menuItem = menu.newMenuItem(activitiesDesktopsMenu);
|
||||
menuItem.text = i18n("All Activities");
|
||||
menuItem.checkable = true;
|
||||
menuItem.checked = Qt.binding(() => {
|
||||
return menu.visualParent && menu.get(atm.Activities).length === 0;
|
||||
});
|
||||
menuItem.toggled.connect(checked => {
|
||||
let newActivities = []; // will cast to an empty QStringList i.e all activities
|
||||
if (!checked) {
|
||||
newActivities = [activityInfo.currentActivity];
|
||||
}
|
||||
tasksModel.requestActivities(menu.modelIndex, newActivities);
|
||||
});
|
||||
|
||||
menu.newSeparator(activitiesDesktopsMenu);
|
||||
|
||||
const runningActivities = activityInfo.runningActivities();
|
||||
for (let i = 0; i < runningActivities.length; ++i) {
|
||||
const activityId = runningActivities[i];
|
||||
|
||||
menuItem = menu.newMenuItem(activitiesDesktopsMenu);
|
||||
menuItem.text = activityInfo.activityName(runningActivities[i]);
|
||||
menuItem.icon = activityInfo.activityIcon(runningActivities[i]);
|
||||
menuItem.checkable = true;
|
||||
menuItem.checked = Qt.binding((activityId => {
|
||||
return () => menu.visualParent && menu.get(atm.Activities).indexOf(activityId) >= 0;
|
||||
})(activityId));
|
||||
menuItem.toggled.connect((activityId => {
|
||||
return checked => {
|
||||
let newActivities = menu.get(atm.Activities);
|
||||
if (checked) {
|
||||
newActivities = newActivities.concat(activityId);
|
||||
} else {
|
||||
const index = newActivities.indexOf(activityId);
|
||||
if (index < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
newActivities.splice(index, 1);
|
||||
}
|
||||
return tasksModel.requestActivities(menu.modelIndex, newActivities);
|
||||
};
|
||||
})(activityId));
|
||||
}
|
||||
|
||||
menu.newSeparator(activitiesDesktopsMenu);
|
||||
|
||||
for (let i = 0; i < runningActivities.length; ++i) {
|
||||
const activityId = runningActivities[i];
|
||||
const onActivities = menu.get(atm.Activities);
|
||||
|
||||
// if the task is on a single activity, don't insert a "move to" item for that activity
|
||||
if (onActivities.length === 1 && onActivities[0] === activityId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
menuItem = menu.newMenuItem(activitiesDesktopsMenu);
|
||||
menuItem.text = i18n("Move to %1", activityInfo.activityName(activityId))
|
||||
menuItem.icon = activityInfo.activityIcon(activityId)
|
||||
menuItem.clicked.connect((activityId => {
|
||||
return () => tasksModel.requestActivities(menu.modelIndex, [activityId]);
|
||||
})(activityId));
|
||||
}
|
||||
|
||||
menu.newSeparator(activitiesDesktopsMenu);
|
||||
}
|
||||
|
||||
Component.onCompleted: refresh()
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
id: launcherToggleAction
|
||||
|
||||
visible: visualParent
|
||||
&& !get(atm.IsLauncher)
|
||||
&& !get(atm.IsStartup)
|
||||
&& Plasmoid.immutability !== PlasmaCore.Types.SystemImmutable
|
||||
&& (activityInfo.numberOfRunningActivities < 2)
|
||||
&& !doesBelongToCurrentActivity()
|
||||
|
||||
enabled: visualParent && get(atm.LauncherUrlWithoutIcon).toString() !== ""
|
||||
|
||||
text: i18n("&Pin to Task Manager")
|
||||
icon: "window-pin"
|
||||
|
||||
function doesBelongToCurrentActivity(): bool {
|
||||
return tasksModel.launcherActivities(get(atm.LauncherUrlWithoutIcon))
|
||||
.some(activity => activity === activityInfo.currentActivity || activity === activityInfo.nullUuid);
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
tasksModel.requestAddLauncher(get(atm.LauncherUrl));
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
id: showLauncherInActivitiesItem
|
||||
|
||||
text: i18n("&Pin to Task Manager")
|
||||
icon: "window-pin"
|
||||
|
||||
visible: visualParent
|
||||
&& !get(atm.IsStartup)
|
||||
&& Plasmoid.immutability !== PlasmaCore.Types.SystemImmutable
|
||||
&& (activityInfo.numberOfRunningActivities >= 2)
|
||||
|
||||
readonly property Connections activitiesLaunchersMenuConnections: Connections {
|
||||
target: activityInfo
|
||||
|
||||
function onNumberOfRunningActivitiesChanged(): void {
|
||||
activitiesDesktopsMenu.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
readonly property PlasmaExtras.Menu _activitiesLaunchersMenu: PlasmaExtras.Menu {
|
||||
id: activitiesLaunchersMenu
|
||||
visualParent: showLauncherInActivitiesItem.action
|
||||
|
||||
function refresh(): void {
|
||||
clearMenuItems();
|
||||
|
||||
if (menu.visualParent === null) return;
|
||||
|
||||
const createNewItem = (id, title, iconName, url, activities) => {
|
||||
var result = menu.newMenuItem(activitiesLaunchersMenu);
|
||||
result.text = title;
|
||||
result.icon = iconName;
|
||||
|
||||
result.visible = true;
|
||||
result.checkable = true;
|
||||
|
||||
result.checked = activities.some(activity => activity === id);
|
||||
|
||||
result.clicked.connect(() => {
|
||||
if (result.checked) {
|
||||
tasksModel.requestAddLauncherToActivity(url, id);
|
||||
} else {
|
||||
tasksModel.requestRemoveLauncherFromActivity(url, id);
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
if (menu.visualParent === null) return;
|
||||
|
||||
const url = menu.get(atm.LauncherUrlWithoutIcon);
|
||||
|
||||
const activities = tasksModel.launcherActivities(url);
|
||||
|
||||
createNewItem(activityInfo.nullUuid, i18n("On All Activities"), "", url, activities);
|
||||
|
||||
if (activityInfo.numberOfRunningActivities <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
createNewItem(activityInfo.currentActivity, i18n("On The Current Activity"), activityInfo.activityIcon(activityInfo.currentActivity), url, activities);
|
||||
|
||||
menu.newSeparator(activitiesLaunchersMenu);
|
||||
|
||||
activityInfo.runningActivities()
|
||||
.forEach(id => {
|
||||
createNewItem(id, activityInfo.activityName(id), activityInfo.activityIcon(id), url, activities);
|
||||
});
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
menu.visualParentChanged.connect(refresh);
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
visible: (visualParent
|
||||
&& get(atm.IsStartup) !== true
|
||||
&& Plasmoid.immutability !== PlasmaCore.Types.SystemImmutable
|
||||
&& !launcherToggleAction.visible
|
||||
&& activityInfo.numberOfRunningActivities < 2)
|
||||
|
||||
text: i18n("Unpin from Task Manager")
|
||||
icon: "window-unpin"
|
||||
|
||||
onClicked: {
|
||||
tasksModel.requestRemoveLauncher(get(atm.LauncherUrlWithoutIcon));
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
id: moreActionsMenuItem
|
||||
|
||||
visible: (visualParent && !get(atm.IsLauncher) && !get(atm.IsStartup))
|
||||
|
||||
enabled: visible
|
||||
|
||||
text: i18n("More")
|
||||
icon: "view-more-symbolic"
|
||||
|
||||
readonly property PlasmaExtras.Menu moreMenu: PlasmaExtras.Menu {
|
||||
visualParent: moreActionsMenuItem.action
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
enabled: menu.visualParent && menu.get(atm.IsMovable)
|
||||
|
||||
text: i18n("&Move")
|
||||
icon: "transform-move"
|
||||
|
||||
onClicked: tasksModel.requestMove(menu.modelIndex)
|
||||
}
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
enabled: menu.visualParent && menu.get(atm.IsResizable)
|
||||
|
||||
text: i18n("Re&size")
|
||||
icon: "transform-scale"
|
||||
|
||||
onClicked: tasksModel.requestResize(menu.modelIndex)
|
||||
}
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
visible: (menu.visualParent && !get(atm.IsLauncher) && !get(atm.IsStartup))
|
||||
|
||||
enabled: menu.visualParent && get(atm.IsMaximizable)
|
||||
|
||||
checkable: true
|
||||
checked: menu.visualParent && get(atm.IsMaximized)
|
||||
|
||||
text: i18n("Ma&ximize")
|
||||
icon: "window-maximize"
|
||||
|
||||
onClicked: tasksModel.requestToggleMaximized(modelIndex)
|
||||
}
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
visible: (menu.visualParent && !get(atm.IsLauncher) && !get(atm.IsStartup))
|
||||
|
||||
enabled: menu.visualParent && get(atm.IsMinimizable)
|
||||
|
||||
checkable: true
|
||||
checked: menu.visualParent && get(atm.IsMinimized)
|
||||
|
||||
text: i18n("Mi&nimize")
|
||||
icon: "window-minimize"
|
||||
|
||||
onClicked: tasksModel.requestToggleMinimized(modelIndex)
|
||||
}
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
checkable: true
|
||||
checked: menu.visualParent && menu.get(atm.IsKeepAbove)
|
||||
|
||||
text: i18n("Keep &Above Others")
|
||||
icon: "window-keep-above"
|
||||
|
||||
onClicked: tasksModel.requestToggleKeepAbove(menu.modelIndex)
|
||||
}
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
checkable: true
|
||||
checked: menu.visualParent && menu.get(atm.IsKeepBelow)
|
||||
|
||||
text: i18n("Keep &Below Others")
|
||||
icon: "window-keep-below"
|
||||
|
||||
onClicked: tasksModel.requestToggleKeepBelow(menu.modelIndex)
|
||||
}
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
enabled: menu.visualParent && menu.get(atm.IsFullScreenable)
|
||||
|
||||
checkable: true
|
||||
checked: menu.visualParent && menu.get(atm.IsFullScreen)
|
||||
|
||||
text: i18n("&Fullscreen")
|
||||
icon: "view-fullscreen"
|
||||
|
||||
onClicked: tasksModel.requestToggleFullScreen(menu.modelIndex)
|
||||
}
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
enabled: menu.visualParent && menu.get(atm.IsShadeable)
|
||||
|
||||
checkable: true
|
||||
checked: menu.visualParent && menu.get(atm.IsShaded)
|
||||
|
||||
text: i18n("&Shade")
|
||||
icon: "window-shade"
|
||||
|
||||
onClicked: tasksModel.requestToggleShaded(menu.modelIndex)
|
||||
}
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
separator: true
|
||||
}
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
visible: (Plasmoid.configuration.groupingStrategy !== 0) && menu.get(atm.IsWindow)
|
||||
|
||||
checkable: true
|
||||
checked: menu.visualParent && menu.get(atm.IsGroupable)
|
||||
|
||||
text: i18n("Allow this program to be grouped")
|
||||
icon: "view-group"
|
||||
|
||||
onClicked: tasksModel.requestToggleGrouping(menu.modelIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaExtras.MenuItem { separator: true }
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
property QtObject configureAction: null
|
||||
|
||||
enabled: configureAction && configureAction.enabled
|
||||
visible: configureAction && configureAction.visible
|
||||
|
||||
text: configureAction ? configureAction.text : ""
|
||||
icon: configureAction ? configureAction.icon : ""
|
||||
|
||||
onClicked: configureAction.trigger()
|
||||
|
||||
Component.onCompleted: configureAction = Plasmoid.internalAction("configure")
|
||||
}
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
property QtObject editModeAction: null
|
||||
|
||||
enabled: editModeAction && editModeAction.enabled
|
||||
visible: editModeAction && editModeAction.visible
|
||||
|
||||
text: editModeAction ? editModeAction.text : ""
|
||||
icon: editModeAction ? editModeAction.icon : ""
|
||||
|
||||
onClicked: editModeAction.trigger()
|
||||
|
||||
Component.onCompleted: editModeAction = Plasmoid.containment.internalAction("configure")
|
||||
}
|
||||
|
||||
PlasmaExtras.MenuItem { separator: true }
|
||||
|
||||
PlasmaExtras.MenuItem {
|
||||
id: closeWindowItem
|
||||
visible: (visualParent && !get(atm.IsLauncher) && !get(atm.IsStartup))
|
||||
|
||||
enabled: visualParent && get(atm.IsClosable)
|
||||
|
||||
text: get(atm.IsGroupParent) ? i18nc("@item:inmenu", "&Close All") : i18n("&Close")
|
||||
icon: "window-close"
|
||||
|
||||
onClicked: {
|
||||
if (tasks.groupDialog !== null && tasks.groupDialog.visualParent === visualParent) {
|
||||
tasks.groupDialog.visible = false;
|
||||
}
|
||||
|
||||
tasksModel.requestClose(modelIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2012-2013 Eike Hein <hein@kde.org>
|
||||
SPDX-FileCopyrightText: 2021 Fushan Wen <qydwhotmail@gmail.com>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
import QtQuick
|
||||
import QtQml.Models
|
||||
|
||||
import org.kde.plasma.core as PlasmaCore
|
||||
import org.kde.plasma.components as PlasmaComponents3
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.plasma.plasmoid
|
||||
|
||||
import "code/layoutmetrics.js" as LayoutMetrics
|
||||
|
||||
PlasmaCore.Dialog {
|
||||
id: groupDialog
|
||||
visible: true
|
||||
|
||||
type: PlasmaCore.Dialog.PopupMenu
|
||||
flags: Qt.WindowStaysOnTopHint
|
||||
hideOnWindowDeactivate: true
|
||||
location: Plasmoid.location
|
||||
|
||||
readonly property real preferredWidth: Screen.width / 3
|
||||
readonly property real preferredHeight: Screen.height / 2
|
||||
readonly property real contentWidth: mainItem.width // No padding here to avoid text elide.
|
||||
|
||||
property /*PlasmaCore.ItemStatus*/int _oldAppletStatus: PlasmaCore.Types.UnknownStatus
|
||||
|
||||
function findActiveTaskIndex(): void {
|
||||
if (!tasksModel.activeTask) {
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < groupListView.count; i++) {
|
||||
if (tasksModel.makeModelIndex(visualParent.index, i) === tasksModel.activeTask) {
|
||||
groupListView.positionViewAtIndex(i, ListView.Contain); // Prevent visual glitches
|
||||
groupListView.currentIndex = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mainItem: MouseHandler {
|
||||
id: mouseHandler
|
||||
width: Math.min(groupDialog.preferredWidth, Math.max(groupListView.maxWidth, groupDialog.visualParent.width))
|
||||
height: Math.min(groupDialog.preferredHeight, groupListView.maxHeight)
|
||||
|
||||
target: groupListView
|
||||
handleWheelEvents: !scrollView.overflowing
|
||||
isGroupDialog: true
|
||||
|
||||
Keys.onEscapePressed: event => {
|
||||
groupDialog.visible = false;
|
||||
}
|
||||
|
||||
function moveRow(event: KeyEvent, insertAt: int): void {
|
||||
if (!(event.modifiers & Qt.ControlModifier) || !(event.modifiers & Qt.ShiftModifier)) {
|
||||
event.accepted = false;
|
||||
return;
|
||||
} else if (insertAt < 0 || insertAt >= groupListView.count) {
|
||||
return;
|
||||
}
|
||||
|
||||
const parentModelIndex = tasksModel.makeModelIndex(groupDialog.visualParent.index);
|
||||
const status = tasksModel.move(groupListView.currentIndex, insertAt, parentModelIndex);
|
||||
if (!status) {
|
||||
return;
|
||||
}
|
||||
|
||||
groupListView.currentIndex = insertAt;
|
||||
}
|
||||
|
||||
PlasmaComponents3.ScrollView {
|
||||
id: scrollView
|
||||
|
||||
// To achieve a bottom-to-top layout on vertical panels, the task manager
|
||||
// is rotated by 180 degrees(see main.qml). This makes the group dialog's
|
||||
// items rotated, so un-rotate them here to fix that.
|
||||
rotation: Plasmoid.configuration.reverseMode && Plasmoid.formFactor === PlasmaCore.Types.Vertical ? 180 : 0
|
||||
|
||||
anchors.fill: parent
|
||||
readonly property bool overflowing: leftPadding > 0 || rightPadding > 0 // Scrollbar is visible
|
||||
|
||||
ListView {
|
||||
id: groupListView
|
||||
|
||||
readonly property real maxWidth: groupFilter.maxTextWidth
|
||||
+ LayoutMetrics.horizontalMargins()
|
||||
+ Kirigami.Units.iconSizes.medium
|
||||
+ 2 * (LayoutMetrics.labelMargin + LayoutMetrics.iconMargin)
|
||||
+ scrollView.leftPadding + scrollView.rightPadding
|
||||
// Use groupFilter.count because sometimes count is not updated in time (BUG 446105)
|
||||
readonly property real maxHeight: groupFilter.count * (LayoutMetrics.verticalMargins() + Math.max(Kirigami.Units.iconSizes.sizeForLabels, Kirigami.Units.iconSizes.medium))
|
||||
|
||||
model: DelegateModel {
|
||||
id: groupFilter
|
||||
|
||||
readonly property TextMetrics textMetrics: TextMetrics {}
|
||||
property real maxTextWidth: 0
|
||||
|
||||
model: tasksModel
|
||||
rootIndex: tasksModel.makeModelIndex(groupDialog.visualParent.index)
|
||||
delegate: Task {
|
||||
width: groupListView.width
|
||||
visible: true
|
||||
inPopup: true
|
||||
tasksRoot: tasks
|
||||
|
||||
ListView.onRemove: Qt.callLater(groupFilter.updateMaxTextWidth)
|
||||
Connections {
|
||||
enabled: index < 20 // 20 is based on performance considerations.
|
||||
|
||||
function onLabelTextChanged(): void { // ListView.onAdd included
|
||||
if (groupFilter.maxTextWidth === 0) {
|
||||
// Update immediately to avoid shrinking
|
||||
groupFilter.updateMaxTextWidth();
|
||||
} else {
|
||||
Qt.callLater(groupFilter.updateMaxTextWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateMaxTextWidth(): void {
|
||||
let tempMaxTextWidth = 0;
|
||||
// 20 is based on performance considerations.
|
||||
for (let i = 0; i < Math.min(count, 20); i++) {
|
||||
textMetrics.text = items.get(i).model.display;
|
||||
if (textMetrics.boundingRect.width > tempMaxTextWidth) {
|
||||
tempMaxTextWidth = textMetrics.boundingRect.width;
|
||||
}
|
||||
}
|
||||
maxTextWidth = tempMaxTextWidth;
|
||||
}
|
||||
}
|
||||
|
||||
reuseItems: false
|
||||
|
||||
Keys.onUpPressed: event => mouseHandler.moveRow(event, groupListView.currentIndex - 1)
|
||||
Keys.onDownPressed: event => mouseHandler.moveRow(event, groupListView.currentIndex + 1)
|
||||
|
||||
onCountChanged: {
|
||||
if (count > 0) {
|
||||
backend.cancelHighlightWindows()
|
||||
} else {
|
||||
groupDialog.visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
_oldAppletStatus = Plasmoid.status;
|
||||
Plasmoid.status = PlasmaCore.Types.RequiresAttentionStatus;
|
||||
|
||||
groupDialog.requestActivate();
|
||||
groupListView.forceActiveFocus(); // Active focus on ListView so keyboard navigation can work.
|
||||
Qt.callLater(findActiveTaskIndex);
|
||||
} else {
|
||||
Plasmoid.status = _oldAppletStatus;
|
||||
tasks.groupDialog = null;
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2012-2013 Eike Hein <hein@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
import QtQuick
|
||||
|
||||
import org.kde.plasma.core as PlasmaCore
|
||||
import org.kde.ksvg as KSvg
|
||||
import org.kde.plasma.plasmoid
|
||||
|
||||
KSvg.SvgItem {
|
||||
id: arrow
|
||||
|
||||
anchors {
|
||||
bottom: arrow.parent.bottom
|
||||
horizontalCenter: iconBox.horizontalCenter
|
||||
}
|
||||
|
||||
visible: parent.model.IsGroupParent
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "top"
|
||||
when: Plasmoid.location === PlasmaCore.Types.TopEdge
|
||||
AnchorChanges {
|
||||
target: arrow
|
||||
anchors.top: arrow.parent.top
|
||||
anchors.left: undefined
|
||||
anchors.right: undefined
|
||||
anchors.bottom: undefined
|
||||
anchors.horizontalCenter: iconBox.horizontalCenter
|
||||
anchors.verticalCenter: undefined
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "left"
|
||||
when: Plasmoid.location === PlasmaCore.Types.LeftEdge
|
||||
AnchorChanges {
|
||||
target: arrow
|
||||
anchors.top: undefined
|
||||
anchors.left: arrow.parent.left
|
||||
anchors.right: undefined
|
||||
anchors.bottom: undefined
|
||||
anchors.horizontalCenter: undefined
|
||||
anchors.verticalCenter: iconBox.verticalCenter
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "right"
|
||||
when: Plasmoid.location === PlasmaCore.Types.RightEdge
|
||||
AnchorChanges {
|
||||
target: arrow
|
||||
anchors.top: undefined
|
||||
anchors.left: undefined
|
||||
anchors.right: arrow.parent.right
|
||||
anchors.bottom: undefined
|
||||
anchors.horizontalCenter: undefined
|
||||
anchors.verticalCenter: iconBox.verticalCenter
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
implicitWidth: Math.min(naturalSize.width, iconBox.width)
|
||||
implicitHeight: Math.min(naturalSize.height, iconBox.width)
|
||||
|
||||
imagePath: "widgets/tasks"
|
||||
elementId: elementForLocation()
|
||||
|
||||
function elementForLocation(): string {
|
||||
switch (Plasmoid.location) {
|
||||
case PlasmaCore.Types.LeftEdge:
|
||||
return "group-expander-left";
|
||||
case PlasmaCore.Types.TopEdge:
|
||||
return "group-expander-top";
|
||||
case PlasmaCore.Types.RightEdge:
|
||||
return "group-expander-right";
|
||||
case PlasmaCore.Types.BottomEdge:
|
||||
default:
|
||||
return "group-expander-bottom";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,362 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2024 User
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Effects
|
||||
import org.kde.plasma.components as PlasmaComponents3
|
||||
import org.kde.plasma.core as PlasmaCore
|
||||
import org.kde.kirigami as Kirigami
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
// Properties that can be set from the outside
|
||||
property int animationType: 0 // 0=BusyIndicator, 1=PulsingIcon, 2=BouncingIcon, etc.
|
||||
property int animationDuration: 1200
|
||||
property real animationIntensity: 0.3
|
||||
property bool active: false
|
||||
property var iconSource: null
|
||||
|
||||
// Animation properties that external icon can bind to
|
||||
property real iconScale: 1.0
|
||||
property real iconRotation: 0
|
||||
property real iconOpacity: 1.0
|
||||
property real iconOffsetY: 0 // For bouncing
|
||||
|
||||
// Animation type constants for clarity
|
||||
readonly property int typeBusyIndicator: 0
|
||||
readonly property int typePulsingIcon: 1
|
||||
readonly property int typeBouncingIcon: 2
|
||||
readonly property int typeRotatingIcon: 3
|
||||
readonly property int typeScalingIcon: 4
|
||||
readonly property int typeFadingIcon: 5
|
||||
readonly property int typeGlowEffect: 6
|
||||
|
||||
onActiveChanged: {
|
||||
if (active) {
|
||||
startAnimation();
|
||||
} else {
|
||||
stopAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
onAnimationTypeChanged: {
|
||||
if (active) {
|
||||
stopAnimation();
|
||||
startAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
function startAnimation() {
|
||||
switch(animationType) {
|
||||
case typeBusyIndicator:
|
||||
// Show busy indicator on top of icon (don't hide the icon)
|
||||
iconScale = 1.0;
|
||||
iconOpacity = 1.0;
|
||||
iconRotation = 0;
|
||||
iconOffsetY = 0;
|
||||
break;
|
||||
case typePulsingIcon:
|
||||
// Reset to normal first, then start animation
|
||||
iconScale = 1.0;
|
||||
iconOpacity = 1.0;
|
||||
iconRotation = 0;
|
||||
iconOffsetY = 0;
|
||||
pulseAnimation.restart();
|
||||
break;
|
||||
case typeBouncingIcon:
|
||||
// Reset to normal first, then start animation
|
||||
iconScale = 1.0;
|
||||
iconOpacity = 1.0;
|
||||
iconRotation = 0;
|
||||
iconOffsetY = 0;
|
||||
bounceAnimation.restart();
|
||||
break;
|
||||
case typeRotatingIcon:
|
||||
// Reset to normal first, then start animation
|
||||
iconScale = 1.0;
|
||||
iconOpacity = 1.0;
|
||||
iconRotation = 0;
|
||||
iconOffsetY = 0;
|
||||
rotateAnimation.restart();
|
||||
break;
|
||||
case typeScalingIcon:
|
||||
// Reset to normal first, then start animation
|
||||
iconScale = 1.0;
|
||||
iconOpacity = 1.0;
|
||||
iconRotation = 0;
|
||||
iconOffsetY = 0;
|
||||
scaleAnimation.restart();
|
||||
break;
|
||||
case typeFadingIcon:
|
||||
// Reset to normal first, then start animation
|
||||
iconScale = 1.0;
|
||||
iconOpacity = 1.0;
|
||||
iconRotation = 0;
|
||||
iconOffsetY = 0;
|
||||
fadeAnimation.restart();
|
||||
break;
|
||||
case typeGlowEffect:
|
||||
// Reset to normal first, then start animation
|
||||
iconScale = 1.0;
|
||||
iconOpacity = 1.0;
|
||||
iconRotation = 0;
|
||||
iconOffsetY = 0;
|
||||
glowAnimation.restart();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function stopAnimation() {
|
||||
pulseAnimation.stop();
|
||||
bounceAnimation.stop();
|
||||
rotateAnimation.stop();
|
||||
scaleAnimation.stop();
|
||||
fadeAnimation.stop();
|
||||
glowAnimation.stop();
|
||||
|
||||
// Reset all animation properties
|
||||
iconScale = 1.0;
|
||||
iconRotation = 0;
|
||||
iconOpacity = 1.0;
|
||||
iconOffsetY = 0;
|
||||
glowEffect.opacity = 0;
|
||||
}
|
||||
|
||||
// Glow effect - Only additional visual element needed
|
||||
Item {
|
||||
id: glowEffect
|
||||
anchors.centerIn: parent
|
||||
width: parent.width * 1.2
|
||||
height: parent.height * 1.2
|
||||
visible: animationType === typeGlowEffect && active
|
||||
opacity: 0
|
||||
z: 5
|
||||
|
||||
Rectangle {
|
||||
anchors.centerIn: parent
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
radius: width / 2
|
||||
color: "transparent"
|
||||
border.color: Kirigami.Theme.highlightColor
|
||||
border.width: 2
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: 2
|
||||
Rectangle {
|
||||
anchors.centerIn: parent
|
||||
width: parent.width + (index * 4)
|
||||
height: parent.height + (index * 4)
|
||||
radius: width / 2
|
||||
color: "transparent"
|
||||
border.color: Kirigami.Theme.highlightColor
|
||||
border.width: 1
|
||||
opacity: 0.4 / (index + 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ANIMATION DEFINITIONS - These modify the exported properties
|
||||
|
||||
// 2. Pulsing Icon Animation - Smooth sine wave
|
||||
SequentialAnimation {
|
||||
id: pulseAnimation
|
||||
loops: Animation.Infinite
|
||||
running: false
|
||||
|
||||
NumberAnimation {
|
||||
target: root
|
||||
property: "iconScale"
|
||||
from: 1.0
|
||||
to: 1.0 + (animationIntensity * 0.6)
|
||||
duration: animationDuration / 2
|
||||
easing.type: Easing.InOutSine
|
||||
}
|
||||
NumberAnimation {
|
||||
target: root
|
||||
property: "iconScale"
|
||||
from: 1.0 + (animationIntensity * 0.6)
|
||||
to: 1.0
|
||||
duration: animationDuration / 2
|
||||
easing.type: Easing.InOutSine
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Bouncing Icon Animation - REALISTIC PHYSICS with multiple bounces
|
||||
SequentialAnimation {
|
||||
id: bounceAnimation
|
||||
loops: Animation.Infinite
|
||||
running: false
|
||||
|
||||
// First big bounce
|
||||
NumberAnimation {
|
||||
target: root
|
||||
property: "iconOffsetY"
|
||||
from: 0
|
||||
to: -(30 * animationIntensity) // Higher initial bounce
|
||||
duration: animationDuration / 6
|
||||
easing.type: Easing.OutQuad // Deceleration going up
|
||||
}
|
||||
NumberAnimation {
|
||||
target: root
|
||||
property: "iconOffsetY"
|
||||
from: -(30 * animationIntensity)
|
||||
to: 0
|
||||
duration: animationDuration / 6
|
||||
easing.type: Easing.InQuad // Acceleration going down
|
||||
}
|
||||
|
||||
// Second smaller bounce
|
||||
NumberAnimation {
|
||||
target: root
|
||||
property: "iconOffsetY"
|
||||
from: 0
|
||||
to: -(18 * animationIntensity) // 60% of original height
|
||||
duration: animationDuration / 8
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
NumberAnimation {
|
||||
target: root
|
||||
property: "iconOffsetY"
|
||||
from: -(18 * animationIntensity)
|
||||
to: 0
|
||||
duration: animationDuration / 8
|
||||
easing.type: Easing.InQuad
|
||||
}
|
||||
|
||||
// Third tiny bounce
|
||||
NumberAnimation {
|
||||
target: root
|
||||
property: "iconOffsetY"
|
||||
from: 0
|
||||
to: -(8 * animationIntensity) // 40% of second bounce
|
||||
duration: animationDuration / 10
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
NumberAnimation {
|
||||
target: root
|
||||
property: "iconOffsetY"
|
||||
from: -(8 * animationIntensity)
|
||||
to: 0
|
||||
duration: animationDuration / 10
|
||||
easing.type: Easing.InQuad
|
||||
}
|
||||
|
||||
// Rest period
|
||||
PauseAnimation { duration: animationDuration / 3 }
|
||||
}
|
||||
|
||||
// 4. Rotating Icon Animation
|
||||
RotationAnimation {
|
||||
id: rotateAnimation
|
||||
target: root
|
||||
property: "iconRotation"
|
||||
from: 0
|
||||
to: 360
|
||||
duration: animationDuration
|
||||
loops: Animation.Infinite
|
||||
running: false
|
||||
easing.type: Easing.Linear
|
||||
}
|
||||
|
||||
// 5. Scaling Icon Animation - Complex bounce-scale with elastic settle
|
||||
SequentialAnimation {
|
||||
id: scaleAnimation
|
||||
loops: Animation.Infinite
|
||||
running: false
|
||||
|
||||
// Quick shrink
|
||||
NumberAnimation {
|
||||
target: root
|
||||
property: "iconScale"
|
||||
from: 1.0
|
||||
to: 1.0 - (animationIntensity * 0.4)
|
||||
duration: animationDuration / 6
|
||||
easing.type: Easing.InQuad
|
||||
}
|
||||
// Big bounce grow
|
||||
NumberAnimation {
|
||||
target: root
|
||||
property: "iconScale"
|
||||
from: 1.0 - (animationIntensity * 0.4)
|
||||
to: 1.0 + (animationIntensity * 0.8)
|
||||
duration: animationDuration / 3
|
||||
easing.type: Easing.OutBack
|
||||
easing.overshoot: 2.0
|
||||
}
|
||||
// Settle back
|
||||
NumberAnimation {
|
||||
target: root
|
||||
property: "iconScale"
|
||||
from: 1.0 + (animationIntensity * 0.8)
|
||||
to: 1.0
|
||||
duration: animationDuration / 2
|
||||
easing.type: Easing.OutElastic
|
||||
easing.amplitude: 1.5
|
||||
}
|
||||
}
|
||||
|
||||
// 6. Fading Icon Animation - Dramatic fade
|
||||
SequentialAnimation {
|
||||
id: fadeAnimation
|
||||
loops: Animation.Infinite
|
||||
running: false
|
||||
|
||||
NumberAnimation {
|
||||
target: root
|
||||
property: "iconOpacity"
|
||||
from: 1.0
|
||||
to: 0.1
|
||||
duration: animationDuration / 2
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
NumberAnimation {
|
||||
target: root
|
||||
property: "iconOpacity"
|
||||
from: 0.1
|
||||
to: 1.0
|
||||
duration: animationDuration / 2
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
}
|
||||
|
||||
// 7. Glow Effect Animation
|
||||
SequentialAnimation {
|
||||
id: glowAnimation
|
||||
loops: Animation.Infinite
|
||||
running: false
|
||||
|
||||
NumberAnimation {
|
||||
target: glowEffect
|
||||
property: "opacity"
|
||||
from: 0
|
||||
to: 0.8
|
||||
duration: animationDuration / 3
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
NumberAnimation {
|
||||
target: glowEffect
|
||||
property: "opacity"
|
||||
from: 0.8
|
||||
to: 0.3
|
||||
duration: animationDuration / 3
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
NumberAnimation {
|
||||
target: glowEffect
|
||||
property: "opacity"
|
||||
from: 0.3
|
||||
to: 0
|
||||
duration: animationDuration / 3
|
||||
easing.type: Easing.InQuad
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2012-2016 Eike Hein <hein@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
import QtQuick
|
||||
|
||||
import org.kde.taskmanager as TaskManager
|
||||
import org.kde.plasma.plasmoid
|
||||
|
||||
import "code/tools.js" as TaskTools
|
||||
|
||||
DropArea {
|
||||
id: dropArea
|
||||
signal urlsDropped(var urls)
|
||||
|
||||
property Item target
|
||||
property Item ignoredItem
|
||||
property Item hoveredItem
|
||||
property bool isGroupDialog: false
|
||||
property bool moved: false
|
||||
|
||||
property alias handleWheelEvents: wheelHandler.handleWheelEvents
|
||||
|
||||
//ignore anything that is neither internal to TaskManager or a URL list
|
||||
onEntered: event => {
|
||||
if (event.formats.indexOf("text/x-plasmoidservicename") >= 0) {
|
||||
event.accepted = false;
|
||||
}
|
||||
if (target.animating) { // Not all targets have an animating property
|
||||
target.animating = false;
|
||||
}
|
||||
}
|
||||
|
||||
onPositionChanged: event => {
|
||||
if (target.animating) {
|
||||
return;
|
||||
}
|
||||
|
||||
let above;
|
||||
if (isGroupDialog) {
|
||||
above = target.itemAt(event.x, event.y);
|
||||
} else {
|
||||
above = target.childAt(event.x, event.y);
|
||||
}
|
||||
|
||||
if (!above) {
|
||||
hoveredItem = null;
|
||||
activationTimer.stop();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// If we're mixing launcher tasks with other tasks and are moving
|
||||
// a (small) launcher task across a non-launcher task, don't allow
|
||||
// the latter to be the move target twice in a row for a while, as
|
||||
// it will naturally be moved underneath the cursor as result of the
|
||||
// initial move, due to being far larger than the launcher delegate.
|
||||
// TODO: This restriction (minus the timer, which improves things)
|
||||
// has been proven out in the EITM fork, but could be improved later
|
||||
// by tracking the cursor movement vector and allowing the drag if
|
||||
// the movement direction has reversed, establishing user intent to
|
||||
// move back.
|
||||
if (!Plasmoid.configuration.separateLaunchers
|
||||
&& tasks.dragSource?.model.IsLauncher
|
||||
&& !above.model.IsLauncher
|
||||
&& above === ignoredItem) {
|
||||
return;
|
||||
} else {
|
||||
ignoredItem = null;
|
||||
}
|
||||
|
||||
if (tasksModel.sortMode === TaskManager.TasksModel.SortManual && tasks.dragSource) {
|
||||
// Reject drags between different TaskList instances.
|
||||
if (tasks.dragSource.parent !== above.parent) {
|
||||
return;
|
||||
}
|
||||
|
||||
const insertAt = above.index;
|
||||
|
||||
if (tasks.dragSource !== above && tasks.dragSource.index !== insertAt) {
|
||||
if (tasks.groupDialog) {
|
||||
tasksModel.move(tasks.dragSource.index, insertAt,
|
||||
tasksModel.makeModelIndex(tasks.groupDialog.visualParent.index));
|
||||
} else {
|
||||
tasksModel.move(tasks.dragSource.index, insertAt);
|
||||
}
|
||||
|
||||
ignoredItem = above;
|
||||
ignoreItemTimer.restart();
|
||||
}
|
||||
} else if (!tasks.dragSource && hoveredItem !== above) {
|
||||
hoveredItem = above;
|
||||
activationTimer.restart();
|
||||
}
|
||||
}
|
||||
|
||||
onExited: {
|
||||
hoveredItem = null;
|
||||
activationTimer.stop();
|
||||
}
|
||||
|
||||
onDropped: event => {
|
||||
// Reject internal drops.
|
||||
if (event.formats.indexOf("application/x-orgkdeplasmataskmanager_taskbuttonitem") >= 0) {
|
||||
event.accepted = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Reject plasmoid drops.
|
||||
if (event.formats.indexOf("text/x-plasmoidservicename") >= 0) {
|
||||
event.accepted = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.hasUrls) {
|
||||
urlsDropped(event.urls);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: tasks
|
||||
|
||||
function onDragSourceChanged(): void {
|
||||
if (!dragSource) {
|
||||
ignoredItem = null;
|
||||
ignoreItemTimer.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: ignoreItemTimer
|
||||
|
||||
repeat: false
|
||||
interval: 750
|
||||
|
||||
onTriggered: {
|
||||
ignoredItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: activationTimer
|
||||
|
||||
interval: 250
|
||||
repeat: false
|
||||
|
||||
onTriggered: {
|
||||
if (parent.hoveredItem.model.IsGroupParent) {
|
||||
TaskTools.createGroupDialog(parent.hoveredItem, tasks);
|
||||
} else if (!parent.hoveredItem.model.IsLauncher) {
|
||||
tasksModel.requestActivate(parent.hoveredItem.modelIndex());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WheelHandler {
|
||||
id: wheelHandler
|
||||
|
||||
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
|
||||
|
||||
property bool handleWheelEvents: true
|
||||
|
||||
enabled: handleWheelEvents && Plasmoid.configuration.wheelEnabled
|
||||
|
||||
onWheel: event => {
|
||||
// magic number 15 for common "one scroll"
|
||||
// See https://doc.qt.io/qt-6/qml-qtquick-wheelhandler.html#rotation-prop
|
||||
let increment = 0;
|
||||
while (rotation >= 15) {
|
||||
rotation -= 15;
|
||||
increment++;
|
||||
}
|
||||
while (rotation <= -15) {
|
||||
rotation += 15;
|
||||
increment--;
|
||||
}
|
||||
const anchor = dropArea.target.childAt(event.x, event.y);
|
||||
|
||||
while (increment !== 0) {
|
||||
TaskTools.activateNextPrevTask(anchor, increment < 0, Plasmoid.configuration.wheelSkipMinimized, tasks);
|
||||
increment += (increment < 0) ? 1 : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2020 Aleix Pol Gonzalez <aleixpol@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
import QtQuick
|
||||
import org.kde.pipewire as PipeWire
|
||||
import org.kde.taskmanager as TaskManager
|
||||
|
||||
PipeWire.PipeWireSourceItem {
|
||||
id: pipeWireSourceItem
|
||||
|
||||
readonly property alias hasThumbnail: pipeWireSourceItem.ready
|
||||
|
||||
anchors.fill: parent
|
||||
nodeId: waylandItem.nodeId
|
||||
|
||||
TaskManager.ScreencastingRequest {
|
||||
id: waylandItem
|
||||
uuid: thumbnailSourceItem.winId
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de>
|
||||
SPDX-FileCopyrightText: 2017 Roman Gilg <subdiff@gmail.com>
|
||||
SPDX-FileCopyrightText: 2020 Nate Graham <nate@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.plasma.components as PlasmaComponents3
|
||||
import org.kde.plasma.extras as PlasmaExtras
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.plasma.private.mpris as Mpris
|
||||
|
||||
RowLayout {
|
||||
enabled: toolTipDelegate.playerData?.canControl ?? false
|
||||
spacing: Kirigami.Units.smallSpacing
|
||||
|
||||
readonly property bool isPlaying: toolTipDelegate.playerData?.playbackStatus === Mpris.PlaybackStatus.Playing
|
||||
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: 0
|
||||
|
||||
ScrollableTextWrapper {
|
||||
id: songTextWrapper
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: songText.height
|
||||
implicitWidth: songText.implicitWidth
|
||||
|
||||
textItem: PlasmaComponents3.Label {
|
||||
id: songText
|
||||
maximumLineCount: artistText.visible ? 1 : 2
|
||||
wrapMode: Text.NoWrap
|
||||
elide: parent.state ? Text.ElideNone : Text.ElideRight
|
||||
text: toolTipDelegate.playerData?.track ?? ""
|
||||
textFormat: Text.PlainText
|
||||
}
|
||||
}
|
||||
|
||||
ScrollableTextWrapper {
|
||||
id: artistTextWrapper
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: artistText.height
|
||||
implicitWidth: artistText.implicitWidth
|
||||
visible: artistText.text.length > 0
|
||||
|
||||
textItem: PlasmaExtras.DescriptiveLabel {
|
||||
id: artistText
|
||||
wrapMode: Text.NoWrap
|
||||
elide: parent.state ? Text.ElideNone : Text.ElideRight
|
||||
text: toolTipDelegate.playerData?.artist ?? ""
|
||||
font: Kirigami.Theme.smallFont
|
||||
textFormat: Text.PlainText
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaComponents3.ToolButton {
|
||||
enabled: toolTipDelegate.playerData?.canGoPrevious ?? false
|
||||
icon.name: mirrored ? "media-skip-forward" : "media-skip-backward"
|
||||
onClicked: toolTipDelegate.playerData.Previous()
|
||||
}
|
||||
|
||||
PlasmaComponents3.ToolButton {
|
||||
enabled: (isPlaying ? toolTipDelegate.playerData?.canPause : toolTipDelegate.playerData?.canPlay) ?? false
|
||||
icon.name: isPlaying ? "media-playback-pause" : "media-playback-start"
|
||||
onClicked: {
|
||||
if (!isPlaying) {
|
||||
toolTipDelegate.playerData.Play();
|
||||
} else {
|
||||
toolTipDelegate.playerData.Pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaComponents3.ToolButton {
|
||||
enabled: toolTipDelegate.playerData?.canGoNext ?? false
|
||||
icon.name: mirrored ? "media-skip-backward" : "media-skip-forward"
|
||||
onClicked: toolTipDelegate.playerData.Next()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2017 Kai Uwe Broulik <kde@privat.broulik.de>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
|
||||
import org.kde.plasma.private.volume
|
||||
|
||||
QtObject {
|
||||
id: pulseAudio
|
||||
|
||||
signal streamsChanged()
|
||||
|
||||
// It's a JS object so we can do key lookup and don't need to take care of filtering duplicates.
|
||||
property var pidMatches: new Set()
|
||||
|
||||
// TODO Evict cache at some point, preferably if all instances of an application closed.
|
||||
function registerPidMatch(appName: string) {
|
||||
if (!hasPidMatch(appName)) {
|
||||
pidMatches.add(appName);
|
||||
|
||||
// In case this match is new, notify that streams might have changed.
|
||||
// This way we also catch the case when the non-playing instance
|
||||
// shows up first.
|
||||
// Only notify if we changed to avoid infinite recursion.
|
||||
streamsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
function hasPidMatch(appName: string): bool {
|
||||
return pidMatches.has(appName);
|
||||
}
|
||||
|
||||
function findStreams(key: string, value: var): /*[QtObject]*/ var {
|
||||
return findStreamsFn(stream => stream[key] === value);
|
||||
}
|
||||
|
||||
function findStreamsFn(fn: var): var {
|
||||
const streams = [];
|
||||
for (let i = 0, count = instantiator.count; i < count; ++i) {
|
||||
const stream = instantiator.objectAt(i);
|
||||
if (fn(stream)) {
|
||||
streams.push(stream);
|
||||
}
|
||||
}
|
||||
return streams;
|
||||
}
|
||||
|
||||
function streamsForAppId(appId: string): /*[QtObject]*/ var {
|
||||
return findStreams("portalAppId", appId);
|
||||
}
|
||||
|
||||
function streamsForAppName(appName: string): /*[QtObject]*/ var {
|
||||
return findStreams("appName", appName);
|
||||
}
|
||||
|
||||
function streamsForPid(pid: int): /*[QtObject]*/ var {
|
||||
// skip stream that has portalAppId
|
||||
// app using portal may have a sandbox pid
|
||||
const streams = findStreamsFn(stream => stream.pid === pid && !stream.portalAppId);
|
||||
|
||||
if (streams.length === 0) {
|
||||
for (let i = 0, length = instantiator.count; i < length; ++i) {
|
||||
const stream = instantiator.objectAt(i);
|
||||
|
||||
if (stream.parentPid === -1) {
|
||||
stream.parentPid = backend.parentPid(stream.pid);
|
||||
}
|
||||
|
||||
if (stream.parentPid === pid) {
|
||||
streams.push(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return streams;
|
||||
}
|
||||
|
||||
// QtObject has no default property, hence adding the Instantiator to one explicitly.
|
||||
readonly property Instantiator instantiator: Instantiator {
|
||||
model: PulseObjectFilterModel {
|
||||
filters: [ { role: "VirtualStream", value: false } ]
|
||||
sourceModel: SinkInputModel {}
|
||||
}
|
||||
|
||||
delegate: QtObject {
|
||||
id: delegate
|
||||
required property var model
|
||||
readonly property int pid: model.Client?.properties["application.process.id"] ?? 0
|
||||
// Determined on demand.
|
||||
property int parentPid: -1
|
||||
readonly property string appName: model.Client?.properties["application.name"] ?? ""
|
||||
readonly property string portalAppId: model.Client?.properties["pipewire.access.portal.app_id"] ?? ""
|
||||
readonly property bool muted: model.Muted
|
||||
// whether there is nothing actually going on on that stream
|
||||
readonly property bool corked: model.Corked
|
||||
readonly property int volume: model.Volume
|
||||
|
||||
function mute(): void {
|
||||
model.Muted = true;
|
||||
}
|
||||
function unmute(): void {
|
||||
model.Muted = false;
|
||||
}
|
||||
}
|
||||
|
||||
onObjectAdded: (index, object) => pulseAudio.streamsChanged()
|
||||
onObjectRemoved: (index, object) => pulseAudio.streamsChanged()
|
||||
}
|
||||
|
||||
readonly property int minimalVolume: PulseAudio.MinimalVolume
|
||||
readonly property int normalVolume: PulseAudio.NormalVolume
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2020 Tranter Madi <trmdi@yandex.com>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
|
||||
MouseArea {
|
||||
id: root
|
||||
|
||||
required property Text textItem
|
||||
|
||||
onTextItemChanged: {
|
||||
textItem.parent = this;
|
||||
textItem.width = Qt.binding(() => width);
|
||||
}
|
||||
|
||||
clip: textItem.elide === Text.ElideNone
|
||||
hoverEnabled: true
|
||||
|
||||
onContainsMouseChanged: {
|
||||
if (!containsMouse) {
|
||||
state = "";
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: timer
|
||||
interval: 500
|
||||
running: root.containsMouse
|
||||
onTriggered: {
|
||||
if (root.width < root.textItem.implicitWidth) {
|
||||
root.state = "ShowRight";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: ""
|
||||
PropertyChanges {
|
||||
target: root.textItem
|
||||
x: 0
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "ShowRight"
|
||||
PropertyChanges {
|
||||
target: root.textItem
|
||||
x: root.width - root.textItem.implicitWidth
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
transitions: Transition {
|
||||
to: "ShowRight"
|
||||
NumberAnimation {
|
||||
target: root.textItem
|
||||
properties: "x"
|
||||
easing.type: Easing.Linear
|
||||
duration: Math.abs(root.textItem.implicitWidth - root.width) * 25
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,971 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2012-2013 Eike Hein <hein@kde.org>
|
||||
SPDX-FileCopyrightText: 2024 Nate Graham <nate@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.plasma.core as PlasmaCore
|
||||
import org.kde.ksvg as KSvg
|
||||
import org.kde.plasma.extras as PlasmaExtras
|
||||
import org.kde.plasma.components as PlasmaComponents3
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.plasma.private.taskmanager as TaskManagerApplet
|
||||
import org.kde.plasma.plasmoid
|
||||
|
||||
import "code/layoutmetrics.js" as LayoutMetrics
|
||||
import "code/tools.js" as TaskTools
|
||||
|
||||
PlasmaCore.ToolTipArea {
|
||||
id: task
|
||||
|
||||
activeFocusOnTab: true
|
||||
|
||||
// To achieve a bottom-to-top layout on vertical panels, the task manager
|
||||
// is rotated by 180 degrees(see main.qml). This makes the tasks rotated,
|
||||
// so un-rotate them here to fix that.
|
||||
rotation: Plasmoid.configuration.reverseMode && Plasmoid.formFactor === PlasmaCore.Types.Vertical ? 180 : 0
|
||||
|
||||
// Transform for movement animations and zoom effect - FIXED BINDING LOOP
|
||||
transform: {
|
||||
// Simple approach: always return appropriate transforms without modifying cache in binding
|
||||
if (frame.zoomEnabled && (frame.isZoomed || frame.isAnimating)) {
|
||||
return [translateTransform, zoomTransform];
|
||||
} else {
|
||||
return [translateTransform];
|
||||
}
|
||||
}
|
||||
|
||||
// Performance: Cache expensive layout calculations - REMOVED CACHING TO FIX BINDING LOOPS
|
||||
implicitHeight: inPopup
|
||||
? LayoutMetrics.preferredHeightInPopup()
|
||||
: Math.max(tasksRoot.height / tasksRoot.plasmoid.configuration.maxStripes,
|
||||
LayoutMetrics.preferredMinHeight())
|
||||
|
||||
implicitWidth: tasksRoot.vertical
|
||||
? Math.max(LayoutMetrics.preferredMinWidth(), Math.min(LayoutMetrics.preferredMaxWidth(), tasksRoot.width / tasksRoot.plasmoid.configuration.maxStripes))
|
||||
: 0
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: !inPopup
|
||||
Layout.maximumWidth: tasksRoot.vertical
|
||||
? -1
|
||||
: ((model.IsLauncher && !tasks.iconsOnly) ? tasksRoot.height / taskList.rows : LayoutMetrics.preferredMaxWidth())
|
||||
Layout.maximumHeight: tasksRoot.vertical ? LayoutMetrics.preferredMaxHeight() : -1
|
||||
|
||||
required property var model
|
||||
required property int index
|
||||
required property /*main.qml*/ Item tasksRoot
|
||||
|
||||
readonly property int pid: model.AppPid
|
||||
readonly property string appName: model.AppName
|
||||
readonly property string appId: model.AppId.replace(/\.desktop/, '')
|
||||
readonly property bool isIcon: tasksRoot.iconsOnly || model.IsLauncher
|
||||
property bool toolTipOpen: false
|
||||
property bool inPopup: false
|
||||
property bool isWindow: model.IsWindow
|
||||
property int childCount: model.ChildCount
|
||||
property int previousChildCount: 0
|
||||
property alias labelText: label.text
|
||||
property QtObject contextMenu: null
|
||||
readonly property bool smartLauncherEnabled: !inPopup && !model.IsStartup
|
||||
property QtObject smartLauncherItem: null
|
||||
|
||||
property Item audioStreamIcon: null
|
||||
property var audioStreams: []
|
||||
property bool delayAudioStreamIndicator: false
|
||||
property bool completed: false
|
||||
readonly property bool audioIndicatorsEnabled: Plasmoid.configuration.interactiveMute
|
||||
readonly property bool hasAudioStream: audioStreams.length > 0
|
||||
readonly property bool playingAudio: hasAudioStream && audioStreams.some(item => !item.corked)
|
||||
readonly property bool muted: hasAudioStream && audioStreams.every(item => item.muted)
|
||||
|
||||
readonly property bool highlighted: (inPopup && activeFocus) || (!inPopup && containsMouse)
|
||||
|| (task.contextMenu && task.contextMenu.status === PlasmaExtras.Menu.Open)
|
||||
|| (!!tasksRoot.groupDialog && tasksRoot.groupDialog.visualParent === task)
|
||||
|
||||
active: !inPopup && !tasksRoot.groupDialog && task.contextMenu?.status !== PlasmaExtras.Menu.Open
|
||||
interactive: model.IsWindow || mainItem.playerData
|
||||
location: Plasmoid.location
|
||||
mainItem: !Plasmoid.configuration.showToolTips || !model.IsWindow ? pinnedAppToolTipDelegate : openWindowToolTipDelegate
|
||||
|
||||
onXChanged: {
|
||||
if (!completed) {
|
||||
return;
|
||||
}
|
||||
if (oldX < 0) {
|
||||
oldX = x;
|
||||
return;
|
||||
}
|
||||
moveAnim.x = oldX - x + translateTransform.x;
|
||||
moveAnim.y = translateTransform.y;
|
||||
oldX = x;
|
||||
moveAnim.restart();
|
||||
}
|
||||
onYChanged: {
|
||||
if (!completed) {
|
||||
return;
|
||||
}
|
||||
if (oldY < 0) {
|
||||
oldY = y;
|
||||
return;
|
||||
}
|
||||
moveAnim.y = oldY - y + translateTransform.y;
|
||||
moveAnim.x = translateTransform.x;
|
||||
oldY = y;
|
||||
moveAnim.restart();
|
||||
}
|
||||
|
||||
property real oldX: -1
|
||||
property real oldY: -1
|
||||
SequentialAnimation {
|
||||
id: moveAnim
|
||||
property real x
|
||||
property real y
|
||||
onRunningChanged: {
|
||||
if (running) {
|
||||
++task.parent.animationsRunning;
|
||||
} else {
|
||||
--task.parent.animationsRunning;
|
||||
}
|
||||
}
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
target: translateTransform
|
||||
properties: "x"
|
||||
from: moveAnim.x
|
||||
to: 0
|
||||
easing.type: Easing.OutCubic
|
||||
duration: Kirigami.Units.longDuration
|
||||
}
|
||||
NumberAnimation {
|
||||
target: translateTransform
|
||||
properties: "y"
|
||||
from: moveAnim.y
|
||||
to: 0
|
||||
easing.type: Easing.OutCubic
|
||||
duration: Kirigami.Units.longDuration
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Accessible.name: model.display
|
||||
Accessible.description: {
|
||||
if (!model.display) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (model.IsLauncher) {
|
||||
return i18nc("@info:usagetip %1 application name", "Launch %1", model.display)
|
||||
}
|
||||
|
||||
let smartLauncherDescription = "";
|
||||
if (iconBox.active) {
|
||||
smartLauncherDescription += i18ncp("@info:tooltip", "There is %1 new message.", "There are %1 new messages.", task.smartLauncherItem.count);
|
||||
}
|
||||
|
||||
if (model.IsGroupParent) {
|
||||
switch (Plasmoid.configuration.groupedTaskVisualization) {
|
||||
case 0:
|
||||
break; // Use the default description
|
||||
case 1: {
|
||||
return `${i18nc("@info:usagetip %1 task name", "Show Task tooltip for %1", model.display)}; ${smartLauncherDescription}`;
|
||||
}
|
||||
case 2: {
|
||||
if (effectWatcher.registered) {
|
||||
return `${i18nc("@info:usagetip %1 task name", "Show windows side by side for %1", model.display)}; ${smartLauncherDescription}`;
|
||||
}
|
||||
// fallthrough
|
||||
}
|
||||
default:
|
||||
return `${i18nc("@info:usagetip %1 task name", "Open textual list of windows for %1", model.display)}; ${smartLauncherDescription}`;
|
||||
}
|
||||
}
|
||||
|
||||
return `${i18n("Activate %1", model.display)}; ${smartLauncherDescription}`;
|
||||
}
|
||||
Accessible.role: Accessible.Button
|
||||
Accessible.onPressAction: leftTapHandler.leftClick()
|
||||
|
||||
onToolTipVisibleChanged: toolTipVisible => {
|
||||
task.toolTipOpen = toolTipVisible;
|
||||
if (!toolTipVisible) {
|
||||
tasksRoot.toolTipOpenedByClick = null;
|
||||
} else {
|
||||
tasksRoot.toolTipAreaItem = task;
|
||||
}
|
||||
}
|
||||
|
||||
onContainsMouseChanged: {
|
||||
if (containsMouse) {
|
||||
task.forceActiveFocus(Qt.MouseFocusReason);
|
||||
task.updateMainItemBindings();
|
||||
} else {
|
||||
tasksRoot.toolTipOpenedByClick = null;
|
||||
}
|
||||
}
|
||||
|
||||
onPidChanged: updateAudioStreams({delay: false})
|
||||
onAppNameChanged: updateAudioStreams({delay: false})
|
||||
|
||||
onIsWindowChanged: {
|
||||
if (model.IsWindow) {
|
||||
taskInitComponent.createObject(task);
|
||||
updateAudioStreams({delay: false});
|
||||
}
|
||||
}
|
||||
|
||||
onChildCountChanged: {
|
||||
if (TaskTools.taskManagerInstanceCount < 2 && childCount > previousChildCount) {
|
||||
tasksModel.requestPublishDelegateGeometry(modelIndex(), backend.globalRect(task), task);
|
||||
}
|
||||
|
||||
previousChildCount = childCount;
|
||||
}
|
||||
|
||||
onIndexChanged: {
|
||||
hideToolTip();
|
||||
|
||||
if (!inPopup && !tasksRoot.vertical
|
||||
&& !Plasmoid.configuration.separateLaunchers) {
|
||||
tasksRoot.requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
onSmartLauncherEnabledChanged: {
|
||||
if (smartLauncherEnabled && !smartLauncherItem) {
|
||||
const component = Qt.createComponent("org.kde.plasma.private.taskmanager", "SmartLauncherItem");
|
||||
const smartLauncher = component.createObject(task);
|
||||
component.destroy();
|
||||
|
||||
smartLauncher.launcherUrl = Qt.binding(() => model.LauncherUrlWithoutIcon);
|
||||
|
||||
smartLauncherItem = smartLauncher;
|
||||
}
|
||||
}
|
||||
|
||||
onHasAudioStreamChanged: {
|
||||
const audioStreamIconActive = hasAudioStream;
|
||||
if (!audioStreamIconActive) {
|
||||
if (audioStreamIcon !== null) {
|
||||
audioStreamIcon.destroy();
|
||||
audioStreamIcon = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Create item on demand instead of using Loader to reduce memory consumption,
|
||||
// because only a few applications have audio streams.
|
||||
const component = Qt.createComponent("AudioStream.qml");
|
||||
audioStreamIcon = component.createObject(task);
|
||||
component.destroy();
|
||||
}
|
||||
onAudioIndicatorsEnabledChanged: task.hasAudioStreamChanged()
|
||||
|
||||
Keys.onMenuPressed: event => contextMenuTimer.start()
|
||||
Keys.onReturnPressed: event => TaskTools.activateTask(modelIndex(), model, event.modifiers, task, Plasmoid, tasksRoot, effectWatcher.registered)
|
||||
Keys.onEnterPressed: event => Keys.returnPressed(event);
|
||||
Keys.onSpacePressed: event => Keys.returnPressed(event);
|
||||
Keys.onUpPressed: event => Keys.leftPressed(event)
|
||||
Keys.onDownPressed: event => Keys.rightPressed(event)
|
||||
Keys.onLeftPressed: event => {
|
||||
if (!inPopup && (event.modifiers & Qt.ControlModifier) && (event.modifiers & Qt.ShiftModifier)) {
|
||||
tasksModel.move(task.index, task.index - 1);
|
||||
} else {
|
||||
event.accepted = false;
|
||||
}
|
||||
}
|
||||
Keys.onRightPressed: event => {
|
||||
if (!inPopup && (event.modifiers & Qt.ControlModifier) && (event.modifiers & Qt.ShiftModifier)) {
|
||||
tasksModel.move(task.index, task.index + 1);
|
||||
} else {
|
||||
event.accepted = false;
|
||||
}
|
||||
}
|
||||
|
||||
function modelIndex(): /*QModelIndex*/ var {
|
||||
return inPopup
|
||||
? tasksModel.makeModelIndex(groupDialog.visualParent.index, index)
|
||||
: tasksModel.makeModelIndex(index);
|
||||
}
|
||||
|
||||
function showContextMenu(args: var): void {
|
||||
task.hideImmediately();
|
||||
contextMenu = tasksRoot.createContextMenu(task, modelIndex(), args);
|
||||
contextMenu.show();
|
||||
}
|
||||
|
||||
function updateAudioStreams(args: var): void {
|
||||
if (args) {
|
||||
// When the task just appeared (e.g. virtual desktop switch), show the audio indicator
|
||||
// right away. Only when audio streams change during the lifetime of this task, delay
|
||||
// showing that to avoid distraction.
|
||||
delayAudioStreamIndicator = !!args.delay;
|
||||
}
|
||||
|
||||
var pa = pulseAudio.item;
|
||||
if (!pa || !task.isWindow) {
|
||||
task.audioStreams = [];
|
||||
return;
|
||||
}
|
||||
|
||||
// Check appid first for app using portal
|
||||
// https://docs.pipewire.org/page_portal.html
|
||||
var streams = pa.streamsForAppId(task.appId);
|
||||
if (!streams.length) {
|
||||
streams = pa.streamsForPid(model.AppPid);
|
||||
if (streams.length) {
|
||||
pa.registerPidMatch(model.AppName);
|
||||
} else {
|
||||
// We only want to fall back to appName matching if we never managed to map
|
||||
// a PID to an audio stream window. Otherwise if you have two instances of
|
||||
// an application, one playing and the other not, it will look up appName
|
||||
// for the non-playing instance and erroneously show an indicator on both.
|
||||
if (!pa.hasPidMatch(model.AppName)) {
|
||||
streams = pa.streamsForAppName(model.AppName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task.audioStreams = streams;
|
||||
}
|
||||
|
||||
function toggleMuted(): void {
|
||||
if (muted) {
|
||||
task.audioStreams.forEach(item => item.unmute());
|
||||
} else {
|
||||
task.audioStreams.forEach(item => item.mute());
|
||||
}
|
||||
}
|
||||
|
||||
// Will also be called in activateTaskAtIndex(index)
|
||||
function updateMainItemBindings(): void {
|
||||
if ((mainItem.parentTask === this && mainItem.rootIndex.row === index)
|
||||
|| (tasksRoot.toolTipOpenedByClick === null && !active)
|
||||
|| (tasksRoot.toolTipOpenedByClick !== null && tasksRoot.toolTipOpenedByClick !== this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainItem.blockingUpdates = (mainItem.isGroup !== model.IsGroupParent); // BUG 464597 Force unload the previous component
|
||||
|
||||
mainItem.parentTask = this;
|
||||
mainItem.rootIndex = tasksModel.makeModelIndex(index, -1);
|
||||
|
||||
mainItem.appName = Qt.binding(() => model.AppName);
|
||||
mainItem.pidParent = Qt.binding(() => model.AppPid);
|
||||
mainItem.windows = Qt.binding(() => model.WinIdList);
|
||||
mainItem.isGroup = Qt.binding(() => model.IsGroupParent);
|
||||
mainItem.icon = Qt.binding(() => model.decoration);
|
||||
mainItem.launcherUrl = Qt.binding(() => model.LauncherUrlWithoutIcon);
|
||||
mainItem.isLauncher = Qt.binding(() => model.IsLauncher);
|
||||
mainItem.isMinimized = Qt.binding(() => model.IsMinimized);
|
||||
mainItem.display = Qt.binding(() => model.display);
|
||||
mainItem.genericName = Qt.binding(() => model.GenericName);
|
||||
mainItem.virtualDesktops = Qt.binding(() => model.VirtualDesktops);
|
||||
mainItem.isOnAllVirtualDesktops = Qt.binding(() => model.IsOnAllVirtualDesktops);
|
||||
mainItem.activities = Qt.binding(() => model.Activities);
|
||||
|
||||
mainItem.smartLauncherCountVisible = Qt.binding(() => smartLauncherItem?.countVisible ?? false);
|
||||
mainItem.smartLauncherCount = Qt.binding(() => mainItem.smartLauncherCountVisible ? smartLauncherItem.count : 0);
|
||||
|
||||
mainItem.blockingUpdates = false;
|
||||
tasksRoot.toolTipAreaItem = this;
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: pulseAudio.item
|
||||
ignoreUnknownSignals: true // Plasma-PA might not be available
|
||||
function onStreamsChanged(): void {
|
||||
task.updateAudioStreams({delay: true})
|
||||
}
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
id: menuTapHandler
|
||||
acceptedButtons: Qt.LeftButton
|
||||
acceptedDevices: PointerDevice.TouchScreen | PointerDevice.Stylus
|
||||
gesturePolicy: TapHandler.ReleaseWithinBounds
|
||||
onLongPressed: {
|
||||
// When we're a launcher, there's no window controls, so we can show all
|
||||
// places without the menu getting super huge.
|
||||
if (model.IsLauncher) {
|
||||
showContextMenu({showAllPlaces: true})
|
||||
} else {
|
||||
showContextMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.RightButton
|
||||
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad | PointerDevice.Stylus
|
||||
gesturePolicy: TapHandler.WithinBounds // Release grab when menu appears
|
||||
onPressedChanged: if (pressed) contextMenuTimer.start()
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: contextMenuTimer
|
||||
interval: 0
|
||||
onTriggered: menuTapHandler.longPressed()
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
id: leftTapHandler
|
||||
acceptedButtons: Qt.LeftButton
|
||||
onTapped: (eventPoint, button) => leftClick()
|
||||
|
||||
function leftClick(): void {
|
||||
if (task.active) {
|
||||
hideToolTip();
|
||||
}
|
||||
TaskTools.activateTask(modelIndex(), model, point.modifiers, task, Plasmoid, tasksRoot, effectWatcher.registered);
|
||||
}
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.MiddleButton | Qt.BackButton | Qt.ForwardButton
|
||||
onTapped: (eventPoint, button) => {
|
||||
if (button === Qt.MiddleButton) {
|
||||
if (Plasmoid.configuration.middleClickAction === TaskManagerApplet.Backend.NewInstance) {
|
||||
tasksModel.requestNewInstance(modelIndex());
|
||||
} else if (Plasmoid.configuration.middleClickAction === TaskManagerApplet.Backend.Close) {
|
||||
tasksRoot.taskClosedWithMouseMiddleButton = model.WinIdList.slice()
|
||||
tasksModel.requestClose(modelIndex());
|
||||
} else if (Plasmoid.configuration.middleClickAction === TaskManagerApplet.Backend.ToggleMinimized) {
|
||||
tasksModel.requestToggleMinimized(modelIndex());
|
||||
} else if (Plasmoid.configuration.middleClickAction === TaskManagerApplet.Backend.ToggleGrouping) {
|
||||
tasksModel.requestToggleGrouping(modelIndex());
|
||||
} else if (Plasmoid.configuration.middleClickAction === TaskManagerApplet.Backend.BringToCurrentDesktop) {
|
||||
tasksModel.requestVirtualDesktops(modelIndex(), [virtualDesktopInfo.currentDesktop]);
|
||||
}
|
||||
} else if (button === Qt.BackButton || button === Qt.ForwardButton) {
|
||||
const playerData = mpris2Source.playerForLauncherUrl(model.LauncherUrlWithoutIcon, model.AppPid);
|
||||
if (playerData) {
|
||||
if (button === Qt.BackButton) {
|
||||
playerData.Previous();
|
||||
} else {
|
||||
playerData.Next();
|
||||
}
|
||||
} else {
|
||||
eventPoint.accepted = false;
|
||||
}
|
||||
}
|
||||
|
||||
backend.cancelHighlightWindows();
|
||||
}
|
||||
}
|
||||
|
||||
KSvg.FrameSvgItem {
|
||||
id: frame
|
||||
|
||||
anchors {
|
||||
fill: parent
|
||||
|
||||
topMargin: (!tasksRoot.vertical && taskList.rows > 1) ? LayoutMetrics.iconMargin : 0
|
||||
bottomMargin: (!tasksRoot.vertical && taskList.rows > 1) ? LayoutMetrics.iconMargin : 0
|
||||
leftMargin: ((inPopup || tasksRoot.vertical) && taskList.columns > 1) ? LayoutMetrics.iconMargin : 0
|
||||
rightMargin: ((inPopup || tasksRoot.vertical) && taskList.columns > 1) ? LayoutMetrics.iconMargin : 0
|
||||
}
|
||||
|
||||
imagePath: "widgets/tasks"
|
||||
property bool isHovered: task.highlighted && Plasmoid.configuration.taskHoverEffect
|
||||
property string basePrefix: "normal"
|
||||
prefix: isHovered ? TaskTools.taskPrefixHovered(basePrefix, Plasmoid.location) : TaskTools.taskPrefix(basePrefix, Plasmoid.location)
|
||||
|
||||
// ALL zoom effect properties moved to frame for complete integration - PERFORMANCE OPTIMIZED
|
||||
property real zoomScale: 1.0
|
||||
property bool zoomEnabled: tasksRoot.iconsOnly && Plasmoid.configuration.magnifyFactor > 0
|
||||
property real magnifyFactor: Plasmoid.configuration.magnifyFactor
|
||||
property bool isZoomed: zoomScale > 1.0
|
||||
property bool hoverDelayActive: false
|
||||
property int zoomDuration: Plasmoid.configuration.zoomDuration
|
||||
property int zoomEasing: Plasmoid.configuration.zoomEasing
|
||||
property int hoverDelay: Plasmoid.configuration.hoverDelay
|
||||
property int resetDelay: Plasmoid.configuration.resetDelay
|
||||
property int zoomAnchor: Plasmoid.configuration.zoomAnchor
|
||||
|
||||
// Performance: Track animation state efficiently
|
||||
property bool isAnimating: zoomScale !== 1.0 || zoomScaleAnimation.running || zoomScaleYAnimation.running
|
||||
|
||||
// Ensure zoomed frames appear above others
|
||||
z: isZoomed ? 100 : 0
|
||||
|
||||
// Performance: Throttle hover detection using existing highlight system
|
||||
property bool shouldZoom: (task.highlighted || model.IsActive || model.IsDemandingAttention) && zoomEnabled && !model.IsStartup
|
||||
|
||||
// Performance: Debounce zoom state changes (but keep it very responsive)
|
||||
property bool _zoomPending: false
|
||||
|
||||
onShouldZoomChanged: {
|
||||
// Much more aggressive response for rapid mouse movements
|
||||
if (_zoomPending) return;
|
||||
_zoomPending = true;
|
||||
zoomDebounceTimer.restart();
|
||||
}
|
||||
|
||||
// Highly responsive debounce timer for smooth rapid movements
|
||||
Timer {
|
||||
id: zoomDebounceTimer
|
||||
interval: 4 // Ultra-responsive ~250fps for rapid mouse movements
|
||||
onTriggered: {
|
||||
frame._zoomPending = false;
|
||||
if (frame.shouldZoom) {
|
||||
resetDelayTimer.stop();
|
||||
// For rapid movements, reduce or eliminate hover delay
|
||||
if (frame.hoverDelay <= 50) {
|
||||
// Very fast or immediate zoom for low hover delays
|
||||
hoverDelayTimer.interval = Math.max(1, frame.hoverDelay);
|
||||
} else {
|
||||
hoverDelayTimer.interval = frame.hoverDelay;
|
||||
}
|
||||
hoverDelayTimer.restart();
|
||||
|
||||
// IMMEDIATE ZOOM: For ultra-low hover delays, apply zoom immediately
|
||||
if (frame.hoverDelay <= 10) {
|
||||
frame.hoverDelayActive = true;
|
||||
|
||||
let zoomIntensity;
|
||||
if (model.IsDemandingAttention || (task.smartLauncherItem && task.smartLauncherItem.urgent)) {
|
||||
zoomIntensity = frame.magnifyFactor * 0.6;
|
||||
} else if (model.IsActive) {
|
||||
zoomIntensity = frame.magnifyFactor * 0.4;
|
||||
} else {
|
||||
zoomIntensity = frame.magnifyFactor * 0.5;
|
||||
}
|
||||
|
||||
const baseZoom = 1.0 + zoomIntensity;
|
||||
frame.zoomScale = Math.max(1.0, baseZoom);
|
||||
}
|
||||
} else {
|
||||
hoverDelayTimer.stop();
|
||||
// Faster reset for rapid movements
|
||||
resetDelayTimer.interval = Math.max(10, frame.resetDelay);
|
||||
resetDelayTimer.restart();
|
||||
|
||||
// IMMEDIATE RESET: For ultra-low reset delays, reset immediately
|
||||
if (frame.resetDelay <= 10) {
|
||||
frame.hoverDelayActive = false;
|
||||
frame.zoomScale = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hover delay timer for smoother experience - HIGHLY OPTIMIZED for rapid movements
|
||||
Timer {
|
||||
id: hoverDelayTimer
|
||||
interval: frame.hoverDelay // Dynamic interval set by debounce timer
|
||||
onTriggered: {
|
||||
if (frame.shouldZoom) {
|
||||
frame.hoverDelayActive = true;
|
||||
|
||||
// Performance: Pre-calculate zoom intensity only when needed
|
||||
let zoomIntensity;
|
||||
if (model.IsDemandingAttention || (task.smartLauncherItem && task.smartLauncherItem.urgent)) {
|
||||
zoomIntensity = frame.magnifyFactor * 0.6;
|
||||
} else if (model.IsActive) {
|
||||
zoomIntensity = frame.magnifyFactor * 0.4;
|
||||
} else {
|
||||
zoomIntensity = frame.magnifyFactor * 0.5;
|
||||
}
|
||||
|
||||
const baseZoom = 1.0 + zoomIntensity;
|
||||
frame.zoomScale = Math.max(1.0, baseZoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reset timer for smooth zoom out - OPTIMIZED for rapid movements
|
||||
Timer {
|
||||
id: resetDelayTimer
|
||||
interval: frame.resetDelay // Dynamic interval set by debounce timer
|
||||
onTriggered: {
|
||||
if (!frame.shouldZoom) {
|
||||
frame.hoverDelayActive = false;
|
||||
frame.zoomScale = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Performance: Static easing type lookup
|
||||
function getEasingType(easingIndex) {
|
||||
const easingTypes = [
|
||||
Easing.Linear, Easing.OutQuad, Easing.OutCubic, Easing.OutQuart,
|
||||
Easing.OutBack, Easing.OutElastic, Easing.OutBounce
|
||||
];
|
||||
return easingTypes[easingIndex] || Easing.OutCubic;
|
||||
}
|
||||
|
||||
// Avoid repositioning delegate item after dragFinished
|
||||
DragHandler {
|
||||
id: dragHandler
|
||||
grabPermissions: PointerHandler.CanTakeOverFromHandlersOfDifferentType
|
||||
|
||||
function setRequestedInhibitDnd(value: bool): void {
|
||||
// This is modifying the value in the panel containment that
|
||||
// inhibits accepting drag and drop, so that we don't accidentally
|
||||
// drop the task on this panel.
|
||||
let item = this;
|
||||
while (item.parent) {
|
||||
item = item.parent;
|
||||
if (item.appletRequestsInhibitDnD !== undefined) {
|
||||
item.appletRequestsInhibitDnD = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onActiveChanged: {
|
||||
if (active) {
|
||||
icon.grabToImage(result => {
|
||||
if (!dragHandler.active) {
|
||||
// BUG 466675 grabToImage is async, so avoid updating dragSource when active is false
|
||||
return;
|
||||
}
|
||||
setRequestedInhibitDnd(true);
|
||||
tasksRoot.dragSource = task;
|
||||
dragHelper.Drag.imageSource = result.url;
|
||||
dragHelper.Drag.mimeData = {
|
||||
"text/x-orgkdeplasmataskmanager_taskurl": backend.tryDecodeApplicationsUrl(model.LauncherUrlWithoutIcon).toString(),
|
||||
[model.MimeType]: model.MimeData,
|
||||
"application/x-orgkdeplasmataskmanager_taskbuttonitem": model.MimeData,
|
||||
};
|
||||
dragHelper.Drag.active = dragHandler.active;
|
||||
});
|
||||
} else {
|
||||
setRequestedInhibitDnd(false);
|
||||
dragHelper.Drag.active = false;
|
||||
dragHelper.Drag.imageSource = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Move iconBox and label to be children of frame so they scale with zoom
|
||||
Loader {
|
||||
id: iconBox
|
||||
|
||||
anchors {
|
||||
left: parent.left
|
||||
leftMargin: adjustMargin(true, parent.width, taskFrame.margins.left)
|
||||
top: parent.top
|
||||
topMargin: adjustMargin(false, parent.height, taskFrame.margins.top)
|
||||
}
|
||||
|
||||
width: task.inPopup ? Math.max(Kirigami.Units.iconSizes.sizeForLabels, Kirigami.Units.iconSizes.medium) : Math.min(task.parent?.minimumWidth ?? 0, task.height)
|
||||
height: task.inPopup ? width : (parent.height - adjustMargin(false, parent.height, taskFrame.margins.top)
|
||||
- adjustMargin(false, parent.height, taskFrame.margins.bottom))
|
||||
|
||||
asynchronous: true
|
||||
active: height >= Kirigami.Units.iconSizes.small
|
||||
&& task.smartLauncherItem && task.smartLauncherItem.countVisible
|
||||
source: "TaskBadgeOverlay.qml"
|
||||
|
||||
function adjustMargin(isVertical: bool, size: real, margin: real): real {
|
||||
if (!size) {
|
||||
return margin;
|
||||
}
|
||||
|
||||
var margins = isVertical ? LayoutMetrics.horizontalMargins() : LayoutMetrics.verticalMargins();
|
||||
|
||||
if ((size - margins) < Kirigami.Units.iconSizes.small) {
|
||||
return Math.ceil((margin * (Kirigami.Units.iconSizes.small / size)) / 2);
|
||||
}
|
||||
|
||||
return margin;
|
||||
}
|
||||
|
||||
Kirigami.Icon {
|
||||
id: icon
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
active: task.highlighted
|
||||
enabled: true
|
||||
|
||||
source: model.decoration
|
||||
|
||||
// Use Transform objects for all animations (this is what works for bouncing)
|
||||
transform: [
|
||||
Translate {
|
||||
y: model.IsStartup && launchAnimationLoader.item ? launchAnimationLoader.item.iconOffsetY : 0
|
||||
},
|
||||
Scale {
|
||||
xScale: model.IsStartup && launchAnimationLoader.item ? launchAnimationLoader.item.iconScale : 1.0
|
||||
yScale: model.IsStartup && launchAnimationLoader.item ? launchAnimationLoader.item.iconScale : 1.0
|
||||
origin.x: width / 2
|
||||
origin.y: height / 2
|
||||
},
|
||||
Rotation {
|
||||
angle: model.IsStartup && launchAnimationLoader.item ? launchAnimationLoader.item.iconRotation : 0
|
||||
origin.x: width / 2
|
||||
origin.y: height / 2
|
||||
}
|
||||
]
|
||||
|
||||
// Opacity still needs to be a direct property
|
||||
opacity: model.IsStartup && launchAnimationLoader.item ? launchAnimationLoader.item.iconOpacity : 1.0
|
||||
}
|
||||
|
||||
states: [
|
||||
// Using a state transition avoids a binding loop between label.visible and
|
||||
// the text label margin, which derives from the icon width.
|
||||
State {
|
||||
name: "standalone"
|
||||
when: !label.visible && task.parent
|
||||
|
||||
AnchorChanges {
|
||||
target: iconBox
|
||||
anchors.left: undefined
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
PropertyChanges {
|
||||
target: iconBox
|
||||
anchors.leftMargin: 0
|
||||
width: Math.min(task.parent.minimumWidth, tasks.height)
|
||||
- adjustMargin(true, task.width, taskFrame.margins.left)
|
||||
- adjustMargin(true, task.width, taskFrame.margins.right)
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Loader {
|
||||
id: launchAnimationLoader
|
||||
anchors.centerIn: parent
|
||||
width: Math.min(parent.width, parent.height)
|
||||
height: width
|
||||
active: model.IsStartup
|
||||
sourceComponent: launchAnimationComponent
|
||||
|
||||
onLoaded: {
|
||||
if (item) {
|
||||
item.active = Qt.binding(() => model.IsStartup);
|
||||
item.iconSource = Qt.binding(() => model.decoration);
|
||||
item.animationType = Qt.binding(() => plasmoid.configuration.launchAnimationType);
|
||||
item.animationDuration = Qt.binding(() => plasmoid.configuration.launchAnimationDuration);
|
||||
item.animationIntensity = Qt.binding(() => plasmoid.configuration.launchAnimationIntensity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Busy indicator overlay - shows on top of icon when animationType is 0
|
||||
PlasmaComponents3.BusyIndicator {
|
||||
anchors.centerIn: parent
|
||||
width: Math.min(parent.width, parent.height) * 0.8
|
||||
height: width
|
||||
visible: model.IsStartup && launchAnimationLoader.item && launchAnimationLoader.item.animationType === 0
|
||||
running: visible
|
||||
z: 20
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaComponents3.Label {
|
||||
id: label
|
||||
|
||||
visible: (inPopup || !iconsOnly && !model.IsLauncher
|
||||
&& (parent.width - iconBox.height - Kirigami.Units.smallSpacing) >= LayoutMetrics.spaceRequiredToShowText())
|
||||
|
||||
anchors {
|
||||
fill: parent
|
||||
leftMargin: taskFrame.margins.left + iconBox.width + LayoutMetrics.labelMargin
|
||||
topMargin: taskFrame.margins.top
|
||||
rightMargin: taskFrame.margins.right + (audioStreamIcon !== null && audioStreamIcon.visible ? (audioStreamIcon.width + LayoutMetrics.labelMargin) : 0)
|
||||
bottomMargin: taskFrame.margins.bottom
|
||||
}
|
||||
|
||||
wrapMode: (maximumLineCount === 1) ? Text.NoWrap : Text.Wrap
|
||||
elide: Text.ElideRight
|
||||
textFormat: Text.PlainText
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
maximumLineCount: Plasmoid.configuration.maxTextLines || undefined
|
||||
|
||||
Accessible.ignored: true
|
||||
|
||||
// use State to avoid unnecessary re-evaluation when the label is invisible
|
||||
states: State {
|
||||
name: "labelVisible"
|
||||
when: label.visible
|
||||
|
||||
PropertyChanges {
|
||||
target: label
|
||||
text: model.display
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: taskProgressOverlayLoader
|
||||
|
||||
anchors.fill: frame
|
||||
asynchronous: true
|
||||
active: model.IsWindow && task.smartLauncherItem && task.smartLauncherItem.progressVisible
|
||||
|
||||
source: "TaskProgressOverlay.qml"
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "launcher"
|
||||
when: model.IsLauncher
|
||||
|
||||
PropertyChanges {
|
||||
target: frame
|
||||
basePrefix: ""
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "attention"
|
||||
when: model.IsDemandingAttention || (task.smartLauncherItem && task.smartLauncherItem.urgent)
|
||||
|
||||
PropertyChanges {
|
||||
target: frame
|
||||
basePrefix: "attention"
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "minimized"
|
||||
when: model.IsMinimized
|
||||
|
||||
PropertyChanges {
|
||||
target: frame
|
||||
basePrefix: "minimized"
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "active"
|
||||
when: model.IsActive
|
||||
|
||||
PropertyChanges {
|
||||
target: frame
|
||||
basePrefix: "focus"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Component.onCompleted: {
|
||||
if (!inPopup && model.IsWindow) {
|
||||
const component = Qt.createComponent("GroupExpanderOverlay.qml");
|
||||
component.createObject(task);
|
||||
component.destroy();
|
||||
updateAudioStreams({delay: false});
|
||||
}
|
||||
|
||||
if (!inPopup && !model.IsWindow) {
|
||||
taskInitComponent.createObject(task);
|
||||
}
|
||||
completed = true;
|
||||
}
|
||||
Component.onDestruction: {
|
||||
if (moveAnim.running) {
|
||||
(task.parent as TaskList).animationsRunning -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
onHighlightedChanged: {
|
||||
// ensure it doesn't get stuck with a window highlighted
|
||||
backend.cancelHighlightWindows();
|
||||
}
|
||||
|
||||
// Performance: Invalidate caches when relevant properties change
|
||||
Connections {
|
||||
target: tasksRoot
|
||||
function onHeightChanged() { }
|
||||
function onWidthChanged() { }
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: Plasmoid.configuration
|
||||
function onMaxStripesChanged() { }
|
||||
function onZoomAnchorChanged() { }
|
||||
// Add invalidation for filter changes that affect task visibility
|
||||
function onShowOnlyCurrentDesktopChanged() { }
|
||||
function onShowOnlyCurrentActivityChanged() { }
|
||||
function onShowOnlyCurrentScreenChanged() { }
|
||||
function onShowOnlyMinimizedChanged() { }
|
||||
}
|
||||
|
||||
// Enhanced: Monitor task model changes that affect individual task layout
|
||||
Connections {
|
||||
target: tasksModel
|
||||
function onCountChanged() { }
|
||||
}
|
||||
|
||||
// Movement transform - always present
|
||||
Translate {
|
||||
id: translateTransform
|
||||
}
|
||||
|
||||
// Zoom transform - only applied when actively zooming - REMOVED CACHING TO FIX BINDING LOOPS
|
||||
Scale {
|
||||
id: zoomTransform
|
||||
|
||||
// Simple, direct origin calculation without caching to avoid binding loops
|
||||
origin.x: {
|
||||
const effectiveWidth = frame.width;
|
||||
const effectiveHeight = frame.height;
|
||||
|
||||
switch(frame.zoomAnchor) {
|
||||
case 0: return effectiveWidth / 2; // Center
|
||||
case 1: return effectiveWidth / 2; // Bottom
|
||||
case 2: return effectiveWidth / 2; // Top
|
||||
case 3: return 0; // Left
|
||||
case 4: return effectiveWidth; // Right
|
||||
case 5: return 0; // BottomLeft
|
||||
case 6: return effectiveWidth; // BottomRight
|
||||
case 7: return 0; // TopLeft
|
||||
case 8: return effectiveWidth; // TopRight
|
||||
default: return effectiveWidth / 2; // Default to Bottom
|
||||
}
|
||||
}
|
||||
|
||||
origin.y: {
|
||||
const effectiveWidth = frame.width;
|
||||
const effectiveHeight = frame.height;
|
||||
|
||||
switch(frame.zoomAnchor) {
|
||||
case 0: return effectiveHeight / 2; // Center
|
||||
case 1: return effectiveHeight; // Bottom
|
||||
case 2: return 0; // Top
|
||||
case 3: return effectiveHeight / 2; // Left
|
||||
case 4: return effectiveHeight / 2; // Right
|
||||
case 5: return effectiveHeight; // BottomLeft
|
||||
case 6: return effectiveHeight; // BottomRight
|
||||
case 7: return 0; // TopLeft
|
||||
case 8: return 0; // TopRight
|
||||
default: return effectiveHeight; // Default to Bottom
|
||||
}
|
||||
}
|
||||
|
||||
xScale: frame.zoomScale
|
||||
yScale: frame.zoomScale
|
||||
|
||||
// Performance: Optimize animation behavior
|
||||
Behavior on xScale {
|
||||
enabled: frame.zoomEnabled
|
||||
NumberAnimation {
|
||||
id: zoomScaleAnimation
|
||||
duration: frame.zoomDuration
|
||||
easing.type: frame.getEasingType(frame.zoomEasing)
|
||||
easing.overshoot: frame.zoomEasing === 4 ? 1.2 : 1.0
|
||||
// Performance: Prevent unnecessary intermediate updates
|
||||
easing.period: frame.zoomEasing === 5 ? 0.3 : 1.0
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on yScale {
|
||||
enabled: frame.zoomEnabled
|
||||
NumberAnimation {
|
||||
id: zoomScaleYAnimation
|
||||
duration: frame.zoomDuration
|
||||
easing.type: frame.getEasingType(frame.zoomEasing)
|
||||
easing.overshoot: frame.zoomEasing === 4 ? 1.2 : 1.0
|
||||
// Performance: Prevent unnecessary intermediate updates
|
||||
easing.period: frame.zoomEasing === 5 ? 0.3 : 1.0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
import QtQuick
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.graphicaleffects as KGraphicalEffects
|
||||
import org.kde.plasma.plasmoid
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
readonly property int iconWidthDelta: (icon.width - icon.paintedWidth) / 2
|
||||
readonly property bool shiftBadgeDown: (Plasmoid.pluginName === "org.kde.plasma.icontasks" || Plasmoid.pluginName === "org.kde.plasma.icontasks.zoom") && task.audioStreamIcon !== null
|
||||
|
||||
Item {
|
||||
id: badgeMask
|
||||
anchors.fill: parent
|
||||
|
||||
Rectangle {
|
||||
readonly property int offset: Math.round(Math.max(Kirigami.Units.smallSpacing / 2, badgeMask.width / 32))
|
||||
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: -offset
|
||||
y: root.shiftBadgeDown ? (icon.height / 2) : 0
|
||||
|
||||
Behavior on y {
|
||||
NumberAnimation { duration: Kirigami.Units.longDuration }
|
||||
}
|
||||
|
||||
visible: task.smartLauncherItem.countVisible
|
||||
width: badgeRect.width + offset * 2
|
||||
height: badgeRect.height + offset * 2
|
||||
radius: badgeRect.radius + offset * 2
|
||||
|
||||
// Badge changes width based on number.
|
||||
onWidthChanged: maskShaderSource.scheduleUpdate()
|
||||
onVisibleChanged: maskShaderSource.scheduleUpdate()
|
||||
onYChanged: maskShaderSource.scheduleUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
ShaderEffectSource {
|
||||
id: iconShaderSource
|
||||
sourceItem: icon
|
||||
hideSource: GraphicsInfo.api !== GraphicsInfo.Software
|
||||
}
|
||||
|
||||
ShaderEffectSource {
|
||||
id: maskShaderSource
|
||||
sourceItem: badgeMask
|
||||
hideSource: true
|
||||
live: false
|
||||
}
|
||||
|
||||
KGraphicalEffects.BadgeEffect {
|
||||
id: shader
|
||||
|
||||
anchors.fill: parent
|
||||
source: iconShaderSource
|
||||
mask: maskShaderSource
|
||||
|
||||
onWidthChanged: maskShaderSource.scheduleUpdate()
|
||||
onHeightChanged: maskShaderSource.scheduleUpdate()
|
||||
}
|
||||
|
||||
Badge {
|
||||
id: badgeRect
|
||||
|
||||
anchors.right: parent.right
|
||||
y: {
|
||||
const offset = Math.round(Math.max(Kirigami.Units.smallSpacing / 2, badgeMask.width / 32));
|
||||
return offset + (root.shiftBadgeDown ? (icon.height / 2) : 0);
|
||||
}
|
||||
|
||||
Behavior on y {
|
||||
NumberAnimation { duration: Kirigami.Units.longDuration }
|
||||
}
|
||||
|
||||
height: Math.round(parent.height * 0.4)
|
||||
visible: task.smartLauncherItem.countVisible
|
||||
number: task.smartLauncherItem.count
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2012-2013 Eike Hein <hein@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import org.kde.plasma.plasmoid
|
||||
import "code/layoutmetrics.js" as LayoutMetrics
|
||||
|
||||
GridLayout {
|
||||
property bool animating: false
|
||||
|
||||
// Prevent clipping of zoomed icons
|
||||
clip: false
|
||||
|
||||
rowSpacing: 0
|
||||
columnSpacing: 0
|
||||
|
||||
property int animationsRunning: 0
|
||||
onAnimationsRunningChanged: {
|
||||
animating = animationsRunning > 0;
|
||||
}
|
||||
|
||||
// Simple direct calculation for minimum width - REMOVED CACHING TO FIX BINDING LOOPS
|
||||
readonly property real minimumWidth: {
|
||||
const visibleChildren = children.filter(item => item.visible && item.width > 0);
|
||||
return visibleChildren.length > 0
|
||||
? visibleChildren.reduce((min, item) => Math.min(min, item.width), Infinity)
|
||||
: Infinity;
|
||||
}
|
||||
|
||||
// Simple direct calculation for stripe count - REMOVED CACHING TO FIX BINDING LOOPS
|
||||
readonly property int stripeCount: {
|
||||
if (tasks.plasmoid.configuration.maxStripes === 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const firstChild = children[0];
|
||||
if (!firstChild) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const stripeSizeLimit = tasks.vertical
|
||||
? Math.floor(tasks.width / firstChild.implicitWidth)
|
||||
: Math.floor(tasks.height / firstChild.implicitHeight);
|
||||
const maxStripes = Math.min(tasks.plasmoid.configuration.maxStripes, stripeSizeLimit);
|
||||
|
||||
if (tasks.plasmoid.configuration.forceStripes) {
|
||||
return maxStripes;
|
||||
} else {
|
||||
const maxTasksPerStripe = tasks.vertical
|
||||
? Math.ceil(tasks.height / LayoutMetrics.preferredMinHeight())
|
||||
: Math.ceil(tasks.width / LayoutMetrics.preferredMinWidth());
|
||||
return Math.min(Math.ceil(tasksModel.count / maxTasksPerStripe), maxStripes);
|
||||
}
|
||||
}
|
||||
|
||||
readonly property int orthogonalCount: {
|
||||
return Math.ceil(tasksModel.count / stripeCount);
|
||||
}
|
||||
|
||||
rows: tasks.vertical ? orthogonalCount : stripeCount
|
||||
columns: tasks.vertical ? stripeCount : orthogonalCount
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Templates as T
|
||||
|
||||
import org.kde.ksvg as KSvg
|
||||
import org.kde.plasma.plasmoid
|
||||
|
||||
import "code/tools.js" as TaskTools
|
||||
|
||||
T.ProgressBar {
|
||||
id: control
|
||||
|
||||
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
|
||||
implicitContentWidth + leftPadding + rightPadding)
|
||||
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
|
||||
implicitContentHeight + topPadding + bottomPadding)
|
||||
|
||||
hoverEnabled: false
|
||||
padding: 0
|
||||
|
||||
from: 0
|
||||
to: 100
|
||||
value: task.smartLauncherItem.progress
|
||||
|
||||
contentItem: Item {
|
||||
clip: true
|
||||
|
||||
KSvg.FrameSvgItem {
|
||||
id: progressFrame
|
||||
|
||||
anchors.left: parent.left
|
||||
width: parent.width * control.position
|
||||
height: parent.height
|
||||
|
||||
imagePath: "widgets/tasks"
|
||||
prefix: TaskTools.taskPrefix("progress", Plasmoid.location).concat(TaskTools.taskPrefix("hover", Plasmoid.location))
|
||||
}
|
||||
}
|
||||
|
||||
background: null
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de>
|
||||
SPDX-FileCopyrightText: 2017 Roman Gilg <subdiff@gmail.com>
|
||||
SPDX-FileCopyrightText: 2024 Nate Graham <nate@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQml.Models
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.plasma.core as PlasmaCore
|
||||
import org.kde.plasma.components as PlasmaComponents3
|
||||
import org.kde.plasma.private.mpris as Mpris
|
||||
import org.kde.kirigami as Kirigami
|
||||
|
||||
import org.kde.plasma.plasmoid
|
||||
|
||||
Loader {
|
||||
id: toolTipDelegate
|
||||
|
||||
property Task parentTask
|
||||
property /*QModelIndex*/var rootIndex
|
||||
|
||||
property string appName
|
||||
property int pidParent
|
||||
property bool isGroup
|
||||
|
||||
property /*list<WId> where WId = int|string*/ var windows: []
|
||||
readonly property bool isWin: windows.length > 0
|
||||
|
||||
property /*QIcon*/ var icon
|
||||
property url launcherUrl
|
||||
property bool isLauncher
|
||||
property bool isMinimized
|
||||
|
||||
// Needed for generateSubtext()
|
||||
property string display
|
||||
property string genericName
|
||||
property /*list<var>*/ var virtualDesktops: [] // Can't use list<var> because of QTBUG-127600
|
||||
property bool isOnAllVirtualDesktops
|
||||
property list<string> activities: []
|
||||
|
||||
property bool smartLauncherCountVisible
|
||||
property int smartLauncherCount
|
||||
|
||||
property bool blockingUpdates: false
|
||||
|
||||
readonly property bool isVerticalPanel: Plasmoid.formFactor === PlasmaCore.Types.Vertical
|
||||
// This number controls the overall size of the window tooltips
|
||||
readonly property int tooltipInstanceMaximumWidth: Kirigami.Units.gridUnit * 16
|
||||
|
||||
// These properties are required to make tooltip interactive when there is a player but no window is present.
|
||||
readonly property Mpris.PlayerContainer playerData: mpris2Source.playerForLauncherUrl(launcherUrl, pidParent)
|
||||
|
||||
LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
|
||||
LayoutMirroring.childrenInherit: true
|
||||
|
||||
active: !blockingUpdates && rootIndex !== undefined && ((parentTask && parentTask.containsMouse) || Window.visibility !== Window.Hidden)
|
||||
asynchronous: true
|
||||
|
||||
sourceComponent: isGroup ? groupToolTip : singleTooltip
|
||||
|
||||
Component {
|
||||
id: singleTooltip
|
||||
|
||||
ToolTipInstance {
|
||||
index: 0 // TODO: maybe set to -1, because that's what the component checks against?
|
||||
submodelIndex: toolTipDelegate.rootIndex
|
||||
appPid: toolTipDelegate.pidParent
|
||||
display: toolTipDelegate.display
|
||||
isMinimized: toolTipDelegate.isMinimized
|
||||
isOnAllVirtualDesktops: toolTipDelegate.isOnAllVirtualDesktops
|
||||
virtualDesktops: toolTipDelegate.virtualDesktops
|
||||
activities: toolTipDelegate.activities
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: groupToolTip
|
||||
|
||||
PlasmaComponents3.ScrollView {
|
||||
// 2 * Kirigami.Units.smallSpacing is for the margin of tooltipDialog
|
||||
implicitWidth: leftPadding + rightPadding + Math.min(Screen.desktopAvailableWidth - 2 * Kirigami.Units.smallSpacing, Math.max(delegateModel.estimatedWidth, contentItem.contentItem.childrenRect.width))
|
||||
implicitHeight: bottomPadding + Math.min(Screen.desktopAvailableHeight - 2 * Kirigami.Units.smallSpacing, Math.max(delegateModel.estimatedHeight, contentItem.contentItem.childrenRect.height))
|
||||
|
||||
ListView {
|
||||
id: groupToolTipListView
|
||||
|
||||
model: delegateModel
|
||||
|
||||
orientation: isVerticalPanel || !Plasmoid.configuration.showToolTips ? ListView.Vertical : ListView.Horizontal
|
||||
reuseItems: true
|
||||
|
||||
// Lots of spacing with no thumbnails looks bad
|
||||
spacing: Plasmoid.configuration.showToolTips ? Kirigami.Units.gridUnit : 0
|
||||
|
||||
// Required to know whether to display the media player buttons on the first window or not
|
||||
property bool hasTrackInATitle: {
|
||||
var found = false
|
||||
for (var i=0; i<model.items.count && !found; i++) {
|
||||
found = model.items.get(i).model.display.includes(playerData?.track)
|
||||
}
|
||||
return found
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DelegateModel {
|
||||
id: delegateModel
|
||||
|
||||
// On Wayland, a tooltip has a significant resizing process, so estimate the size first.
|
||||
readonly property real estimatedWidth: (toolTipDelegate.isVerticalPanel || !Plasmoid.configuration.showToolTips ? 1 : count) * (toolTipDelegate.tooltipInstanceMaximumWidth + Kirigami.Units.gridUnit) - Kirigami.Units.gridUnit
|
||||
readonly property real estimatedHeight: (toolTipDelegate.isVerticalPanel || !Plasmoid.configuration.showToolTips ? count : 1) * (Plasmoid.configuration.showToolTips ? (toolTipDelegate.tooltipInstanceMaximumWidth / 2 + Kirigami.Units.gridUnit) : Kirigami.Units.gridUnit * 2) - Kirigami.Units.gridUnit
|
||||
|
||||
model: tasksModel
|
||||
|
||||
rootIndex: toolTipDelegate.rootIndex
|
||||
onRootIndexChanged: groupToolTipListView.positionViewAtBeginning() // Fix a visual glitch (when the mouse moves from a tooltip with a moved scrollbar to another tooltip without a scrollbar)
|
||||
|
||||
delegate: ToolTipInstance {
|
||||
required property var model
|
||||
|
||||
submodelIndex: tasksModel.makeModelIndex(toolTipDelegate.rootIndex.row, index)
|
||||
appPid: model.AppPid
|
||||
// 'display' is required already
|
||||
isMinimized: model.IsMinimized
|
||||
isOnAllVirtualDesktops: model.IsOnAllVirtualDesktops
|
||||
virtualDesktops: model.VirtualDesktops
|
||||
activities: model.Activities
|
||||
hasTrackInATitle: groupToolTipListView.hasTrackInATitle
|
||||
orientation: groupToolTipListView.orientation
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,499 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de>
|
||||
SPDX-FileCopyrightText: 2017 Roman Gilg <subdiff@gmail.com>
|
||||
SPDX-FileCopyrightText: 2020-2024 Nate Graham <nate@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Qt5Compat.GraphicalEffects as GE
|
||||
|
||||
import org.kde.plasma.plasmoid
|
||||
import org.kde.plasma.core as PlasmaCore
|
||||
import org.kde.plasma.components as PlasmaComponents3
|
||||
import org.kde.plasma.extras as PlasmaExtras
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kwindowsystem
|
||||
|
||||
ColumnLayout {
|
||||
id: root
|
||||
|
||||
required property int index
|
||||
required property /*QModelIndex*/ var submodelIndex
|
||||
required property int appPid
|
||||
required property string display
|
||||
required property bool isMinimized
|
||||
required property bool isOnAllVirtualDesktops
|
||||
required property /*list<var>*/ var virtualDesktops // Can't use list<var> because of QTBUG-127600
|
||||
required property list<string> activities
|
||||
|
||||
property bool hasTrackInATitle: false
|
||||
property int orientation: ListView.Vertical // vertical for compact single-window tooltips
|
||||
|
||||
// HACK: Avoid blank space in the tooltip after closing a window
|
||||
ListView.onPooled: width = height = 0
|
||||
ListView.onReused: width = height = undefined
|
||||
|
||||
readonly property string title: {
|
||||
if (!toolTipDelegate.isWin) {
|
||||
return toolTipDelegate.genericName;
|
||||
}
|
||||
|
||||
let text = display;
|
||||
if (toolTipDelegate.isGroup && text === "") {
|
||||
return "";
|
||||
}
|
||||
|
||||
// Normally the window title will always have " — [app name]" at the end of
|
||||
// the window-provided title. But if it doesn't, this is intentional 100%
|
||||
// of the time because the developer or user has deliberately removed that
|
||||
// part, so just display it with no more fancy processing.
|
||||
if (!text.match(/\s+(—|-|–)/)) {
|
||||
return text;
|
||||
}
|
||||
|
||||
// KWin appends increasing integers in between pointy brackets to otherwise equal window titles.
|
||||
// In this case save <#number> as counter and delete it at the end of text.
|
||||
text = `${(text.match(/.*(?=\s+(—|-|–))/) || [""])[0]}${(text.match(/<\d+>/) || [""]).pop()}`;
|
||||
|
||||
// In case the window title had only redundant information (i.e. appName), text is now empty.
|
||||
// Add a hyphen to indicate that and avoid empty space.
|
||||
if (text === "") {
|
||||
text = "—";
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
readonly property bool titleIncludesTrack: toolTipDelegate.playerData !== null && title.includes(toolTipDelegate.playerData.track)
|
||||
|
||||
// Lots of spacing with no thumbnails looks bad
|
||||
spacing: Plasmoid.configuration.showToolTips ? Kirigami.Units.smallSpacing : 0
|
||||
|
||||
// text labels + close button
|
||||
Item {
|
||||
id: headerItem
|
||||
implicitHeight: header.height
|
||||
implicitWidth: header.implicitWidth
|
||||
Layout.fillWidth: true
|
||||
|
||||
// This number controls the overall size of the window tooltips
|
||||
Layout.maximumWidth: toolTipDelegate.tooltipInstanceMaximumWidth
|
||||
Layout.minimumWidth: (toolTipDelegate.isWin && Plasmoid.configuration.showToolTips) || toolTipDelegate.isGroup ? Layout.maximumWidth : 0
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||
// match margins of DefaultToolTip.qml in plasma-framework
|
||||
Layout.margins: toolTipDelegate.isWin && Plasmoid.configuration.showToolTips ? 0 : Kirigami.Units.gridUnit / 2
|
||||
|
||||
RowLayout {
|
||||
id: header
|
||||
width: parent.width
|
||||
// match spacing of DefaultToolTip.qml in plasma-framework
|
||||
spacing: Kirigami.Units.smallSpacing
|
||||
|
||||
// all textlabels
|
||||
ColumnLayout {
|
||||
spacing: 0
|
||||
// app name
|
||||
Kirigami.Heading {
|
||||
id: appNameHeading
|
||||
level: 3
|
||||
maximumLineCount: 1
|
||||
Layout.fillWidth: true
|
||||
lineHeight: toolTipDelegate.isWin && Plasmoid.configuration.showToolTips ? 1 : appNameHeading.lineHeight
|
||||
elide: Text.ElideRight
|
||||
text: toolTipDelegate.appName
|
||||
color: (headerHoverHandler.visible && headerHoverHighlight.pressed) ? PlasmaCore.Theme.highlightedTextColor : PlasmaCore.Theme.textColor
|
||||
opacity: root.index === 0 ? 1 : 0
|
||||
visible: (text.length !== 0) && (root.orientation === ListView.Horizontal || root.index === 0)
|
||||
textFormat: Text.PlainText
|
||||
}
|
||||
// window title
|
||||
PlasmaComponents3.Label {
|
||||
id: winTitle
|
||||
maximumLineCount: 1
|
||||
Layout.fillWidth: true
|
||||
elide: Text.ElideRight
|
||||
property bool somethingVisible: (thumbnailSourceItem.visible ||
|
||||
appNameHeading.visible || subtext.visible)
|
||||
text: ((root.titleIncludesTrack && playerController.active) ||
|
||||
(root.title === appNameHeading.text && somethingVisible))
|
||||
? "" : root.title
|
||||
color: (headerHoverHandler.visible && headerHoverHighlight.pressed) ? PlasmaCore.Theme.highlightedTextColor : PlasmaCore.Theme.textColor
|
||||
opacity: 0.75
|
||||
visible: root.orientation === ListView.Horizontal || text.length !== 0
|
||||
textFormat: Text.PlainText
|
||||
}
|
||||
// subtext
|
||||
PlasmaComponents3.Label {
|
||||
id: subtext
|
||||
maximumLineCount: 2
|
||||
Layout.fillWidth: true
|
||||
elide: Text.ElideRight
|
||||
text: toolTipDelegate.isWin ? root.generateSubText() : ""
|
||||
color: (headerHoverHandler.visible && headerHoverHighlight.pressed) ? PlasmaCore.Theme.highlightedTextColor : PlasmaCore.Theme.textColor
|
||||
opacity: 0.6
|
||||
visible: text.length !== 0 && text !== appNameHeading.text
|
||||
textFormat: Text.PlainText
|
||||
}
|
||||
}
|
||||
|
||||
// Count badge.
|
||||
// The badge itself is inside an item to better center the text in the bubble
|
||||
Item {
|
||||
Layout.alignment: !Plasmoid.configuration.showToolTips && !playerController.active && !volumeControls.active ? Qt.AlignVCenter : Qt.AlignTop
|
||||
Layout.preferredHeight: closeButton.height
|
||||
Layout.preferredWidth: closeButton.width
|
||||
visible: root.index === 0 && toolTipDelegate.smartLauncherCountVisible
|
||||
|
||||
Badge {
|
||||
anchors.centerIn: parent
|
||||
height: Kirigami.Units.iconSizes.smallMedium
|
||||
number: toolTipDelegate.smartLauncherCount
|
||||
}
|
||||
}
|
||||
|
||||
// close button
|
||||
PlasmaComponents3.ToolButton {
|
||||
id: closeButton
|
||||
Layout.alignment: Qt.AlignTop// | Qt.AlignRight
|
||||
Layout.rightMargin: -headerItem.Layout.margins
|
||||
Layout.topMargin: -headerItem.Layout.margins
|
||||
visible: toolTipDelegate.isWin
|
||||
icon.name: "window-close"
|
||||
onClicked: {
|
||||
backend.cancelHighlightWindows();
|
||||
tasksModel.requestClose(root.submodelIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// make the header clickable if image tooltips are disabled (and thus there is no other clickable area that activates the window)
|
||||
// headerHoverHandler has to be unloaded after the instance is pooled in order to avoid getting the old containsMouse status when the same instance is reused, so put it in a Loader.
|
||||
Loader {
|
||||
id: headerHoverHandler
|
||||
active: (root.index !== -1) && !Plasmoid.configuration.showToolTips
|
||||
z: -2
|
||||
anchors.fill: headerItem
|
||||
anchors.margins: -headerItem.Layout.margins
|
||||
sourceComponent: ToolTipWindowMouseArea {
|
||||
rootTask: toolTipDelegate.parentTask
|
||||
modelIndex: root.submodelIndex
|
||||
winId: thumbnailSourceItem.winId
|
||||
}
|
||||
}
|
||||
|
||||
// There's no PlasmaComponents3 version
|
||||
PlasmaExtras.Highlight {
|
||||
id: headerHoverHighlight
|
||||
anchors.fill: headerHoverHandler
|
||||
z: -1
|
||||
visible: (headerHoverHandler.item as MouseArea)?.containsMouse ?? false
|
||||
pressed: (headerHoverHandler.item as MouseArea)?.containsPress ?? false
|
||||
hovered: true
|
||||
}
|
||||
}
|
||||
|
||||
// thumbnail container
|
||||
Item {
|
||||
id: thumbnailSourceItem
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: Kirigami.Units.gridUnit * 8
|
||||
|
||||
clip: true
|
||||
visible: Plasmoid.configuration.showToolTips && toolTipDelegate.isWin
|
||||
|
||||
readonly property /*undefined|WId where WId = int|string*/ var winId:
|
||||
toolTipDelegate.isWin ? toolTipDelegate.windows[root.index] : undefined
|
||||
|
||||
// There's no PlasmaComponents3 version
|
||||
PlasmaExtras.Highlight {
|
||||
anchors.fill: hoverHandler
|
||||
visible: (hoverHandler.item as MouseArea)?.containsMouse ?? false
|
||||
pressed: (hoverHandler.item as MouseArea)?.containsPress ?? false
|
||||
hovered: true
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: thumbnailLoader
|
||||
active: !toolTipDelegate.isLauncher
|
||||
&& !albumArtImage.visible
|
||||
&& (Number.isInteger(thumbnailSourceItem.winId) || pipeWireLoader.item && !pipeWireLoader.item.hasThumbnail)
|
||||
&& root.index !== -1 // Avoid loading when the instance is going to be destroyed
|
||||
asynchronous: true
|
||||
visible: active
|
||||
anchors.fill: hoverHandler
|
||||
// Indent a little bit so that neither the thumbnail nor the drop
|
||||
// shadow can cover up the highlight
|
||||
anchors.margins: Kirigami.Units.smallSpacing * 2
|
||||
|
||||
sourceComponent: root.isMinimized || pipeWireLoader.active ? iconItem : x11Thumbnail
|
||||
|
||||
Component {
|
||||
id: x11Thumbnail
|
||||
|
||||
PlasmaCore.WindowThumbnail {
|
||||
winId: thumbnailSourceItem.winId
|
||||
}
|
||||
}
|
||||
|
||||
// when minimized, we don't have a preview on X11, so show the icon
|
||||
Component {
|
||||
id: iconItem
|
||||
|
||||
Kirigami.Icon {
|
||||
id: realIconItem
|
||||
source: toolTipDelegate.icon
|
||||
animated: false
|
||||
visible: valid
|
||||
opacity: pipeWireLoader.active ? 0 : 1
|
||||
|
||||
SequentialAnimation {
|
||||
running: true
|
||||
|
||||
PauseAnimation {
|
||||
duration: Kirigami.Units.humanMoment
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
id: showAnimation
|
||||
duration: Kirigami.Units.longDuration
|
||||
easing.type: Easing.OutCubic
|
||||
property: "opacity"
|
||||
target: realIconItem
|
||||
to: 1
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: pipeWireLoader
|
||||
anchors.fill: hoverHandler
|
||||
// Indent a little bit so that neither the thumbnail nor the drop
|
||||
// shadow can cover up the highlight
|
||||
anchors.margins: thumbnailLoader.anchors.margins
|
||||
|
||||
active: !toolTipDelegate.isLauncher && !albumArtImage.visible && KWindowSystem.isPlatformWayland && root.index !== -1
|
||||
asynchronous: true
|
||||
//In a loader since we might not have PipeWire available yet (WITH_PIPEWIRE could be undefined in plasma-workspace/libtaskmanager/declarative/taskmanagerplugin.cpp)
|
||||
source: "PipeWireThumbnail.qml"
|
||||
}
|
||||
|
||||
Loader {
|
||||
active: (pipeWireLoader.item?.hasThumbnail ?? false) || (thumbnailLoader.status === Loader.Ready && !root.isMinimized)
|
||||
asynchronous: true
|
||||
visible: active
|
||||
anchors.fill: pipeWireLoader.active ? pipeWireLoader : thumbnailLoader
|
||||
|
||||
sourceComponent: GE.DropShadow {
|
||||
horizontalOffset: 0
|
||||
verticalOffset: 3
|
||||
radius: 8
|
||||
samples: Math.round(radius * 1.5)
|
||||
color: "Black"
|
||||
source: pipeWireLoader.active ? pipeWireLoader.item : thumbnailLoader.item // source could be undefined when albumArt is available, so put it in a Loader.
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
active: albumArtImage.visible && albumArtImage.status === Image.Ready && root.index !== -1 // Avoid loading when the instance is going to be destroyed
|
||||
asynchronous: true
|
||||
visible: active
|
||||
anchors.centerIn: hoverHandler
|
||||
|
||||
sourceComponent: ShaderEffect {
|
||||
id: albumArtBackground
|
||||
readonly property Image source: albumArtImage
|
||||
|
||||
// Manual implementation of Image.PreserveAspectCrop
|
||||
readonly property real scaleFactor: Math.max(hoverHandler.width / source.paintedWidth, hoverHandler.height / source.paintedHeight)
|
||||
width: Math.round(source.paintedWidth * scaleFactor)
|
||||
height: Math.round(source.paintedHeight * scaleFactor)
|
||||
layer.enabled: true
|
||||
opacity: 0.25
|
||||
layer.effect: GE.FastBlur {
|
||||
source: albumArtBackground
|
||||
anchors.fill: source
|
||||
radius: 30
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
id: albumArtImage
|
||||
// also Image.Loading to prevent loading thumbnails just because the album art takes a split second to load
|
||||
// if this is a group tooltip, we check if window title and track match, to allow distinguishing the different windows
|
||||
// if this app is a browser, we also check the title, so album art is not shown when the user is on some other tab
|
||||
// in all other cases we can safely show the album art without checking the title
|
||||
readonly property bool available: (status === Image.Ready || status === Image.Loading)
|
||||
&& (!(toolTipDelegate.isGroup || backend.applicationCategories(launcherUrl).includes("WebBrowser")) || root.titleIncludesTrack)
|
||||
|
||||
anchors.fill: hoverHandler
|
||||
// Indent by one pixel to make sure we never cover up the entire highlight
|
||||
anchors.margins: 1
|
||||
sourceSize: Qt.size(parent.width, parent.height)
|
||||
|
||||
asynchronous: true
|
||||
source: toolTipDelegate.playerData?.artUrl ?? ""
|
||||
fillMode: Image.PreserveAspectFit
|
||||
visible: available
|
||||
}
|
||||
|
||||
// hoverHandler has to be unloaded after the instance is pooled in order to avoid getting the old containsMouse status when the same instance is reused, so put it in a Loader.
|
||||
Loader {
|
||||
id: hoverHandler
|
||||
active: root.index !== -1
|
||||
anchors.fill: parent
|
||||
sourceComponent: ToolTipWindowMouseArea {
|
||||
rootTask: toolTipDelegate.parentTask
|
||||
modelIndex: root.submodelIndex
|
||||
winId: thumbnailSourceItem.winId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Player controls row, load on demand so group tooltips could be loaded faster
|
||||
Loader {
|
||||
id: playerController
|
||||
// Only load for one entry, as the controls only apply to one window.
|
||||
// If this is changed in the future, test for index != -1 to avoid loading
|
||||
// when the instance is going to be destroyed
|
||||
active: toolTipDelegate.playerData && ((hasTrackInATitle && albumArtImage.available) || (!hasTrackInATitle && root.index == 0))
|
||||
|
||||
asynchronous: true
|
||||
visible: active
|
||||
Layout.fillWidth: true
|
||||
Layout.maximumWidth: headerItem.Layout.maximumWidth
|
||||
Layout.leftMargin: headerItem.Layout.margins
|
||||
Layout.rightMargin: headerItem.Layout.margins
|
||||
|
||||
source: "PlayerController.qml"
|
||||
}
|
||||
|
||||
// Volume controls
|
||||
Loader {
|
||||
id: volumeControls
|
||||
active: toolTipDelegate.parentTask !== null
|
||||
&& pulseAudio.item !== null
|
||||
&& toolTipDelegate.parentTask.hasAudioStream
|
||||
// Only load for one entry, as the controls only apply to one window.
|
||||
// If this is changed in the future, test for index != -1 to avoid loading
|
||||
// when the instance is going to be destroyed
|
||||
&& ((hasTrackInATitle && albumArtImage.available) || (!hasTrackInATitle && root.index == 0))
|
||||
asynchronous: true
|
||||
visible: active
|
||||
Layout.fillWidth: true
|
||||
Layout.maximumWidth: headerItem.Layout.maximumWidth
|
||||
Layout.leftMargin: headerItem.Layout.margins
|
||||
Layout.rightMargin: headerItem.Layout.margins
|
||||
sourceComponent: RowLayout {
|
||||
PlasmaComponents3.ToolButton { // Mute button
|
||||
icon.width: Kirigami.Units.iconSizes.small
|
||||
icon.height: Kirigami.Units.iconSizes.small
|
||||
icon.name: if (checked) {
|
||||
"audio-volume-muted"
|
||||
} else if (slider.displayValue <= 25) {
|
||||
"audio-volume-low"
|
||||
} else if (slider.displayValue <= 75) {
|
||||
"audio-volume-medium"
|
||||
} else {
|
||||
"audio-volume-high"
|
||||
}
|
||||
onClicked: toolTipDelegate.parentTask.toggleMuted()
|
||||
checked: toolTipDelegate.parentTask.muted
|
||||
|
||||
PlasmaComponents3.ToolTip {
|
||||
text: parent.checked
|
||||
? i18nc("button to unmute app", "Unmute %1", toolTipDelegate.parentTask.appName)
|
||||
: i18nc("button to mute app", "Mute %1", toolTipDelegate.parentTask.appName)
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaComponents3.Slider {
|
||||
id: slider
|
||||
|
||||
readonly property int displayValue: Math.round(value / to * 100)
|
||||
readonly property int loudestVolume: toolTipDelegate.parentTask.audioStreams
|
||||
.reduce((loudestVolume, stream) => Math.max(loudestVolume, stream.volume), 0)
|
||||
|
||||
Layout.fillWidth: true
|
||||
from: pulseAudio.item.minimalVolume
|
||||
to: pulseAudio.item.normalVolume
|
||||
value: loudestVolume
|
||||
stepSize: to / 100
|
||||
opacity: toolTipDelegate.parentTask.muted ? 0.5 : 1
|
||||
|
||||
Accessible.name: i18nc("Accessibility data on volume slider", "Adjust volume for %1", toolTipDelegate.parentTask.appName)
|
||||
|
||||
onMoved: toolTipDelegate.parentTask.audioStreams.forEach((stream) => {
|
||||
let v = Math.max(from, value)
|
||||
if (v > 0 && loudestVolume > 0) { // prevent divide by 0
|
||||
// adjust volume relative to the loudest stream
|
||||
v = Math.min(Math.round(stream.volume / loudestVolume * v), to)
|
||||
}
|
||||
stream.model.Volume = v
|
||||
stream.model.Muted = v === 0
|
||||
})
|
||||
}
|
||||
PlasmaComponents3.Label { // percent label
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
Layout.minimumWidth: percentMetrics.advanceWidth
|
||||
horizontalAlignment: Qt.AlignRight
|
||||
text: i18nc("volume percentage", "%1%", slider.displayValue)
|
||||
textFormat: Text.PlainText
|
||||
TextMetrics {
|
||||
id: percentMetrics
|
||||
text: i18nc("only used for sizing, should be widest possible string", "100%")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function generateSubText(): string {
|
||||
const subTextEntries = [];
|
||||
|
||||
if (!Plasmoid.configuration.showOnlyCurrentDesktop && virtualDesktopInfo.numberOfDesktops > 1) {
|
||||
if (!isOnAllVirtualDesktops && virtualDesktops.length > 0) {
|
||||
const virtualDesktopNameList = virtualDesktops.map(virtualDesktop => {
|
||||
const index = virtualDesktopInfo.desktopIds.indexOf(virtualDesktop);
|
||||
return virtualDesktopInfo.desktopNames[index];
|
||||
});
|
||||
|
||||
subTextEntries.push(i18nc("Comma-separated list of desktops", "On %1",
|
||||
virtualDesktopNameList.join(", ")));
|
||||
} else if (isOnAllVirtualDesktops) {
|
||||
subTextEntries.push(i18nc("Comma-separated list of desktops", "Pinned to all desktops"));
|
||||
}
|
||||
}
|
||||
|
||||
if (activities.length === 0 && activityInfo.numberOfRunningActivities > 1) {
|
||||
subTextEntries.push(i18nc("Which virtual desktop a window is currently on",
|
||||
"Available on all activities"));
|
||||
} else if (activities.length > 0) {
|
||||
const activityNames = activities
|
||||
.filter(activity => activity !== activityInfo.currentActivity)
|
||||
.map(activity => activityInfo.activityName(activity))
|
||||
.filter(activityName => activityName !== "");
|
||||
|
||||
if (Plasmoid.configuration.showOnlyCurrentActivity) {
|
||||
if (activityNames.length > 0) {
|
||||
subTextEntries.push(i18nc("Activities a window is currently on (apart from the current one)",
|
||||
"Also available on %1", activityNames.join(", ")));
|
||||
}
|
||||
} else if (activityNames.length > 0) {
|
||||
subTextEntries.push(i18nc("Which activities a window is currently on",
|
||||
"Available on %1", activityNames.join(", ")));
|
||||
}
|
||||
}
|
||||
|
||||
return subTextEntries.join("\n");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
|
||||
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
||||
SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
|
||||
MouseArea {
|
||||
required property /*QModelIndex*/var modelIndex
|
||||
required property /*undefined|WId where WId = int|string*/ var winId
|
||||
required property Task rootTask
|
||||
|
||||
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
|
||||
hoverEnabled: true
|
||||
enabled: winId !== undefined
|
||||
|
||||
onClicked: (mouse) => {
|
||||
switch (mouse.button) {
|
||||
case Qt.LeftButton:
|
||||
tasksModel.requestActivate(modelIndex);
|
||||
rootTask.hideImmediately();
|
||||
backend.cancelHighlightWindows();
|
||||
break;
|
||||
case Qt.MiddleButton:
|
||||
backend.cancelHighlightWindows();
|
||||
tasksModel.requestClose(modelIndex);
|
||||
break;
|
||||
case Qt.RightButton:
|
||||
tasks.createContextMenu(rootTask, modelIndex).show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
onContainsMouseChanged: {
|
||||
tasks.windowsHovered([winId], containsMouse);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2012-2013 Eike Hein <hein@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
.import org.kde.kirigami as Kirigami
|
||||
|
||||
const iconMargin = Math.round(Kirigami.Units.smallSpacing / 4);
|
||||
const labelMargin = Kirigami.Units.smallSpacing;
|
||||
|
||||
function horizontalMargins() {
|
||||
const spacingAdjustment = (tasks.plasmoid.pluginName === "org.kde.plasma.icontasks") ? (Kirigami.Settings.tabletMode ? 3 : tasks.plasmoid.configuration.iconSpacing) : 1
|
||||
return (taskFrame.margins.left + taskFrame.margins.right) * (tasks.vertical ? 1 : spacingAdjustment);
|
||||
}
|
||||
|
||||
function verticalMargins() {
|
||||
const spacingAdjustment = (tasks.plasmoid.pluginName === "org.kde.plasma.icontasks") ? (Kirigami.Settings.tabletMode ? 3 : tasks.plasmoid.configuration.iconSpacing) : 1
|
||||
return (taskFrame.margins.top + taskFrame.margins.bottom) * (tasks.vertical ? spacingAdjustment : 1);
|
||||
}
|
||||
|
||||
function adjustMargin(height, margin) {
|
||||
const available = height - verticalMargins();
|
||||
|
||||
if (available < Kirigami.Units.iconSizes.small) {
|
||||
return Math.floor((margin * (Kirigami.Units.iconSizes.small / available)) / 3);
|
||||
}
|
||||
|
||||
return margin;
|
||||
}
|
||||
|
||||
function maxStripes() {
|
||||
const length = tasks.vertical ? tasks.width : tasks.height;
|
||||
const minimum = tasks.vertical ? preferredMinWidth() : preferredMinHeight();
|
||||
|
||||
return Math.min(tasks.plasmoid.configuration.maxStripes, Math.max(1, Math.floor(length / minimum)));
|
||||
}
|
||||
|
||||
function optimumCapacity(width, height) {
|
||||
const length = tasks.vertical ? height : width;
|
||||
const maximum = tasks.vertical ? preferredMaxHeight() : preferredMaxWidth();
|
||||
|
||||
if (!tasks.vertical) {
|
||||
// Fit more tasks in this case, that is possible to cut text, before combining tasks.
|
||||
return Math.ceil(length / maximum) * maxStripes() + 1;
|
||||
}
|
||||
|
||||
return Math.floor(length / maximum) * maxStripes();
|
||||
}
|
||||
|
||||
function preferredMinWidth() {
|
||||
let width = preferredMinLauncherWidth();
|
||||
|
||||
if (!tasks.vertical && !tasks.iconsOnly) {
|
||||
width +=
|
||||
(Kirigami.Units.smallSpacing * 2) +
|
||||
(Kirigami.Units.gridUnit * 8);
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
function preferredMaxWidth() {
|
||||
if (tasks.iconsOnly) {
|
||||
if (tasks.vertical) {
|
||||
if (tasks.width === 0) {
|
||||
return 0
|
||||
}
|
||||
return tasks.width + verticalMargins();
|
||||
} else {
|
||||
if (tasks.height === 0) {
|
||||
return 0
|
||||
}
|
||||
return tasks.height + horizontalMargins();
|
||||
}
|
||||
}
|
||||
|
||||
// Avoid doing a bunch of unnecessary work below in vertical mode
|
||||
if (tasks.vertical) {
|
||||
return preferredMinWidth();
|
||||
}
|
||||
|
||||
// Visually, a large max item width on a tall panel looks cluttered even
|
||||
// with just a task or two open. This clutter is less pronounced on panels
|
||||
// lower in height, as there is generally more horizontal space.
|
||||
//
|
||||
// This allows for one default value for max item width where clutter is
|
||||
// reduced at low task counts for tall panels, while leaving low height
|
||||
// panels less affected (unaffected at 20px).
|
||||
const laneHeight = tasks.height / maxStripes(); // correct for multiple rows
|
||||
let baseFactor = 1; // sane default in case something goes wrong
|
||||
switch (tasks.plasmoid.configuration.taskMaxWidth) {
|
||||
case 0: // narrow
|
||||
baseFactor = 1.2;
|
||||
break;
|
||||
case 1: // medium
|
||||
baseFactor = 1.6;
|
||||
break;
|
||||
case 2: // wide
|
||||
baseFactor = 2;
|
||||
break;
|
||||
}
|
||||
// For every pixel of height above 20, knock the factor down by 0.01. This
|
||||
// produces nice results for 20~50 pixels. Above 50, it suddenly feels like
|
||||
// it's shrinking a lot, and above 80 the Medium and Narrow settings would
|
||||
// end up setting the same width, so don't apply further reduction above 50.
|
||||
const factorReduction = (Math.min(50, laneHeight) - 20) * 0.01;
|
||||
// Clamp the minimum factor to 1 to ensure max width is always >= min width.
|
||||
// and the factor reduction to 0 so we don't ever increase the factor
|
||||
const factor = Math.max(1, baseFactor - Math.max(0, factorReduction));
|
||||
return Math.floor(preferredMinWidth() * factor);
|
||||
}
|
||||
|
||||
function preferredMinHeight() {
|
||||
// TODO FIXME UPSTREAM: Port to proper font metrics for descenders once we have access to them.
|
||||
return Kirigami.Units.iconSizes.sizeForLabels + 4;
|
||||
}
|
||||
|
||||
function preferredMaxHeight() {
|
||||
if (tasks.vertical) {
|
||||
let taskPreferredSize = 0;
|
||||
if (tasks.iconsOnly) {
|
||||
taskPreferredSize = tasks.width / maxStripes();
|
||||
} else {
|
||||
taskPreferredSize = Math.max(Kirigami.Units.iconSizes.sizeForLabels,
|
||||
Kirigami.Units.iconSizes.medium);
|
||||
}
|
||||
return verticalMargins() +
|
||||
Math.min(
|
||||
// Do not allow the preferred icon size to exceed the width of
|
||||
// the vertical task manager.
|
||||
tasks.width / maxStripes(),
|
||||
taskPreferredSize);
|
||||
} else {
|
||||
return verticalMargins() +
|
||||
Math.min(
|
||||
Kirigami.Units.iconSizes.small * 3,
|
||||
Kirigami.Units.iconSizes.sizeForLabels * 3);
|
||||
}
|
||||
}
|
||||
|
||||
function preferredHeightInPopup() {
|
||||
return verticalMargins() + Math.max(Kirigami.Units.iconSizes.sizeForLabels,
|
||||
Kirigami.Units.iconSizes.medium);
|
||||
}
|
||||
|
||||
function spaceRequiredToShowText() {
|
||||
// gridUnit is the height of the default font, but only one isn't enough to
|
||||
// show anything but the elision character. 2 is too high and results in
|
||||
// text appearing only at excessively high widths.
|
||||
return Math.round(Kirigami.Units.gridUnit * 1.5);
|
||||
}
|
||||
|
||||
function preferredMinLauncherWidth() {
|
||||
const baseWidth = tasks.vertical ? preferredMinHeight() : Math.min(tasks.height, Kirigami.Units.iconSizes.small * 3);
|
||||
|
||||
return (baseWidth + horizontalMargins())
|
||||
- (adjustMargin(baseWidth, taskFrame.margins.top) + adjustMargin(baseWidth, taskFrame.margins.bottom));
|
||||
}
|
||||
|
||||
function maximumContextMenuTextWidth() {
|
||||
return (Kirigami.Units.iconSizes.sizeForLabels * 28);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2012-2016 Eike Hein <hein@kde.org>
|
||||
SPDX-FileCopyrightText: 2020 Nate Graham <nate@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
.pragma library
|
||||
|
||||
.import org.kde.taskmanager as TaskManager
|
||||
.import org.kde.plasma.core as PlasmaCore // Needed by TaskManager
|
||||
|
||||
// Can't be `let`, or else QML counterpart won't be able to assign to it.
|
||||
var taskManagerInstanceCount = 0;
|
||||
|
||||
function activateNextPrevTask(anchor, next, wheelSkipMinimized, tasks) {
|
||||
// FIXME TODO: Unnecessarily convoluted and costly; optimize.
|
||||
|
||||
let taskIndexList = [];
|
||||
const activeTaskIndex = tasks.tasksModel.activeTask;
|
||||
|
||||
for (let i = 0; i < tasks.taskList.children.length - 1; ++i) {
|
||||
const task = tasks.taskList.children[i];
|
||||
const modelIndex = task.modelIndex(i);
|
||||
|
||||
if (!task.model.IsLauncher && !task.model.IsStartup) {
|
||||
if (task.model.IsGroupParent) {
|
||||
if (task === anchor) { // If the anchor is a group parent, collect only windows within the group.
|
||||
taskIndexList = [];
|
||||
}
|
||||
|
||||
for (let j = 0; j < tasks.tasksModel.rowCount(modelIndex); ++j) {
|
||||
const childModelIndex = tasks.tasksModel.makeModelIndex(i, j);
|
||||
const childHidden = tasks.tasksModel.data(childModelIndex, TaskManager.AbstractTasksModel.IsHidden);
|
||||
if (!wheelSkipMinimized || !childHidden) {
|
||||
taskIndexList.push(childModelIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if (task === anchor) { // See above.
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (!wheelSkipMinimized || !task.model.IsHidden) {
|
||||
taskIndexList.push(modelIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!taskIndexList.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
let target = taskIndexList[0];
|
||||
|
||||
for (let i = 0; i < taskIndexList.length; ++i) {
|
||||
if (taskIndexList[i] === activeTaskIndex)
|
||||
{
|
||||
if (next && i < (taskIndexList.length - 1)) {
|
||||
target = taskIndexList[i + 1];
|
||||
} else if (!next) {
|
||||
if (i) {
|
||||
target = taskIndexList[i - 1];
|
||||
} else {
|
||||
target = taskIndexList[taskIndexList.length - 1];
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tasks.tasksModel.requestActivate(target);
|
||||
}
|
||||
|
||||
function activateTask(index, model, modifiers, task, plasmoid, tasks, windowViewAvailable) {
|
||||
if (modifiers & Qt.ShiftModifier) {
|
||||
tasks.tasksModel.requestNewInstance(index);
|
||||
return;
|
||||
}
|
||||
// Publish delegate geometry again if there are more than one task manager instance
|
||||
if (taskManagerInstanceCount >= 2) {
|
||||
tasks.tasksModel.requestPublishDelegateGeometry(task.modelIndex(), tasks.backend.globalRect(task), task);
|
||||
}
|
||||
|
||||
if (model.IsGroupParent) {
|
||||
// Option 1 (default): Cycle through this group's tasks
|
||||
// ====================================================
|
||||
// If the grouped task does not include the currently active task, bring
|
||||
// forward the most recently used task in the group according to the
|
||||
// Stacking order.
|
||||
// Otherwise cycle through all tasks in the group without paying attention
|
||||
// to the stacking order, which otherwise would change with every click
|
||||
if (plasmoid.configuration.groupedTaskVisualization === 0) {
|
||||
let childTaskList = [];
|
||||
let highestStacking = -1;
|
||||
let lastUsedTask = undefined;
|
||||
|
||||
// Build list of child tasks and get stacking order data for them
|
||||
for (let i = 0; i < tasks.tasksModel.rowCount(task.modelIndex(index)); ++i) {
|
||||
const childTaskModelIndex = tasks.tasksModel.makeModelIndex(task.index, i);
|
||||
childTaskList.push(childTaskModelIndex);
|
||||
const stacking = tasks.tasksModel.data(childTaskModelIndex, TaskManager.AbstractTasksModel.StackingOrder);
|
||||
if (stacking > highestStacking) {
|
||||
highestStacking = stacking;
|
||||
lastUsedTask = childTaskModelIndex;
|
||||
}
|
||||
}
|
||||
|
||||
// If the active task is from a different app from the group that
|
||||
// was clicked on switch to the last-used task from that app.
|
||||
if (!childTaskList.some(index => tasks.tasksModel.data(index, TaskManager.AbstractTasksModel.IsActive))) {
|
||||
tasks.tasksModel.requestActivate(lastUsedTask);
|
||||
} else {
|
||||
// If the active task is already among in the group that was
|
||||
// activated, cycle through all tasks according to the order of
|
||||
// the immutable model index so the order doesn't change with
|
||||
// every click.
|
||||
for (let j = 0; j < childTaskList.length; ++j) {
|
||||
const childTask = childTaskList[j];
|
||||
if (tasks.tasksModel.data(childTask, TaskManager.AbstractTasksModel.IsActive)) {
|
||||
// Found the current task. Activate the next one
|
||||
let nextTask = j + 1;
|
||||
if (nextTask >= childTaskList.length) {
|
||||
nextTask = 0;
|
||||
}
|
||||
tasks.tasksModel.requestActivate(childTaskList[nextTask]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Option 2: show tooltips for all child tasks
|
||||
// ===========================================
|
||||
else if (plasmoid.configuration.groupedTaskVisualization === 1) {
|
||||
if (tasks.toolTipOpenedByClick) {
|
||||
task.hideImmediately();
|
||||
} else {
|
||||
tasks.toolTipOpenedByClick = task;
|
||||
task.updateMainItemBindings(); // BUG 452187
|
||||
task.showToolTip();
|
||||
}
|
||||
}
|
||||
|
||||
// Option 3: show Window View for all child tasks
|
||||
// ==================================================
|
||||
// Make sure the Window View effect is are actually enabled though;
|
||||
// if not, fall through to the next option.
|
||||
else if (plasmoid.configuration.groupedTaskVisualization === 2 && windowViewAvailable) {
|
||||
task.hideToolTip();
|
||||
tasks.activateWindowView(model.WinIdList);
|
||||
}
|
||||
|
||||
// Option 4: show group dialog/textual list
|
||||
// ========================================
|
||||
// This is also the final fallback option if Window View
|
||||
// is chosen but not actually available
|
||||
else {
|
||||
if (tasks.groupDialog) {
|
||||
task.hideToolTip();
|
||||
tasks.groupDialog.visible = false;
|
||||
} else {
|
||||
createGroupDialog(task, tasks);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (model.IsMinimized) {
|
||||
tasks.tasksModel.requestToggleMinimized(index);
|
||||
tasks.tasksModel.requestActivate(index);
|
||||
} else if (model.IsActive && plasmoid.configuration.minimizeActiveTaskOnClick) {
|
||||
tasks.tasksModel.requestToggleMinimized(index);
|
||||
} else {
|
||||
tasks.tasksModel.requestActivate(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function taskPrefix(prefix, location) {
|
||||
let effectivePrefix;
|
||||
|
||||
switch (location) {
|
||||
case PlasmaCore.Types.LeftEdge:
|
||||
effectivePrefix = "west-" + prefix;
|
||||
break;
|
||||
case PlasmaCore.Types.TopEdge:
|
||||
effectivePrefix = "north-" + prefix;
|
||||
break;
|
||||
case PlasmaCore.Types.RightEdge:
|
||||
effectivePrefix = "east-" + prefix;
|
||||
break;
|
||||
default:
|
||||
effectivePrefix = "south-" + prefix;
|
||||
}
|
||||
return [effectivePrefix, prefix];
|
||||
}
|
||||
|
||||
function taskPrefixHovered(prefix, location) {
|
||||
return [
|
||||
...taskPrefix((prefix || "launcher") + "-hover", location),
|
||||
...prefix ? taskPrefix("hover", location) : [],
|
||||
...taskPrefix(prefix, location),
|
||||
];
|
||||
}
|
||||
|
||||
function createGroupDialog(visualParent, tasks) {
|
||||
if (!visualParent) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tasks.groupDialog) {
|
||||
tasks.groupDialog.visualParent = visualParent;
|
||||
return;
|
||||
}
|
||||
|
||||
tasks.groupDialog = tasks.groupDialogComponent.createObject(tasks, { visualParent });
|
||||
}
|
||||
@@ -0,0 +1,642 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2012-2016 Eike Hein <hein@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.plasma.plasmoid
|
||||
import org.kde.plasma.components as PlasmaComponents3
|
||||
import org.kde.plasma.core as PlasmaCore
|
||||
import org.kde.ksvg as KSvg
|
||||
import org.kde.plasma.private.mpris as Mpris
|
||||
import org.kde.kirigami as Kirigami
|
||||
|
||||
import org.kde.plasma.workspace.trianglemousefilter
|
||||
|
||||
import org.kde.taskmanager as TaskManager
|
||||
import org.kde.plasma.private.taskmanager as TaskManagerApplet
|
||||
import org.kde.plasma.workspace.dbus as DBus
|
||||
|
||||
import "code/layoutmetrics.js" as LayoutMetrics
|
||||
import "code/tools.js" as TaskTools
|
||||
|
||||
PlasmoidItem {
|
||||
id: tasks
|
||||
|
||||
// Prevent clipping of zoomed icons
|
||||
clip: false
|
||||
|
||||
// For making a bottom to top layout since qml flow can't do that.
|
||||
// We just hang the task manager upside down to achieve that.
|
||||
// This mirrors the tasks and group dialog as well, so we un-rotate them
|
||||
// to fix that (see Task.qml and GroupDialog.qml).
|
||||
rotation: Plasmoid.configuration.reverseMode && Plasmoid.formFactor === PlasmaCore.Types.Vertical ? 180 : 0
|
||||
|
||||
readonly property bool shouldShrinkToZero: tasks.tasksModel.count === 0 && Plasmoid.configuration.fill
|
||||
readonly property bool vertical: Plasmoid.formFactor === PlasmaCore.Types.Vertical
|
||||
readonly property bool iconsOnly: Plasmoid.pluginName === "org.kde.plasma.icontasks" || Plasmoid.pluginName === "org.kde.plasma.icontasks.zoom"
|
||||
|
||||
property Item toolTipOpenedByClick
|
||||
property Item toolTipAreaItem
|
||||
|
||||
readonly property Component contextMenuComponent: Qt.createComponent("ContextMenu.qml")
|
||||
readonly property Component pulseAudioComponent: Qt.createComponent("PulseAudio.qml")
|
||||
|
||||
property bool needLayoutRefresh: false
|
||||
property /*list<WId> where WId = int|string*/ var taskClosedWithMouseMiddleButton: []
|
||||
property alias taskList: taskList
|
||||
|
||||
// Zoom effect properties - PERFORMANCE OPTIMIZED
|
||||
property bool zoomEffectEnabled: iconsOnly && Plasmoid.configuration.magnifyFactor > 0
|
||||
|
||||
preferredRepresentation: fullRepresentation
|
||||
|
||||
Plasmoid.constraintHints: Plasmoid.CanFillArea
|
||||
|
||||
Plasmoid.onUserConfiguringChanged: {
|
||||
if (Plasmoid.userConfiguring && groupDialog !== null) {
|
||||
groupDialog.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
Layout.fillWidth: vertical ? true : Plasmoid.configuration.fill
|
||||
Layout.fillHeight: !vertical ? true : Plasmoid.configuration.fill
|
||||
Layout.minimumWidth: {
|
||||
if (shouldShrinkToZero) {
|
||||
return Kirigami.Units.gridUnit; // For edit mode
|
||||
}
|
||||
return vertical ? 0 : LayoutMetrics.preferredMinWidth();
|
||||
}
|
||||
Layout.minimumHeight: {
|
||||
if (shouldShrinkToZero) {
|
||||
return Kirigami.Units.gridUnit; // For edit mode
|
||||
}
|
||||
return !vertical ? 0 : LayoutMetrics.preferredMinHeight();
|
||||
}
|
||||
|
||||
//BEGIN TODO: this is not precise enough: launchers are smaller than full tasks
|
||||
Layout.preferredWidth: {
|
||||
if (shouldShrinkToZero) {
|
||||
return 0.01;
|
||||
}
|
||||
// Simple direct calculation - REMOVED CACHING TO FIX BINDING LOOPS
|
||||
return vertical ? (Kirigami.Units.gridUnit * 10) : taskList.Layout.maximumWidth;
|
||||
}
|
||||
Layout.preferredHeight: {
|
||||
if (shouldShrinkToZero) {
|
||||
return 0.01;
|
||||
}
|
||||
// Simple direct calculation - REMOVED CACHING TO FIX BINDING LOOPS
|
||||
return vertical ? taskList.Layout.maximumHeight : (Kirigami.Units.gridUnit * 2);
|
||||
}
|
||||
//END TODO
|
||||
|
||||
property Item dragSource
|
||||
|
||||
signal requestLayout
|
||||
signal windowsHovered(var winIds, bool hovered)
|
||||
signal activateWindowView(var winIds)
|
||||
|
||||
onDragSourceChanged: {
|
||||
if (dragSource === null) {
|
||||
tasksModel.syncLaunchers();
|
||||
}
|
||||
}
|
||||
|
||||
function publishIconGeometries(taskItems: /*list<Item>*/var): void {
|
||||
if (TaskTools.taskManagerInstanceCount >= 2) {
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < taskItems.length - 1; ++i) {
|
||||
const task = taskItems[i];
|
||||
|
||||
if (!task.model.IsLauncher && !task.model.IsStartup) {
|
||||
tasksModel.requestPublishDelegateGeometry(tasksModel.makeModelIndex(task.index),
|
||||
backend.globalRect(task), task);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readonly property TaskManager.TasksModel tasksModel: TaskManager.TasksModel {
|
||||
id: tasksModel
|
||||
|
||||
readonly property int logicalLauncherCount: {
|
||||
if (Plasmoid.configuration.separateLaunchers) {
|
||||
return launcherCount;
|
||||
}
|
||||
|
||||
let startupsWithLaunchers = 0;
|
||||
|
||||
for (let i = 0; i < taskRepeater.count; ++i) {
|
||||
const item = taskRepeater.itemAt(i);
|
||||
|
||||
// During destruction required properties such as item.model can go null for a while,
|
||||
// so in paths that can trigger on those moments, they need to be guarded
|
||||
if (item?.model?.IsStartup && item.model.HasLauncher) {
|
||||
++startupsWithLaunchers;
|
||||
}
|
||||
}
|
||||
|
||||
return launcherCount + startupsWithLaunchers;
|
||||
}
|
||||
|
||||
virtualDesktop: virtualDesktopInfo.currentDesktop
|
||||
screenGeometry: Plasmoid.containment.screenGeometry
|
||||
activity: activityInfo.currentActivity
|
||||
|
||||
filterByVirtualDesktop: Plasmoid.configuration.showOnlyCurrentDesktop
|
||||
filterByScreen: Plasmoid.configuration.showOnlyCurrentScreen
|
||||
filterByActivity: Plasmoid.configuration.showOnlyCurrentActivity
|
||||
filterNotMinimized: Plasmoid.configuration.showOnlyMinimized
|
||||
|
||||
hideActivatedLaunchers: tasks.iconsOnly || Plasmoid.configuration.hideLauncherOnStart
|
||||
sortMode: sortModeEnumValue(Plasmoid.configuration.sortingStrategy)
|
||||
launchInPlace: tasks.iconsOnly && Plasmoid.configuration.sortingStrategy === 1
|
||||
separateLaunchers: {
|
||||
if (!tasks.iconsOnly && !Plasmoid.configuration.separateLaunchers
|
||||
&& Plasmoid.configuration.sortingStrategy === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
groupMode: groupModeEnumValue(Plasmoid.configuration.groupingStrategy)
|
||||
groupInline: !Plasmoid.configuration.groupPopups && !tasks.iconsOnly
|
||||
groupingWindowTasksThreshold: (Plasmoid.configuration.onlyGroupWhenFull && !tasks.iconsOnly
|
||||
? LayoutMetrics.optimumCapacity(width, height) + 1 : -1)
|
||||
|
||||
onLauncherListChanged: {
|
||||
Plasmoid.configuration.launchers = launcherList;
|
||||
}
|
||||
|
||||
onGroupingAppIdBlacklistChanged: {
|
||||
Plasmoid.configuration.groupingAppIdBlacklist = groupingAppIdBlacklist;
|
||||
}
|
||||
|
||||
onGroupingLauncherUrlBlacklistChanged: {
|
||||
Plasmoid.configuration.groupingLauncherUrlBlacklist = groupingLauncherUrlBlacklist;
|
||||
}
|
||||
|
||||
function sortModeEnumValue(index: int): /*TaskManager.TasksModel.SortMode*/ int {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return TaskManager.TasksModel.SortDisabled;
|
||||
case 1:
|
||||
return TaskManager.TasksModel.SortManual;
|
||||
case 2:
|
||||
return TaskManager.TasksModel.SortAlpha;
|
||||
case 3:
|
||||
return TaskManager.TasksModel.SortVirtualDesktop;
|
||||
case 4:
|
||||
return TaskManager.TasksModel.SortActivity;
|
||||
default:
|
||||
return TaskManager.TasksModel.SortDisabled;
|
||||
}
|
||||
}
|
||||
|
||||
function groupModeEnumValue(index: int): /*TaskManager.TasksModel.GroupMode*/ int {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return TaskManager.TasksModel.GroupDisabled;
|
||||
case 1:
|
||||
return TaskManager.TasksModel.GroupApplications;
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
launcherList = Plasmoid.configuration.launchers;
|
||||
groupingAppIdBlacklist = Plasmoid.configuration.groupingAppIdBlacklist;
|
||||
groupingLauncherUrlBlacklist = Plasmoid.configuration.groupingLauncherUrlBlacklist;
|
||||
|
||||
// Only hook up view only after the above churn is done.
|
||||
taskRepeater.model = tasksModel;
|
||||
}
|
||||
}
|
||||
|
||||
readonly property TaskManagerApplet.Backend backend: TaskManagerApplet.Backend {
|
||||
id: backend
|
||||
highlightWindows: Plasmoid.configuration.highlightWindows
|
||||
|
||||
onAddLauncher: {
|
||||
tasks.addLauncher(url);
|
||||
}
|
||||
}
|
||||
|
||||
DBus.DBusServiceWatcher {
|
||||
id: effectWatcher
|
||||
busType: DBus.BusType.Session
|
||||
watchedService: "org.kde.KWin.Effect.WindowView1"
|
||||
}
|
||||
|
||||
readonly property Component taskInitComponent: Component {
|
||||
Timer {
|
||||
interval: 200
|
||||
running: true
|
||||
|
||||
onTriggered: {
|
||||
const task = parent as Task;
|
||||
if (task) {
|
||||
tasksModel.requestPublishDelegateGeometry(task.modelIndex(), backend.globalRect(task), task);
|
||||
}
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: Plasmoid
|
||||
|
||||
function onLocationChanged(): void {
|
||||
if (TaskTools.taskManagerInstanceCount >= 2) {
|
||||
return;
|
||||
}
|
||||
// This is on a timer because the panel may not have
|
||||
// settled into position yet when the location prop-
|
||||
// erty updates.
|
||||
iconGeometryTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: Plasmoid.containment
|
||||
|
||||
function onScreenGeometryChanged(): void {
|
||||
iconGeometryTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
Mpris.Mpris2Model {
|
||||
id: mpris2Source
|
||||
}
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
|
||||
TaskManager.VirtualDesktopInfo {
|
||||
id: virtualDesktopInfo
|
||||
}
|
||||
|
||||
TaskManager.ActivityInfo {
|
||||
id: activityInfo
|
||||
readonly property string nullUuid: "00000000-0000-0000-0000-000000000000"
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: pulseAudio
|
||||
sourceComponent: pulseAudioComponent
|
||||
active: pulseAudioComponent.status === Component.Ready
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: iconGeometryTimer
|
||||
|
||||
interval: 500
|
||||
repeat: false
|
||||
|
||||
onTriggered: {
|
||||
tasks.publishIconGeometries(taskList.children, tasks);
|
||||
}
|
||||
}
|
||||
|
||||
Binding {
|
||||
target: Plasmoid
|
||||
property: "status"
|
||||
value: (tasksModel.anyTaskDemandsAttention && Plasmoid.configuration.unhideOnAttention
|
||||
? PlasmaCore.Types.NeedsAttentionStatus : PlasmaCore.Types.PassiveStatus)
|
||||
restoreMode: Binding.RestoreBinding
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: Plasmoid.configuration
|
||||
|
||||
function onLaunchersChanged(): void {
|
||||
tasksModel.launcherList = Plasmoid.configuration.launchers
|
||||
}
|
||||
function onGroupingAppIdBlacklistChanged(): void {
|
||||
tasksModel.groupingAppIdBlacklist = Plasmoid.configuration.groupingAppIdBlacklist;
|
||||
}
|
||||
function onGroupingLauncherUrlBlacklistChanged(): void {
|
||||
tasksModel.groupingLauncherUrlBlacklist = Plasmoid.configuration.groupingLauncherUrlBlacklist;
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: launchAnimationComponent
|
||||
LaunchAnimation {
|
||||
animationType: Plasmoid.configuration.launchAnimationType
|
||||
animationDuration: Plasmoid.configuration.launchAnimationDuration
|
||||
animationIntensity: Plasmoid.configuration.launchAnimationIntensity
|
||||
}
|
||||
}
|
||||
|
||||
// Save drag data
|
||||
Item {
|
||||
id: dragHelper
|
||||
|
||||
Drag.dragType: Drag.Automatic
|
||||
Drag.supportedActions: Qt.CopyAction | Qt.MoveAction | Qt.LinkAction
|
||||
Drag.onDragFinished: dropAction => {
|
||||
tasks.dragSource = null;
|
||||
}
|
||||
}
|
||||
|
||||
KSvg.FrameSvgItem {
|
||||
id: taskFrame
|
||||
|
||||
visible: false
|
||||
|
||||
imagePath: "widgets/tasks"
|
||||
prefix: TaskTools.taskPrefix("normal", Plasmoid.location)
|
||||
}
|
||||
|
||||
MouseHandler {
|
||||
id: mouseHandler
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
target: taskList
|
||||
|
||||
onUrlsDropped: urls => {
|
||||
// If all dropped URLs point to application desktop files, we'll add a launcher for each of them.
|
||||
const createLaunchers = urls.every(item => backend.isApplication(item));
|
||||
|
||||
if (createLaunchers) {
|
||||
urls.forEach(item => addLauncher(item));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hoveredItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise we'll just start a new instance of the application with the URLs as argument,
|
||||
// as you probably don't expect some of your files to open in the app and others to spawn launchers.
|
||||
tasksModel.requestOpenUrls(hoveredItem.modelIndex(), urls);
|
||||
}
|
||||
}
|
||||
|
||||
ToolTipDelegate {
|
||||
id: openWindowToolTipDelegate
|
||||
visible: false
|
||||
}
|
||||
|
||||
ToolTipDelegate {
|
||||
id: pinnedAppToolTipDelegate
|
||||
visible: false
|
||||
}
|
||||
|
||||
TriangleMouseFilter {
|
||||
id: tmf
|
||||
filterTimeOut: 300
|
||||
active: tasks.toolTipAreaItem && tasks.toolTipAreaItem.toolTipOpen
|
||||
blockFirstEnter: false
|
||||
|
||||
// Prevent clipping of zoomed icons
|
||||
clip: false
|
||||
|
||||
edge: {
|
||||
switch (Plasmoid.location) {
|
||||
case PlasmaCore.Types.BottomEdge:
|
||||
return Qt.TopEdge;
|
||||
case PlasmaCore.Types.TopEdge:
|
||||
return Qt.BottomEdge;
|
||||
case PlasmaCore.Types.LeftEdge:
|
||||
return Qt.RightEdge;
|
||||
case PlasmaCore.Types.RightEdge:
|
||||
return Qt.LeftEdge;
|
||||
default:
|
||||
return Qt.TopEdge;
|
||||
}
|
||||
}
|
||||
|
||||
LayoutMirroring.enabled: tasks.shouldBeMirrored(Plasmoid.configuration.reverseMode, Qt.application.layoutDirection, vertical)
|
||||
anchors {
|
||||
left: parent.left
|
||||
top: parent.top
|
||||
}
|
||||
|
||||
height: taskList.height
|
||||
width: taskList.width
|
||||
|
||||
TaskList {
|
||||
id: taskList
|
||||
|
||||
LayoutMirroring.enabled: tasks.shouldBeMirrored(Plasmoid.configuration.reverseMode, Qt.application.layoutDirection, vertical)
|
||||
anchors {
|
||||
left: parent.left
|
||||
top: parent.top
|
||||
}
|
||||
|
||||
readonly property real widthOccupation: taskRepeater.count / columns
|
||||
readonly property real heightOccupation: taskRepeater.count / rows
|
||||
|
||||
Layout.maximumWidth: {
|
||||
const totalMaxWidth = children.reduce((accumulator, child) => {
|
||||
if (!isFinite(child.Layout.maximumWidth)) {
|
||||
return accumulator;
|
||||
}
|
||||
return accumulator + child.Layout.maximumWidth
|
||||
}, 0);
|
||||
return Math.round(totalMaxWidth / widthOccupation);
|
||||
}
|
||||
Layout.maximumHeight: {
|
||||
const totalMaxHeight = children.reduce((accumulator, child) => {
|
||||
if (!isFinite(child.Layout.maximumHeight)) {
|
||||
return accumulator;
|
||||
}
|
||||
return accumulator + child.Layout.maximumHeight
|
||||
}, 0);
|
||||
return Math.round(totalMaxHeight / heightOccupation);
|
||||
}
|
||||
width: {
|
||||
if (tasks.shouldShrinkToZero) {
|
||||
return 0;
|
||||
}
|
||||
if (tasks.vertical) {
|
||||
return tasks.width * Math.min(1, widthOccupation);
|
||||
} else {
|
||||
return Math.min(tasks.width, Layout.maximumWidth);
|
||||
}
|
||||
}
|
||||
height: {
|
||||
if (tasks.shouldShrinkToZero) {
|
||||
return 0;
|
||||
}
|
||||
if (tasks.vertical) {
|
||||
return Math.min(tasks.height, Layout.maximumHeight);
|
||||
} else {
|
||||
return tasks.height * Math.min(1, heightOccupation);
|
||||
}
|
||||
}
|
||||
|
||||
flow: {
|
||||
if (tasks.vertical) {
|
||||
return Plasmoid.configuration.forceStripes ? Grid.LeftToRight : Grid.TopToBottom
|
||||
}
|
||||
return Plasmoid.configuration.forceStripes ? Grid.TopToBottom : Grid.LeftToRight
|
||||
}
|
||||
|
||||
onAnimatingChanged: {
|
||||
if (!animating) {
|
||||
tasks.publishIconGeometries(children, tasks);
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
id: taskRepeater
|
||||
|
||||
delegate: Task {
|
||||
tasksRoot: tasks
|
||||
}
|
||||
onItemRemoved: (index, item) => {
|
||||
if (tasks.containsMouse && index !== taskRepeater.count &&
|
||||
item.model.WinIdList.length > 0 &&
|
||||
taskClosedWithMouseMiddleButton.includes(item.winIdList[0])) {
|
||||
needLayoutRefresh = true;
|
||||
}
|
||||
taskClosedWithMouseMiddleButton = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readonly property Component groupDialogComponent: Qt.createComponent("GroupDialog.qml")
|
||||
property GroupDialog groupDialog
|
||||
|
||||
readonly property bool supportsLaunchers: true
|
||||
|
||||
function hasLauncher(url: url): bool {
|
||||
return tasksModel.launcherPosition(url) !== -1;
|
||||
}
|
||||
|
||||
function addLauncher(url: url): void {
|
||||
if (Plasmoid.immutability !== PlasmaCore.Types.SystemImmutable) {
|
||||
tasksModel.requestAddLauncher(url);
|
||||
}
|
||||
}
|
||||
|
||||
function removeLauncher(url: url): void {
|
||||
if (Plasmoid.immutability !== PlasmaCore.Types.SystemImmutable) {
|
||||
tasksModel.requestRemoveLauncher(url);
|
||||
}
|
||||
}
|
||||
|
||||
// This is called by plasmashell in response to a Meta+number shortcut.
|
||||
// TODO: Change type to int
|
||||
function activateTaskAtIndex(index: var): void {
|
||||
if (typeof index !== "number") {
|
||||
return;
|
||||
}
|
||||
|
||||
const task = taskRepeater.itemAt(index);
|
||||
if (task) {
|
||||
TaskTools.activateTask(task.modelIndex(), task.model, null, task, Plasmoid, this, effectWatcher.registered);
|
||||
}
|
||||
}
|
||||
|
||||
function createContextMenu(rootTask, modelIndex, args = {}) {
|
||||
const initialArgs = Object.assign(args, {
|
||||
visualParent: rootTask,
|
||||
modelIndex,
|
||||
mpris2Source,
|
||||
backend,
|
||||
});
|
||||
return contextMenuComponent.createObject(rootTask, initialArgs);
|
||||
}
|
||||
|
||||
function shouldBeMirrored(reverseMode, layoutDirection, vertical): bool {
|
||||
// LayoutMirroring is only horizontal
|
||||
if (vertical) {
|
||||
return layoutDirection === Qt.RightToLeft;
|
||||
}
|
||||
|
||||
if (layoutDirection === Qt.LeftToRight) {
|
||||
return reverseMode;
|
||||
}
|
||||
return !reverseMode;
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
TaskTools.taskManagerInstanceCount += 1;
|
||||
requestLayout.connect(iconGeometryTimer.restart);
|
||||
windowsHovered.connect(backend.windowsHovered);
|
||||
activateWindowView.connect(backend.activateWindowView);
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
TaskTools.taskManagerInstanceCount -= 1;
|
||||
}
|
||||
|
||||
// Critical: Invalidate caches when task filtering changes (activity/virtual desktop switches)
|
||||
Connections {
|
||||
target: tasksModel
|
||||
function onCountChanged() {
|
||||
// Simple layout request without caching
|
||||
Qt.callLater(() => {
|
||||
requestLayout();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Invalidate caches when virtual desktop info changes
|
||||
Connections {
|
||||
target: virtualDesktopInfo
|
||||
function onCurrentDesktopChanged() {
|
||||
// Delay to ensure tasksModel has processed the change
|
||||
Qt.callLater(() => {
|
||||
requestLayout();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Invalidate caches when activity changes
|
||||
Connections {
|
||||
target: activityInfo
|
||||
function onCurrentActivityChanged() {
|
||||
// Delay to ensure tasksModel has processed the change
|
||||
Qt.callLater(() => {
|
||||
requestLayout();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Invalidate when filter settings change
|
||||
Connections {
|
||||
target: Plasmoid.configuration
|
||||
function onShowOnlyCurrentDesktopChanged() {
|
||||
Qt.callLater(() => {
|
||||
requestLayout();
|
||||
});
|
||||
}
|
||||
function onShowOnlyCurrentActivityChanged() {
|
||||
Qt.callLater(() => {
|
||||
requestLayout();
|
||||
});
|
||||
}
|
||||
function onShowOnlyCurrentScreenChanged() {
|
||||
Qt.callLater(() => {
|
||||
requestLayout();
|
||||
});
|
||||
}
|
||||
function onShowOnlyMinimizedChanged() {
|
||||
Qt.callLater(() => {
|
||||
requestLayout();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onVerticalChanged: { }
|
||||
onHeightChanged: { }
|
||||
onWidthChanged: { }
|
||||
|
||||
// Monitor shouldShrinkToZero changes for immediate layout response
|
||||
onShouldShrinkToZeroChanged: {
|
||||
// Immediate layout request
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user