diff --git a/applets/weather/package/contents/ui/config/WeatherStationPicker.qml b/applets/weather/package/contents/ui/config/WeatherStationPicker.qml index 171fd50d2..b22a70fff 100644 --- a/applets/weather/package/contents/ui/config/WeatherStationPicker.qml +++ b/applets/weather/package/contents/ui/config/WeatherStationPicker.qml @@ -1,177 +1,175 @@ /* * 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.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 { id: serviceSelectionMenu Instantiator { model: serviceListModel delegate: QtControls.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) } } - ColumnLayout { - RowLayout { - Layout.fillWidth: true + RowLayout { + Layout.fillWidth: true - QtControls.TextField { - id: searchStringEdit + QtControls.TextField { + id: searchStringEdit - Layout.fillWidth: true - Layout.minimumWidth: implicitWidth - placeholderText: i18nc("@info:placeholder", "Enter location") - onAccepted: { - searchLocation(); - } + Layout.fillWidth: true + Layout.minimumWidth: implicitWidth + placeholderText: i18nc("@info:placeholder", "Enter location") + onAccepted: { + searchLocation(); } + } - QtControls.Button { - id: serviceSelectionButton + QtControls.Button { + id: serviceSelectionButton - iconName: "services" - tooltip: i18nc("@info:tooltip", "Select weather services providers") - menu: serviceSelectionMenu - } + 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 + Item { + Layout.preferredHeight: Math.max(searchButton.height, searchStringEdit.height) + Layout.preferredWidth: Layout.preferredHeight - PlasmaComponents.BusyIndicator { - id: busy + PlasmaComponents.BusyIndicator { + id: busy - anchors.fill: parent - visible: locationListModel.validatingInput - } + anchors.fill: parent + visible: locationListModel.validatingInput } + } - QtControls.Button { - id: searchButton + QtControls.Button { + id: searchButton - iconName: "edit-find" - text: i18nc("@action:button", "Search") - enabled: canSearch + iconName: "edit-find" + text: i18nc("@action:button", "Search") + enabled: canSearch - onClicked: { - searchLocation(); - } + onClicked: { + searchLocation(); } } + } - QtControls.TableView { - id: locationListView + QtControls.TableView { + id: locationListView - Layout.minimumWidth: implicitWidth - Layout.minimumHeight: implicitHeight - Layout.fillWidth: true - Layout.fillHeight: true + Layout.minimumWidth: implicitWidth + Layout.minimumHeight: implicitHeight + Layout.fillWidth: true + Layout.fillHeight: true - headerVisible: false - model: locationListModel + headerVisible: false + model: locationListModel - onActivated: { - if (row !== -1 && rowCount) { - source = locationListModel.valueForListIndex(row); - } + onActivated: { + if (row !== -1 && rowCount) { + source = locationListModel.valueForListIndex(row); } + } - QtControls.TableViewColumn { - id: locationListViewStationColumn + QtControls.TableViewColumn { + id: locationListViewStationColumn - movable: false - resizable: false - role: "display" - } + movable: false + resizable: false + role: "display" + } - QtControls.Label { - id: noSearchResultReport + QtControls.Label { + id: noSearchResultReport - anchors.fill: parent - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - wrapMode: Text.WordWrap - visible: false - } + anchors.fill: parent + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + visible: false } } 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 ab93a51f2..56565025b 100644 --- a/applets/weather/package/contents/ui/config/WeatherStationPickerDialog.qml +++ b/applets/weather/package/contents/ui/config/WeatherStationPickerDialog.qml @@ -1,115 +1,113 @@ /* * 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.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 - minimumWidth: mainColumn.Layout.minimumWidth - minimumHeight: mainColumn.Layout.minimumHeight + 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 { id: acceptAction shortcut: "Return" enabled: !!source && !stationPicker.handlesEnterKey onTriggered: { accepted(); dialog.close(); } } QtControls.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 } - // TODO: not yet perfect - Layout.minimumWidth: Math.max(stationPicker.Layout.minimumWidth, buttonsRow.implicitWidth) + 2*anchors.margins - Layout.minimumHeight: stationPicker.Layout.minimumHeight + buttonsRow.implicitHeight + 2*anchors.margins WeatherStationPicker { id: stationPicker Layout.fillWidth: true Layout.fillHeight: true } RowLayout { id: buttonsRow Layout.alignment: Qt.AlignVCenter | Qt.AlignRight QtControls.Button { enabled: !!source iconName: "dialog-ok" text: i18nc("@action:button", "Select") onClicked: { acceptAction.trigger(); } } QtControls.Button { iconName: "dialog-cancel" text: i18nc("@action:button", "Cancel") onClicked: { cancelAction.trigger(); } } } } }