Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit bc9f70ff authored by Martin Kacej's avatar Martin Kacej

saving new connections prototype, loading active connections settings prototype

parent a4ef94d7
......@@ -518,10 +518,50 @@ QVariantMap Handler::getConnectionSettings(const QString &connection, const QStr
if (!con)
return QVariantMap();
QVariantMap map = con->settings()->toMap().value(type);
qCWarning(PLASMA_NM) << "Map:" <<con->settings()->toMap().value(type);
//qCWarning(PLASMA_NM) << "Map:" <<con->settings()->toMap().value(type);
return map;
}
QVariantMap Handler::getActiveConnectionInfo(const QString &connection)
{
if (connection.isEmpty())
return QVariantMap();
NetworkManager::ActiveConnection::Ptr con = NetworkManager::findActiveConnection(connection);
if(!con){
qWarning(PLASMA_NM) << "Active" << connection << "not found";
return QVariantMap();
}
qWarning(PLASMA_NM) << "Active" << con->ipV4Config().addresses().first().ip().toString();
return QVariantMap();
}
void Handler::addConnectionFromQML(const QVariantMap &QMLmap)
{
if(!QMLmap.isEmpty()){
NMVariantMapMap map;
for(QVariantMap::const_iterator iter = QMLmap.begin(); iter != QMLmap.end(); ++iter) {
qWarning(PLASMA_NM) << iter.key() << iter.value();
//map.insert(iter.key(),iter.value());
}
if (!QMLmap.contains("uuid")){
QVariant foo = QMLmap.value("connection");
/*for(QVariantMap::const_iterator iter = foo.value<QVariantMap>().begin(); iter != foo.value<QVariantMap>().end(); ++iter) {
qWarning(PLASMA_NM) << iter.key() << iter.value();
map.insert(iter.key(),iter.value());
}
foo.insert("connection",NetworkManager::ConnectionSettings::createNewUuid());
QMLmap.insert("connection",foo);*/
}
map.insert("connection",QMLmap);
//TODO add UUID, SSID
QDBusPendingReply<QDBusObjectPath> reply = NetworkManager::addConnection(map);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
watcher->setProperty("action", AddConnection);
watcher->setProperty("connection", map.value("connection").value("id"));
connect(watcher, &QDBusPendingCallWatcher::finished, this, &Handler::replyFinished);
}
}
#if WITH_MODEMMANAGER_SUPPORT
void Handler::unlockRequiredChanged(MMModemLock modemLock)
{
......
......@@ -88,6 +88,8 @@ public Q_SLOTS:
void enableWireless(bool enable);
QVariantMap getConnectionSettings(const QString &connection, const QString &type);
QVariantMap getActiveConnectionInfo(const QString &connection);
void addConnectionFromQML(const QVariantMap &map);
void enableWwan(bool enable);
......
......@@ -26,8 +26,9 @@ import org.kde.plasma.extras 2.0 as PlasmaExtras
PlasmaExtras.ScrollArea{
property var details
property var str: 0
property var connection : {}
property var enabledSaving: (editorIpSection.enabledSave && editorSecuritySection.enabledSave)
property var connection : ({})
property var wirelessSettings: ({})
property var enabledSaving: (editorIpSection.enabledSave && editorSecuritySection.enabledSave && ssidField.text)
ColumnLayout{
id: columnlayout
......@@ -55,11 +56,14 @@ PlasmaExtras.ScrollArea{
}
function save() {
connection["ssid"] = ssidField.text
var m = ({});
connection["id"] = ssidField.text
connection["type"] = "802-11-wireless"
connection["mode"] = "infrastructure"
connection["method"] = editorIpSection.ipMethodComb.get(currentIndex).method
// TODO
console.info('Connection saved')
wirelessSettings["mode"] = "infrastructure"
m["connection"] = connection
m["ipv4"] = editorIpSection.ipmap
m["802-11-wireless"] = wirelessSettings
handler.addConnectionFromQML(m)
console.info('Connection saved '+ connection["id"])
}
}
......@@ -23,32 +23,41 @@ import QtQuick.Layouts 1.2
import org.kde.plasma.components 2.0 as PlasmaComponents
ColumnLayout{
property var ipmap: []
property var address: ""
property var gateway: ""
property var enabledSave: false
id: ipmain
property var ipmap: ({})
property alias address: manualIPaddress.text
property alias gateway: manualIPgateway.text
property alias prefix: manualIPprefix.text
property alias dns: manualIPdns.text
property bool enabledSave: false
spacing: units.gridUnit
ColumnLayout {
PlasmaComponents.Label {
anchors.left: parent.left
text: i18n("IP settings")
font.weight: Font.Bold
}
Controls.ComboBox {
id: ipMethodComb
model: ListModel{
ListElement{ text: "Automatic"; method: "auto" }
ListElement{ text: "Manual"; method: "manual"}
model:["Automatic","Manual"]
onCurrentIndexChanged: {
if (ipMethodComb.currentIndex == 0){
ipmain.state = "Automatic"
}
if(ipMethodComb.currentIndex == 1){
ipmain.state = "Manual"
}
}
}
}
ColumnLayout{
id: manuaIPSettings
enabled: ipMethodComb.currentText == "Manual"
visible: ipMethodComb.currentText == "Manual"
id: manualIPSettings
Layout.fillWidth: true
PlasmaComponents.Label {
......@@ -56,8 +65,9 @@ ColumnLayout{
}
Controls.TextField {
id: manualIPaddress
placeholderText: i18n("193.168.1.128")
text: address ? address : ""
text: address
}
PlasmaComponents.Label {
......@@ -65,7 +75,9 @@ ColumnLayout{
}
Controls.TextField {
id: manualIPgateway
placeholderText: i18n("192.168.1.1")
text: gateway
}
PlasmaComponents.Label {
......@@ -73,7 +85,9 @@ ColumnLayout{
}
Controls.TextField {
id: manualIPprefix
placeholderText: i18n("24")
text: prefix
}
PlasmaComponents.Label{
......@@ -81,12 +95,31 @@ ColumnLayout{
}
Controls.TextField {
id:manualIPdns
placeholderText: i18n("8.8.8.8")
text: dns
}
}
onVisibleChanged: {
if (visible == true){
address = ipmap["address-data"]
states: [
State {
name: "Automatic"
PropertyChanges{ target: manualIPSettings; visible : false }
PropertyChanges{ target: ipmain; ipmap : {"method":"auto"}}
},
State {
name:"Manual"
PropertyChanges{ target: manualIPSettings; visible : true }
PropertyChanges{
target: ipmain;
ipmap : {
"method" : "manual",
"address-data" : [{"address":address, "prefix":prefix}],
"gateway" : gateway,
"dns" : dns
}
}
}
}
]
}
......@@ -116,15 +116,18 @@ PlasmaExtras.ScrollArea{
function fillDetails() {
var d = {}
for (var i = 0; i < (details.length / 2); i++){
//console.info(details[i])
d[details[(i * 2)]] = details[(i * 2) + 1]
}
for (var i in map) {
if (map.hasOwnProperty(i)) {
console.info(i + ' = ' + map[i]);
}
}
if (d['Access point (SSID)'])
detailsDialog.titleText = d['Access point (SSID)']
signal_strength = d['Signal strength']
if (d['IPv4 Address'])
ip_address = detailsIP.adress = d['IPv4 Address']
ip_address = detailsIP.address = d['IPv4 Address']
if (d['Security type'])
security = d['Security type']
if (d['Connection speed'])
......
......@@ -103,6 +103,9 @@ Kirigami.SwipeListItem {
detailsDialog.titleText = i18n("Network details")
}
map = handler.getConnectionSettings(ConnectionPath,"ipv4")
if (ConnectionState == PlasmaNM.Enums.Activated){
handler.getActiveConnectionInfo(ConnectionPath)
}
networkDetailsViewContent.map = map
console.info(map["method"])
networkDetailsViewContent.fillDetails()
......
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