Commit 7e65fd05 authored by Tobias Fella's avatar Tobias Fella

Refactor and fix the mobile wifi kcm

Summary:
Previous refactoring and existing errors made editing connections impossible. Also, existing work for adding hidden networks was broken. By fixing these problems, this patch implements T12893.

The checks for signal strength being > 0 were removed to make make hidden networks show up in the list

Test Plan: Test adding and editing connections

Reviewers: #plasma, ngraham, jgrulich, jbbgameich

Reviewed By: jgrulich, jbbgameich

Subscribers: nicolasfella, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D28799
parent c1370419
......@@ -63,8 +63,6 @@ bool MobileProxyModel::filterAcceptsRow(int source_row, const QModelIndex& sourc
if (showSavedMode()) {
return itemType == NetworkModelItem::UnavailableConnection;
} else {
if (sourceModel()->data(index,NetworkModel::SignalRole).toUInt() == 0)
return false; // if signal is 0 yet we still have connection, it means local access point -> we don't want to show that
return itemType >= NetworkModelItem::AvailableConnection;
}
}
......
/*
* Copyright 2017 Martin Kacej <m.kacej@atlas.sk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.6
import QtQuick.Controls 2.2 as Controls
import QtQuick.Layouts 1.2
import org.kde.kirigami 2.2 as Kirigami
Kirigami.ScrollablePage {
property var details
property var str: 0
property var connection : ({})
property var enabledSaving: (editorIpSection.enabledSave && editorSecuritySection.enabledSave && ssidField.text)
title: i18n("Connection Editor")
width: parent.width
ColumnLayout {
Controls.Label {
text: i18n("SSID")
font.weight: Font.Bold
//anchors.horizontalCenter: parent.horizontalCenter
}
Controls.TextField {
id: ssidField
//anchors.horizontalCenter: parent.horizontalCenter
placeholderText: i18n("None")
}
IPAddressSetting {
id: editorIpSection
width: parent.width
//anchors.horizontalCenter: parent.horizontalCenter
}
WirelessSecuritySetting {
id: editorSecuritySection
anchors.topMargin: units.gridUnit
//anchors.horizontalCenter: parent.horizontalCenter
width: parent.width
}
}
footer: Item {
height: Kirigami.Units.gridUnit * 4
RowLayout {
anchors.horizontalCenter: parent.horizontalCenter
spacing: Kirigami.Units.gridUnit
Controls.Button {
enabled: enabledSaving
text: i18n("Save")
icon.name: "document-save"
onPressed: {
save()
kcm.pop()
}
}
Controls.Button {
icon.name: "dialog-cancel"
text: i18n("Cancel")
onPressed: {
kcm.pop()
}
}
}
}
function save() {
connection = editorIpSection.ipmap
connection["id"] = ssidField.text
connection["mode"] = "infrastructure"
connection["802-11-wireless-security"] = editorSecuritySection.securityMap
console.info(connection)
kcm.addConnectionFromQML(connection)
console.info('Connection saved '+ connection["id"])
}
}
......@@ -96,7 +96,7 @@ Kirigami.SwipeListItem {
actions: [
Kirigami.Action {
iconName: "network-connect"
visible: ConnectionState != PlasmaNM.Enums.Activated && Signal > 0
visible: ConnectionState != PlasmaNM.Enums.Activated
onTriggered: changeState()
},
Kirigami.Action {
......@@ -123,8 +123,6 @@ Kirigami.SwipeListItem {
}
function changeState() {
if (Signal === 0)
return
if (Uuid || !predictableWirelessPassword || connectionPasswordField.visible) {
if (ConnectionState == PlasmaNM.Enums.Deactivated) {
if (!predictableWirelessPassword && !Uuid) {
......
......@@ -102,7 +102,7 @@ ScrollViewKCM {
iconName: "edit"
text: i18n("Add custom connection")
onTriggered: {
kcm.push("ConnectionEditor.qml")
kcm.push("NetworkSettings.qml")
contextDrawer.close()
}
},
......
......@@ -62,6 +62,9 @@ QVariantMap WifiSettings::getConnectionSettings(const QString &connection, const
if (!con)
return QVariantMap();
if (type == "secrets")
return con->secrets(QLatin1String("802-11-wireless-security")).value().value(QLatin1String("802-11-wireless-security"));
QVariantMap map = con->settings()->toMap().value(type);
if (type == "ipv4") {
NetworkManager::Ipv4Setting::Ptr ipSettings = NetworkManager::Ipv4Setting::Ptr(new NetworkManager::Ipv4Setting());
......@@ -74,7 +77,7 @@ QVariantMap WifiSettings::getConnectionSettings(const QString &connection, const
if (ipSettings->method() == NetworkManager::Ipv4Setting::Manual) {
map.insert(QLatin1String("method"),QVariant(QLatin1String("manual")));
map.insert(QLatin1String("address"),QVariant(ipSettings->addresses().first().ip().toString()));
map.insert(QLatin1String("prefix"),QVariant(ipSettings->addresses().first().netmask().toString()));
map.insert(QLatin1String("prefix"),QVariant(ipSettings->addresses().first().prefixLength()));
map.insert(QLatin1String("gateway"),QVariant(ipSettings->addresses().first().gateway().toString()));
map.insert(QLatin1String("dns"),QVariant(ipSettings->dns().first().toString()));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment