Warning, /plasma/kdeplasma-addons/applets/weather/package/contents/ui/TopPanel.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2018 Friedrich W. H. Kossebau <kossebau@kde.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 0008 0009 import QtQuick.Layouts 0010 0011 import org.kde.kirigami as Kirigami 0012 import org.kde.ksvg as KSvg 0013 import org.kde.plasma.components as PlasmaComponents 0014 0015 GridLayout { 0016 property var generalModel 0017 property var observationModel 0018 0019 readonly property int sideWidth: Math.max( 0020 windSpeedLabel.implicitWidth, 0021 tempLabel.implicitWidth, 0022 windSpeedDirection.naturalSize.width 0023 ) 0024 0025 Layout.minimumWidth: Math.max( 0026 locationLabel.implicitWidth, 0027 (sideWidth + columnSpacing) * 2 + conditionIcon.Layout.minimumWidth 0028 ) 0029 0030 visible: !!generalModel.location 0031 0032 columnSpacing: Kirigami.Units.gridUnit 0033 rowSpacing: Kirigami.Units.gridUnit 0034 0035 columns: 3 0036 0037 Kirigami.Heading { 0038 id: locationLabel 0039 0040 Layout.row: 0 0041 Layout.column: 0 0042 Layout.columnSpan: 3 0043 Layout.fillWidth: true 0044 0045 wrapMode: Text.NoWrap 0046 0047 text: generalModel.location 0048 textFormat: Text.PlainText 0049 } 0050 0051 Kirigami.Icon { 0052 id: conditionIcon 0053 0054 Layout.row: 1 0055 Layout.column: 1 0056 Layout.minimumHeight: Kirigami.Units.iconSizes.huge 0057 Layout.minimumWidth: Kirigami.Units.iconSizes.huge 0058 Layout.preferredHeight: Layout.minimumHeight 0059 Layout.fillWidth: true 0060 // All the items have `fillWidth: true`, so the layout weights each 0061 // contribution and splits the space accordingly to their proportion. 0062 Layout.preferredWidth: 50 // 50% of the view 0063 0064 source: generalModel.currentConditionIconName 0065 } 0066 0067 PlasmaComponents.Label { 0068 id: conditionLabel 0069 0070 Layout.row: 2 0071 Layout.column: 0 0072 Layout.columnSpan: 3 0073 Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter 0074 0075 text: observationModel.conditions 0076 textFormat: Text.PlainText 0077 } 0078 0079 Item { 0080 Layout.row: 1 0081 Layout.column: 0 0082 Layout.fillWidth: true 0083 Layout.preferredWidth: 25 // 25% of the view 0084 Layout.minimumWidth: sideWidth 0085 Layout.alignment: Qt.AlignCenter 0086 0087 implicitHeight: windSpeedDirection.implicitHeight + windSpeedLabel.implicitHeight 0088 0089 KSvg.SvgItem { 0090 id: windSpeedDirection 0091 0092 anchors.horizontalCenter: parent.horizontalCenter 0093 implicitWidth: Kirigami.Units.iconSizes.medium 0094 implicitHeight: Kirigami.Units.iconSizes.medium 0095 0096 imagePath: "weather/wind-arrows" 0097 elementId: observationModel.windDirectionId || "" 0098 0099 visible: !!observationModel.windDirectionId 0100 } 0101 0102 PlasmaComponents.Label { 0103 id: windSpeedLabel 0104 anchors { 0105 top: windSpeedDirection.bottom 0106 horizontalCenter: parent.horizontalCenter 0107 } 0108 text: observationModel.windSpeed 0109 textFormat: Text.PlainText 0110 } 0111 } 0112 0113 PlasmaComponents.Label { 0114 id: tempLabel 0115 0116 Layout.row: 1 0117 Layout.column: 2 0118 Layout.fillWidth: true 0119 Layout.preferredWidth: 25 // 25% of the view 0120 Layout.minimumWidth: sideWidth 0121 Layout.alignment: Qt.AlignCenter 0122 0123 font.pixelSize: Kirigami.Units.iconSizes.medium 0124 font.bold: true 0125 horizontalAlignment: Text.AlignHCenter 0126 wrapMode: Text.NoWrap 0127 0128 text: observationModel.temperature 0129 textFormat: Text.PlainText 0130 } 0131 }