summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Uwe Broulik <kde@privat.broulik.de>2017-02-08 14:05:45 (GMT)
committerKai Uwe Broulik <kde@privat.broulik.de>2017-02-08 14:05:45 (GMT)
commitee26a139378535042411a345fea7d73efc79a73f (patch)
treecdc8084a092579cefc731ce2d0a2c53bff0b8f75
parent27b1030756002e91b60ba51483efe9c2c477d16e (diff)
[Clipboard plasmoid] Fix line breaks
This fixes the list only showing one line of text instead of the supposed maximum of 3 lines. Differential Revision: https://phabricator.kde.org/D4497
-rw-r--r--applets/clipboard/contents/ui/ClipboardItemDelegate.qml13
1 files changed, 7 insertions, 6 deletions
diff --git a/applets/clipboard/contents/ui/ClipboardItemDelegate.qml b/applets/clipboard/contents/ui/ClipboardItemDelegate.qml
index 81712b5..c20fcb3 100644
--- a/applets/clipboard/contents/ui/ClipboardItemDelegate.qml
+++ b/applets/clipboard/contents/ui/ClipboardItemDelegate.qml
@@ -99,10 +99,8 @@ PlasmaComponents.ListItem {
verticalCenter: parent.verticalCenter
}
PlasmaComponents.Label {
- anchors {
- left: parent.left
- right: parent.right
- }
+ width: parent.width
+ height: undefined // unset PlasmaComponents.Label default height
maximumLineCount: 3
text: {
var highlightFontTag = "<font color='" + theme.highlightColor + "'>%1</font>"
@@ -114,7 +112,7 @@ PlasmaComponents.ListItem {
// color code leading or trailing whitespace
// the first regex is basically "trim"
- text = text.replace(/^\s+|\s+$/g, function(match) {
+ text = text.replace(/^\s+|\s+$/gm, function(match) {
// then inside the trimmed characters ("match") we replace each one individually
match = match.replace(/ /g, "␣") // space
.replace(/\t/g, "↹") // tab
@@ -122,11 +120,14 @@ PlasmaComponents.ListItem {
return highlightFontTag.arg(match)
})
+ // finally turn line breaks into HTML br tags
+ text = text.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, "<br>")
+
return text
}
visible: TypeRole == 0 // TypeRole: 0: Text, 1: Image, 2: Url
elide: Text.ElideRight
- wrapMode: Text.Wrap
+ wrapMode: Text.WrapAtWordBoundaryOrAnywhere
textFormat: Text.StyledText
}
KQuickControlsAddons.QPixmapItem {