Changeset View
Changeset View
Standalone View
Standalone View
lookandfeel/contents/components/UserDelegate.qml
Show All 26 Lines | 26 | Item { | |||
---|---|---|---|---|---|
27 | id: wrapper | 27 | id: wrapper | ||
28 | 28 | | |||
29 | property bool isCurrent: true | 29 | property bool isCurrent: true | ||
30 | 30 | | |||
31 | property string name | 31 | property string name | ||
32 | property string userName | 32 | property string userName | ||
33 | property string avatarPath | 33 | property string avatarPath | ||
34 | property string iconSource | 34 | property string iconSource | ||
35 | property bool constrainText: true | ||||
35 | signal clicked() | 36 | signal clicked() | ||
36 | 37 | | |||
37 | property real faceSize: Math.min(width, height - usernameDelegate.height - units.largeSpacing) | 38 | property real faceSize: Math.min(width, height - usernameDelegate.height - units.largeSpacing) | ||
38 | 39 | | |||
39 | opacity: isCurrent ? 1.0 : 0.5 | 40 | opacity: isCurrent ? 1.0 : 0.5 | ||
40 | 41 | | |||
41 | Behavior on opacity { | 42 | Behavior on opacity { | ||
42 | OpacityAnimator { | 43 | OpacityAnimator { | ||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | |||||
127 | } | 128 | } | ||
128 | 129 | | |||
129 | 130 | | |||
130 | 131 | | |||
131 | PlasmaComponents.Label { | 132 | PlasmaComponents.Label { | ||
132 | id: usernameDelegate | 133 | id: usernameDelegate | ||
133 | anchors { | 134 | anchors { | ||
134 | bottom: parent.bottom | 135 | bottom: parent.bottom | ||
135 | left: parent.left | 136 | horizontalCenter: parent.horizontalCenter | ||
136 | right: parent.right | | |||
137 | } | 137 | } | ||
138 | height: implicitHeight // work around stupid bug in Plasma Components that sets the height | 138 | height: implicitHeight // work around stupid bug in Plasma Components that sets the height | ||
139 | width: constrainText ? parent.width : implicitWidth | ||||
139 | text: wrapper.name | 140 | text: wrapper.name | ||
140 | elide: Text.ElideRight | 141 | elide: Text.ElideRight | ||
broulik: We could also just disable eliding and it will overflow? | |||||
Yes, but it would overflow to the right not over the centre. I could do width: parent.width and then put the ? : on elide. davidedmundson: Yes, but it would overflow to the right not over the centre.
And if I change the anchor to… | |||||
141 | horizontalAlignment: Text.AlignHCenter | 142 | horizontalAlignment: Text.AlignHCenter | ||
142 | //make an indication that this has active focus, this only happens when reached with keyboard navigation | 143 | //make an indication that this has active focus, this only happens when reached with keyboard navigation | ||
143 | font.underline: wrapper.activeFocus | 144 | font.underline: wrapper.activeFocus | ||
144 | } | 145 | } | ||
145 | 146 | | |||
146 | MouseArea { | 147 | MouseArea { | ||
147 | anchors.fill: parent | 148 | anchors.fill: parent | ||
148 | hoverEnabled: true | 149 | hoverEnabled: true | ||
149 | 150 | | |||
150 | onClicked: wrapper.clicked(); | 151 | onClicked: wrapper.clicked(); | ||
151 | } | 152 | } | ||
152 | 153 | | |||
153 | Accessible.name: name | 154 | Accessible.name: name | ||
154 | Accessible.role: Accessible.Button | 155 | Accessible.role: Accessible.Button | ||
155 | function accessiblePressAction() { wrapper.clicked() } | 156 | function accessiblePressAction() { wrapper.clicked() } | ||
156 | } | 157 | } |
We could also just disable eliding and it will overflow?