Skip to content

Commit

Permalink
[WiFi] implement saved networks
Browse files Browse the repository at this point in the history
  • Loading branch information
akaWolf committed Dec 11, 2018
1 parent c6ddfc4 commit d05d19b
Show file tree
Hide file tree
Showing 7 changed files with 318 additions and 110 deletions.
10 changes: 8 additions & 2 deletions glacier-settings.pro
Expand Up @@ -65,7 +65,10 @@ displayplugin.path = /usr/share/glacier-settings/qml/plugins/display
wifiplugin.files = qml/plugins/wifi/wifi.qml\
qml/plugins/wifi/WifiSettings.qml\
qml/plugins/wifi/WifiStatus.qml\
qml/plugins/wifi/wifi.svg
qml/plugins/wifi/wifi.svg\
qml/plugins/wifi/SavedServices.qml\
qml/plugins/wifi/SavedStatus.qml\
qml/plugins/wifi/NetworkDelegate.qml

wifiplugin.path = /usr/share/glacier-settings/qml/plugins/wifi

Expand Down Expand Up @@ -148,4 +151,7 @@ DISTFILES += \
qml/plugins/about/about.svg \
qml/plugins/about/icon-glacier-icon.png \
qml/plugins/about/magic.qml \
qml/plugins/keyboard/keyboard.qml
qml/plugins/keyboard/keyboard.qml \
qml/plugins/wifi/SavedServices.qml \
qml/plugins/wifi/SavedStatus.qml \
qml/plugins/wifi/NetworkDelegate.qml
120 changes: 120 additions & 0 deletions qml/plugins/wifi/NetworkDelegate.qml
@@ -0,0 +1,120 @@
import QtQuick 2.6
import QtQuick.Window 2.1

import QtQuick.Controls 1.0
import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0

import MeeGo.Connman 0.2

import "../../components"

Item {
width: childrenRect.width
height: childrenRect.height

property bool saved

ListViewItemWithActions{
height: {
if (visible) return size.dp(80)
else return 0
}
visible: {
if (saved) {
return modelData.saved
}
else {
return !modelData.saved
}
}

label: modelData.name
width: wifiPage.width

description: {
if ((modelData.state === "online") || (modelData.state === "ready")) {
return qsTr("connected");
} else if (modelData.state === "association" || modelData.state === "configuration") {
return qsTr("connecting")+"...";
} else {
if (modelData.security[0] === "none") {
return qsTr("open");
} else {
return qsTr("secure");
}
}
}
icon: (getStrengthIndex(modelData.strength) === "0") ?
"image://theme/icon_wifi_0" : "image://theme/icon_wifi_focused" +
getStrengthIndex(modelData.strength)

onClicked:{
if (modelData.state === "idle" || modelData.state === "failure"){
console.log("Show settings page");
pageStack.push(Qt.resolvedUrl("WifiSettings.qml"),{modelData: modelData});
} else {
console.log("Show network status page");
var component = Qt.createComponent(Qt.resolvedUrl("WifiStatus.qml")).errorString();
console.log(component);
pageStack.push(Qt.resolvedUrl("WifiStatus.qml"),{modelData: modelData});
}
}

actions: Rectangle{
width: childrenRect.width+16
height: parent.height
Image{
id: removeNetworkButton
source: "../../img/trash.svg"
width: 64
height: 64
fillMode: Image.PreserveAspectFit
sourceSize{
width: width
height: height
}
anchors{
top:parent.top
topMargin: 8
left: parent.left
leftMargin: 8
}
MouseArea{
anchors.fill: parent
onClicked: {
modelData.remove();
model.hideAllActions(-1);
}
}
}

Image{
source: "../../img/disconnect.svg"
visible: (modelData.state === "online" || modelData.state === "ready")

width: Theme.itemHeightLarge
height: Theme.itemHeightLarge
fillMode: Image.PreserveAspectFit
sourceSize{
width: width
height: height
}
anchors{
top:parent.top
topMargin: 8
left: removeNetworkButton.right

leftMargin: 16
}
MouseArea{
anchors.fill: parent
onClicked: {
modelData.requestDisconnect();
model.hideAllActions(-1);
}
}
}
}
}
}
43 changes: 43 additions & 0 deletions qml/plugins/wifi/SavedServices.qml
@@ -0,0 +1,43 @@
import QtQuick 2.6
import QtQuick.Window 2.1

import QtQuick.Controls 1.0
import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0

import MeeGo.Connman 0.2

import "../../components"

