diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-03-09 15:13:00 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-03-09 15:14:19 +0100 |
commit | 2dac72ae43f627340694d89db68184cb07e68650 (patch) | |
tree | 5397a5b6216bd05f9f48a219f379d59d64c8bde4 /components/package/contents/ui/Avatar.qml | |
parent | da079fe211094621fbcb89614e58b84caa9a603b (diff) | |
download | kube-2dac72ae43f627340694d89db68184cb07e68650.tar.gz kube-2dac72ae43f627340694d89db68184cb07e68650.zip |
Moved application to components
Diffstat (limited to 'components/package/contents/ui/Avatar.qml')
-rw-r--r-- | components/package/contents/ui/Avatar.qml | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/components/package/contents/ui/Avatar.qml b/components/package/contents/ui/Avatar.qml new file mode 100644 index 00000000..33d6733c --- /dev/null +++ b/components/package/contents/ui/Avatar.qml | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 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 3 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 | ||
15 | * along with this program; if not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | import QtQuick 2.4 | ||
19 | import QtQuick.Controls 1.3 | ||
20 | import QtQuick.Layouts 1.1 | ||
21 | |||
22 | |||
23 | Rectangle { | ||
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: 2 | ||
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 | } | ||