Changeset View
Changeset View
Standalone View
Standalone View
mobile/wifi/package/contents/ui/main.qml
Show All 15 Lines | |||||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.6 | 20 | import QtQuick 2.6 | ||
21 | import QtQuick.Layouts 1.2 | 21 | import QtQuick.Layouts 1.2 | ||
22 | import QtQuick.Controls 2.2 as Controls | 22 | import QtQuick.Controls 2.2 as Controls | ||
23 | import org.kde.plasma.networkmanagement 0.2 as PlasmaNM | 23 | import org.kde.plasma.networkmanagement 0.2 as PlasmaNM | ||
24 | import org.kde.kirigami 2.2 as Kirigami | 24 | import org.kde.kirigami 2.5 as Kirigami | ||
25 | import org.kde.kcm 1.1 | ||||
25 | 26 | | |||
26 | Kirigami.ApplicationItem { | 27 | SimpleKCM { | ||
27 | id: main | 28 | id: main | ||
28 | objectName: "wifiMain" | | |||
29 | | ||||
30 | pageStack.defaultColumnWidth: Kirigami.Units.gridUnit * 25 | | |||
31 | pageStack.initialPage: networkListview | | |||
32 | Kirigami.Theme.colorSet: Kirigami.Theme.Window | | |||
33 | | ||||
34 | anchors.fill: parent | | |||
35 | 29 | | |||
36 | PlasmaNM.Handler { | 30 | PlasmaNM.Handler { | ||
37 | id: handler | 31 | id: handler | ||
38 | onWirelessScanTimerEnabled: { | 32 | onWirelessScanTimerEnabled: { | ||
39 | if (enabled) { | 33 | if (enabled) { | ||
40 | scanTimer.restart() | 34 | scanTimer.restart() | ||
41 | } else { | 35 | } else { | ||
42 | scanTimer.stop() | 36 | scanTimer.stop() | ||
43 | } | 37 | } | ||
44 | } | 38 | } | ||
45 | } | 39 | } | ||
46 | 40 | | |||
47 | PlasmaNM.EnabledConnections { | 41 | PlasmaNM.EnabledConnections { | ||
48 | id: enabledConnections | 42 | id: enabledConnections | ||
49 | 43 | | |||
50 | onWirelessEnabledChanged: { | 44 | onWirelessEnabledChanged: { | ||
51 | wifiSwitchButton.checked = wifiSwitchButton.enabled && enabled | 45 | wifiSwitchButton.checked = wifiSwitchButton.enabled && enabled | ||
52 | } | 46 | } | ||
53 | } | 47 | } | ||
54 | 48 | | |||
55 | contextDrawer: Kirigami.ContextDrawer { | | |||
56 | id: contextDrawer | | |||
57 | } | | |||
58 | | ||||
59 | PlasmaNM.NetworkModel { | 49 | PlasmaNM.NetworkModel { | ||
60 | id: connectionModel | 50 | id: connectionModel | ||
61 | } | 51 | } | ||
62 | 52 | | |||
63 | PlasmaNM.MobileProxyModel { | 53 | PlasmaNM.MobileProxyModel { | ||
64 | id: mobileProxyModel | 54 | id: mobileProxyModel | ||
65 | sourceModel: connectionModel | 55 | sourceModel: connectionModel | ||
66 | showSavedMode: false | 56 | showSavedMode: false | ||
67 | } | 57 | } | ||
68 | 58 | | |||
69 | Component.onCompleted: handler.requestScan() | 59 | Component.onCompleted: handler.requestScan() | ||
70 | 60 | | |||
71 | Timer { | 61 | Timer { | ||
72 | id: scanTimer | 62 | id: scanTimer | ||
73 | interval: 15000 | 63 | interval: 15000 | ||
74 | repeat: true | 64 | repeat: true | ||
75 | running: parent.visible | 65 | running: parent.visible | ||
76 | 66 | | |||
77 | onTriggered: handler.requestScan() | 67 | onTriggered: handler.requestScan() | ||
78 | } | 68 | } | ||
79 | 69 | | |||
80 | NetworkListView { | 70 | header: Kirigami.InlineMessage { | ||
81 | id: networkListview | 71 | id: inlineError | ||
72 | Layout.fillWidth: true | ||||
73 | showCloseButton: true | ||||
74 | | ||||
75 | visible: false | ||||
76 | | ||||
77 | type: Kirigami.MessageType.Warning | ||||
78 | Connections { | ||||
79 | target: handler | ||||
80 | onConnectionActivationFailed: { | ||||
81 | inlineError.text = message; | ||||
82 | inlineError.visible = true; | ||||
83 | } | ||||
84 | } | ||||
82 | } | 85 | } | ||
83 | 86 | | |||
84 | Component { | 87 | ListView { | ||
85 | id: connectionEditorDialogComponent | 88 | id: view | ||
86 | ConnectionEditor { } | 89 | | ||
90 | anchors.fill: parent | ||||
91 | clip: true | ||||
92 | width: parent.width | ||||
93 | currentIndex: -1 | ||||
94 | boundsBehavior: Flickable.StopAtBounds | ||||
95 | | ||||
96 | header: Controls.Label { | ||||
97 | leftPadding: Kirigami.Units.smallSpacing | ||||
98 | text: mobileProxyModel.showSavedMode ? i18n("Saved networks") : i18n("Available networks") | ||||
99 | } | ||||
100 | | ||||
101 | model: mobileProxyModel | ||||
102 | delegate: ConnectionItemDelegate {} | ||||
103 | } | ||||
104 | | ||||
105 | actions.main: Kirigami.Action { | ||||
106 | iconName: enabledConnections.wirelessEnabled ? "network-wireless-disconnected" : "network-wireless-connected" | ||||
107 | text: enabledConnections.wirelessEnabled ? i18n("Disable Wi-Fi") : i18n("Enable Wi-Fi") | ||||
108 | onTriggered: handler.enableWireless(!enabledConnections.wirelessEnabled); | ||||
109 | } | ||||
110 | | ||||
111 | actions.contextualActions: [ | ||||
112 | | ||||
113 | Kirigami.Action { | ||||
114 | iconName: "edit" | ||||
115 | text: i18n("Add custom connection") | ||||
116 | onTriggered: { | ||||
117 | applicationWindow().pageStack.push(connectionEditorDialogComponent) | ||||
118 | contextDrawer.close() | ||||
119 | } | ||||
120 | }, | ||||
121 | | ||||
122 | Kirigami.Action { | ||||
123 | iconName: "edit" | ||||
124 | text: i18n("Create Hotspot") | ||||
125 | onTriggered: { | ||||
126 | applicationWindow().pageStack.push(tetheringComponent) | ||||
127 | contextDrawer.close() | ||||
128 | } | ||||
129 | }, | ||||
130 | Kirigami.Action { | ||||
131 | iconName: "edit" | ||||
132 | text: i18n("Saved Connections") | ||||
133 | checkable: true | ||||
134 | checked: false | ||||
135 | onTriggered: { | ||||
136 | mobileProxyModel.showSavedMode = !mobileProxyModel.showSavedMode | ||||
137 | } | ||||
138 | } | ||||
139 | ] | ||||
140 | /* | ||||
141 | footer: Controls.Button { | ||||
142 | width: parent.width | ||||
143 | text: "ContextualActions" | ||||
144 | iconName: "edit" | ||||
145 | onClicked: bottomDrawer.open() | ||||
146 | } | ||||
147 | | ||||
148 | Kirigami.OverlayDrawer { | ||||
149 | id: bottomDrawer | ||||
150 | edge: Qt.BottomEdge | ||||
151 | contentItem: Item { | ||||
152 | implicitHeight: childrenRect.height + Kirigami.Units.gridUnit | ||||
153 | ColumnLayout{ | ||||
154 | anchors.centerIn: parent | ||||
155 | Controls.Button { | ||||
156 | text: "Add custom connection" | ||||
157 | onClicked: applicationWindow().pageStack.push(connectionEditorDialogComponent) | ||||
158 | } | ||||
159 | Controls.Button { | ||||
160 | text: "Create Hotspot" | ||||
161 | onClicked: showPassiveNotification("Open tethering") | ||||
162 | } | ||||
163 | Item { | ||||
164 | Layout.minimumHeight: Units.gridUnit * 4 | ||||
165 | } | ||||
166 | } | ||||
167 | } | ||||
168 | } | ||||
169 | */ | ||||
170 | Kirigami.OverlayDrawer { | ||||
171 | id: deleteConnectionDialog | ||||
172 | property var name | ||||
173 | property var dbusPath | ||||
174 | edge: Qt.BottomEdge | ||||
175 | | ||||
176 | contentItem: Column { | ||||
177 | anchors.centerIn: parent | ||||
178 | spacing: Kirigami.Units.largeSpacing | ||||
179 | bottomPadding: Kirigami.Units.largeSpacing | ||||
180 | | ||||
181 | Controls.Label { | ||||
182 | anchors.horizontalCenter: parent.horizontalCenter | ||||
183 | text: i18n("Delete connection %1 from device?", deleteConnectionDialog.name) | ||||
184 | } | ||||
185 | Controls.Button { | ||||
186 | text: i18n("Delete") | ||||
187 | anchors.horizontalCenter: parent.horizontalCenter | ||||
188 | onClicked: { | ||||
189 | handler.removeConnection(deleteConnectionDialog.dbusPath) | ||||
190 | deleteConnectionDialog.close() | ||||
191 | } | ||||
192 | } | ||||
193 | Controls.Button { | ||||
194 | text: i18n("Cancel") | ||||
195 | anchors.horizontalCenter: parent.horizontalCenter | ||||
196 | onClicked: deleteConnectionDialog.close() | ||||
197 | } | ||||
198 | } | ||||
199 | onVisibleChanged: { | ||||
200 | if (!visible) { | ||||
201 | deleteConnectionDialog.name = "" | ||||
202 | deleteConnectionDialog.dbusPath = "" | ||||
203 | } | ||||
204 | } | ||||
87 | } | 205 | } | ||
88 | 206 | | |||
89 | Component { | 207 | Component { | ||
90 | id: networkDetailsViewComponent | 208 | id: connectionEditorDialogComponent | ||
91 | NetworkSettings { } | 209 | ConnectionEditor { } | ||
92 | } | 210 | } | ||
93 | 211 | | |||
94 | Component { | 212 | Component { | ||
95 | id: tetheringComponent | 213 | id: tetheringComponent | ||
96 | TetheringSetting { } | 214 | TetheringSetting { } | ||
97 | } | 215 | } | ||
98 | } | 216 | } |