Changeset View
Changeset View
Standalone View
Standalone View
kcm/package/contents/ui/main.qml
Show All 20 Lines | |||||
21 | import "editor" | 21 | import "editor" | ||
22 | 22 | | |||
23 | import QtQuick 2.6 | 23 | import QtQuick 2.6 | ||
24 | import QtQuick.Dialogs 1.1 | 24 | import QtQuick.Dialogs 1.1 | ||
25 | import QtQuick.Layouts 1.3 | 25 | import QtQuick.Layouts 1.3 | ||
26 | import QtQuick.Controls 2.2 as QtControls | 26 | import QtQuick.Controls 2.2 as QtControls | ||
27 | 27 | | |||
28 | import org.kde.kcm 1.2 | 28 | import org.kde.kcm 1.2 | ||
29 | import org.kde.kirigami 2.3 as Kirigami // for Kirigami.Units | 29 | import org.kde.kirigami 2.4 as Kirigami // for Kirigami.Units | ||
30 | import org.kde.plasma.networkmanagement 0.2 as PlasmaNM | 30 | import org.kde.plasma.networkmanagement 0.2 as PlasmaNM | ||
31 | 31 | | |||
32 | ScrollViewKCM { | 32 | ScrollViewKCM { | ||
33 | id: root | 33 | id: root | ||
34 | 34 | | |||
35 | ConfigModule.quickHelp: i18n("Connections") | 35 | ConfigModule.quickHelp: i18n("Connections") | ||
36 | 36 | | |||
37 | title: i18n("Edit your Network Connections") | 37 | title: i18n("Edit your Network Connections") | ||
Show All 21 Lines | |||||
59 | } | 59 | } | ||
60 | 60 | | |||
61 | PlasmaNM.EditorProxyModel { | 61 | PlasmaNM.EditorProxyModel { | ||
62 | id: editorProxyModel | 62 | id: editorProxyModel | ||
63 | 63 | | |||
64 | sourceModel: connectionModel | 64 | sourceModel: connectionModel | ||
65 | } | 65 | } | ||
66 | 66 | | |||
67 | header: Rectangle { | 67 | header: QtControls.TextField { | ||
68 | color: Kirigami.Theme.backgroundColor | | |||
69 | | ||||
70 | width: root.width | | |||
71 | height: Math.round(Kirigami.Units.gridUnit * 2.5) | | |||
72 | | ||||
73 | RowLayout { | | |||
74 | id: searchLayout | | |||
75 | | ||||
76 | spacing: Kirigami.Units.smallSpacing | | |||
77 | anchors { | | |||
78 | fill: parent | | |||
79 | margins: Kirigami.Units.smallSpacing | | |||
80 | } | | |||
81 | | ||||
82 | QtControls.TextField { | | |||
83 | id: searchField | 68 | id: searchField | ||
84 | 69 | | |||
85 | Layout.minimumHeight: Layout.maximumHeight | 70 | Layout.minimumHeight: Layout.maximumHeight | ||
86 | Layout.maximumHeight: Kirigami.Units.iconSizes.smallMedium + Kirigami.Units.smallSpacing * 2 | 71 | Layout.maximumHeight: Kirigami.Units.iconSizes.smallMedium + Kirigami.Units.smallSpacing * 2 | ||
87 | Layout.fillWidth: true | 72 | Layout.fillWidth: true | ||
88 | 73 | | |||
89 | focus: true | 74 | focus: true | ||
90 | placeholderText: i18n("Type here to search connection...") | 75 | placeholderText: i18n("Type here to search connection...") | ||
Show All 25 Lines | 81 | MouseArea { | |||
116 | Behavior on opacity { | 101 | Behavior on opacity { | ||
117 | OpacityAnimator { | 102 | OpacityAnimator { | ||
118 | duration: Kirigami.Units.longDuration | 103 | duration: Kirigami.Units.longDuration | ||
119 | easing.type: Easing.InOutQuad | 104 | easing.type: Easing.InOutQuad | ||
120 | } | 105 | } | ||
121 | } | 106 | } | ||
122 | } | 107 | } | ||
123 | } | 108 | } | ||
124 | } | | |||
125 | 109 | | |||
126 | Kirigami.Separator { | | |||
127 | visible: !connectionView.atYBeginning | | |||
128 | anchors { | | |||
129 | left: parent.left | | |||
130 | right: parent.right | | |||
131 | top: parent.bottom | | |||
132 | } | | |||
133 | } | | |||
134 | } | | |||
135 | 110 | | |||
136 | view: ListView { | 111 | view: ListView { | ||
137 | id: connectionView | 112 | id: connectionView | ||
138 | clip: true | | |||
139 | model: editorProxyModel | 113 | model: editorProxyModel | ||
140 | currentIndex: -1 | 114 | currentIndex: -1 | ||
141 | boundsBehavior: Flickable.StopAtBounds | 115 | // activeFocusOnTab: true | ||
142 | activeFocusOnTab: true | 116 | // keyNavigationWraps: true | ||
143 | keyNavigationWraps: true | | |||
144 | Accessible.role: Accessible.List | 117 | Accessible.role: Accessible.List | ||
145 | Keys.onTabPressed: { | 118 | Keys.onTabPressed: {//this shouldn't be needed | ||
146 | if (applicationWindow().wideScreen && root.pageStack.depth > 1) { | 119 | if (applicationWindow().wideScreen && root.pageStack.depth > 1) { | ||
147 | connectionEditor.focus = true; | 120 | connectionEditor.focus = true; | ||
148 | } | 121 | } | ||
149 | } | 122 | } | ||
150 | 123 | | |||
151 | section { | 124 | section { | ||
152 | property: "KcmConnectionType" | 125 | property: "KcmConnectionType" | ||
153 | delegate: Kirigami.AbstractListItem { | 126 | delegate: Kirigami.AbstractListItem { | ||
154 | supportsMouseEvents: false | 127 | supportsMouseEvents: false | ||
128 | width: connectionView.width | ||||
155 | background: Rectangle { | 129 | background: Rectangle { | ||
156 | color: palette.window | 130 | color: palette.window | ||
157 | } | 131 | } | ||
158 | QtControls.Label { | 132 | QtControls.Label { | ||
159 | id: headerLabel | 133 | id: headerLabel | ||
160 | anchors.centerIn: parent | 134 | anchors.centerIn: parent | ||
161 | font.weight: Font.DemiBold | 135 | font.weight: Font.DemiBold | ||
162 | text: section | 136 | text: section | ||
163 | } | 137 | } | ||
164 | } | 138 | } | ||
165 | } | 139 | } | ||
166 | 140 | | |||
167 | delegate: ConnectionItemDelegate { | 141 | delegate: ConnectionItemDelegate { | ||
142 | width: connectionView.width | ||||
168 | onAboutToChangeConnection: { | 143 | onAboutToChangeConnection: { | ||
169 | // // Shouldn't be problem to set this in advance | 144 | // // Shouldn't be problem to set this in advance | ||
170 | // root.currentConnectionExportable = exportable | 145 | // root.currentConnectionExportable = exportable | ||
171 | // if (kcm.needsSave) { | 146 | // if (kcm.needsSave) { | ||
172 | // confirmSaveDialog.connectionName = name | 147 | // confirmSaveDialog.connectionName = name | ||
173 | // confirmSaveDialog.connectionPath = path | 148 | // confirmSaveDialog.connectionPath = path | ||
174 | // confirmSaveDialog.open() | 149 | // confirmSaveDialog.open() | ||
175 | // } else { | 150 | // } else { | ||
Show All 10 Lines | 154 | // } | |||
186 | onAboutToRemoveConnection: { | 161 | onAboutToRemoveConnection: { | ||
187 | deleteConfirmationDialog.connectionName = name | 162 | deleteConfirmationDialog.connectionName = name | ||
188 | deleteConfirmationDialog.connectionPath = path | 163 | deleteConfirmationDialog.connectionPath = path | ||
189 | deleteConfirmationDialog.open() | 164 | deleteConfirmationDialog.open() | ||
190 | } | 165 | } | ||
191 | } | 166 | } | ||
192 | } | 167 | } | ||
193 | 168 | | |||
194 | footer: Row { | 169 | footer: RowLayout { | ||
195 | layoutDirection: Qt.RightToLeft | | |||
196 | spacing: Kirigami.Units.smallSpacing | 170 | spacing: Kirigami.Units.smallSpacing | ||
197 | padding: Kirigami.Units.smallSpacing | | |||
198 | | ||||
199 | QtControls.Button { | | |||
200 | id: exportConnectionButton | | |||
201 | 171 | | |||
202 | height: Kirigami.Units.iconSizes.medium | 172 | Item { | ||
203 | width: Kirigami.Units.iconSizes.medium | 173 | Layout.fillWidth: true | ||
174 | } | ||||
204 | 175 | | |||
205 | enabled: root.currentConnectionExportable | 176 | QtControls.Button { | ||
206 | icon.name: "document-export" | 177 | id: addConnectionButton | ||
178 | icon.name: "list-add" | ||||
207 | 179 | | |||
208 | QtControls.ToolTip.text: i18n("Export selected connection") | 180 | QtControls.ToolTip.text: i18n("Add new connection") | ||
209 | QtControls.ToolTip.visible: exportConnectionButton.hovered | 181 | QtControls.ToolTip.visible: addConnectionButton.hovered | ||
210 | 182 | | |||
211 | onClicked: { | 183 | onClicked: { | ||
212 | kcm.requestExportConnection(root.currentConnectionPath) | 184 | addNewConnectionDialog.open() | ||
213 | } | 185 | } | ||
214 | } | 186 | } | ||
215 | 187 | | |||
216 | QtControls.Button { | 188 | QtControls.Button { | ||
217 | id: removeConnectionButton | 189 | id: removeConnectionButton | ||
218 | 190 | | |||
219 | height: Kirigami.Units.iconSizes.medium | | |||
220 | width: Kirigami.Units.iconSizes.medium | | |||
221 | | ||||
222 | enabled: root.currentConnectionPath && root.currentConnectionPath.length | 191 | enabled: root.currentConnectionPath && root.currentConnectionPath.length | ||
223 | icon.name: "list-remove" | 192 | icon.name: "list-remove" | ||
224 | 193 | | |||
225 | QtControls.ToolTip.text: i18n("Remove selected connection") | 194 | QtControls.ToolTip.text: i18n("Remove selected connection") | ||
226 | QtControls.ToolTip.visible: removeConnectionButton.hovered | 195 | QtControls.ToolTip.visible: removeConnectionButton.hovered | ||
227 | 196 | | |||
228 | onClicked: { | 197 | onClicked: { | ||
229 | deleteConfirmationDialog.connectionName = root.currentConnectionName | 198 | deleteConfirmationDialog.connectionName = root.currentConnectionName | ||
230 | deleteConfirmationDialog.connectionPath = root.currentConnectionPath | 199 | deleteConfirmationDialog.connectionPath = root.currentConnectionPath | ||
231 | deleteConfirmationDialog.open() | 200 | deleteConfirmationDialog.open() | ||
232 | } | 201 | } | ||
233 | } | 202 | } | ||
234 | 203 | | |||
235 | QtControls.Button { | 204 | QtControls.Button { | ||
236 | id: addConnectionButton | 205 | id: exportConnectionButton | ||
237 | 206 | enabled: root.currentConnectionExportable | |||
238 | width: Kirigami.Units.iconSizes.medium | 207 | icon.name: "document-export" | ||
239 | height: Kirigami.Units.iconSizes.medium | | |||
240 | | ||||
241 | icon.name: "list-add" | | |||
242 | 208 | | |||
243 | QtControls.ToolTip.text: i18n("Add new connection") | 209 | QtControls.ToolTip.text: i18n("Export selected connection") | ||
244 | QtControls.ToolTip.visible: addConnectionButton.hovered | 210 | QtControls.ToolTip.visible: exportConnectionButton.hovered | ||
245 | 211 | | |||
246 | onClicked: { | 212 | onClicked: { | ||
247 | addNewConnectionDialog.open() | 213 | kcm.requestExportConnection(root.currentConnectionPath) | ||
248 | } | 214 | } | ||
249 | } | 215 | } | ||
250 | } | 216 | } | ||
251 | 217 | | |||
252 | ConnectionEditor { | 218 | ConnectionEditor { | ||
253 | id: connectionEditor | 219 | id: connectionEditor | ||
254 | opacity: applicationWindow().pageStack.currentIndex == 1 | 220 | visible: false | ||
255 | } | 221 | } | ||
256 | 222 | | |||
257 | MessageDialog { | 223 | MessageDialog { | ||
258 | id: deleteConfirmationDialog | 224 | id: deleteConfirmationDialog | ||
259 | 225 | | |||
260 | property string connectionName | 226 | property string connectionName | ||
261 | property string connectionPath | 227 | property string connectionPath | ||
262 | 228 | | |||
Show All 36 Lines | 264 | onRequestCreateConnection: { | |||
299 | kcm.requestCreateConnection(type, vpnType, specificType, shared) | 265 | kcm.requestCreateConnection(type, vpnType, specificType, shared) | ||
300 | } | 266 | } | ||
301 | } | 267 | } | ||
302 | 268 | | |||
303 | onCurrentConnectionPathChanged: { | 269 | onCurrentConnectionPathChanged: { | ||
304 | if (currentConnectionPath) { | 270 | if (currentConnectionPath) { | ||
305 | if (applicationWindow().pageStack.depth < 2) { | 271 | if (applicationWindow().pageStack.depth < 2) { | ||
306 | applicationWindow().pageStack.push(connectionEditor) | 272 | applicationWindow().pageStack.push(connectionEditor) | ||
273 | connectionEditor.visible = true; | ||||
307 | } else { | 274 | } else { | ||
308 | applicationWindow().pageStack.currentIndex = 1 | 275 | applicationWindow().pageStack.currentIndex = 1 | ||
309 | } | 276 | } | ||
310 | kcm.selectConnection(root.currentConnectionPath) | 277 | kcm.selectConnection(root.currentConnectionPath) | ||
311 | } | 278 | } | ||
312 | } | 279 | } | ||
313 | 280 | | |||
314 | function loadConnectionSetting() { | 281 | function loadConnectionSetting() { | ||
Show All 12 Lines |