| 1 |
/* |
| 2 |
* Copyright 2012 Canonical Ltd. |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU Lesser General Public License as published by |
| 6 |
* the Free Software Foundation; version 3. |
| 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 Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
import QtQuick 2.4 |
| 18 |
import Lomiri.Components 1.2 |
| 19 |
|
| 20 |
// internal helper class to create the visuals |
| 21 |
// for the icon. |
| 22 |
Item { |
| 23 |
id: iconVisual |
| 24 |
|
| 25 |
/*! |
| 26 |
\qmlproperty url source |
| 27 |
*/ |
| 28 |
property alias source: icon.source |
| 29 |
/*! |
| 30 |
\qmlproperty url fallbackSource |
| 31 |
*/ |
| 32 |
property alias fallbackSource: icon.fallbackSource |
| 33 |
/*! |
| 34 |
\qmlproperty string fallbackIconName |
| 35 |
*/ |
| 36 |
property string fallbackIconName |
| 37 |
|
| 38 |
visible: source != "" |
| 39 |
property bool hasFrame: true |
| 40 |
|
| 41 |
ImageWithFallback { |
| 42 |
id: icon |
| 43 |
visible: !iconVisual.hasFrame |
| 44 |
opacity: iconVisual.enabled ? 1.0 : 0.5 |
| 45 |
fillMode: Image.PreserveAspectCrop |
| 46 |
anchors.fill: parent |
| 47 |
smooth: true |
| 48 |
asynchronous: true |
| 49 |
fallbackSource: iconVisual.fallbackIconName ? "image://theme/" + iconVisual.fallbackIconName : "" |
| 50 |
} |
| 51 |
|
| 52 |
LomiriShape { |
| 53 |
id: shape |
| 54 |
visible: iconVisual.hasFrame |
| 55 |
anchors.fill: parent |
| 56 |
image: icon |
| 57 |
} |
| 58 |
} |