Commit 6894a1c9 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

[weather applet] Rework top panel: show wind, remove h/l temp, reorder

parent 7e5e9f34
......@@ -19,7 +19,6 @@ import QtQuick 2.9
import QtQuick.Layouts 1.3
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents
ColumnLayout {
......@@ -27,12 +26,6 @@ ColumnLayout {
property alias model: repeater.model
PlasmaCore.Svg {
id: windSvg
imagePath: "weather/wind-arrows"
}
ColumnLayout {
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
......@@ -54,18 +47,6 @@ ColumnLayout {
sourceComponent: RowLayout {
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
PlasmaCore.SvgItem {
id: icon
Layout.preferredHeight: naturalSize.height
Layout.preferredWidth: naturalSize.width
svg: windSvg
elementId: rowData.icon || ""
visible: !!rowData.icon
}
PlasmaComponents.Label {
id: text
......
......@@ -23,122 +23,111 @@ import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
PlasmaCore.FrameSvgItem {
GridLayout {
property var generalModel
property var observationModel
implicitWidth: contentLayout.implicitWidth
implicitHeight: contentLayout.implicitHeight
readonly property int sideWidth: Math.max(
windSpeedLabel.implicitWidth,
tempLabel.implicitWidth,
windSpeedDirection.naturalSize.width
)
Layout.minimumHeight: contentLayout.Layout.minimumHeight + margins.top + margins.bottom
Layout.minimumWidth: contentLayout.Layout.minimumWidth + margins.left + margins.right
Layout.preferredHeight: contentLayout.Layout.preferredHeight + margins.top + margins.bottom
Layout.preferredWidth: contentLayout.Layout.preferredWidth + margins.left + margins.right
Layout.maximumHeight: contentLayout.Layout.maximumHeight + margins.top + margins.bottom
Layout.maximumWidth: contentLayout.Layout.maximumWidth + margins.left + margins.right
Layout.minimumWidth: Math.max(
locationLabel.implicitWidth,
(sideWidth + columnSpacing) * 2 + conditionIcon.Layout.minimumWidth
)
visible: !!generalModel.location
imagePath: "widgets/frame"
prefix: "plain"
GridLayout {
id: contentLayout
anchors {
fill: parent
leftMargin: parent.margins.left
topMargin: parent.margins.top
rightMargin: parent.margins.right
bottomMargin: parent.margins.bottom
}
Layout.preferredWidth: iconItem.Layout.preferredWidth + locationLabel.Layout.preferredWidth + tempLabel.Layout.preferredWidth + 2 * columnSpacing
columnSpacing: units.largeSpacing
rowSpacing: units.smallSpacing
columnSpacing: units.largeSpacing
rowSpacing: units.smallSpacing
columns: 3
rows: 2
columns: 3
PlasmaCore.IconItem {
id: iconItem
PlasmaCore.Svg {
id: windSvg
Layout.row: 0
Layout.column: 0
Layout.rowSpan: 2
Layout.preferredHeight: units.iconSizes.huge
Layout.preferredWidth: units.iconSizes.huge
imagePath: "weather/wind-arrows"
}
source: generalModel.currentConditionIconName
}
PlasmaExtras.Heading {
id: locationLabel
PlasmaExtras.Heading {
id: locationLabel
Layout.row: 0
Layout.column: 0
Layout.columnSpan: 3
Layout.fillWidth: true
Layout.row: 0
Layout.column: 1
Layout.fillWidth: true
Layout.preferredWidth: implicitWidth
wrapMode: Text.NoWrap
level: 2
elide: Text.ElideRight
wrapMode: Text.NoWrap
text: generalModel.location
}
PlasmaCore.IconItem {
id: conditionIcon
Layout.row: 1
Layout.column: 1
Layout.minimumHeight: units.iconSizes.huge
Layout.minimumWidth: units.iconSizes.huge
Layout.fillWidth: true
source: generalModel.currentConditionIconName
}
PlasmaComponents.Label {
id: conditionLabel
text: generalModel.location
Layout.row: 2
Layout.column: 0
Layout.columnSpan: 3
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
PlasmaCore.ToolTipArea {
id: locationToolTip
text: observationModel.conditions
}
ColumnLayout {
Layout.row: 1
Layout.column: 0
Layout.minimumWidth: sideWidth
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
PlasmaCore.SvgItem {
id: windSpeedDirection
anchors.fill: parent
visible: parent.truncated
mainText: parent.text
}
Layout.preferredHeight: naturalSize.height
Layout.preferredWidth: naturalSize.width
svg: windSvg
elementId: observationModel.windDirectionId || ""
visible: !!observationModel.windDirectionId
}
PlasmaComponents.Label {
id: conditionLabel
Layout.row: 1
Layout.column: 1
Layout.preferredWidth: implicitWidth
id: windSpeedLabel
text: observationModel.conditions
text: observationModel.windSpeed
}
}
ColumnLayout {
Layout.row: 1
Layout.column: 2
Layout.minimumWidth: sideWidth
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
PlasmaExtras.Heading {
id: tempLabel
Layout.row: 0
Layout.column: 2
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
Layout.preferredWidth: implicitWidth
level: 2
level: 3
horizontalAlignment: Text.AlignRight
wrapMode: Text.NoWrap
text: observationModel.temperature
}
PlasmaComponents.Label {
id: forecastTempsLabel
Layout.row: 1
Layout.column: 2
Layout.alignment: Qt.AlignBaseline | Qt.AlignRight
Layout.preferredWidth: implicitWidth
text: {
var low = generalModel.currentDayLowTemperature, high = generalModel.currentDayHighTemperature;
if (!!low && !!high) {
return i18nc("High & Low temperature", "H: %1 L: %2", high, low);
}
if (!!low) {
return i18nc("Low temperature", "Low: %1", low);
}
if (!!high) {
return i18nc("High temperature", "High: %1", high);
}
return "";
}
}
}
}
......@@ -122,7 +122,6 @@ Item {
var data = weatherDataSource.currentData;
var todayForecastTokens = ((data && data["Short Forecast Day 0"]) || "").split("|");
var reportTemperatureUnit = (data && data["Temperature Unit"]) || invalidUnit;
model["location"] = (data && data["Place"]) || "";
model["courtesy"] = (data && data["Credit"]) || "";
......@@ -148,22 +147,6 @@ Item {
}
model["currentConditionIconName"] = conditionIconName;
var currentDayLowTemperature;
var currentDayHighTemperature;
if (todayForecastTokens.length === 6) {
var reportLowString = todayForecastTokens[4];
if (reportLowString && reportLowString !== "N/A") {
currentDayLowTemperature = Util.temperatureToDisplayString(displayTemperatureUnit, reportLowString, reportTemperatureUnit, true);
}
var reportHighString = todayForecastTokens[3];
if (reportHighString && reportHighString !== "N/A") {
currentDayHighTemperature = Util.temperatureToDisplayString(displayTemperatureUnit, reportHighString, reportTemperatureUnit, true);
}
}
model["currentDayLowTemperature"] = currentDayLowTemperature || "";
model["currentDayHighTemperature"] = currentDayHighTemperature || "";
return model;
}
......@@ -199,20 +182,6 @@ Item {
model.push({ "text": i18n("Humidity: %1", observationModel.humidity) });
}
if (observationModel.windSpeed) {
var windSpeedText;
if (observationModel.windDirection) {
windSpeedText = i18nc("winddirection windspeed","%1 %2", observationModel.windDirection, observationModel.windSpeed);
} else {
windSpeedText = observationModel.windSpeed;
}
model.push({
"icon": observationModel.windDirectionId,
"text": windSpeedText
});
}
if (observationModel.windGust) {
model.push({ "text": i18n("Wind Gust: %1",observationModel. windGust) });
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment