Warning, /plasma/plasma-nano/shell/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.4 0007 import QtQuick.Layouts 1.1 0008 import QtQuick.Window 2.0 0009 0010 import org.kde.plasma.core as PlasmaCore 0011 import org.kde.ksvg 1.0 as KSvg 0012 import org.kde.kquickcontrolsaddons 2.0 0013 import org.kde.plasma.plasmoid 2.0 0014 import org.kde.plasma.private.nanoshell 2.0 as NanoShell 0015 import org.kde.kirigami 2.20 as Kirigami 0016 0017 Item { 0018 id: root 0019 objectName: "org.kde.desktop-CompactApplet" 0020 anchors.fill: parent 0021 0022 property Item fullRepresentation 0023 property Item compactRepresentation 0024 property Item expandedFeedback: expandedItem 0025 property PlasmoidItem plasmoidItem 0026 0027 property Item rootItem: { 0028 var item = root 0029 while (item.parent) { 0030 item = item.parent; 0031 } 0032 return item; 0033 } 0034 onCompactRepresentationChanged: { 0035 if (compactRepresentation) { 0036 compactRepresentation.parent = compactRepresentationParent; 0037 compactRepresentation.anchors.fill = compactRepresentationParent; 0038 compactRepresentation.visible = true; 0039 } 0040 root.visible = true; 0041 } 0042 0043 onFullRepresentationChanged: { 0044 0045 if (!fullRepresentation) { 0046 return; 0047 } 0048 0049 fullRepresentation.parent = appletParent; 0050 fullRepresentation.anchors.fill = fullRepresentation.parent; 0051 fullRepresentation.anchors.margins = appletParent.margins.top; 0052 } 0053 0054 FocusScope { 0055 id: compactRepresentationParent 0056 anchors.fill: parent 0057 activeFocusOnTab: true 0058 onActiveFocusChanged: { 0059 // When the scope gets the active focus, try to focus its first descendant, 0060 // if there is on which has activeFocusOnTab 0061 if (!activeFocus) { 0062 return; 0063 } 0064 let nextItem = nextItemInFocusChain(); 0065 let candidate = nextItem; 0066 while (candidate.parent) { 0067 if (candidate === compactRepresentationParent) { 0068 nextItem.forceActiveFocus(); 0069 return; 0070 } 0071 candidate = candidate.parent; 0072 } 0073 } 0074 // This object name is needed for GUI testing. all gui tests in plasma-workspace are done with plasma-nano 0075 objectName: "expandApplet" 0076 Accessible.name: root.plasmoidItem?.toolTipMainText??"" 0077 Accessible.description: i18nd("plasma_shell_org.kde.plasma.nano", "Open %1", root.plasmoidItem?.toolTipSubText??"") 0078 Accessible.role: Accessible.Button 0079 Accessible.onPressAction: Plasmoid.activated() 0080 } 0081 0082 Rectangle { 0083 id: expandedItem 0084 anchors { 0085 left: parent.left 0086 right: parent.right 0087 bottom: parent.top 0088 } 0089 0090 height: Kirigami.Units.smallSpacing 0091 color: Kirigami.Theme.highlightColor 0092 visible: plasmoid.formFactor != PlasmaCore.Types.Planar && Boolean(plasmoidItem?.expanded) 0093 } 0094 0095 Connections { 0096 target: plasmoidItem 0097 function onExpandedChanged() { 0098 if (plasmoidItem.expanded) { 0099 expandedOverlay.showFullScreen() 0100 } else { 0101 expandedOverlay.visible = false; 0102 } 0103 } 0104 } 0105 0106 NanoShell.FullScreenOverlay { 0107 id: expandedOverlay 0108 color: Qt.rgba(0, 0, 0, 0.6) 0109 visible: plasmoidItem?.expanded??false 0110 width: Screen.width 0111 height: Screen.height 0112 MouseArea { 0113 anchors.fill: parent 0114 onClicked: plasmoidItem.expanded = false 0115 } 0116 0117 KSvg.FrameSvgItem { 0118 id: appletParent 0119 imagePath: "widgets/background" 0120 //used only indesktop mode, not panel 0121 0122 x: Math.max(0, Math.min(parent.width - width - Kirigami.Units.gridUnit, Math.max(Kirigami.Units.gridUnit, root.mapToItem(root.rootItem, 0, 0).x + root.width / 2 - width / 2))) 0123 y: Math.max(0, Math.min(parent.height - height - Kirigami.Units.gridUnit, Math.max(Kirigami.Units.gridUnit, root.mapToItem(root.rootItem, 0, 0).y + root.height / 2 - height / 2))) 0124 width: Math.min(expandedOverlay.width, Math.max(Math.max(root.fullRepresentation?.implicitWidth ?? 0, Kirigami.Units.gridUnit * 15), plasmoidItem?.switchWidth ?? 0) * 1.5) 0125 height: Math.min(expandedOverlay.height, Math.max(Math.max(root.fullRepresentation?.implicitHeight ?? 0, Kirigami.Units.gridUnit * 15), plasmoidItem?.switchHeight ?? 0) * 1.5) 0126 } 0127 } 0128 }