Page {
id: savedPage
headerTools: HeaderToolsLayout{
id: header
showBackButton: true
title: qsTr("Manage saved networks")
}

SavedServiceModel{
id: savedModel
}

Component.onCompleted: {
savedModel.name = "wifi";
}

ListView{
y: header.height
width: parent.width
height: parent.height - header.height
model: savedModel
delegate: ListViewItemWithActions{
height: size.dp(80)
label: networkService.name
width: savedPage.width

onClicked: {
pageStack.push(Qt.resolvedUrl("SavedStatus.qml"), {modelData: networkService});
}
}
}
}
76 changes: 76 additions & 0 deletions qml/plugins/wifi/SavedStatus.qml
@@ -0,0 +1,76 @@
import QtQuick 2.6
import QtQuick.Window 2.1

import QtQuick.Controls 1.0
import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0

import MeeGo.Connman 0.2

import "../../components"

Page {
id: savedWifiStatusPage
property var modelData

headerTools: HeaderToolsLayout {
id: header
showBackButton: true
title: modelData.name
}

SettingsColumn{
id: actionColumn

Rectangle{
width: parent.width
height: childrenRect.height
color: "transparent"

Label{
id: nameLabel
text: qsTr("Auto connect")
anchors{
left: parent.left
}
wrapMode: Text.Wrap
font.bold: true
}

CheckBox {
id: columnCheckBox
checked: modelData.autoConnect
anchors{
right: parent.right
verticalCenter: nameLabel.verticalCenter
}

onClicked: {
modelData.autoConnect = !modelData.autoConnect;
}
}
}

Rectangle{
width: parent.width
height: childrenRect.height

color: "transparent"

Button{
id: disconnectButton
width: parent.width
anchors{
horizontalCenter: parent.horizontalCenter
verticalCenter: parent.verticalCenter
}
text: qsTr("Remove")
onClicked: {
modelData.remove();
console.log("Remove clicked");
pageStack.pop();
}
}
}
}
}
17 changes: 11 additions & 6 deletions qml/plugins/wifi/WifiSettings.qml
Expand Up @@ -70,29 +70,34 @@ Page {
}
}


Component.onCompleted: {
modelData.requestConnect();
networkingModel.networkName.text = modelData.name;
}

SettingsColumn {
TextField {
SettingsColumn{
TextField{
id: passphrase
text: modelData.passphrase
}

Button {
Button{
id: connectButton
height: 48

onClicked: {
modelData.passphrase = passphrase.text;
modelData.requestConnect();
networkingModel.networkName.text = modelData.name;
pageStack.pop();
}

text: qsTr("Connect")
}
}

Connections {
target: modelData
onConnectRequestFailed: {
console.log(error)
}
}
}
30 changes: 16 additions & 14 deletions qml/plugins/wifi/WifiStatus.qml
Expand Up @@ -31,13 +31,13 @@ Page {
id: wifiSettingsPage
property var modelData

headerTools: HeaderToolsLayout {
headerTools: HeaderToolsLayout{
id: header
showBackButton: true;
title: modelData.name
}

TechnologyModel {
TechnologyModel{
id: networkingModel
name: "wifi"
}
Expand All @@ -48,11 +48,11 @@ Page {
Row{
spacing: 24

Label {
Label{
text: qsTr("Method")
}

ButtonRow {
ButtonRow{
id: methodButtonRow
model: ListModel{
id: methodModel
Expand All @@ -65,19 +65,16 @@ Page {
}

Component.onCompleted: {
if(modelData.ipv4["Method"] === "manual")
{
if(modelData.ipv4["Method"] === "manual") {
methodButtonRow.currentIndex = 1
}
else
{
}else{
methodButtonRow.currentIndex = 0
}
}
}
}

Label {
Label{
text: qsTr("Network info")
}

Expand Down Expand Up @@ -109,7 +106,6 @@ Page {
}
}


Row{
spacing: 24
Label {
Expand All @@ -124,16 +120,16 @@ Page {
}
}

Rectangle {
Rectangle{
width: parent.width
height: childrenRect.height

color: "transparent"

Button {
Button{
id: disconnectButton
width: parent.width
anchors {
anchors{
horizontalCenter: parent.horizontalCenter
verticalCenter: parent.verticalCenter
}
Expand All @@ -145,6 +141,12 @@ Page {
}
}
}
}

Connections{
target: modelData
onConnectRequestFailed: {
console.log(error)
}
}
}

0 comments on commit d05d19b

Please sign in to comment.