Changeset View
Changeset View
Standalone View
Standalone View
lookandfeel/contents/components/UserDelegate.qml
Show All 16 Lines | |||||
17 | * Free Software Foundation, Inc., | 17 | * Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | import QtQuick 2.8 | 21 | import QtQuick 2.8 | ||
22 | import QtGraphicalEffects 1.0 | 22 | import QtGraphicalEffects 1.0 | ||
23 | 23 | | |||
24 | import org.kde.plasma.core 2.0 as PlasmaCore | 24 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
25 | import org.kde.plasma.components 2.0 as PlasmaComponents | 25 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||
26 | 26 | | |||
27 | Item { | 27 | Item { | ||
28 | id: wrapper | 28 | id: wrapper | ||
29 | 29 | | |||
30 | // If we're using software rendering, draw outlines instead of shadows | 30 | // If we're using software rendering, draw outlines instead of shadows | ||
31 | // See https://bugs.kde.org/show_bug.cgi?id=398317 | 31 | // See https://bugs.kde.org/show_bug.cgi?id=398317 | ||
32 | readonly property bool softwareRendering: GraphicsInfo.api === GraphicsInfo.Software | 32 | readonly property bool softwareRendering: GraphicsInfo.api === GraphicsInfo.Software | ||
33 | 33 | | |||
34 | property bool isCurrent: true | 34 | property bool isCurrent: true | ||
35 | 35 | | |||
36 | readonly property var m: model | 36 | readonly property var m: model | ||
37 | property string name | 37 | property string name | ||
38 | property string userName | 38 | property string userName | ||
39 | property string avatarPath | 39 | property string avatarPath | ||
40 | property string iconSource | 40 | property string iconSource | ||
41 | property bool constrainText: true | 41 | property bool constrainText: true | ||
42 | signal clicked() | 42 | signal clicked() | ||
43 | 43 | | |||
44 | property real faceSize: Math.min(width, height - usernameDelegate.height - units.largeSpacing) | 44 | property real faceSize: Math.min(width, height - usernameDelegate.height - units.smallSpacing) | ||
45 | 45 | | |||
46 | opacity: isCurrent ? 1.0 : 0.5 | 46 | opacity: isCurrent ? 1.0 : 0.5 | ||
47 | 47 | | |||
48 | Behavior on opacity { | 48 | Behavior on opacity { | ||
49 | OpacityAnimator { | 49 | OpacityAnimator { | ||
50 | duration: units.longDuration | 50 | duration: units.longDuration | ||
51 | } | 51 | } | ||
52 | } | 52 | } | ||
53 | 53 | | |||
54 | // Draw a translucent background circle under the user picture | 54 | // Draw a translucent background circle under the user picture | ||
55 | Rectangle { | 55 | Rectangle { | ||
56 | anchors.centerIn: imageSource | 56 | anchors.centerIn: imageSource | ||
57 | 57 | | |||
58 | width: imageSource.width + 2 | 58 | width: imageSource.width + 2 | ||
59 | height: width | 59 | height: width | ||
60 | radius: width / 2 | 60 | radius: width / 2 | ||
61 | 61 | | |||
62 | color: PlasmaCore.ColorScope.backgroundColor | 62 | color: PlasmaCore.ColorScope.backgroundColor | ||
63 | opacity: 0.9 | 63 | opacity: 0.9 | ||
64 | } | 64 | } | ||
65 | 65 | | |||
66 | Item { | 66 | Item { | ||
67 | id: imageSource | 67 | id: imageSource | ||
68 | anchors.horizontalCenter: parent.horizontalCenter | 68 | anchors { | ||
69 | bottom: usernameDelegate.top | ||||
70 | bottomMargin: units.largeSpacing | ||||
71 | horizontalCenter: parent.horizontalCenter | ||||
72 | } | ||||
69 | width: faceSize | 73 | width: faceSize | ||
70 | height: faceSize | 74 | height: faceSize | ||
71 | 75 | | |||
72 | //Image takes priority, taking a full path to a file, if that doesn't exist we show an icon | 76 | //Image takes priority, taking a full path to a file, if that doesn't exist we show an icon | ||
73 | Image { | 77 | Image { | ||
74 | id: face | 78 | id: face | ||
75 | source: wrapper.avatarPath | 79 | source: wrapper.avatarPath | ||
76 | sourceSize: Qt.size(faceSize, faceSize) | 80 | sourceSize: Qt.size(faceSize, faceSize) | ||
77 | fillMode: Image.PreserveAspectCrop | 81 | fillMode: Image.PreserveAspectCrop | ||
78 | anchors.fill: parent | 82 | anchors.fill: parent | ||
79 | } | 83 | } | ||
80 | 84 | | |||
81 | PlasmaCore.IconItem { | 85 | PlasmaCore.IconItem { | ||
82 | id: faceIcon | 86 | id: faceIcon | ||
83 | source: iconSource | 87 | source: iconSource | ||
84 | visible: (face.status == Image.Error || face.status == Image.Null) | 88 | visible: (face.status == Image.Error || face.status == Image.Null) | ||
85 | anchors.fill: parent | 89 | anchors.fill: parent | ||
86 | anchors.margins: units.gridUnit * 0.5 // because mockup says so... | 90 | anchors.margins: units.gridUnit * 0.5 // because mockup says so... | ||
87 | colorGroup: PlasmaCore.ColorScope.colorGroup | 91 | colorGroup: PlasmaCore.ColorScope.colorGroup | ||
88 | } | 92 | } | ||
89 | } | 93 | } | ||
90 | 94 | | |||
91 | ShaderEffect { | 95 | ShaderEffect { | ||
92 | anchors.top: parent.top | 96 | anchors { | ||
93 | anchors.horizontalCenter: parent.horizontalCenter | 97 | bottom: usernameDelegate.top | ||
98 | bottomMargin: units.largeSpacing | ||||
99 | horizontalCenter: parent.horizontalCenter | ||||
100 | } | ||||
94 | 101 | | |||
95 | width: imageSource.width | 102 | width: imageSource.width | ||
96 | height: imageSource.height | 103 | height: imageSource.height | ||
97 | 104 | | |||
98 | supportsAtlasTextures: true | 105 | supportsAtlasTextures: true | ||
99 | 106 | | |||
100 | property var source: ShaderEffectSource { | 107 | property var source: ShaderEffectSource { | ||
101 | sourceItem: imageSource | 108 | sourceItem: imageSource | ||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 157 | DropShadow { | |||
155 | horizontalOffset: 1 | 162 | horizontalOffset: 1 | ||
156 | verticalOffset: 1 | 163 | verticalOffset: 1 | ||
157 | radius: 4 | 164 | radius: 4 | ||
158 | samples: 9 | 165 | samples: 9 | ||
159 | spread: 0.35 | 166 | spread: 0.35 | ||
160 | color: "black" // matches Breeze window decoration and desktopcontainment | 167 | color: "black" // matches Breeze window decoration and desktopcontainment | ||
161 | } | 168 | } | ||
162 | 169 | | |||
163 | PlasmaComponents.Label { | 170 | PlasmaExtras.Heading { | ||
164 | id: usernameDelegate | 171 | id: usernameDelegate | ||
172 | level: 4 | ||||
165 | anchors { | 173 | anchors { | ||
166 | bottom: parent.bottom | 174 | bottom: parent.bottom | ||
167 | horizontalCenter: parent.horizontalCenter | 175 | horizontalCenter: parent.horizontalCenter | ||
168 | } | 176 | } | ||
169 | height: implicitHeight // work around stupid bug in Plasma Components that sets the height | 177 | height: implicitHeight // work around stupid bug in Plasma Components that sets the height | ||
170 | width: constrainText ? parent.width : implicitWidth | 178 | width: constrainText ? parent.width : implicitWidth | ||
171 | text: wrapper.name | 179 | text: wrapper.name | ||
172 | style: softwareRendering ? Text.Outline : undefined | 180 | style: softwareRendering ? Text.Outline : undefined | ||
Show All 18 Lines |