summaryrefslogtreecommitdiffstats
path: root/framework/qml/Avatar.qml
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-04-04 19:19:41 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-04-04 19:19:41 +0200
commitd9295fc8f19e4005f8454e7f193f80316550ac0c (patch)
treef27c370d54bced09212b9c4a12b827d1cebb6110 /framework/qml/Avatar.qml
parentd002eae7f8b443dd1bad914444c296088c2b6e85 (diff)
downloadkube-d9295fc8f19e4005f8454e7f193f80316550ac0c.tar.gz
kube-d9295fc8f19e4005f8454e7f193f80316550ac0c.zip
One framework plugin to rule them all
Diffstat (limited to 'framework/qml/Avatar.qml')
-rw-r--r--framework/qml/Avatar.qml57
1 files changed, 57 insertions, 0 deletions
diff --git a/framework/qml/Avatar.qml b/framework/qml/Avatar.qml
new file mode 100644
index 00000000..0a7c4c18
--- /dev/null
+++ b/framework/qml/Avatar.qml
@@ -0,0 +1,57 @@
1/*
2 Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17*/
18
19import QtQuick 2.7
20import QtQuick.Layouts 1.1
21
22
23Rectangle {
24
25 property string name;
26
27 //colors taken from https://techbase.kde.org/Projects/Usability/HIG/Color
28 function calcColor(x)
29 {
30 switch (x % 5) {
31 case 0:
32 return "#16a085"
33 case 1:
34 return "#27ae60"
35 case 2:
36 return "#2980b9"
37 case 3:
38 return "#8e44ad"
39 case 4:
40 return "#c0392b"
41 }
42 }
43
44 radius: 100
45
46 color: calcColor(name.length)
47
48 Text {
49 anchors.centerIn: parent
50
51 text: name.charAt(0)
52
53 color: "#ecf0f1"
54
55 font.capitalization: Font.AllUppercase
56 }
57}