Warning, /plasma/plasma-desktop/toolboxes/desktoptoolbox/contents/ui/main.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2011 Sebastian Kügler <sebas@kde.org> 0003 SPDX-FileCopyrightText: 2011 Marco Martin <mart@kde.org> 0004 SPDX-FileCopyrightText: 2015 Kai Uwe Broulik <kde@privat.broulik.de> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 import QtQuick 2.2 0010 import QtQuick.Window 2.2 0011 import org.kde.plasma.plasmoid 2.0 0012 import org.kde.kirigami 2.20 as Kirigami 0013 0014 0015 Item { 0016 id: main 0017 objectName: "org.kde.desktoptoolbox" 0018 0019 z: 999 0020 anchors.fill: parent 0021 0022 property Item toolBoxContent 0023 0024 Connections { 0025 target: Plasmoid 0026 function onAvailableScreenRegionChanged() { 0027 placeToolBoxTimer.restart(); 0028 } 0029 } 0030 0031 property int iconSize: Kirigami.Units.iconSizes.small 0032 property int iconWidth: Kirigami.Units.iconSizes.smallMedium 0033 property int iconHeight: iconWidth 0034 property bool dialogWasVisible: false 0035 property bool open: false 0036 0037 onWidthChanged: placeToolBoxTimer.restart(); 0038 onHeightChanged: placeToolBoxTimer.restart(); 0039 0040 LayoutMirroring.enabled: (Qt.application.layoutDirection === Qt.RightToLeft) 0041 LayoutMirroring.childrenInherit: true 0042 0043 Plasmoid.containment.corona.onEditModeChanged: { 0044 if (!Plasmoid.containment.corona.editMode) { 0045 toolBoxContent.exitAnimation.start(); 0046 return; 0047 } 0048 0049 const component = Qt.createComponent(Qt.resolvedUrl("./ToolBoxContent.qml"), main); 0050 toolBoxContent = component.createObject(main); 0051 component.destroy(); 0052 placeToolBox(Plasmoid.configuration.ToolBoxButtonState); 0053 toolBoxContent.enterAnimation.start(); 0054 } 0055 0056 Timer { 0057 id: placeToolBoxTimer 0058 interval: 100 0059 repeat: false 0060 running: false 0061 onTriggered: { 0062 placeToolBox(Plasmoid.configuration.ToolBoxButtonState); 0063 } 0064 } 0065 0066 function placeToolBox(ts) { 0067 if (!main.toolBoxContent) { 0068 return; 0069 } 0070 // if nothing has been setup yet, determine default position based on layout direction 0071 if (!ts) { 0072 placeToolBox("topcenter"); 0073 return; 0074 } 0075 0076 var tx = Plasmoid.configuration.ToolBoxButtonX 0077 var ty = Plasmoid.configuration.ToolBoxButtonY 0078 var pos; 0079 const plasmoidItem = main.parent; 0080 0081 switch (ts) { 0082 case "top": 0083 ty = main.y; 0084 pos = plasmoidItem.adjustToAvailableScreenRegion(tx, ty, toolBoxContent.width, toolBoxContent.height); 0085 break; 0086 case "bottom": 0087 ty = main.height + main.y - toolBoxContent.height; 0088 pos = plasmoidItem.adjustToAvailableScreenRegion(tx, ty, toolBoxContent.width, toolBoxContent.height); 0089 break; 0090 case "bottomcenter": 0091 tx = main.width / 2 - toolBoxContent.width / 2; 0092 ty = main.height + main.y - toolBoxContent.height; 0093 pos = plasmoidItem.adjustToAvailableScreenRegion(tx, ty, toolBoxContent.width, toolBoxContent.height); 0094 break; 0095 case "topcenter": 0096 default: 0097 tx = main.width / 2 - toolBoxContent.width / 2; 0098 ty = main.y; 0099 pos = plasmoidItem.adjustToAvailableScreenRegion(tx, ty, toolBoxContent.width, toolBoxContent.height); 0100 break; 0101 } 0102 //print("XXXY Setting toolbox to: " + ts + " " + tx + "x" + ty + " screen: " + main.width+ "x" + main.height+""); 0103 0104 toolBoxContent.x = pos.x; 0105 toolBoxContent.y = pos.y; 0106 } 0107 }