call: set displayName for ring accounts
Send the alias of the Ring account as the displayName
This is retro-compatible, by setting the displayName field on any ring
account created before this change.
Issue: #77365
Change-Id: Ifbe6269fa5fd6095cd0f61bfb23e443998418a16
diff --git a/src/AccGeneralVC.mm b/src/AccGeneralVC.mm
index a2d33b1..2d6f45d 100644
--- a/src/AccGeneralVC.mm
+++ b/src/AccGeneralVC.mm
@@ -206,6 +206,7 @@
switch ([textField tag]) {
case ALIAS_TAG:
[self currentAccount]->setAlias([[textField stringValue] UTF8String]);
+ [self currentAccount]->setDisplayName([[textField stringValue] UTF8String]);
break;
case HOSTNAME_TAG:
[self currentAccount]->setHostname([[textField stringValue] UTF8String]);
diff --git a/src/AccRingVC.mm b/src/AccRingVC.mm
index f262f4e..30418fa 100644
--- a/src/AccRingVC.mm
+++ b/src/AccRingVC.mm
@@ -148,6 +148,7 @@
switch ([textField tag]) {
case ALIAS_TAG:
[self currentAccount]->setAlias([[textField stringValue] UTF8String]);
+ [self currentAccount]->setDisplayName([[textField stringValue] UTF8String]);
break;
case HOSTNAME_TAG:
[self currentAccount]->setHostname([[textField stringValue] UTF8String]);
diff --git a/src/AccountsVC.mm b/src/AccountsVC.mm
index 168e59b..0fc4844 100644
--- a/src/AccountsVC.mm
+++ b/src/AccountsVC.mm
@@ -180,7 +180,8 @@
auto newAccName = [[NSString alloc] initWithFormat:@"%@ account",
AccountModel::instance()->protocolModel()->data(qIdx, Qt::DisplayRole).toString().toNSString(), nil];
- AccountModel::instance()->add([newAccName UTF8String], qIdx);
+ auto acc = AccountModel::instance()->add([newAccName UTF8String], qIdx);
+ acc->setDisplayName(acc->alias());
AccountModel::instance()->save();
}
diff --git a/src/AppDelegate.mm b/src/AppDelegate.mm
index 6325438..08ed94e 100644
--- a/src/AppDelegate.mm
+++ b/src/AppDelegate.mm
@@ -123,14 +123,17 @@
- (BOOL) checkForRingAccount
{
+ BOOL foundRingAcc = NO;
for (int i = 0 ; i < AccountModel::instance()->rowCount() ; ++i) {
QModelIndex idx = AccountModel::instance()->index(i);
Account* acc = AccountModel::instance()->getAccountByModelIndex(idx);
if(acc->protocol() == Account::Protocol::RING) {
- return YES;
+ if (acc->displayName().isEmpty())
+ acc->setDisplayName(acc->alias());
+ foundRingAcc = YES;
}
}
- return FALSE;
+ return foundRingAcc;
}
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
diff --git a/src/RingWizardWC.mm b/src/RingWizardWC.mm
index 5868bc6..eab4b79 100644
--- a/src/RingWizardWC.mm
+++ b/src/RingWizardWC.mm
@@ -122,6 +122,8 @@
NSString* newAccName = @"My Ring";
Account* newAcc = AccountModel::instance()->add([newAccName UTF8String], Account::Protocol::RING);
newAcc->setAlias([[nickname stringValue] UTF8String]);
+ newAcc->setDisplayName([[nickname stringValue] UTF8String]);
+
newAcc->setUpnpEnabled(YES); // Always active upnp
newAcc << Account::EditAction::SAVE;
}