Warning, /utilities/kweather/src/qml/ForecastContainerPage.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-2021 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 
0016 Kirigami.Page {
0017     id: page
0018     topPadding: 0; bottomPadding: 0; rightPadding: 0; leftPadding: 0
0019 
0020     title: {
0021         if (WeatherLocationListModel.locations.count == 0) {
0022             return i18n("Forecast");
0023         } else if (settingsModel.forecastStyle === "Dynamic") {
0024             return ""; // provided by DynamicForecastPage
0025         } else if (WeatherLocationListModel.locations[loader.item.currentIndex]) {
0026             return WeatherLocationListModel.locations[loader.item.currentIndex].name;
0027         } else {
0028             return "";
0029         }
0030     }
0031     
0032     globalToolBarStyle: (settingsModel.forecastStyle === "Dynamic" && pageStack.layers.depth <= 1) ? Kirigami.ApplicationHeaderStyle.None : Kirigami.ApplicationHeaderStyle.ToolBar
0033     
0034     property real yTranslate: 0
0035     
0036     function switchPageIndex(pageIndex) {
0037         loader.item.currentIndex = pageIndex;
0038     }
0039     
0040     // actions (only shown in flat view since the toolbar is hidden in dynamic view)
0041     actions: [
0042         Kirigami.Action {
0043             icon.name: "find-location"
0044             text: i18n("Locations")
0045             onTriggered: applicationWindow().openLocationsList()
0046         },
0047         Kirigami.Action {
0048             icon.name: "settings-configure"
0049             text: i18n("Settings")
0050             displayHint: Kirigami.Action.IconOnly
0051             onTriggered: applicationWindow().openSettings()
0052         },
0053         Kirigami.Action {
0054             visible: !Kirigami.Settings.isMobile
0055             icon.name: "view-refresh"
0056             text: i18n("Refresh")
0057             displayHint: Kirigami.Action.IconOnly
0058             onTriggered: WeatherLocationListModel.locations[loader.item.currentIndex].update()
0059         }
0060     ]
0061 
0062     Loader {
0063         id: loader
0064         transform: Translate { y: yTranslate }
0065         anchors.fill: parent
0066         
0067         Component.onCompleted: loadStyle()
0068         function loadStyle() {
0069             setSource(settingsModel.forecastStyle === "Dynamic" ? "DynamicForecastPage.qml" : "FlatForecastPage.qml");
0070         }
0071         
0072         Connections {
0073             target: settingsModel
0074             function onForecastStyleChanged() {
0075                 loader.loadStyle();
0076             }
0077         }
0078     }
0079 }
0080 
0081