diff --git a/applets/kickoff/package/contents/ui/Header.qml b/applets/kickoff/package/contents/ui/Header.qml --- a/applets/kickoff/package/contents/ui/Header.qml +++ b/applets/kickoff/package/contents/ui/Header.qml @@ -16,12 +16,13 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -import QtQuick 2.0 +import QtQuick 2.4 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.kcoreaddons 1.0 as KCoreAddons import org.kde.kquickcontrolsaddons 2.0 +import QtGraphicalEffects 1.0 Item { id: header @@ -51,43 +52,102 @@ } } - Image { - id: faceIcon - source: kuser.faceIconUrl - cache: false - visible: source !== "" + Image { + id: squareFace + source: kuser.faceIconUrl + cache: false + visible: false; + width: units.gridUnit * 3 + height: width - width: units.gridUnit * 3 - height: width - - sourceSize.width: width - sourceSize.height: height + sourceSize.width: width + sourceSize.height: height - fillMode: Image.PreserveAspectFit + fillMode: Image.PreserveAspectFit - anchors { - top: parent.top - left: parent.left - topMargin: units.gridUnit - leftMargin: units.gridUnit + anchors { + top: parent.top + left: parent.left + topMargin: units.gridUnit + leftMargin: units.gridUnit + } } - } + // Shader effect for circle-drawing from sddm-theme by David Edmundson + // ../plasma-workspace/sddm-theme/components/UserDelegate.qml + ShaderEffect { + anchors.top: squareFace.top + anchors.horizontalCenter: squareFace.horizontalCenter + + width: squareFace.width + height: squareFace.height + + supportsAtlasTextures: true + antialiasing: true + + property var source: ShaderEffectSource { + sourceItem: squareFace + hideSource: true + live: true + } + + property var colorBorder: PlasmaCore.ColorScope.textColor + + //draw a circle with an antialised border + //innerRadius = size of the inner circle with contents + //outerRadius = size of the border + //blend = area to blend between two colours + //all sizes are normalised so 0.5 == half the width of the texture + + //if copying into another project don't forget to connect themeChanged to update() + //but in SDDM that's a bit pointless + fragmentShader: " + varying highp vec2 qt_TexCoord0; + uniform highp float qt_Opacity; + uniform lowp sampler2D source; + + uniform lowp vec4 colorBorder; + highp float blend = 0.03; + highp float innerRadius = 0.46; + highp float outerRadius = 0.48; + lowp vec4 colorEmpty = vec4(0.0, 0.0, 0.0, 0.0); + + void main() { + lowp vec4 colorSource = texture2D(source, qt_TexCoord0.st); + + highp vec2 m = qt_TexCoord0 - vec2(0.5, 0.5); + highp float dist = sqrt(m.x * m.x + m.y * m.y); + + if (dist < innerRadius) + gl_FragColor = colorSource; + else if (dist < innerRadius + blend) + gl_FragColor = mix(colorSource, colorBorder, ((dist - innerRadius) / blend)); + else if (dist < outerRadius) + gl_FragColor = colorBorder; + else if (dist < outerRadius + blend) + gl_FragColor = mix(colorBorder, colorEmpty, ((dist - outerRadius) / blend)); + else + gl_FragColor = colorEmpty ; + + gl_FragColor = gl_FragColor * qt_Opacity; + } + " + } + PlasmaCore.IconItem { - source: "user-identity" - visible: faceIcon.status !== Image.Ready + source: squareFace width: units.gridUnit * 3 height: width anchors { - top: faceIcon.top - right: faceIcon.right + top: squareFace.top + right: squareFace.right rightMargin: -units.gridUnit/2 } usesPlasmaTheme: false } MouseArea { - anchors.fill: faceIcon + anchors.fill: squareFace acceptedButtons: Qt.LeftButton cursorShape: Qt.PointingHandCursor onClicked: { @@ -107,8 +167,8 @@ height: paintedHeight anchors { - left: faceIcon.right - top: faceIcon.top + left: squareFace.right + top: squareFace.top right: parent.right leftMargin: units.gridUnit rightMargin: units.gridUnit