disconnectedIcon = QIcon(":/22x22/actions/network-disconnect");
currentId = 0;
- setEnabled(false); // need a core connection!
+ setEnabled(Client::isConnected()); // need a core connection!
setWidgetStates();
connect(Client::instance(), SIGNAL(coreConnectionStateChanged(bool)), this, SLOT(coreConnectionStateChanged(bool)));
connect(Client::instance(), SIGNAL(networkCreated(NetworkId)), this, SLOT(clientNetworkAdded(NetworkId)));
ui.upServer->setEnabled(false);
ui.downServer->setEnabled(false);
}
-
- // FIXME disable network creation/deletion because of the storage issue
- ui.addNetwork->setEnabled(false);
- ui.deleteNetwork->setEnabled(false);
}
void NetworksSettingsPage::setItemState(NetworkId id, QListWidgetItem *item) {
- if(!item) item = networkItem(id);
+ if(!item && !(item = networkItem(id))) return;
const Network *net = Client::network(id);
if(!net || net->isInitialized()) item->setFlags(item->flags() | Qt::ItemIsEnabled);
else item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
item->setIcon(disconnectedIcon);
}
if(net) {
+ bool select = false;
// check if we already have another net of this name in the list, and replace it
QList<QListWidgetItem *> items = ui.networkList->findItems(net->networkName(), Qt::MatchExactly);
if(items.count()) {
foreach(QListWidgetItem *i, items) {
NetworkId oldid = i->data(Qt::UserRole).value<NetworkId>();
if(oldid > 0) continue; // only locally created nets should be replaced
- if(oldid == currentId) item->setSelected(true);
- delete ui.networkList->takeItem(ui.networkList->row(i));
+ if(oldid == currentId) select = true;
+ int row = ui.networkList->row(i);
+ if(row >= 0) delete ui.networkList->takeItem(row);
networkInfos.remove(oldid);
break;
}
}
item->setText(net->networkName());
+ if(select) item->setSelected(true);
}
}
if(ui.networkList->selectedItems().count()) {
NetworkId netid = ui.networkList->selectedItems()[0]->data(Qt::UserRole).value<NetworkId>();
int ret = QMessageBox::question(this, tr("Delete Network?"),
- tr("Do you really want to delete the network \"%1\" and all related settings, including the backlog?"
- "<br><br><em>NOTE: Backlog deletion hasn't actually been implemented yet.</em>").arg(networkInfos[netid].networkName),
+ tr("Do you really want to delete the network \"%1\" and all related settings, including the backlog?").arg(networkInfos[netid].networkName),
QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
if(ret == QMessageBox::Yes) {
currentId = 0;
ui.password->setText(serverData["Password"].toString());
ui.useSSL->setChecked(serverData["UseSSL"].toBool());
} else {
- ui.port->setValue(Global::defaultPort);
+ ui.port->setValue(6667);
}
on_host_textChanged();
}