Debian Codegraph @

modules/Lomiri/Components/Extras/qml6/TabsBar/TabIcon.qml

raw
1 /*
2 * Copyright (C) 2016 Canonical Ltd.
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 version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored-by: Florian Boucault <[email protected]>
17 * Andrew Hayzen <[email protected]>
18 */
19
20 import QtQuick 2.4
21 import Lomiri.Components
22
23 Item {
24 id: tabIcon
25
26 property string iconName
27 property alias iconSource: image.source
28 property alias fallbackIcon: fallbackIcon.name
29
30 implicitHeight: units.gu(2)
31 implicitWidth: units.gu(2)
32
33 Component.onCompleted: image.completed = true
34
35 Image {
36 id: image
37 anchors.fill: parent
38 asynchronous: true
39 fillMode: Image.PreserveAspectFit
40 source: completed && tabIcon.iconName ? "image://theme/%1".arg(tabIcon.name) : ""
41 sourceSize {
42 height: tabIcon.height
43 width: tabIcon.width
44 }
45
46 property bool completed: false
47 }
48
49 Icon {
50 id: fallbackIcon
51 anchors.fill: parent
52 asynchronous: true
53 visible: (image.status !== Image.Ready) || !image.source.toString()
54 }
55 }