Commit 486c81d0 authored by Martin Kacej's avatar Martin Kacej

active connection info loading, refactoring

parent 2954f00c
......@@ -526,13 +526,23 @@ QVariantMap Handler::getActiveConnectionInfo(const QString &connection)
{
if (connection.isEmpty())
return QVariantMap();
NetworkManager::ActiveConnection::Ptr con = NetworkManager::findActiveConnection(connection);
if(!con){
NetworkManager::ActiveConnection::Ptr activeCon;
NetworkManager::Connection::Ptr con = NetworkManager::findConnection(connection);
Q_FOREACH (const NetworkManager::ActiveConnection::Ptr &active, NetworkManager::activeConnections()) {
if (active->uuid() == con->uuid())
activeCon = active;
}
if(!activeCon){
qWarning(PLASMA_NM) << "Active" << connection << "not found";
return QVariantMap();
}
qWarning(PLASMA_NM) << "Active" << con->ipV4Config().addresses().first().ip().toString();
return QVariantMap();
QVariantMap map;
map.insert("address",QVariant(activeCon->ipV4Config().addresses().first().ip().toString()));
map.insert("prefix",QVariant(activeCon->ipV4Config().addresses().first().netmask().toString()));
map.insert("gateway",QVariant(activeCon->ipV4Config().gateway()));
map.insert("dns",QVariant(activeCon->ipV4Config().nameservers().first().toString()));
//qWarning() << map;
return map;
}
void Handler::addConnectionFromQML(const QVariantMap &QMLmap)
......
......@@ -34,6 +34,7 @@ ColumnLayout {
ipMethodComb.currentIndex == 1 && manualIPaddress.acceptableInput
&& manualIPgateway.acceptableInput && manualIPprefix.acceptableInput
&& manualIPdns.acceptableInput ))
property var ipRegex: /^(([01]?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))\.){3}([01]?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))$/
spacing: units.gridUnit
......@@ -71,9 +72,8 @@ ColumnLayout {
id: manualIPaddress
placeholderText: "193.168.1.128"
text: address
//inputMask: "000.000.000.000;_"
validator: RegExpValidator{
regExp: /^(([01]?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))\.){3}([01]?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))$/
validator: RegExpValidator {
regExp: ipRegex
}
}
......@@ -85,8 +85,8 @@ ColumnLayout {
id: manualIPgateway
placeholderText: "192.168.1.1"
text: gateway
validator: RegExpValidator{
regExp: /^(([01]?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))\.){3}([01]?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))$/
validator: RegExpValidator {
regExp: ipRegex
}
}
......@@ -96,9 +96,11 @@ ColumnLayout {
Controls.TextField {
id: manualIPprefix
placeholderText: "24"
placeholderText: "255.255.255.0"
text: prefix
validator: IntValidator { bottom: 1; top: 32; }
validator: RegExpValidator {
regExp: ipRegex
}
}
Controls.Label {
......@@ -109,8 +111,8 @@ ColumnLayout {
id: manualIPdns
placeholderText: "8.8.8.8"
text: dns
validator: RegExpValidator{
regExp: /^(([01]?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))\.){3}([01]?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))$/
validator: RegExpValidator {
regExp: ipRegex
}
}
}
......
......@@ -133,6 +133,11 @@ Kirigami.ScrollablePage{
security = d['Security type']
if (d['Connection speed'])
signal_speed = d['Connection speed']
IPDetailsSection.address = activeMap["address"]
IPDetailsSection.dns = activeMap["dns"]
IPDetailsSection.prefix = activeMap["prefix"]
IPDetailsSection.gateway = activeMap["gateway"]
}
function clearDetails() {
signal_speed = signal_strength = ip_address = 0
......
......@@ -80,7 +80,7 @@ Kirigami.SwipeListItem {
visible: running
}
PlasmaComponents.Label {
Controls.Label {
id: connectionNameLabel
anchors {
......@@ -110,8 +110,9 @@ Kirigami.SwipeListItem {
PasswordField{
id: connectionPasswordFieldField
anchors.verticalCenter: parent.verticalCenter
height: units.gridUnit * 2
securityType: SecurityType
height: parent.height
onAcceptableInputChanged: {
connectionPasswordFieldButton.enabled = acceptableInput
}
......@@ -158,6 +159,7 @@ Kirigami.SwipeListItem {
applicationWindow().pageStack.push(networkDetailsViewComponent)
if (networkDetailsViewComponent.status == Component.Ready){
console.info("Network view ready")
//handler.getActiveConnectionInfo(ConnectionPath)
if (ConnectionDetails)
networkDetailsViewComponentView.details = ConnectionDetails
if (ConnectionDetails[1] !== "") {
......@@ -167,7 +169,7 @@ Kirigami.SwipeListItem {
}
map = handler.getConnectionSettings(ConnectionPath,"ipv4")
if (ConnectionState == PlasmaNM.Enums.Activated){
networkDetailsViewComponentView.activeMap = handler.getActiveConnectionInfo(SpecificPath)
networkDetailsViewComponentView.activeMap = handler.getActiveConnectionInfo(ConnectionPath)
}
//networkDetailsViewContent.map = map
networkDetailsViewComponentView.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