Debian Codegraph @

src/app/qml/components/ForecastDetailsDelegate.qml

raw
1 /*
2 * Copyright (C) 2015 Canonical Ltd.
3 *
4 * This file is part of Lomiri Weather App
5 *
6 * Lomiri Weather App is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3 as
8 * published by the Free Software Foundation.
9 *
10 * Lomiri Weather App is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 import QtQuick 2.12
20 import Lomiri.Components 1.3
21
22 Row {
23 id: forecastDelegateRow
24 height: forecastLabel.lineCount > forecastValue.lineCount ? forecastLabel.height : forecastValue.height
25 width: parent.width //gu(39): (gu(45) - two times margins at gu(3)
26 spacing: units.gu(1.75)
27 visible: value !== ""
28
29 anchors {
30 left: parent.left
31 right: parent.right
32 }
33
34 property alias imageName: icon.name
35 property alias imageSource: icon.source //name and source needed depending on platform
36 property alias forecast: forecastLabel.text
37 property alias value: forecastValue.text
38 property alias labelText: textLabel.text
39 property var availableColumnWidth: (width - (iconLabelCombo.width + spacing + spacing))/2
40
41 //Button is one of the few components that do allow icon and label
42 //workaround to display icon and text in the same place
43 Button {
44 id: iconLabelCombo
45 height: units.gu(2)
46 width: height
47 color: "transparent"
48 Icon {
49 id: icon
50 color: theme.palette.normal.backgroundSecondaryText
51 height: units.gu(2)
52 width: height
53 }
54 Label{
55 id: textLabel
56 font.italic: true
57 }
58 }
59
60 Label {
61 id: forecastLabel
62 elide: Text.ElideRight
63 wrapMode: Text.WordWrap
64 color: theme.palette.normal.backgroundText
65 width: availableColumnWidth
66 }
67
68 Label {
69 id: forecastValue
70 elide: Text.ElideRight
71 wrapMode: Text.WordWrap
72 color: theme.palette.normal.backgroundText
73 width: availableColumnWidth
74 //with more than one line from wordwrap give it some space between the lines
75 lineHeight: lineCount > 0 ? 1.25 : 1.0
76 }
77 }