Warning, /plasma/plasma-workspace/applets/clipboard/contents/ui/TextItemDelegate.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.kirigami 2.20 as Kirigami
0012 
0013 PlasmaComponents3.Label {
0014     maximumLineCount: 3
0015     verticalAlignment: Text.AlignVCenter
0016 
0017     text: {
0018         var highlightFontTag = "<font color='" + Kirigami.Theme.highlightColor + "'>%1</font>"
0019 
0020         var text = DisplayRole.slice(0, 100)
0021 
0022         // first escape any HTML characters to prevent privacy issues
0023         text = text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")
0024 
0025         // color code leading or trailing whitespace
0026         // the first regex is basically "trim"
0027         text = text.replace(/^\s+|\s+$/gm, function(match) {
0028             // then inside the trimmed characters ("match") we replace each one individually
0029             match = match.replace(/ /g, "␣") // space
0030                          .replace(/\t/g, "⇥") // tab
0031                          .replace(/\n/g, "↵") // return
0032             return highlightFontTag.arg(match)
0033         })
0034 
0035         // finally turn line breaks into HTML br tags
0036         text = text.replace(/\r\n|\r|\n/g, "<br>")
0037 
0038         return text
0039     }
0040     elide: Text.ElideRight
0041     wrapMode: Text.WrapAtWordBoundaryOrAnywhere
0042     textFormat: Text.StyledText
0043 
0044     Drag.active: dragHandler.active
0045     Drag.dragType: Drag.Automatic
0046     Drag.supportedActions: Qt.CopyAction
0047     Drag.mimeData: {
0048         "text/plain": DisplayRole,
0049     }
0050 }