Warning, /plasma/plasma-workspace/applets/systemtray/package/contents/ui/CurrentItemHighLight.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2011 Marco Martin <mart@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.15 0008 0009 import org.kde.plasma.core as PlasmaCore 0010 import org.kde.kirigami 2.20 as Kirigami 0011 import org.kde.ksvg 1.0 as KSvg 0012 import org.kde.plasma.plasmoid 2.0 0013 0014 KSvg.FrameSvgItem { 0015 id: currentItemHighLight 0016 0017 property int location 0018 0019 property bool animationEnabled: true 0020 property var highlightedItem: null 0021 0022 property var containerMargins: { 0023 let item = currentItemHighLight; 0024 while (item.parent) { 0025 item = item.parent; 0026 if (item.isAppletContainer) { 0027 return item.getMargins; 0028 } 0029 } 0030 return undefined; 0031 } 0032 0033 z: -1 // always draw behind icons 0034 opacity: systemTrayState.expanded ? 1 : 0 0035 0036 imagePath: "widgets/tabbar" 0037 prefix: { 0038 let prefix; 0039 switch (location) { 0040 case PlasmaCore.Types.LeftEdge: 0041 prefix = "west-active-tab"; 0042 break; 0043 case PlasmaCore.Types.TopEdge: 0044 prefix = "north-active-tab"; 0045 break; 0046 case PlasmaCore.Types.RightEdge: 0047 prefix = "east-active-tab"; 0048 break; 0049 default: 0050 prefix = "south-active-tab"; 0051 } 0052 if (!hasElementPrefix(prefix)) { 0053 prefix = "active-tab"; 0054 } 0055 return prefix; 0056 } 0057 0058 // update when System Tray is expanded - applet activated or hidden icons shown 0059 Connections { 0060 target: systemTrayState 0061 0062 function onActiveAppletChanged() { 0063 Qt.callLater(updateHighlightedItem); 0064 } 0065 0066 function onExpandedChanged() { 0067 Qt.callLater(updateHighlightedItem); 0068 } 0069 } 0070 0071 // update when applet changes parent (e.g. moves from active to hidden icons) 0072 Connections { 0073 target: systemTrayState.activeApplet 0074 0075 function onParentChanged() { 0076 Qt.callLater(updateHighlightedItem); 0077 } 0078 } 0079 0080 // update when System Tray size changes 0081 Connections { 0082 target: parent 0083 0084 function onWidthChanged() { 0085 Qt.callLater(updateHighlightedItem); 0086 } 0087 0088 function onHeightChanged() { 0089 Qt.callLater(updateHighlightedItem); 0090 } 0091 } 0092 0093 // update when scale of newly added tray item changes (check 'add' animation in GridView in main.qml) 0094 Connections { 0095 target: !!highlightedItem && highlightedItem.parent ? highlightedItem.parent : null 0096 0097 function onScaleChanged() { 0098 Qt.callLater(updateHighlightedItem); 0099 } 0100 } 0101 0102 function updateHighlightedItem() { 0103 if (systemTrayState.expanded) { 0104 if (systemTrayState.activeApplet && systemTrayState.activeApplet.parent && systemTrayState.activeApplet.parent.inVisibleLayout) { 0105 changeHighlightedItem(systemTrayState.activeApplet.parent.container, /*forceEdgeHighlight*/false); 0106 } else { // 'Show hidden items' popup 0107 changeHighlightedItem(parent, /*forceEdgeHighlight*/true); 0108 } 0109 } else { 0110 highlightedItem = null; 0111 } 0112 } 0113 0114 function changeHighlightedItem(nextItem, forceEdgeHighlight) { 0115 // do not animate the first appearance 0116 // or when the property value of a highlighted item changes 0117 if (!highlightedItem || (highlightedItem === nextItem)) { 0118 animationEnabled = false; 0119 } 0120 0121 const p = parent.mapFromItem(nextItem, 0, 0); 0122 if (containerMargins && (parent.oneRowOrColumn || forceEdgeHighlight)) { 0123 x = p.x - containerMargins('left', /*returnAllMargins*/true); 0124 y = p.y - containerMargins('top', /*returnAllMargins*/true); 0125 width = nextItem.width + containerMargins('left', /*returnAllMargins*/true) + containerMargins('right', /*returnAllMargins*/true); 0126 height = nextItem.height + containerMargins('bottom', /*returnAllMargins*/true) + containerMargins('top', /*returnAllMargins*/true); 0127 } else { 0128 x = p.x; 0129 y = p.y; 0130 width = nextItem.width 0131 height = nextItem.height 0132 } 0133 0134 highlightedItem = nextItem; 0135 animationEnabled = true; 0136 } 0137 0138 Behavior on opacity { 0139 NumberAnimation { 0140 duration: Kirigami.Units.longDuration 0141 easing.type: systemTrayState.expanded ? Easing.OutCubic : Easing.InCubic 0142 } 0143 } 0144 Behavior on x { 0145 id: xAnim 0146 enabled: animationEnabled 0147 NumberAnimation { 0148 duration: Kirigami.Units.longDuration 0149 easing.type: Easing.InOutCubic 0150 } 0151 } 0152 Behavior on y { 0153 id: yAnim 0154 enabled: animationEnabled 0155 NumberAnimation { 0156 duration: Kirigami.Units.longDuration 0157 easing.type: Easing.InOutCubic 0158 } 0159 } 0160 Behavior on width { 0161 id: widthAnim 0162 enabled: animationEnabled 0163 NumberAnimation { 0164 duration: Kirigami.Units.longDuration 0165 easing.type: Easing.InOutCubic 0166 } 0167 } 0168 Behavior on height { 0169 id: heightAnim 0170 enabled: animationEnabled 0171 NumberAnimation { 0172 duration: Kirigami.Units.longDuration 0173 easing.type: Easing.InOutCubic 0174 } 0175 } 0176 }