settings: Fix NetworkAddDlg states on type change
[quassel.git] / src / qtui / settingspages / networkssettingspage.cpp
index d8309ad..57d8ca0 100644 (file)
@@ -207,6 +207,9 @@ void NetworksSettingsPage::load()
     sslUpdated();
 #endif
 
+    // Reset network capability status in case no valid networks get selected (a rare situation)
+    resetNetworkCapStates();
+
     foreach(NetworkId netid, Client::networkIds()) {
         clientNetworkAdded(netid);
     }
@@ -355,10 +358,17 @@ void NetworksSettingsPage::setItemState(NetworkId id, QListWidgetItem *item)
 }
 
 
+void NetworksSettingsPage::resetNetworkCapStates()
+{
+    // Set the status to a blank (invalid) network ID, reseting all UI
+    setNetworkCapStates(NetworkId());
+}
+
+
 void NetworksSettingsPage::setNetworkCapStates(NetworkId id)
 {
     const Network *net = Client::network(id);
-    if (Client::isCoreFeatureEnabled(Quassel::Feature::CapNegotiation) && net) {
+    if (net && Client::isCoreFeatureEnabled(Quassel::Feature::CapNegotiation)) {
         // Capability negotiation is supported, network exists.
         // Check if the network is connected.  Don't use net->isConnected() as that won't be true
         // during capability negotiation when capabilities are added and removed.
@@ -1060,6 +1070,8 @@ NetworkAddDlg::NetworkAddDlg(const QStringList &exist, QWidget *parent) : QDialo
     }
     connect(ui.networkName, SIGNAL(textChanged(const QString &)), SLOT(setButtonStates()));
     connect(ui.serverAddress, SIGNAL(textChanged(const QString &)), SLOT(setButtonStates()));
+    connect(ui.usePreset, SIGNAL(toggled(bool)), SLOT(setButtonStates()));
+    connect(ui.useManual, SIGNAL(toggled(bool)), SLOT(setButtonStates()));
     setButtonStates();
 }