Warning, /plasma/plasma-workspace/applets/clipboard/contents/ui/UrlItemDelegate.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org> 0003 SPDX-FileCopyrightText: 2014 Sebastian Kügler <sebas@kde.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 import QtQuick 2.15 0009 0010 import org.kde.plasma.components 3.0 as PlasmaComponents3 0011 import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons 0012 import org.kde.kirigami 2.20 as Kirigami 0013 0014 Item { 0015 id: previewItem 0016 height: Kirigami.Units.gridUnit * 4 + Kirigami.Units.smallSpacing * 2 0017 0018 Drag.active: dragHandler.active 0019 Drag.dragType: Drag.Automatic 0020 Drag.supportedActions: Qt.CopyAction 0021 Drag.mimeData: { 0022 "text/uri-list": DisplayRole.split(" "), 0023 } 0024 0025 ListView { 0026 id: previewList 0027 model: DisplayRole.split(" ", maximumNumberOfPreviews) 0028 property int itemWidth: Kirigami.Units.gridUnit * 4 0029 property int itemHeight: Kirigami.Units.gridUnit * 4 0030 interactive: false 0031 0032 spacing: Kirigami.Units.smallSpacing 0033 orientation: Qt.Horizontal 0034 width: (itemWidth + spacing) * model.length 0035 anchors { 0036 top: parent.top 0037 left: parent.left 0038 bottom: parent.bottom 0039 } 0040 0041 delegate: Item { 0042 width: previewList.itemWidth 0043 height: previewList.itemHeight 0044 y: Math.round((parent.height - previewList.itemHeight) / 2) 0045 clip: true 0046 0047 KQuickControlsAddons.QPixmapItem { 0048 id: previewPixmap 0049 0050 anchors.centerIn: parent 0051 0052 Component.onCompleted: { 0053 function result(job) { 0054 if (!job.error) { 0055 pixmap = job.result.preview; 0056 previewPixmap.width = job.result.previewWidth 0057 previewPixmap.height = job.result.previewHeight 0058 } 0059 } 0060 var service = clipboardSource.serviceForSource(UuidRole) 0061 var operation = service.operationDescription("preview"); 0062 operation.url = modelData; 0063 // We request a bigger size and then clip out a square in the middle 0064 // so we get uniform delegate sizes without distortion 0065 operation.previewWidth = previewList.itemWidth * 2; 0066 operation.previewHeight = previewList.itemHeight * 2; 0067 var serviceJob = service.startOperationCall(operation); 0068 serviceJob.finished.connect(result); 0069 } 0070 } 0071 Rectangle { 0072 id: overlay 0073 color: Kirigami.Theme.textColor 0074 opacity: 0.6 0075 height: Kirigami.Units.gridUnit 0076 anchors { 0077 left: parent.left 0078 right: parent.right 0079 bottom: parent.bottom 0080 } 0081 } 0082 PlasmaComponents3.Label { 0083 font: Kirigami.Theme.smallFont 0084 color: Kirigami.Theme.backgroundColor 0085 maximumLineCount: 1 0086 anchors { 0087 verticalCenter: overlay.verticalCenter 0088 left: overlay.left 0089 right: overlay.right 0090 leftMargin: Kirigami.Units.smallSpacing 0091 rightMargin: Kirigami.Units.smallSpacing 0092 } 0093 elide: Text.ElideRight 0094 horizontalAlignment: Text.AlignHCenter 0095 text: { 0096 var u = modelData.split("/"); 0097 return decodeURIComponent(u[u.length - 1]); 0098 } 0099 textFormat: Text.PlainText 0100 } 0101 } 0102 } 0103 PlasmaComponents3.Label { 0104 property int additionalItems: DisplayRole.split(" ").length - maximumNumberOfPreviews 0105 visible: additionalItems > 0 0106 opacity: 0.6 0107 text: i18nc("Indicator that there are more urls in the clipboard than previews shown", "+%1", additionalItems) 0108 textFormat: Text.PlainText 0109 anchors { 0110 left: previewList.right 0111 right: parent.right 0112 bottom: parent.bottom 0113 margins: Kirigami.Units.smallSpacing 0114 0115 } 0116 verticalAlignment: Text.AlignBottom 0117 horizontalAlignment: Text.AlignCenter 0118 font: Kirigami.Theme.smallFont 0119 } 0120 }