[PC-BSD Commits] r19222 - pcbsd/current/src-qt4/pc-netmanager/src/NetworkManager

svn at pcbsd.org svn at pcbsd.org
Mon Sep 17 07:21:03 PDT 2012


Author: kris
Date: 2012-09-17 14:21:03 +0000 (Mon, 17 Sep 2012)
New Revision: 19222

Modified:
   pcbsd/current/src-qt4/pc-netmanager/src/NetworkManager/networkman.cpp
Log:

Fix some issues with validating gateway / dns and advanced settings, just disable save button and show 
text until the user finishes entering valid information



Modified: pcbsd/current/src-qt4/pc-netmanager/src/NetworkManager/networkman.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-netmanager/src/NetworkManager/networkman.cpp	2012-09-17 14:05:17 UTC (rev 19221)
+++ pcbsd/current/src-qt4/pc-netmanager/src/NetworkManager/networkman.cpp	2012-09-17 14:21:03 UTC (rev 19222)
@@ -75,10 +75,10 @@
     // Set the slots for the advanced tab
     connect(lineDNS1, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckGlobalText()) );
     connect(lineDNS2, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckGlobalText()) );
-    connect(lineIPv6DNS1, SIGNAL(editingFinished()), this, SLOT(slotCheckGlobalText()) );
-    connect(lineIPv6DNS2, SIGNAL(editingFinished()), this, SLOT(slotCheckGlobalText()) );
+    connect(lineIPv6DNS1, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckGlobalText()) );
+    connect(lineIPv6DNS2, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckGlobalText()) );
     connect(lineGateway, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckGlobalText()) );
-    connect(lineIPv6Gateway, SIGNAL(editingFinished()), this, SLOT(slotCheckGlobalText()) );
+    connect(lineIPv6Gateway, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckGlobalText()) );
     connect(lineHostname, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckGlobalText()) );
 
     connect(PublicDNS1, SIGNAL(clicked()), this, SLOT(slotPublicDNS1Clicked()) );
@@ -797,6 +797,7 @@
 void NetworkMan::slotCheckGlobalText()
 {
 
+   pushSave->setEnabled(false);
    QRegExp hostnameRegExp("^(([a-z0-9][a-z0-9-]*[a-z0-9])|([a-z0-9]+))$");
    textGlobalError->setText("");
 
@@ -804,43 +805,37 @@
 	QHostAddress addr;
         if ( ! lineIPv6DNS1->text().isEmpty() ) {
             if ( addr.setAddress(lineIPv6DNS1->text()) == false || addr.protocol() != QAbstractSocket::IPv6Protocol ) {
-	        QMessageBox::warning( this, tr("Warning"),
-	            tr("IPv6 DNS #1 (") + lineIPv6DNS1->text() + tr(") not a valid address.") );
+         	textGlobalError->setText(tr("Invalid IPv6 DNS specified"));
 	        return;
             }
         }
         if ( ! lineIPv6DNS2->text().isEmpty() ) {
             if ( addr.setAddress(lineIPv6DNS2->text()) == false || addr.protocol() != QAbstractSocket::IPv6Protocol ) {
-	        QMessageBox::warning( this, tr("Warning"),
-	            tr("IPv6 DNS #2 (") + lineIPv6DNS2->text() + tr(") not a valid address.") );
+         	textGlobalError->setText(tr("Invalid IPv6 DNS specified"));
 	        return;
             }
         }
         if ( ! lineIPv6Gateway->text().isEmpty() ) {
             if ( addr.setAddress(lineIPv6Gateway->text()) == false || addr.protocol() != QAbstractSocket::IPv6Protocol ) {
-	        QMessageBox::warning( this, tr("Warning"),
-	            tr("IPv6 gateway (") + lineIPv6Gateway->text() + tr(") not a valid address.") );
+         	textGlobalError->setText(tr("Invalid IPv6 Gateway specified"));
 	        return;
             }
         }
     }
   
      if ( lineDNS1->text() != "..."  && ! Utils::validateIPV4(lineDNS1->text() ) && groupDNS->isChecked()) {
-	 QMessageBox::warning( this, tr("Warning"),
-	  tr("DNS #1 is out of range! (") + lineDNS1->text() + tr(") Fields must be between 0-255.") );
+         textGlobalError->setText(tr("Invalid DNS specified"));
 	 return;
      }
     
     if ( lineDNS2->text() != "..."  && ! Utils::validateIPV4(lineDNS2->text() ) && groupDNS->isChecked()) {
-	 QMessageBox::warning( this, tr("Warning"),
-	  tr("DNS #2 is out of range! (") + lineDNS2->text() + tr(") Fields must be between 0-255.") );
+         textGlobalError->setText(tr("Invalid DNS specified"));
 	 return;
      }
     
     
      if ( lineGateway->text() != "..."  && ! Utils::validateIPV4(lineGateway->text())  && groupGateway->isChecked() ) {
-	 QMessageBox::warning( this, tr("Warning"),
-	  tr("Gateway is out of range! (") + lineGateway->text() + tr(") Fields must be between 0-255.") );
+         textGlobalError->setText(tr("Invalid Gateway specified"));
 	 return;
      }
      
@@ -861,6 +856,8 @@
 	return;
      }
 
+     pushSave->setEnabled(true);
+
 }
 
 void NetworkMan::slotClose()



More information about the Commits mailing list