Warning, /utilities/kweather/src/qml/DefaultPage.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * SPDX-FileCopyrightText: 2020 Han Young <hanyoung@protonmail.com>
0003  * SPDX-FileCopyrightText: 2020 Devin Lin <espidev@gmail.com>
0004  *
0005  * SPDX-License-Identifier: GPL-2.0-or-later
0006  */
0007 
0008 import QtQuick
0009 import QtQuick.Controls
0010 import QtQuick.Layouts
0011 
0012 import org.kde.kirigami as Kirigami
0013 
0014 import org.kde.kweather
0015 import org.kde.kweather.locations
0016 
0017 // page shown if there are no weather locations configured
0018 Kirigami.Page {
0019     title: i18n("Forecast")
0020 
0021     property bool loading: false
0022     
0023     property int yTranslate: 0
0024     
0025     Connections {
0026         target: WeatherLocationListModel
0027         function onNetworkErrorCreatingDefault() {
0028             showPassiveNotification(i18n("Network error when obtaining current location"));
0029             loading = false;
0030         }
0031         function onSuccessfullyCreatedDefault() {
0032             switchToPage(getPage("Forecast"), 0);
0033             loading = false;
0034         }
0035     }
0036     
0037     actions: [
0038         Kirigami.Action {
0039             visible: Kirigami.Settings.isMobile
0040             icon.name: "settings-configure"
0041             onTriggered: applicationWindow().openSettings()
0042         }
0043     ]
0044 
0045     Item { // empty list view to centre placeholdermessage
0046         anchors.fill: parent
0047         transform: Translate { y: yTranslate }
0048         BusyIndicator {
0049             anchors.centerIn: parent
0050             running: loading
0051             Layout.minimumWidth: Kirigami.Units.iconSizes.huge
0052             Layout.minimumHeight: width
0053         }
0054         
0055         
0056         ColumnLayout {
0057             visible: !loading
0058             anchors.centerIn: parent
0059             spacing: Kirigami.Units.gridUnit
0060             
0061             Kirigami.Icon {
0062                 Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
0063                 source: "qrc:/resources/kweather.svg"
0064                 implicitWidth: Kirigami.Units.iconSizes.enormous * 1.5
0065                 implicitHeight: Kirigami.Units.iconSizes.enormous * 1.5
0066             }
0067             
0068             Kirigami.Heading {
0069                 Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
0070                 text: i18n("Weather")
0071                 type: Kirigami.Heading.Type.Primary
0072                 horizontalAlignment: Qt.AlignHCenter
0073             }
0074             
0075             Button {
0076                 Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
0077                 icon.name: "list-add"
0078                 text: i18n("Add Location")
0079                 onClicked: applicationWindow().openAddLocation();
0080             }
0081         }
0082     }
0083 }