diff --git a/applets/weather/package/contents/ui/config/ConfigWeatherStation.qml b/applets/weather/package/contents/ui/config/ConfigWeatherStation.qml index d16831fcd..3233b6ae1 100644 --- a/applets/weather/package/contents/ui/config/ConfigWeatherStation.qml +++ b/applets/weather/package/contents/ui/config/ConfigWeatherStation.qml @@ -1,112 +1,112 @@ /* * Copyright 2016,2018 Friedrich W. H. Kossebau * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.9 -import QtQuick.Controls 2.5 as QtControls +import QtQuick.Controls 2.5 as QQC2 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.5 as Kirigami import org.kde.plasma.private.weather 1.0 Kirigami.FormLayout { id: weatherStationConfigPage property string source signal configurationChanged function saveConfig() { var config = { services: stationPicker.selectedServices, source: source, updateInterval: updateIntervalSpin.value }; plasmoid.nativeInterface.saveConfig(config); plasmoid.nativeInterface.configChanged(); } Component.onCompleted: { var config = plasmoid.nativeInterface.configValues(); stationPicker.selectedServices = config.services; source = config.source; updateIntervalSpin.value = config.updateInterval; } WeatherStationPickerDialog { id: stationPicker onAccepted: { weatherStationConfigPage.source = source; weatherStationConfigPage.configurationChanged(); } } RowLayout { Kirigami.FormData.label: i18nc("@label", "Location:") Layout.fillWidth: true - QtControls.Label { + QQC2.Label { id: locationDisplay Layout.fillWidth: true elide: Text.ElideRight visible: text != "" text: { var sourceDetails = source.split('|'); if (sourceDetails.length > 2) { return i18nc("A weather station location and the weather service it comes from", "%1 (%2)", sourceDetails[2], sourceDetails[0]); } return "" } } - QtControls.Button { + QQC2.Button { id: selectButton Layout.fillWidth: true icon.name: "find-location" text: i18nc("@action:button", "Choose...") onClicked: stationPicker.visible = true; } } - QtControls.SpinBox { + QQC2.SpinBox { id: updateIntervalSpin Kirigami.FormData.label: i18nc("@label:spinbox", "Update every:") textFromValue: function(value) { return (i18np("%1 minute", "%1 minutes", value)); } valueFromText: function(text) { return parseInt(text); } from: 30 to: 3600 editable: true onValueChanged: weatherStationConfigPage.configurationChanged(); } } diff --git a/applets/weather/package/contents/ui/config/WeatherStationPicker.qml b/applets/weather/package/contents/ui/config/WeatherStationPicker.qml index b22a70fff..80cd1e91e 100644 --- a/applets/weather/package/contents/ui/config/WeatherStationPicker.qml +++ b/applets/weather/package/contents/ui/config/WeatherStationPicker.qml @@ -1,175 +1,179 @@ /* * Copyright 2016,2018 Friedrich W. H. Kossebau * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.9 -import QtQuick.Controls 1.4 as QtControls +import QtQuick.Controls 1.4 as QQC1 +import QtQuick.Controls 2.5 as QQC2 import QtQuick.Layouts 1.3 -import org.kde.plasma.components 2.0 as PlasmaComponents - import org.kde.plasma.private.weather 1.0 ColumnLayout { id: root property alias selectedServices: serviceListModel.selectedServices property string source readonly property bool canSearch: !!searchStringEdit.text && selectedServices.length readonly property bool handlesEnterKey: canSearch && searchStringEdit.activeFocus function searchLocation() { if (!canSearch) { return; } // avoid automatic selection once model is refilled locationListView.currentRow = -1; locationListView.selection.clear(); noSearchResultReport.visible = false; source = ""; locationListView.forceActiveFocus(); locationListModel.searchLocations(searchStringEdit.text, selectedServices); } function handleLocationSearchDone(success, searchString) { if (!success) { noSearchResultReport.text = i18nc("@info", "No weather stations found for '%1'", searchString); noSearchResultReport.visible = true; } } LocationListModel { id: locationListModel onLocationSearchDone: handleLocationSearchDone(success, searchString); } ServiceListModel { id: serviceListModel } - QtControls.Menu { + QQC2.Menu { id: serviceSelectionMenu Instantiator { model: serviceListModel - delegate: QtControls.MenuItem { + delegate: QQC2.MenuItem { text: model.display checkable: true checked: model.checked onToggled: { model.checked = checked; checked = Qt.binding(function() { return model.checked; }); weatherStationConfigPage.configurationChanged(); } } onObjectAdded: serviceSelectionMenu.insertItem(index, object) onObjectRemoved: serviceSelectionMenu.removeItem(object) } } RowLayout { Layout.fillWidth: true - QtControls.TextField { + QQC2.TextField { id: searchStringEdit Layout.fillWidth: true Layout.minimumWidth: implicitWidth placeholderText: i18nc("@info:placeholder", "Enter location") onAccepted: { searchLocation(); } } - QtControls.Button { + QQC2.Button { id: serviceSelectionButton - iconName: "services" - tooltip: i18nc("@info:tooltip", "Select weather services providers") - menu: serviceSelectionMenu - } - - Item { - Layout.preferredHeight: Math.max(searchButton.height, searchStringEdit.height) - Layout.preferredWidth: Layout.preferredHeight + icon.name: "services" - PlasmaComponents.BusyIndicator { - id: busy + checkable: true + checked: serviceSelectionMenu.opened + onClicked: serviceSelectionMenu.popup(serviceSelectionButton, serviceSelectionButton.width - serviceSelectionMenu.width, serviceSelectionButton.height) - anchors.fill: parent - visible: locationListModel.validatingInput + QQC2.ToolTip { + text: i18nc("@info:tooltip", "Select weather services providers") + visible: hovered } } - QtControls.Button { + QQC2.Button { id: searchButton - iconName: "edit-find" + icon.name: "edit-find" text: i18nc("@action:button", "Search") enabled: canSearch onClicked: { searchLocation(); } } } - QtControls.TableView { + QQC1.TableView { id: locationListView Layout.minimumWidth: implicitWidth Layout.minimumHeight: implicitHeight Layout.fillWidth: true Layout.fillHeight: true headerVisible: false model: locationListModel onActivated: { if (row !== -1 && rowCount) { source = locationListModel.valueForListIndex(row); } } - QtControls.TableViewColumn { + QQC1.TableViewColumn { id: locationListViewStationColumn movable: false resizable: false role: "display" } - QtControls.Label { + QQC2.Label { id: noSearchResultReport anchors.fill: parent horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter wrapMode: Text.WordWrap visible: false } + + QQC2.BusyIndicator { + id: busy + + anchors.centerIn: parent + width: Kirigami.Units.gridUnit + height: width + + visible: locationListModel.validatingInput + } } Component.onCompleted: { searchStringEdit.forceActiveFocus(); } } diff --git a/applets/weather/package/contents/ui/config/WeatherStationPickerDialog.qml b/applets/weather/package/contents/ui/config/WeatherStationPickerDialog.qml index 56565025b..6ebc6a338 100644 --- a/applets/weather/package/contents/ui/config/WeatherStationPickerDialog.qml +++ b/applets/weather/package/contents/ui/config/WeatherStationPickerDialog.qml @@ -1,113 +1,112 @@ /* * Copyright 2018 Friedrich W. H. Kossebau * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.9 import QtQuick.Window 2.2 -import QtQuick.Controls 1.4 as QtControls +import QtQuick.Controls 2.5 as QQC2 import QtQuick.Layouts 1.3 -import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.kirigami 2.5 as Kirigami Window { id: dialog LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft LayoutMirroring.childrenInherit: true flags: Qt.Dialog modality: Qt.WindowModal width: Kirigami.Units.gridUnit * 25 height: Kirigami.Units.gridUnit * 20 title: i18nc("@title:window", "Select Weather Station") color: syspal.window property alias selectedServices : stationPicker.selectedServices property alias source: stationPicker.source signal accepted function close() { dialog.visible = false; } SystemPalette { id: syspal } - QtControls.Action { + QQC2.Action { id: acceptAction shortcut: "Return" enabled: !!source && !stationPicker.handlesEnterKey onTriggered: { accepted(); dialog.close(); } } - QtControls.Action { + QQC2.Action { id: cancelAction shortcut: "Escape" onTriggered: { dialog.close(); } } ColumnLayout { id: mainColumn anchors { fill: parent - margins: mainColumn.spacing * units.devicePixelRatio //margins are hardcoded in QStyle we should match that here + margins: mainColumn.spacing * Screen.devicePixelRatio //margins are hardcoded in QStyle we should match that here } WeatherStationPicker { id: stationPicker Layout.fillWidth: true Layout.fillHeight: true } RowLayout { id: buttonsRow Layout.alignment: Qt.AlignVCenter | Qt.AlignRight - QtControls.Button { + QQC2.Button { enabled: !!source - iconName: "dialog-ok" + icon.name: "dialog-ok" text: i18nc("@action:button", "Select") onClicked: { acceptAction.trigger(); } } - QtControls.Button { - iconName: "dialog-cancel" + QQC2.Button { + icon.name: "dialog-cancel" text: i18nc("@action:button", "Cancel") onClicked: { cancelAction.trigger(); } } } } }