From f7cf3c2a68e609afebada4c781a116d2a5d2740a Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Wed, 23 Aug 2017 09:59:09 +0100 Subject: [PATCH] Don't elide UserDelegate text when there's only one item Summary: In the lock screen the user delegate has to elide the text when there are multiple items next to each other, otherwise it will overlap. When there's only one item (which is quite common) we don't need to and doing so looks weird. Test Plan: Modified SDDM dummydata/userModel to have one entry with a long name and back to multiple entries. Reviewers: #plasma, broulik Reviewed By: #plasma, broulik Subscribers: broulik, plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D7472 --- lookandfeel/contents/components/UserDelegate.qml | 5 +++-- lookandfeel/contents/components/UserList.qml | 3 +++ lookandfeel/contents/logout/Logout.qml | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lookandfeel/contents/components/UserDelegate.qml b/lookandfeel/contents/components/UserDelegate.qml index c19f92fb1..b74e657ce 100644 --- a/lookandfeel/contents/components/UserDelegate.qml +++ b/lookandfeel/contents/components/UserDelegate.qml @@ -32,6 +32,7 @@ Item { property string userName property string avatarPath property string iconSource + property bool constrainText: true signal clicked() property real faceSize: Math.min(width, height - usernameDelegate.height - units.largeSpacing) @@ -132,10 +133,10 @@ Item { id: usernameDelegate anchors { bottom: parent.bottom - left: parent.left - right: parent.right + horizontalCenter: parent.horizontalCenter } height: implicitHeight // work around stupid bug in Plasma Components that sets the height + width: constrainText ? parent.width : implicitWidth text: wrapper.name elide: Text.ElideRight horizontalAlignment: Text.AlignHCenter diff --git a/lookandfeel/contents/components/UserList.qml b/lookandfeel/contents/components/UserList.qml index e4a863101..a2d85088f 100644 --- a/lookandfeel/contents/components/UserList.qml +++ b/lookandfeel/contents/components/UserList.qml @@ -76,6 +76,9 @@ ListView { width: userItemWidth height: userItemHeight + //if we only have one delegate, we don't need to clip the text as it won't be overlapping with anything + constrainText: ListView.view.count > 1 + isCurrent: ListView.isCurrentItem onClicked: { diff --git a/lookandfeel/contents/logout/Logout.qml b/lookandfeel/contents/logout/Logout.qml index 251e1ee1f..180dd5ae2 100644 --- a/lookandfeel/contents/logout/Logout.qml +++ b/lookandfeel/contents/logout/Logout.qml @@ -132,6 +132,7 @@ PlasmaCore.ColorScope { horizontalCenter: parent.horizontalCenter bottom: parent.verticalCenter } + constrainText: false avatarPath: kuser.faceIconUrl iconSource: "user-identity" isCurrent: true