Changeset View
Changeset View
Standalone View
Standalone View
kcm/qml/main.qml
Show All 14 Lines | 1 | /* | |||
---|---|---|---|---|---|
15 | Lesser General Public License for more details. | 15 | Lesser General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU Lesser General Public | 17 | You should have received a copy of the GNU Lesser General Public | ||
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | 18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | import QtQuick 2.1 | 21 | import QtQuick 2.1 | ||
22 | import QtQuick.Dialogs 1.1 | 22 | import QtQuick.Dialogs 1.1 | ||
23 | import QtQuick.Controls 1.2 as QtControls | 23 | import QtQuick.Controls 2.5 as QQC2 | ||
24 | import org.kde.plasma.core 2.0 as PlasmaCore | 24 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
25 | import org.kde.plasma.extras 2.0 as PlasmaExtras | 25 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||
26 | import org.kde.plasma.networkmanagement 0.2 as PlasmaNM | 26 | import org.kde.plasma.networkmanagement 0.2 as PlasmaNM | ||
27 | import org.kde.kirigami 2.9 as Kirigami | ||||
27 | 28 | | |||
28 | Item { | 29 | Item { | ||
29 | id: root | 30 | id: root | ||
30 | 31 | | |||
31 | focus: true | 32 | focus: true | ||
32 | 33 | | |||
33 | signal selectedConnectionChanged(string connection) | 34 | signal selectedConnectionChanged(string connection) | ||
34 | signal requestCreateConnection(int type, string vpnType, string specificType, bool shared) | 35 | signal requestCreateConnection(int type, string vpnType, string specificType, bool shared) | ||
35 | signal requestExportConnection(string connection) | 36 | signal requestExportConnection(string connection) | ||
36 | signal requestToChangeConnection(string name, string path) | 37 | signal requestToChangeConnection(string name, string path) | ||
37 | 38 | | |||
39 | Kirigami.Theme.colorSet: Kirigami.Theme.Window | ||||
40 | | ||||
38 | Rectangle { | 41 | Rectangle { | ||
39 | id: background | 42 | id: background | ||
40 | anchors.fill: parent | 43 | anchors.fill: parent | ||
41 | focus: true | 44 | focus: true | ||
42 | color: baseColor | 45 | color: Kirigami.Theme.backgroundColor | ||
43 | } | 46 | } | ||
44 | 47 | | |||
45 | PlasmaNM.Handler { | 48 | PlasmaNM.Handler { | ||
46 | id: handler | 49 | id: handler | ||
47 | } | 50 | } | ||
48 | 51 | | |||
49 | PlasmaNM.KcmIdentityModel { | 52 | PlasmaNM.KcmIdentityModel { | ||
50 | id: connectionModel | 53 | id: connectionModel | ||
51 | } | 54 | } | ||
52 | 55 | | |||
53 | PlasmaNM.EditorProxyModel { | 56 | PlasmaNM.EditorProxyModel { | ||
54 | id: editorProxyModel | 57 | id: editorProxyModel | ||
55 | 58 | | |||
56 | sourceModel: connectionModel | 59 | sourceModel: connectionModel | ||
57 | } | 60 | } | ||
58 | 61 | | |||
59 | QtControls.TextField { | 62 | PlasmaNM.Configuration { | ||
63 | id: configuration | ||||
64 | } | ||||
65 | | ||||
66 | QQC2.TextField { | ||||
60 | id: searchField | 67 | id: searchField | ||
61 | 68 | | |||
62 | anchors { | 69 | anchors { | ||
63 | left: parent.left | 70 | left: parent.left | ||
64 | right: parent.right | 71 | right: parent.right | ||
65 | top: parent.top | 72 | top: parent.top | ||
66 | } | 73 | } | ||
67 | 74 | | |||
68 | placeholderText: i18n("Search...") | 75 | placeholderText: i18n("Search...") | ||
69 | 76 | | |||
70 | onTextChanged: { | 77 | onTextChanged: { | ||
71 | editorProxyModel.setFilterRegExp(text) | 78 | editorProxyModel.setFilterRegExp(text) | ||
72 | } | 79 | } | ||
73 | } | 80 | } | ||
74 | 81 | | |||
75 | QtControls.ScrollView { | 82 | QQC2.ScrollView { | ||
76 | id: scrollView | 83 | id: scrollView | ||
77 | 84 | | |||
85 | Component.onCompleted: scrollView.background.visible = true // show frame | ||||
86 | | ||||
78 | anchors { | 87 | anchors { | ||
79 | bottom: buttonRow.top | 88 | bottom: rightButtonRow.top | ||
80 | bottomMargin: Math.round(units.gridUnit / 3) | 89 | bottomMargin: units.smallSpacing | ||
81 | left: parent.left | 90 | left: parent.left | ||
82 | right: parent.right | 91 | right: parent.right | ||
83 | top: searchField.bottom | 92 | top: searchField.bottom | ||
84 | } | 93 | } | ||
85 | 94 | | |||
86 | ListView { | 95 | ListView { | ||
87 | id: connectionView | 96 | id: connectionView | ||
88 | 97 | | |||
89 | property bool currentConnectionExportable: false | 98 | property bool currentConnectionExportable: false | ||
90 | property string currentConnectionName | 99 | property string currentConnectionName | ||
91 | property string currentConnectionPath | 100 | property string currentConnectionPath | ||
92 | 101 | | |||
93 | anchors.fill: parent | | |||
94 | clip: true | 102 | clip: true | ||
103 | focus: true | ||||
104 | activeFocusOnTab: true | ||||
95 | model: editorProxyModel | 105 | model: editorProxyModel | ||
96 | currentIndex: -1 | 106 | currentIndex: -1 | ||
97 | boundsBehavior: Flickable.StopAtBounds | 107 | boundsBehavior: Flickable.StopAtBounds | ||
98 | section.property: "KcmConnectionType" | 108 | section.property: "KcmConnectionType" | ||
99 | section.delegate: Header { text: section } | 109 | section.delegate: Header { text: section } | ||
100 | delegate: ConnectionItem { | 110 | delegate: ConnectionItem { | ||
101 | onAboutToChangeConnection: { | 111 | onAboutToChangeConnection: { | ||
102 | // Shouldn't be problem to set this in advance | 112 | // Shouldn't be problem to set this in advance | ||
Show All 19 Lines | |||||
122 | 132 | | |||
123 | onCurrentConnectionPathChanged: { | 133 | onCurrentConnectionPathChanged: { | ||
124 | root.selectedConnectionChanged(currentConnectionPath) | 134 | root.selectedConnectionChanged(currentConnectionPath) | ||
125 | } | 135 | } | ||
126 | } | 136 | } | ||
127 | } | 137 | } | ||
128 | 138 | | |||
129 | Row { | 139 | Row { | ||
130 | id: buttonRow | 140 | id: rightButtonRow | ||
131 | 141 | | |||
132 | anchors { | 142 | anchors { | ||
133 | bottom: parent.bottom | 143 | bottom: parent.bottom | ||
134 | right: parent.right | 144 | right: parent.right | ||
135 | margins: Math.round(units.gridUnit / 3) | 145 | margins: units.smallSpacing | ||
136 | } | 146 | } | ||
137 | spacing: Math.round(units.gridUnit / 2) | 147 | spacing: units.smallSpacing | ||
138 | 148 | | |||
139 | QtControls.ToolButton { | 149 | QQC2.ToolButton { | ||
140 | id: addConnectionButton | 150 | id: addConnectionButton | ||
141 | 151 | | |||
142 | iconName: "list-add" | 152 | icon.name: "list-add" | ||
143 | tooltip: i18n("Add new connection") | 153 | | ||
154 | QQC2.ToolTip.text: i18n("Add new connection") | ||||
155 | QQC2.ToolTip.visible: hovered | ||||
144 | 156 | | |||
145 | onClicked: { | 157 | onClicked: { | ||
146 | addNewConnectionDialog.open() | 158 | addNewConnectionDialog.open() | ||
147 | } | 159 | } | ||
148 | } | 160 | } | ||
149 | 161 | | |||
150 | QtControls.ToolButton { | 162 | QQC2.ToolButton { | ||
151 | id: removeConnectionButton | 163 | id: removeConnectionButton | ||
152 | 164 | | |||
153 | enabled: connectionView.currentConnectionPath && connectionView.currentConnectionPath.length | 165 | enabled: connectionView.currentConnectionPath && connectionView.currentConnectionPath.length | ||
154 | iconName: "list-remove" | 166 | icon.name: "list-remove" | ||
155 | tooltip: i18n("Remove selected connection") | 167 | | ||
168 | QQC2.ToolTip.text: i18n("Remove selected connection") | ||||
169 | QQC2.ToolTip.visible: hovered | ||||
156 | 170 | | |||
157 | onClicked: { | 171 | onClicked: { | ||
158 | deleteConfirmationDialog.connectionName = connectionView.currentConnectionName | 172 | deleteConfirmationDialog.connectionName = connectionView.currentConnectionName | ||
159 | deleteConfirmationDialog.connectionPath = connectionView.currentConnectionPath | 173 | deleteConfirmationDialog.connectionPath = connectionView.currentConnectionPath | ||
160 | deleteConfirmationDialog.open() | 174 | deleteConfirmationDialog.open() | ||
161 | } | 175 | } | ||
162 | } | 176 | } | ||
163 | 177 | | |||
164 | QtControls.ToolButton { | 178 | QQC2.ToolButton { | ||
165 | id: exportConnectionButton | 179 | id: exportConnectionButton | ||
166 | 180 | | |||
167 | enabled: connectionView.currentConnectionExportable | 181 | enabled: connectionView.currentConnectionExportable | ||
168 | iconName: "document-export" | 182 | icon.name: "document-export" | ||
169 | tooltip: i18n("Export selected connection") | 183 | | ||
184 | QQC2.ToolTip.text: i18n("Export selected connection") | ||||
185 | QQC2.ToolTip.visible: hovered | ||||
170 | 186 | | |||
171 | onClicked: { | 187 | onClicked: { | ||
172 | root.requestExportConnection(connectionView.currentConnectionPath) | 188 | root.requestExportConnection(connectionView.currentConnectionPath) | ||
173 | } | 189 | } | ||
174 | } | 190 | } | ||
175 | } | 191 | } | ||
176 | 192 | | |||
193 | Row { | ||||
194 | id: leftButtonRow | ||||
195 | | ||||
196 | anchors { | ||||
197 | bottom: parent.bottom | ||||
198 | left: parent.left | ||||
199 | margins: units.smallSpacing | ||||
200 | } | ||||
201 | spacing: units.smallSpacing | ||||
202 | | ||||
203 | QQC2.ToolButton { | ||||
204 | id: configureButton | ||||
205 | | ||||
206 | icon.name: "configure" | ||||
207 | | ||||
208 | QQC2.ToolTip.text: i18n("Configuration") | ||||
209 | QQC2.ToolTip.visible: hovered | ||||
210 | | ||||
211 | onClicked: { | ||||
212 | configurationDialog.open() | ||||
213 | } | ||||
214 | } | ||||
215 | } | ||||
216 | | ||||
177 | MessageDialog { | 217 | MessageDialog { | ||
178 | id: deleteConfirmationDialog | 218 | id: deleteConfirmationDialog | ||
179 | 219 | | |||
180 | property string connectionName | 220 | property string connectionName | ||
181 | property string connectionPath | 221 | property string connectionPath | ||
182 | 222 | | |||
183 | icon: StandardIcon.Question | 223 | icon: StandardIcon.Question | ||
184 | standardButtons: StandardButton.Ok | StandardButton.Cancel | 224 | standardButtons: StandardButton.Ok | StandardButton.Cancel | ||
185 | title: i18nc("@title:window", "Remove Connection") | 225 | title: i18nc("@title:window", "Remove Connection") | ||
186 | text: i18n("Do you want to remove the connection '%1'?", connectionName) | 226 | text: i18n("Do you want to remove the connection '%1'?", connectionName) | ||
187 | 227 | | |||
188 | onAccepted: { | 228 | onAccepted: { | ||
189 | if (connectionPath == connectionView.currentConnectionPath) { | 229 | if (connectionPath == connectionView.currentConnectionPath) { | ||
190 | // Deselect now non-existing connection | 230 | // Deselect now non-existing connection | ||
191 | deselectConnections() | 231 | deselectConnections() | ||
192 | } | 232 | } | ||
193 | handler.removeConnection(connectionPath) | 233 | handler.removeConnection(connectionPath) | ||
194 | } | 234 | } | ||
195 | } | 235 | } | ||
196 | 236 | | |||
197 | Dialog { | 237 | AddConnectionDialog { | ||
198 | id: addNewConnectionDialog | 238 | id: addNewConnectionDialog | ||
199 | 239 | | |||
200 | onRequestCreateConnection: { | 240 | onRequestCreateConnection: { | ||
201 | root.requestCreateConnection(type, vpnType, specificType, shared) | 241 | root.requestCreateConnection(type, vpnType, specificType, shared) | ||
202 | } | 242 | } | ||
203 | } | 243 | } | ||
204 | 244 | | |||
245 | ConfigurationDialog { | ||||
246 | id: configurationDialog | ||||
247 | } | ||||
248 | | ||||
205 | function deselectConnections() { | 249 | function deselectConnections() { | ||
206 | connectionView.currentConnectionPath = "" | 250 | connectionView.currentConnectionPath = "" | ||
207 | } | 251 | } | ||
208 | 252 | | |||
209 | function selectConnection(connectionName, connectionPath) { | 253 | function selectConnection(connectionName, connectionPath) { | ||
210 | connectionView.currentConnectionName = connectionName | 254 | connectionView.currentConnectionName = connectionName | ||
211 | connectionView.currentConnectionPath = connectionPath | 255 | connectionView.currentConnectionPath = connectionPath | ||
212 | } | 256 | } | ||
213 | } | 257 | } |