summaryrefslogtreecommitdiffstats
path: root/components/package/contents/ui
diff options
context:
space:
mode:
Diffstat (limited to 'components/package/contents/ui')
-rw-r--r--components/package/contents/ui/Icon.qml54
1 files changed, 54 insertions, 0 deletions
diff --git a/components/package/contents/ui/Icon.qml b/components/package/contents/ui/Icon.qml
new file mode 100644
index 00000000..dfddfa6a
--- /dev/null
+++ b/components/package/contents/ui/Icon.qml
@@ -0,0 +1,54 @@
1/*
2 * Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com>
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
20
21Item {
22 id: root
23 property string iconName
24 property url iconSource
25 property alias implicitHeight: image.implicitHeight
26 property alias implicitWidth: image.implicitWidth
27 property alias status: image.status
28 width: implicitWidth
29 height: implicitHeight
30
31 onIconNameChanged: setImageSource()
32 onIconSourceChanged: setImageSource()
33
34 function setImageSource() {
35 // Icon names have precedence over icon URLs
36 if (root.iconName.indexOf("/") != -1)
37 image.source = root.iconName;
38 else if (root.iconName != "")
39 image.source = "image://kube/" + root.iconName;
40 else if (root.iconSource != "")
41 image.source = root.iconSource;
42 else
43 image.source = "";
44 }
45
46 Image {
47 id: image
48 anchors.fill: parent
49 sourceSize.width: width
50 sourceSize.height: height
51 cache: true
52 smooth: true
53 }
54}