Commit 484199e3 authored by Devin Lin's avatar Devin Lin 🎨
Browse files

Fix warnings

parent 1f8c0809
Pipeline #102986 passed with stage
in 1 minute and 21 seconds
......@@ -24,7 +24,7 @@ Kirigami.ScrollablePage {
Component.onCompleted: {
search.forceActiveFocus();
}
header: RowLayout {
anchors.margins: Kirigami.Units.largeSpacing
spacing: Kirigami.Units.smallSpacing
......
......@@ -20,11 +20,11 @@ Kirigami.ScrollablePage {
Connections {
target: weatherLocationListModel
onNetworkErrorCreatingDefault: {
function onNetworkErrorCreatingDefault() {
showPassiveNotification(i18n("Network error when obtaining current location"));
loading = false;
}
onSuccessfullyCreatedDefault: {
function onSuccessfullyCreatedDefault() {
switchToPage(getPage("Forecast"), 0);
loading = false;
}
......
......@@ -85,14 +85,14 @@ Kirigami.ScrollablePage {
// background colours
gradient: Gradient {
GradientStop {
color: backgroundLoader.item.gradientColorTop
color: backgroundLoader.item ? backgroundLoader.item.gradientColorTop : "white"
position: 0.0
Behavior on color {
ColorAnimation { duration: Kirigami.Units.longDuration }
}
}
GradientStop {
color: backgroundLoader.item.gradientColorBottom
color: backgroundLoader.item ? backgroundLoader.item.gradientColorBottom : "white"
position: 1.0
Behavior on color {
ColorAnimation { duration: Kirigami.Units.longDuration }
......@@ -152,7 +152,11 @@ Kirigami.ScrollablePage {
Loader {
id: backgroundLoader
anchors.fill: parent
Component.onCompleted: source = weatherLocation.backgroundComponent
Component.onCompleted: {
if (weatherLocation) {
source = weatherLocation.backgroundComponent;
}
}
NumberAnimation {
id: backgroundLoaderOpacity
......
......@@ -19,8 +19,10 @@ Kirigami.Page {
return i18n("Forecast");
} else if (settingsModel.forecastStyle === "Dynamic") {
return ""; // provided by DynamicForecastPage
} else {
} else if (weatherLocationListModel.locations[loader.item.currentIndex]) {
return weatherLocationListModel.locations[loader.item.currentIndex].name;
} else {
return "";
}
}
......
......@@ -30,7 +30,9 @@ Kirigami.ScrollablePage {
Connections {
target: weatherLocationListModel
onNetworkErrorCreating: showPassiveNotification(i18n("Unable to fetch timezone information"))
function onNetworkErrorCreating() {
showPassiveNotification(i18n("Unable to fetch timezone information"));
}
}
ListView {
......@@ -88,7 +90,14 @@ Kirigami.ScrollablePage {
Kirigami.Action {
iconName: "delete"
text: i18n("Remove")
onTriggered: weatherLocationListModel.remove(index);
onTriggered: {
weatherLocationListModel.remove(index);
// switch to default page if there are no locations left
if (weatherLocationListModel.count === 0) {
switchToPage(getPage("Forecast"), 0);
}
}
}
]
......@@ -126,7 +135,7 @@ Kirigami.ScrollablePage {
spacing: Kirigami.Units.smallSpacing
Kirigami.Icon {
Layout.alignment: Qt.AlignHCenter
source: modelData.hourForecasts[0] ? modelData.hourForecasts[0].weatherIcon : "weather-none-available"
source: (modelData && modelData.hourForecasts[0]) ? modelData.hourForecasts[0].weatherIcon : "weather-none-available"
Layout.maximumHeight: Kirigami.Units.iconSizes.sizeForLabels * 2
Layout.preferredWidth: height
Layout.preferredHeight: Kirigami.Units.iconSizes.sizeForLabels * 2
......@@ -134,7 +143,7 @@ Kirigami.ScrollablePage {
Label {
Layout.alignment: Qt.AlignHCenter
font.pointSize: Kirigami.Theme.defaultFont.pointSize * 1.3
text: Formatter.formatTemperatureRounded(modelData.hourForecasts[0].temperature, settingsModel.temperatureUnits)
text: modelData ? Formatter.formatTemperatureRounded(modelData.hourForecasts[0].temperature, settingsModel.temperatureUnits) : ""
}
}
......@@ -143,7 +152,7 @@ Kirigami.ScrollablePage {
Layout.fillWidth: true
level: 2
text: modelData.name
text: modelData ? modelData.name : ""
elide: Text.ElideRight
maximumLineCount: 2
wrapMode: Text.Wrap
......
Markdown is supported
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