-bool IdentitiesSettingsPage::testHasChanged() {
- if(deletedIdentities.count()) return true;
- if(currentId < 0) {
- return true; // new identity
- } else {
- if(currentId != 0) {
- changedIdentities.removeAll(currentId);
- CertIdentity temp(currentId, this);
- ui.identityEditor->saveToIdentity(&temp);
- temp.setIdentityName(identities[currentId]->identityName());
- if(temp != *Client::identity(currentId) || temp.isDirty())
- changedIdentities.append(currentId);
+void IdentitiesSettingsPage::setWidgetStates()
+{
+ bool enabled = (ui.identityList->count() > 0);
+ ui.identityEditor->setEnabled(enabled);
+ ui.renameIdentity->setEnabled(enabled);
+ ui.deleteIdentity->setEnabled(ui.identityList->count() > 1);
+}
+
+bool IdentitiesSettingsPage::testHasChanged()
+{
+ if (deletedIdentities.count())
+ return true;
+ if (currentId < 0) {
+ return true; // new identity
+ }
+ else {
+ if (currentId != 0) {
+ changedIdentities.removeAll(currentId);
+ CertIdentity temp(currentId, this);
+#ifdef HAVE_SSL
+ // we need to set the cert and key manually, as they aren't synced
+ CertIdentity* old = identities[currentId];
+ temp.setSslKey(old->sslKey());
+ temp.setSslCert(old->sslCert());
+#endif
+ ui.identityEditor->saveToIdentity(&temp);
+ temp.setIdentityName(identities[currentId]->identityName());
+ if (temp != *Client::identity(currentId) || temp.isDirty())
+ changedIdentities.append(currentId);
+ }
+ return changedIdentities.count();