Changeset View
Changeset View
Standalone View
Standalone View
applets/weather/package/contents/ui/config/WeatherStationPicker.qml
Show All 11 Lines | |||||
12 | * GNU General Public License for more details. | 12 | * GNU General Public License for more details. | ||
13 | * | 13 | * | ||
14 | * You should have received a copy of the GNU General Public License | 14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | 16 | */ | ||
17 | 17 | | |||
18 | import QtQuick 2.9 | 18 | import QtQuick 2.9 | ||
19 | 19 | | |||
20 | import QtQuick.Controls 1.4 as QtControls | 20 | import QtQuick.Controls 1.4 as QQC1 | ||
21 | import QtQuick.Controls 2.5 as QQC2 | ||||
21 | import QtQuick.Layouts 1.3 | 22 | import QtQuick.Layouts 1.3 | ||
22 | 23 | | |||
23 | import org.kde.plasma.components 2.0 as PlasmaComponents | | |||
24 | | ||||
25 | import org.kde.plasma.private.weather 1.0 | 24 | import org.kde.plasma.private.weather 1.0 | ||
26 | 25 | | |||
27 | 26 | | |||
28 | ColumnLayout { | 27 | ColumnLayout { | ||
29 | id: root | 28 | id: root | ||
30 | 29 | | |||
31 | property alias selectedServices: serviceListModel.selectedServices | 30 | property alias selectedServices: serviceListModel.selectedServices | ||
32 | property string source | 31 | property string source | ||
Show All 26 Lines | 57 | LocationListModel { | |||
59 | id: locationListModel | 58 | id: locationListModel | ||
60 | onLocationSearchDone: handleLocationSearchDone(success, searchString); | 59 | onLocationSearchDone: handleLocationSearchDone(success, searchString); | ||
61 | } | 60 | } | ||
62 | 61 | | |||
63 | ServiceListModel { | 62 | ServiceListModel { | ||
64 | id: serviceListModel | 63 | id: serviceListModel | ||
65 | } | 64 | } | ||
66 | 65 | | |||
67 | QtControls.Menu { | 66 | QQC2.Menu { | ||
68 | id: serviceSelectionMenu | 67 | id: serviceSelectionMenu | ||
69 | 68 | | |||
70 | Instantiator { | 69 | Instantiator { | ||
71 | model: serviceListModel | 70 | model: serviceListModel | ||
72 | delegate: QtControls.MenuItem { | 71 | delegate: QQC2.MenuItem { | ||
73 | text: model.display | 72 | text: model.display | ||
74 | checkable: true | 73 | checkable: true | ||
75 | checked: model.checked | 74 | checked: model.checked | ||
76 | 75 | | |||
77 | onToggled: { | 76 | onToggled: { | ||
78 | model.checked = checked; | 77 | model.checked = checked; | ||
79 | checked = Qt.binding(function() { return model.checked; }); | 78 | checked = Qt.binding(function() { return model.checked; }); | ||
80 | weatherStationConfigPage.configurationChanged(); | 79 | weatherStationConfigPage.configurationChanged(); | ||
81 | } | 80 | } | ||
82 | } | 81 | } | ||
83 | onObjectAdded: serviceSelectionMenu.insertItem(index, object) | 82 | onObjectAdded: serviceSelectionMenu.insertItem(index, object) | ||
84 | onObjectRemoved: serviceSelectionMenu.removeItem(object) | 83 | onObjectRemoved: serviceSelectionMenu.removeItem(object) | ||
85 | } | 84 | } | ||
86 | 85 | | |||
87 | } | 86 | } | ||
88 | 87 | | |||
89 | RowLayout { | 88 | RowLayout { | ||
90 | Layout.fillWidth: true | 89 | Layout.fillWidth: true | ||
91 | 90 | | |||
92 | QtControls.TextField { | 91 | QQC2.TextField { | ||
93 | id: searchStringEdit | 92 | id: searchStringEdit | ||
94 | 93 | | |||
95 | Layout.fillWidth: true | 94 | Layout.fillWidth: true | ||
96 | Layout.minimumWidth: implicitWidth | 95 | Layout.minimumWidth: implicitWidth | ||
97 | placeholderText: i18nc("@info:placeholder", "Enter location") | 96 | placeholderText: i18nc("@info:placeholder", "Enter location") | ||
98 | onAccepted: { | 97 | onAccepted: { | ||
99 | searchLocation(); | 98 | searchLocation(); | ||
100 | } | 99 | } | ||
101 | } | 100 | } | ||
102 | 101 | | |||
103 | QtControls.Button { | 102 | QQC2.Button { | ||
104 | id: serviceSelectionButton | 103 | id: serviceSelectionButton | ||
105 | 104 | | |||
106 | iconName: "services" | 105 | icon.name: "services" | ||
107 | tooltip: i18nc("@info:tooltip", "Select weather services providers") | | |||
108 | menu: serviceSelectionMenu | | |||
109 | } | | |||
110 | | ||||
111 | Item { | | |||
112 | Layout.preferredHeight: Math.max(searchButton.height, searchStringEdit.height) | | |||
113 | Layout.preferredWidth: Layout.preferredHeight | | |||
114 | 106 | | |||
115 | PlasmaComponents.BusyIndicator { | 107 | checkable: true | ||
116 | id: busy | 108 | checked: serviceSelectionMenu.opened | ||
109 | onClicked: serviceSelectionMenu.popup(serviceSelectionButton, serviceSelectionButton.width - serviceSelectionMenu.width, serviceSelectionButton.height) | ||||
117 | 110 | | |||
118 | anchors.fill: parent | 111 | QQC2.ToolTip { | ||
119 | visible: locationListModel.validatingInput | 112 | text: i18nc("@info:tooltip", "Select weather services providers") | ||
113 | visible: hovered | ||||
120 | } | 114 | } | ||
121 | } | 115 | } | ||
122 | 116 | | |||
123 | QtControls.Button { | 117 | QQC2.Button { | ||
124 | id: searchButton | 118 | id: searchButton | ||
125 | 119 | | |||
126 | iconName: "edit-find" | 120 | icon.name: "edit-find" | ||
127 | text: i18nc("@action:button", "Search") | 121 | text: i18nc("@action:button", "Search") | ||
128 | enabled: canSearch | 122 | enabled: canSearch | ||
129 | 123 | | |||
130 | onClicked: { | 124 | onClicked: { | ||
131 | searchLocation(); | 125 | searchLocation(); | ||
132 | } | 126 | } | ||
133 | } | 127 | } | ||
134 | } | 128 | } | ||
135 | 129 | | |||
136 | QtControls.TableView { | 130 | QQC1.TableView { | ||
137 | id: locationListView | 131 | id: locationListView | ||
138 | 132 | | |||
139 | Layout.minimumWidth: implicitWidth | 133 | Layout.minimumWidth: implicitWidth | ||
140 | Layout.minimumHeight: implicitHeight | 134 | Layout.minimumHeight: implicitHeight | ||
141 | Layout.fillWidth: true | 135 | Layout.fillWidth: true | ||
142 | Layout.fillHeight: true | 136 | Layout.fillHeight: true | ||
143 | 137 | | |||
144 | headerVisible: false | 138 | headerVisible: false | ||
145 | model: locationListModel | 139 | model: locationListModel | ||
146 | 140 | | |||
147 | onActivated: { | 141 | onActivated: { | ||
148 | if (row !== -1 && rowCount) { | 142 | if (row !== -1 && rowCount) { | ||
149 | source = locationListModel.valueForListIndex(row); | 143 | source = locationListModel.valueForListIndex(row); | ||
150 | } | 144 | } | ||
151 | } | 145 | } | ||
152 | 146 | | |||
153 | QtControls.TableViewColumn { | 147 | QQC1.TableViewColumn { | ||
154 | id: locationListViewStationColumn | 148 | id: locationListViewStationColumn | ||
155 | 149 | | |||
156 | movable: false | 150 | movable: false | ||
157 | resizable: false | 151 | resizable: false | ||
158 | role: "display" | 152 | role: "display" | ||
159 | } | 153 | } | ||
160 | 154 | | |||
161 | QtControls.Label { | 155 | QQC2.Label { | ||
162 | id: noSearchResultReport | 156 | id: noSearchResultReport | ||
163 | 157 | | |||
164 | anchors.fill: parent | 158 | anchors.fill: parent | ||
165 | horizontalAlignment: Text.AlignHCenter | 159 | horizontalAlignment: Text.AlignHCenter | ||
166 | verticalAlignment: Text.AlignVCenter | 160 | verticalAlignment: Text.AlignVCenter | ||
167 | wrapMode: Text.WordWrap | 161 | wrapMode: Text.WordWrap | ||
168 | visible: false | 162 | visible: false | ||
169 | } | 163 | } | ||
164 | | ||||
165 | QQC2.BusyIndicator { | ||||
166 | id: busy | ||||
167 | | ||||
168 | anchors.centerIn: parent | ||||
169 | width: Kirigami.Units.gridUnit | ||||
170 | height: width | ||||
171 | | ||||
172 | visible: locationListModel.validatingInput | ||||
173 | } | ||||
170 | } | 174 | } | ||
171 | 175 | | |||
172 | Component.onCompleted: { | 176 | Component.onCompleted: { | ||
173 | searchStringEdit.forceActiveFocus(); | 177 | searchStringEdit.forceActiveFocus(); | ||
174 | } | 178 | } | ||
175 | } | 179 | } |