1/* 2 * SPDX-FileCopyrightText: 2018 Friedrich W. H. Kossebau <kossebau@kde.org> 3 * 4 * SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 7import QtQuick 2.9 8 9import QtQuick.Layouts 1.3 10 11import org.kde.plasma.core 2.0 as PlasmaCore 12import org.kde.plasma.components 3.0 as PlasmaComponents 13import org.kde.plasma.extras 2.0 as PlasmaExtras 14 15GridLayout { 16 property var generalModel 17 property var observationModel 18 19 readonly property int sideWidth: Math.max( 20 windSpeedLabel.implicitWidth, 21 tempLabel.implicitWidth, 22 windSpeedDirection.naturalSize.width 23 ) 24 25 Layout.minimumWidth: Math.max( 26 locationLabel.implicitWidth, 27 (sideWidth + columnSpacing) * 2 + conditionIcon.Layout.minimumWidth 28 ) 29 30 visible: !!generalModel.location 31 32 columnSpacing: PlasmaCore.Units.largeSpacing 33 rowSpacing: PlasmaCore.Units.smallSpacing 34 35 columns: 3 36 37 PlasmaCore.Svg { 38 id: windSvg 39 40 imagePath: "weather/wind-arrows" 41 colorGroup: parent.PlasmaCore.ColorScope.colorGroup 42 } 43 44 PlasmaExtras.Heading { 45 id: locationLabel 46 47 Layout.row: 0 48 Layout.column: 0 49 Layout.columnSpan: 3 50 Layout.fillWidth: true 51 52 wrapMode: Text.NoWrap 53 54 text: generalModel.location 55 } 56 57 PlasmaCore.IconItem { 58 id: conditionIcon 59 60 Layout.row: 1 61 Layout.column: 1 62 Layout.minimumHeight: PlasmaCore.Units.iconSizes.huge 63 Layout.minimumWidth: PlasmaCore.Units.iconSizes.huge 64 Layout.preferredHeight: Layout.minimumHeight 65 Layout.preferredWidth: Layout.minimumWidth 66 Layout.fillWidth: true 67 68 source: generalModel.currentConditionIconName 69 } 70 71 PlasmaComponents.Label { 72 id: conditionLabel 73 74 Layout.row: 2 75 Layout.column: 0 76 Layout.columnSpan: 3 77 Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter 78 79 text: observationModel.conditions 80 } 81 82 ColumnLayout { 83 Layout.row: 1 84 Layout.column: 0 85 Layout.minimumWidth: sideWidth 86 Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft 87 88 PlasmaCore.SvgItem { 89 id: windSpeedDirection 90 91 Layout.preferredHeight: naturalSize.height 92 Layout.preferredWidth: naturalSize.width 93 94 svg: windSvg 95 elementId: observationModel.windDirectionId || "" 96 97 visible: !!observationModel.windDirectionId 98 } 99 100 PlasmaComponents.Label { 101 id: windSpeedLabel 102 103 text: observationModel.windSpeed 104 } 105 } 106 107 ColumnLayout { 108 Layout.row: 1 109 Layout.column: 2 110 Layout.minimumWidth: sideWidth 111 Layout.alignment: Qt.AlignVCenter | Qt.AlignRight 112 113 PlasmaExtras.Heading { 114 id: tempLabel 115 116 Layout.alignment: Qt.AlignVCenter | Qt.AlignRight 117 118 level: 3 119 horizontalAlignment: Text.AlignRight 120 wrapMode: Text.NoWrap 121 122 text: observationModel.temperature 123 } 124 } 125} 126