| 1 |
/* |
| 2 |
* Copyright 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 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 |
| 19 |
|
| 20 |
Item { |
| 21 |
id: visuals |
| 22 |
// styling properties |
| 23 |
property int iconWidth: units.gu(2) |
| 24 |
property int iconHeight: units.gu(2) |
| 25 |
|
| 26 |
implicitWidth: label.paintedWidth |
| 27 |
anchors.fill: parent |
| 28 |
|
| 29 |
Item { |
| 30 |
anchors.centerIn: parent |
| 31 |
height: icon.height + label.height + label.anchors.topMargin |
| 32 |
|
| 33 |
// FIXME: is there a reason we are still using styledItem.iconSource instead of iconName |
| 34 |
// so we coudl use the Icon? |
| 35 |
Icon { |
| 36 |
id: icon |
| 37 |
anchors { |
| 38 |
top: parent.top |
| 39 |
horizontalCenter: parent.horizontalCenter |
| 40 |
} |
| 41 |
width: iconWidth |
| 42 |
height: iconWidth |
| 43 |
name: styledItem.iconName |
| 44 |
color: label.color |
| 45 |
} |
| 46 |
|
| 47 |
Label { |
| 48 |
id: label |
| 49 |
anchors { |
| 50 |
horizontalCenter: parent.horizontalCenter |
| 51 |
top: icon.bottom |
| 52 |
topMargin: units.gu(1) |
| 53 |
} |
| 54 |
width: paintedWidth |
| 55 |
text: styledItem.text |
| 56 |
textSize: Label.XSmall |
| 57 |
color: styledItem.enabled |
| 58 |
? theme.palette.normal.overlayText |
| 59 |
: theme.palette.disabled.overlayText |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
Component.onCompleted: styledItem.implicitWidth = implicitWidth |
| 64 |
} |