Changeset View
Changeset View
Standalone View
Standalone View
kcm/qml/main.qml
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 28 | Item { | |||
---|---|---|---|---|---|
73 | } | 73 | } | ||
74 | 74 | | |||
75 | QQC2.ScrollView { | 75 | QQC2.ScrollView { | ||
76 | id: scrollView | 76 | id: scrollView | ||
77 | 77 | | |||
78 | Component.onCompleted: background.visible = true // show frame | 78 | Component.onCompleted: background.visible = true // show frame | ||
79 | 79 | | |||
80 | anchors { | 80 | anchors { | ||
81 | bottom: buttonRow.top | 81 | bottom: rightButtonRow.top | ||
82 | bottomMargin: Math.round(units.gridUnit / 3) | 82 | bottomMargin: units.smallSpacing | ||
83 | left: parent.left | 83 | left: parent.left | ||
84 | right: parent.right | 84 | right: parent.right | ||
85 | top: searchField.bottom | 85 | top: searchField.bottom | ||
86 | } | 86 | } | ||
87 | 87 | | |||
88 | ListView { | 88 | ListView { | ||
89 | id: connectionView | 89 | id: connectionView | ||
90 | 90 | | |||
Show All 35 Lines | |||||
126 | 126 | | |||
127 | onCurrentConnectionPathChanged: { | 127 | onCurrentConnectionPathChanged: { | ||
128 | root.selectedConnectionChanged(currentConnectionPath) | 128 | root.selectedConnectionChanged(currentConnectionPath) | ||
129 | } | 129 | } | ||
130 | } | 130 | } | ||
131 | } | 131 | } | ||
132 | 132 | | |||
133 | Row { | 133 | Row { | ||
134 | id: buttonRow | 134 | id: rightButtonRow | ||
135 | 135 | | |||
136 | anchors { | 136 | anchors { | ||
137 | bottom: parent.bottom | 137 | bottom: parent.bottom | ||
138 | right: parent.right | 138 | right: parent.right | ||
139 | margins: Math.round(units.gridUnit / 3) | 139 | margins: units.smallSpacing | ||
140 | } | 140 | } | ||
141 | spacing: Math.round(units.gridUnit / 2) | 141 | spacing: units.smallSpacing | ||
142 | 142 | | |||
143 | QQC2.ToolButton { | 143 | QQC2.ToolButton { | ||
144 | id: addConnectionButton | 144 | id: addConnectionButton | ||
145 | 145 | | |||
146 | icon.name: "list-add" | 146 | icon.name: "list-add" | ||
147 | 147 | | |||
148 | QQC2.ToolTip { | 148 | QQC2.ToolTip.text: i18n("Add new connection") | ||
149 | text: i18n("Add new connection") | 149 | QQC2.ToolTip.visible: hovered | ||
150 | } | | |||
151 | 150 | | |||
152 | onClicked: { | 151 | onClicked: { | ||
153 | addNewConnectionDialog.open() | 152 | addNewConnectionDialog.open() | ||
154 | } | 153 | } | ||
155 | } | 154 | } | ||
156 | 155 | | |||
157 | QQC2.ToolButton { | 156 | QQC2.ToolButton { | ||
158 | id: removeConnectionButton | 157 | id: removeConnectionButton | ||
159 | 158 | | |||
160 | enabled: connectionView.currentConnectionPath && connectionView.currentConnectionPath.length | 159 | enabled: connectionView.currentConnectionPath && connectionView.currentConnectionPath.length | ||
161 | icon.name: "list-remove" | 160 | icon.name: "list-remove" | ||
162 | 161 | | |||
163 | QQC2.ToolTip { | 162 | QQC2.ToolTip.text: i18n("Remove selected connection") | ||
164 | text: i18n("Remove selected connection") | 163 | QQC2.ToolTip.visible: hovered | ||
165 | } | | |||
166 | 164 | | |||
167 | onClicked: { | 165 | onClicked: { | ||
168 | deleteConfirmationDialog.connectionName = connectionView.currentConnectionName | 166 | deleteConfirmationDialog.connectionName = connectionView.currentConnectionName | ||
169 | deleteConfirmationDialog.connectionPath = connectionView.currentConnectionPath | 167 | deleteConfirmationDialog.connectionPath = connectionView.currentConnectionPath | ||
170 | deleteConfirmationDialog.open() | 168 | deleteConfirmationDialog.open() | ||
171 | } | 169 | } | ||
172 | } | 170 | } | ||
173 | 171 | | |||
174 | QQC2.ToolButton { | 172 | QQC2.ToolButton { | ||
175 | id: exportConnectionButton | 173 | id: exportConnectionButton | ||
176 | 174 | | |||
177 | enabled: connectionView.currentConnectionExportable | 175 | enabled: connectionView.currentConnectionExportable | ||
178 | icon.name: "document-export" | 176 | icon.name: "document-export" | ||
179 | 177 | | |||
180 | QQC2.ToolTip { | 178 | QQC2.ToolTip.text: i18n("Export selected connection") | ||
181 | text: i18n("Export selected connection") | 179 | QQC2.ToolTip.visible: hovered | ||
182 | } | | |||
183 | 180 | | |||
184 | onClicked: { | 181 | onClicked: { | ||
185 | root.requestExportConnection(connectionView.currentConnectionPath) | 182 | root.requestExportConnection(connectionView.currentConnectionPath) | ||
186 | } | 183 | } | ||
187 | } | 184 | } | ||
188 | } | 185 | } | ||
189 | 186 | | |||
187 | Row { | ||||
188 | id: leftButtonRow | ||||
189 | | ||||
190 | anchors { | ||||
191 | bottom: parent.bottom | ||||
192 | left: parent.left | ||||
193 | margins: units.smallSpacing | ||||
ngraham: `units.smallSpacing` | |||||
194 | } | ||||
195 | spacing: units.smallSpacing | ||||
ngraham: ditto | |||||
196 | | ||||
197 | QQC2.ToolButton { | ||||
198 | id: configureButton | ||||
199 | | ||||
200 | icon.name: "configure" | ||||
201 | | ||||
202 | QQC2.ToolTip.text: i18n("Configuration") | ||||
Use the attached ToolTip property instead of creating a whole object; it's lighter that way ngraham: Use the attached ToolTip property instead of creating a whole object; it's lighter that way | |||||
I tried, doesn't seem to work. I followed the example from https://doc-snapshots.qt.io/qt5-5.12/qml-qtquick-controls2-tooltip.html and it says there is no such attached property. jgrulich: I tried, doesn't seem to work. I followed the example from https://doc-snapshots.qt.io/qt5-5. | |||||
Gotta include the namespace, e.g.: QQC2.toolTip.visible: hovered QQC2.toolTip.text: i18n("blabla") ngraham: Gotta include the namespace, e.g.:
```
QQC2.toolTip.visible: hovered
QQC2.toolTip.text: i18n… | |||||
203 | QQC2.ToolTip.visible: hovered | ||||
204 | | ||||
205 | onClicked: { | ||||
206 | configurationDialog.open() | ||||
207 | } | ||||
208 | } | ||||
209 | } | ||||
210 | | ||||
190 | MessageDialog { | 211 | MessageDialog { | ||
191 | id: deleteConfirmationDialog | 212 | id: deleteConfirmationDialog | ||
192 | 213 | | |||
193 | property string connectionName | 214 | property string connectionName | ||
194 | property string connectionPath | 215 | property string connectionPath | ||
195 | 216 | | |||
196 | icon: StandardIcon.Question | 217 | icon: StandardIcon.Question | ||
197 | standardButtons: StandardButton.Ok | StandardButton.Cancel | 218 | standardButtons: StandardButton.Ok | StandardButton.Cancel | ||
198 | title: i18nc("@title:window", "Remove Connection") | 219 | title: i18nc("@title:window", "Remove Connection") | ||
199 | text: i18n("Do you want to remove the connection '%1'?", connectionName) | 220 | text: i18n("Do you want to remove the connection '%1'?", connectionName) | ||
200 | 221 | | |||
201 | onAccepted: { | 222 | onAccepted: { | ||
202 | if (connectionPath == connectionView.currentConnectionPath) { | 223 | if (connectionPath == connectionView.currentConnectionPath) { | ||
203 | // Deselect now non-existing connection | 224 | // Deselect now non-existing connection | ||
204 | deselectConnections() | 225 | deselectConnections() | ||
205 | } | 226 | } | ||
206 | handler.removeConnection(connectionPath) | 227 | handler.removeConnection(connectionPath) | ||
207 | } | 228 | } | ||
208 | } | 229 | } | ||
209 | 230 | | |||
210 | Dialog { | 231 | AddConnectionDialog { | ||
211 | id: addNewConnectionDialog | 232 | id: addNewConnectionDialog | ||
212 | 233 | | |||
213 | onRequestCreateConnection: { | 234 | onRequestCreateConnection: { | ||
214 | root.requestCreateConnection(type, vpnType, specificType, shared) | 235 | root.requestCreateConnection(type, vpnType, specificType, shared) | ||
215 | } | 236 | } | ||
216 | } | 237 | } | ||
217 | 238 | | |||
239 | ConfigurationDialog { | ||||
240 | id: configurationDialog | ||||
241 | } | ||||
242 | | ||||
218 | function deselectConnections() { | 243 | function deselectConnections() { | ||
219 | connectionView.currentConnectionPath = "" | 244 | connectionView.currentConnectionPath = "" | ||
220 | } | 245 | } | ||
221 | 246 | | |||
222 | function selectConnection(connectionName, connectionPath) { | 247 | function selectConnection(connectionName, connectionPath) { | ||
223 | connectionView.currentConnectionName = connectionName | 248 | connectionView.currentConnectionName = connectionName | ||
224 | connectionView.currentConnectionPath = connectionPath | 249 | connectionView.currentConnectionPath = connectionPath | ||
225 | } | 250 | } | ||
226 | } | 251 | } |
units.smallSpacing