#include <QHeaderView>
#include <QMessageBox>
#include <QTextCodec>
+#include <utility>
#include "networkssettingspage.h"
NetworksSettingsPage::NetworksSettingsPage(QWidget *parent)
: SettingsPage(tr("IRC"), tr("Networks"), parent)
-#ifdef HAVE_SSL
- , _cid(0)
-#endif
{
ui.setupUi(this);
sslUpdated();
#endif
+ // Reset network capability status in case no valid networks get selected (a rare situation)
+ resetNetworkCapStates();
+
foreach(NetworkId netid, Client::networkIds()) {
clientNetworkAdded(netid);
}
}
+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.
QListWidgetItem *item = ui.networkList->item(i);
if (item->data(Qt::UserRole).value<NetworkId>() == id) return item;
}
- return 0;
+ return nullptr;
}
QListWidgetItem *NetworksSettingsPage::insertNetwork(const NetworkInfo &info)
{
- QListWidgetItem *item = 0;
+ QListWidgetItem *item = nullptr;
QList<QListWidgetItem *> items = ui.networkList->findItems(info.networkName, Qt::MatchExactly);
if (!items.count()) item = new QListWidgetItem(disconnectedIcon, info.networkName, ui.networkList);
else {
* NetworkAddDlg
*************************************************************************/
-NetworkAddDlg::NetworkAddDlg(const QStringList &exist, QWidget *parent) : QDialog(parent), existing(exist)
+NetworkAddDlg::NetworkAddDlg(QStringList exist, QWidget *parent) : QDialog(parent), existing(std::move(exist))
{
ui.setupUi(this);
ui.useSSL->setIcon(icon::get("document-encrypt"));
}
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();
}
* NetworkEditDlg
*************************************************************************/
-NetworkEditDlg::NetworkEditDlg(const QString &old, const QStringList &exist, QWidget *parent) : QDialog(parent), existing(exist)
+NetworkEditDlg::NetworkEditDlg(const QString &old, QStringList exist, QWidget *parent) : QDialog(parent), existing(std::move(exist))
{
ui.setupUi(this);