Warning, /plasma/kdeplasma-addons/applets/quicklaunch/package/contents/ui/Popup.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2015 David Rosca <nowrep@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 import QtQuick 2.2 0008 0009 import org.kde.kirigami 2.20 as Kirigami 0010 import org.kde.plasma.extras 2.0 as PlasmaExtras 0011 0012 import org.kde.draganddrop 2.0 as DragAndDrop 0013 0014 import "layout.js" as LayoutManager 0015 0016 Item { 0017 id: popup 0018 0019 property bool dragging: false 0020 property alias popupModel : popupModel 0021 property alias listView: listView 0022 0023 width: LayoutManager.popupItemWidth() 0024 height: Math.max(1, popupModel.count) * LayoutManager.popupItemHeight() 0025 0026 DragAndDrop.DropArea { 0027 anchors.fill: parent 0028 preventStealing: true 0029 enabled: !plasmoid.immutable 0030 0031 onDragEnter: { 0032 dragging = true; 0033 } 0034 0035 onDragMove: { 0036 if (!event.mimeData.hasUrls) { 0037 return; 0038 } 0039 0040 var index = listView.indexAt(event.x, event.y); 0041 0042 if (isInternalDrop(event)) { 0043 popupModel.moveUrl(event.mimeData.source.itemIndex, index); 0044 } else if (event.mimeData.hasUrls) { 0045 popupModel.showDropMarker(index); 0046 } 0047 } 0048 0049 onDragLeave: { 0050 dragging = false; 0051 popupModel.clearDropMarker(); 0052 } 0053 0054 onDrop: { 0055 dragging = false; 0056 popupModel.clearDropMarker(); 0057 0058 if (isInternalDrop(event)) { 0059 event.accept(Qt.IgnoreAction); 0060 saveConfiguration(); 0061 } else if (event.mimeData.hasUrls) { 0062 var index = listView.indexAt(event.x, event.y); 0063 popupModel.insertUrls(index == -1 ? popupModel.count : index, event.mimeData.urls); 0064 event.accept(event.proposedAction); 0065 } 0066 } 0067 } 0068 0069 ListView { 0070 id: listView 0071 anchors.fill: parent 0072 0073 focus: true 0074 interactive: true 0075 keyNavigationWraps: true 0076 0077 model: UrlModel { 0078 id: popupModel 0079 } 0080 0081 delegate: IconItem { 0082 isPopupItem: true 0083 } 0084 0085 highlight: PlasmaExtras.Highlight {} 0086 0087 highlightMoveDuration: Kirigami.Units.longDuration 0088 highlightMoveVelocity: 1 0089 0090 function moveItemToGrid(iconItem, url) { 0091 launcherModel.insertUrl(launcherModel.count, url); 0092 listView.currentIndex = launcherModel.count - 1; 0093 iconItem.removeLauncher(); 0094 } 0095 } 0096 0097 Connections { 0098 target: plasmoid.configuration 0099 function onPopupUrlsChanged() { 0100 popupModel.urlsChanged.disconnect(saveConfiguration); 0101 popupModel.setUrls(plasmoid.configuration.popupUrls); 0102 popupModel.urlsChanged.connect(saveConfiguration); 0103 } 0104 } 0105 0106 Component.onCompleted: { 0107 popupModel.setUrls(plasmoid.configuration.popupUrls); 0108 popupModel.urlsChanged.connect(saveConfiguration); 0109 } 0110 0111 function saveConfiguration() 0112 { 0113 if (!dragging) { 0114 plasmoid.configuration.popupUrls = popupModel.urls(); 0115 } 0116 } 0117 0118 function isInternalDrop(event) 0119 { 0120 return event.mimeData.source 0121 && event.mimeData.source.ListView 0122 && event.mimeData.source.ListView.view == listView; 0123 } 0124 }