Warning, /plasma/latte-dock/shell/package/contents/applet/CompactApplet.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2013 Marco Martin <mart@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 import QtQuick 2.0 0007 import QtQuick.Layouts 1.1 0008 import QtQuick.Window 2.0 0009 import QtGraphicalEffects 1.0 0010 0011 import org.kde.plasma.core 2.0 as PlasmaCore 0012 import org.kde.plasma.components 2.0 as PlasmaComponents 0013 import org.kde.kquickcontrolsaddons 2.0 0014 0015 import org.kde.latte.core 0.2 as LatteCore 0016 0017 PlasmaCore.ToolTipArea { 0018 id: root 0019 objectName: "org.kde.desktop-CompactApplet" 0020 anchors.fill: parent 0021 0022 mainText: plasmoid.toolTipMainText 0023 subText: plasmoid.toolTipSubText 0024 location: plasmoid.location 0025 active: !plasmoid.expanded 0026 textFormat: plasmoid.toolTipTextFormat 0027 mainItem: plasmoid.toolTipItem ? plasmoid.toolTipItem : null 0028 0029 property Item fullRepresentation: null 0030 property Item compactRepresentation: null 0031 /*Discover real visual parent - the following code points to Applet::ItemWrapper*/ 0032 property Item originalCompactRepresenationParent: null 0033 property Item compactRepresentationVisualParent: originalCompactRepresenationParent && originalCompactRepresenationParent.parent 0034 ? originalCompactRepresenationParent.parent.parent : null 0035 0036 property Item appletItem: compactRepresentationVisualParent 0037 && compactRepresentationVisualParent.parent 0038 && compactRepresentationVisualParent.parent.parent ? compactRepresentationVisualParent.parent.parent.parent : null 0039 0040 onCompactRepresentationChanged: { 0041 if (compactRepresentation) { 0042 originalCompactRepresenationParent = compactRepresentation.parent; 0043 0044 compactRepresentation.parent = root; 0045 compactRepresentation.anchors.centerIn = root; 0046 compactRepresentation.width = Qt.binding(function() { 0047 return root.width; 0048 }); 0049 0050 compactRepresentation.height = Qt.binding(function() { 0051 return root.height; 0052 }); 0053 0054 compactRepresentation.visible = true; 0055 } 0056 root.visible = true; 0057 } 0058 0059 onFullRepresentationChanged: { 0060 0061 if (!fullRepresentation) { 0062 return; 0063 } 0064 0065 //if the fullRepresentation size was restored to a stored size, or if is dragged from the desktop, restore popup size 0066 if (fullRepresentation.Layout && fullRepresentation.Layout.preferredWidth > 0) { 0067 popupWindow.mainItem.width = Qt.binding(function() { 0068 return fullRepresentation.Layout.preferredWidth 0069 }) 0070 } else if (fullRepresentation.implicitWidth > 0) { 0071 popupWindow.mainItem.width = Qt.binding(function() { 0072 return fullRepresentation.implicitWidth 0073 }) 0074 } else if (fullRepresentation.width > 0) { 0075 popupWindow.mainItem.width = Qt.binding(function() { 0076 return fullRepresentation.width 0077 }) 0078 } else { 0079 popupWindow.mainItem.width = Qt.binding(function() { 0080 return PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).width * 35 0081 }) 0082 } 0083 0084 if (fullRepresentation.Layout && fullRepresentation.Layout.preferredHeight > 0) { 0085 popupWindow.mainItem.height = Qt.binding(function() { 0086 return fullRepresentation.Layout.preferredHeight 0087 }) 0088 } else if (fullRepresentation.implicitHeight > 0) { 0089 popupWindow.mainItem.height = Qt.binding(function() { 0090 return fullRepresentation.implicitHeight 0091 }) 0092 } else if (fullRepresentation.height > 0) { 0093 popupWindow.mainItem.height = Qt.binding(function() { 0094 return fullRepresentation.height 0095 }) 0096 } else { 0097 popupWindow.mainItem.height = Qt.binding(function() { 0098 return PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height * 25 0099 }) 0100 } 0101 0102 fullRepresentation.parent = appletParent; 0103 fullRepresentation.anchors.fill = fullRepresentation.parent; 0104 } 0105 0106 /* PlasmaCore.FrameSvgItem { 0107 id: expandedItem 0108 anchors.fill: parent 0109 imagePath: "widgets/tabbar" 0110 visible: fromCurrentTheme && opacity > 0 0111 prefix: { 0112 var prefix; 0113 switch (plasmoid.location) { 0114 case PlasmaCore.Types.LeftEdge: 0115 prefix = "west-active-tab"; 0116 break; 0117 case PlasmaCore.Types.TopEdge: 0118 prefix = "north-active-tab"; 0119 break; 0120 case PlasmaCore.Types.RightEdge: 0121 prefix = "east-active-tab"; 0122 break; 0123 default: 0124 prefix = "south-active-tab"; 0125 } 0126 if (!hasElementPrefix(prefix)) { 0127 prefix = "active-tab"; 0128 } 0129 return prefix; 0130 } 0131 opacity: plasmoid.expanded ? 1 : 0 0132 Behavior on opacity { 0133 NumberAnimation { 0134 duration: PlasmaCore.Units.shortDuration 0135 easing.type: Easing.InOutQuad 0136 } 0137 } 0138 }*/ 0139 0140 //! This timer is needed in order for the applet popup to not reshow instantly and faulty after the user 0141 //! clicks compact representation to hide it 0142 Timer { 0143 id: expandedSync 0144 interval: 500 0145 onTriggered: plasmoid.expanded = popupWindow.visible; 0146 } 0147 0148 Connections { 0149 target: plasmoid.action("configure") 0150 function onTriggered() { plasmoid.expanded = false } 0151 } 0152 0153 Connections { 0154 target: plasmoid 0155 function onContextualActionsAboutToShow() { root.hideToolTip() } 0156 } 0157 0158 LatteCore.Dialog { 0159 id: popupWindow 0160 objectName: "popupWindow" 0161 flags: Qt.WindowStaysOnTopHint 0162 visible: plasmoid.expanded && fullRepresentation 0163 visualParent: compactRepresentationVisualParent ? compactRepresentationVisualParent : (compactRepresentation ? compactRepresentation : null) 0164 // location: PlasmaCore.Types.Floating //plasmoid.location 0165 edge: plasmoid.location /*this way dialog borders are not updated and it is used only for adjusting dialog position*/ 0166 hideOnWindowDeactivate: plasmoid.hideOnWindowDeactivate 0167 backgroundHints: (plasmoid.containmentDisplayHints & PlasmaCore.Types.DesktopFullyCovered) ? PlasmaCore.Dialog.SolidBackground : PlasmaCore.Dialog.StandardBackground 0168 0169 property var oldStatus: PlasmaCore.Types.UnknownStatus 0170 0171 //It's a MouseEventListener to get all the events, so the eventfilter will be able to catch them 0172 mainItem: MouseEventListener { 0173 id: appletParent 0174 0175 focus: true 0176 0177 Keys.onEscapePressed: { 0178 plasmoid.expanded = false; 0179 } 0180 0181 LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft 0182 LayoutMirroring.childrenInherit: true 0183 0184 Layout.minimumWidth: (fullRepresentation && fullRepresentation.Layout) ? fullRepresentation.Layout.minimumWidth : 0 0185 Layout.minimumHeight: (fullRepresentation && fullRepresentation.Layout) ? fullRepresentation.Layout.minimumHeight: 0 0186 0187 Layout.preferredWidth: (fullRepresentation && fullRepresentation.Layout) ? fullRepresentation.Layout.preferredWidth : -1 0188 Layout.preferredHeight: (fullRepresentation && fullRepresentation.Layout) ? fullRepresentation.Layout.preferredHeight: -1 0189 0190 Layout.maximumWidth: (fullRepresentation && fullRepresentation.Layout) ? fullRepresentation.Layout.maximumWidth : Infinity 0191 Layout.maximumHeight: (fullRepresentation && fullRepresentation.Layout) ? fullRepresentation.Layout.maximumHeight: Infinity 0192 0193 onActiveFocusChanged: { 0194 if (activeFocus && fullRepresentation) { 0195 fullRepresentation.forceActiveFocus() 0196 } 0197 } 0198 } 0199 0200 onVisibleChanged: { 0201 if (!visible) { 0202 expandedSync.restart(); 0203 plasmoid.status = oldStatus; 0204 } else { 0205 oldStatus = plasmoid.status; 0206 plasmoid.status = PlasmaCore.Types.RequiresAttentionStatus; 0207 // This call currently fails and complains at runtime: 0208 // QWindow::setWindowState: QWindow::setWindowState does not accept Qt::WindowActive 0209 popupWindow.requestActivate(); 0210 } 0211 } 0212 } 0213 0214 ////Indicators API //// 0215 Binding { 0216 target: compactRepresentation ? compactRepresentation.anchors : null 0217 property: "horizontalCenterOffset" 0218 when: compactRepresentation 0219 value: appletItem ? appletItem.iconOffsetX : 0 0220 } 0221 0222 Binding { 0223 target: compactRepresentation ? compactRepresentation.anchors : null 0224 property: "verticalCenterOffset" 0225 when: compactRepresentation 0226 value: appletItem ? appletItem.iconOffsetY : 0 0227 } 0228 0229 Binding { 0230 target: root 0231 property: "transformOrigin" 0232 value: appletItem && compactRepresentation ? appletItem.iconTransformOrigin : Item.Center 0233 } 0234 0235 Binding { 0236 target: root 0237 property: "opacity" 0238 value: appletItem && compactRepresentation ? appletItem.iconOpacity : 1.0 0239 } 0240 0241 Binding { 0242 target: root 0243 property: "rotation" 0244 value: appletItem && compactRepresentation ? appletItem.iconRotation : 0 0245 } 0246 0247 Binding { 0248 target: root 0249 property: "scale" 0250 value: appletItem && compactRepresentation ? appletItem.iconScale : 1.0 0251 } 0252 0253 ////Clicked Effect //// 0254 BrightnessContrast { 0255 id: _clickedEffect 0256 anchors.centerIn: parent 0257 anchors.horizontalCenterOffset: compactRepresentation ? compactRepresentation.anchors.horizontalCenterOffset : 0 0258 anchors.verticalCenterOffset: compactRepresentation ? compactRepresentation.anchors.verticalCenterOffset : 0 0259 source: compactRepresentation 0260 width: root.width 0261 height: root.height 0262 visible: appletItem && clickedAnimation.running && !appletItem.indicators.info.providesClickedAnimation 0263 z:1000 0264 } 0265 0266 /////Clicked Animation///// 0267 SequentialAnimation{ 0268 id: clickedAnimation 0269 alwaysRunToEnd: true 0270 running: appletItem 0271 && appletItem.animations 0272 && appletItem.indicators 0273 && appletItem.isSquare 0274 && appletItem.pressed 0275 && !appletItem.originalAppletBehavior 0276 && (appletItem.animations.speedFactor.current > 0) 0277 && !appletItem.indicators.info.providesClickedAnimation 0278 0279 ParallelAnimation{ 0280 PropertyAnimation { 0281 target: _clickedEffect 0282 property: "brightness" 0283 to: -0.35 0284 duration: appletItem && appletItem.animations ? appletItem.animations.duration.large : 0 0285 easing.type: Easing.OutQuad 0286 } 0287 } 0288 ParallelAnimation{ 0289 PropertyAnimation { 0290 target: _clickedEffect 0291 property: "brightness" 0292 to: 0 0293 duration: appletItem && appletItem.animations ? appletItem.animations.duration.large : 0 0294 easing.type: Easing.OutQuad 0295 } 0296 } 0297 } 0298 //END animations 0299 }