summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-04-03 10:57:48 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-04-03 10:57:48 +0200
commitf62018ca5f03f44342528d035aa7b45ae438cd1a (patch)
tree3838520cd7055658d87671fb37fa241d4f6d941f
parent49824a0bb7ca2d35b5a3f074ecd86ffd6a1f177a (diff)
downloadkube-f62018ca5f03f44342528d035aa7b45ae438cd1a.tar.gz
kube-f62018ca5f03f44342528d035aa7b45ae438cd1a.zip
An Icon component that requests icons from the kube image provider
-rw-r--r--components/mail/contents/ui/Mail.qml2
-rw-r--r--components/package/contents/ui/Icon.qml54
-rw-r--r--components/qmldir1
3 files changed, 56 insertions, 1 deletions
diff --git a/components/mail/contents/ui/Mail.qml b/components/mail/contents/ui/Mail.qml
index 6779cd10..3978098f 100644
--- a/components/mail/contents/ui/Mail.qml
+++ b/components/mail/contents/ui/Mail.qml
@@ -294,7 +294,7 @@ Controls2.ApplicationWindow {
294 color: KubeTheme.Colors.highlightedTextColor 294 color: KubeTheme.Colors.highlightedTextColor
295 } 295 }
296 296
297 ToolButton { 297 KubeComponents.Icon {
298 id: statusIcon 298 id: statusIcon
299 visible: false 299 visible: false
300 iconName: "" 300 iconName: ""
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}
diff --git a/components/qmldir b/components/qmldir
index 94ac9caf..24c93d94 100644
--- a/components/qmldir
+++ b/components/qmldir
@@ -12,3 +12,4 @@ OverlayDialog 1.0 OverlayDialog.qml
12Outbox 1.0 Outbox.qml 12Outbox 1.0 Outbox.qml
13People 1.0 People.qml 13People 1.0 People.qml
14Notification 1.0 Notification.qml 14Notification 1.0 Notification.qml
15Icon 1.0 Icon.qml