Commit b61cb100 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/views/App/Main/Assistant): supports display name

parent 46e9c13b
...@@ -515,6 +515,10 @@ Server url not configured.</translation> ...@@ -515,6 +515,10 @@ Server url not configured.</translation>
<source>quitWarning</source> <source>quitWarning</source>
<translation>Your account has been created but is not yet validated. If you quit this view, you should add manually your account and validate it within 24 hours.</translation> <translation>Your account has been created but is not yet validated. If you quit this view, you should add manually your account and validate it within 24 hours.</translation>
</message> </message>
<message>
<source>displayNameLabel</source>
<translation>Display name (optional)</translation>
</message>
</context> </context>
<context> <context>
<name>CreateLinphoneSipAccountWithPhoneNumber</name> <name>CreateLinphoneSipAccountWithPhoneNumber</name>
...@@ -534,6 +538,10 @@ Server url not configured.</translation> ...@@ -534,6 +538,10 @@ Server url not configured.</translation>
<source>usernameLabel</source> <source>usernameLabel</source>
<translation>Username</translation> <translation>Username</translation>
</message> </message>
<message>
<source>displayNameLabel</source>
<translation>Display name (optional)</translation>
</message>
</context> </context>
<context> <context>
<name>DroppableTextArea</name> <name>DroppableTextArea</name>
...@@ -982,10 +990,6 @@ to chat or see the conversation history.</translation> ...@@ -982,10 +990,6 @@ to chat or see the conversation history.</translation>
<source>defaultIdentityTitle</source> <source>defaultIdentityTitle</source>
<translation>Default identity</translation> <translation>Default identity</translation>
</message> </message>
<message>
<source>defaultDisplaynameLabel</source>
<translation>Display name</translation>
</message>
<message> <message>
<source>defaultUsernameLabel</source> <source>defaultUsernameLabel</source>
<translation>Username</translation> <translation>Username</translation>
...@@ -1026,6 +1030,10 @@ to chat or see the conversation history.</translation> ...@@ -1026,6 +1030,10 @@ to chat or see the conversation history.</translation>
<source>eraseAllPasswordsDescription</source> <source>eraseAllPasswordsDescription</source>
<translation>Are you sure you want to erase all passwords?</translation> <translation>Are you sure you want to erase all passwords?</translation>
</message> </message>
<message>
<source>defaultDisplayNameLabel</source>
<translation>Display name</translation>
</message>
</context> </context>
<context> <context>
<name>SettingsSipAccountsEdit</name> <name>SettingsSipAccountsEdit</name>
......
...@@ -515,6 +515,10 @@ Url du serveur non configurée.</translation> ...@@ -515,6 +515,10 @@ Url du serveur non configurée.</translation>
<source>quitWarning</source> <source>quitWarning</source>
<translation>Votre compte a été crée mais il n&apos;a pas été validé. Si vous quittez cette vue, vous devrez ajouter manuellement votre compte et le valider dans les 24 heures.</translation> <translation>Votre compte a été crée mais il n&apos;a pas été validé. Si vous quittez cette vue, vous devrez ajouter manuellement votre compte et le valider dans les 24 heures.</translation>
</message> </message>
<message>
<source>displayNameLabel</source>
<translation>Nom d&apos;affichage (optionnel)</translation>
</message>
</context> </context>
<context> <context>
<name>CreateLinphoneSipAccountWithPhoneNumber</name> <name>CreateLinphoneSipAccountWithPhoneNumber</name>
...@@ -534,6 +538,10 @@ Url du serveur non configurée.</translation> ...@@ -534,6 +538,10 @@ Url du serveur non configurée.</translation>
<source>usernameLabel</source> <source>usernameLabel</source>
<translation>Nom d&apos;utilisateur</translation> <translation>Nom d&apos;utilisateur</translation>
</message> </message>
<message>
<source>displayNameLabel</source>
<translation>Nom d&apos;affichage (optionnel)</translation>
</message>
</context> </context>
<context> <context>
<name>DroppableTextArea</name> <name>DroppableTextArea</name>
...@@ -981,10 +989,6 @@ chatter ou voir l&apos;historique de conversation.</translation> ...@@ -981,10 +989,6 @@ chatter ou voir l&apos;historique de conversation.</translation>
<source>defaultIdentityTitle</source> <source>defaultIdentityTitle</source>
<translation>Identité par défaut</translation> <translation>Identité par défaut</translation>
</message> </message>
<message>
<source>defaultDisplaynameLabel</source>
<translation>Nom d&apos;affichage</translation>
</message>
<message> <message>
<source>defaultUsernameLabel</source> <source>defaultUsernameLabel</source>
<translation>Nom d&apos;utilisateur</translation> <translation>Nom d&apos;utilisateur</translation>
...@@ -1025,6 +1029,10 @@ chatter ou voir l&apos;historique de conversation.</translation> ...@@ -1025,6 +1029,10 @@ chatter ou voir l&apos;historique de conversation.</translation>
<source>eraseAllPasswordsDescription</source> <source>eraseAllPasswordsDescription</source>
<translation>Êtes-vous sûr de vouloir supprimer tous vos mots de passe ?</translation> <translation>Êtes-vous sûr de vouloir supprimer tous vos mots de passe ?</translation>
</message> </message>
<message>
<source>defaultDisplayNameLabel</source>
<translation>Nom d&apos;affichage</translation>
</message>
</context> </context>
<context> <context>
<name>SettingsSipAccountsEdit</name> <name>SettingsSipAccountsEdit</name>
......
...@@ -207,6 +207,8 @@ void AssistantModel::setEmail (const QString &email) { ...@@ -207,6 +207,8 @@ void AssistantModel::setEmail (const QString &email) {
emit emailChanged(email, error); emit emailChanged(email, error);
} }
// -----------------------------------------------------------------------------
QString AssistantModel::getPassword () const { QString AssistantModel::getPassword () const {
return ::Utils::linphoneStringToQString(mAccountCreator->getPassword()); return ::Utils::linphoneStringToQString(mAccountCreator->getPassword());
} }
...@@ -237,6 +239,8 @@ void AssistantModel::setPassword (const QString &password) { ...@@ -237,6 +239,8 @@ void AssistantModel::setPassword (const QString &password) {
emit passwordChanged(password, error); emit passwordChanged(password, error);
} }
// -----------------------------------------------------------------------------
QString AssistantModel::getPhoneNumber () const { QString AssistantModel::getPhoneNumber () const {
return ::Utils::linphoneStringToQString(mAccountCreator->getPhoneNumber()); return ::Utils::linphoneStringToQString(mAccountCreator->getPhoneNumber());
} }
...@@ -250,15 +254,43 @@ void AssistantModel::setPhoneNumber (const QString &phoneNumber) { ...@@ -250,15 +254,43 @@ void AssistantModel::setPhoneNumber (const QString &phoneNumber) {
emit phoneNumberChanged(phoneNumber, error); emit phoneNumberChanged(phoneNumber, error);
} }
// -----------------------------------------------------------------------------
QString AssistantModel::getUsername () const { QString AssistantModel::getUsername () const {
return ::Utils::linphoneStringToQString(mAccountCreator->getUsername()); return ::Utils::linphoneStringToQString(mAccountCreator->getUsername());
} }
void AssistantModel::setUsername (const QString &username) { void AssistantModel::setUsername (const QString &username) {
emit usernameChanged(
username,
mapAccountCreatorUsernameStatusToString(
mAccountCreator->setUsername(::Utils::qStringToLinphoneString(username))
)
);
}
// -----------------------------------------------------------------------------
QString AssistantModel::getDisplayName () const {
return ::Utils::linphoneStringToQString(mAccountCreator->getDisplayName());
}
void AssistantModel::setDisplayName (const QString &displayName) {
emit displayNameChanged(
displayName,
mapAccountCreatorUsernameStatusToString(
mAccountCreator->setDisplayName(::Utils::qStringToLinphoneString(displayName))
)
);
}
// -----------------------------------------------------------------------------
QString AssistantModel::mapAccountCreatorUsernameStatusToString (linphone::AccountCreatorUsernameStatus status) const {
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig(); shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
QString error; QString error;
switch (mAccountCreator->setUsername(::Utils::qStringToLinphoneString(username))) { switch (status) {
case linphone::AccountCreatorUsernameStatusOk: case linphone::AccountCreatorUsernameStatusOk:
break; break;
case linphone::AccountCreatorUsernameStatusTooShort: case linphone::AccountCreatorUsernameStatusTooShort:
...@@ -276,5 +308,5 @@ void AssistantModel::setUsername (const QString &username) { ...@@ -276,5 +308,5 @@ void AssistantModel::setUsername (const QString &username) {
break; break;
} }
emit usernameChanged(username, error); return error;
} }
...@@ -37,6 +37,7 @@ class AssistantModel : public QObject { ...@@ -37,6 +37,7 @@ class AssistantModel : public QObject {
Q_PROPERTY(QString password READ getPassword WRITE setPassword NOTIFY passwordChanged); Q_PROPERTY(QString password READ getPassword WRITE setPassword NOTIFY passwordChanged);
Q_PROPERTY(QString phoneNumber READ getPhoneNumber WRITE setPhoneNumber NOTIFY phoneNumberChanged); Q_PROPERTY(QString phoneNumber READ getPhoneNumber WRITE setPhoneNumber NOTIFY phoneNumberChanged);
Q_PROPERTY(QString username READ getUsername WRITE setUsername NOTIFY usernameChanged); Q_PROPERTY(QString username READ getUsername WRITE setUsername NOTIFY usernameChanged);
Q_PROPERTY(QString displayName READ getDisplayName WRITE setDisplayName NOTIFY displayNameChanged);
public: public:
AssistantModel (QObject *parent = Q_NULLPTR); AssistantModel (QObject *parent = Q_NULLPTR);
...@@ -52,6 +53,7 @@ signals: ...@@ -52,6 +53,7 @@ signals:
void passwordChanged (const QString &password, const QString &error); void passwordChanged (const QString &password, const QString &error);
void phoneNumberChanged (const QString &phoneNumber, const QString &error); void phoneNumberChanged (const QString &phoneNumber, const QString &error);
void usernameChanged (const QString &username, const QString &error); void usernameChanged (const QString &username, const QString &error);
void displayNameChanged (const QString &displayName, const QString &error);
void activateStatusChanged (const QString &error); void activateStatusChanged (const QString &error);
void createStatusChanged (const QString &error); void createStatusChanged (const QString &error);
...@@ -70,6 +72,11 @@ private: ...@@ -70,6 +72,11 @@ private:
QString getUsername () const; QString getUsername () const;
void setUsername (const QString &username); void setUsername (const QString &username);
QString getDisplayName () const;
void setDisplayName (const QString &displayName);
QString mapAccountCreatorUsernameStatusToString (linphone::AccountCreatorUsernameStatus status) const;
std::shared_ptr<linphone::AccountCreator> mAccountCreator; std::shared_ptr<linphone::AccountCreator> mAccountCreator;
std::shared_ptr<Handlers> mHandlers; std::shared_ptr<Handlers> mHandlers;
}; };
......
...@@ -246,11 +246,11 @@ QString AccountSettingsModel::getPrimaryDisplayname () const { ...@@ -246,11 +246,11 @@ QString AccountSettingsModel::getPrimaryDisplayname () const {
); );
} }
void AccountSettingsModel::setPrimaryDisplayname (const QString &displayname) { void AccountSettingsModel::setPrimaryDisplayname (const QString &displayName) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::Address> primary = core->getPrimaryContactParsed(); shared_ptr<linphone::Address> primary = core->getPrimaryContactParsed();
primary->setDisplayName(::Utils::qStringToLinphoneString(displayname)); primary->setDisplayName(::Utils::qStringToLinphoneString(displayName));
core->setPrimaryContact(primary->asString()); core->setPrimaryContact(primary->asString());
emit accountSettingsUpdated(); emit accountSettingsUpdated();
......
...@@ -91,7 +91,7 @@ private: ...@@ -91,7 +91,7 @@ private:
void setPrimaryUsername (const QString &username); void setPrimaryUsername (const QString &username);
QString getPrimaryDisplayname () const; QString getPrimaryDisplayname () const;
void setPrimaryDisplayname (const QString &displayname); void setPrimaryDisplayname (const QString &displayName);
QString getPrimarySipAddress () const; QString getPrimarySipAddress () const;
......
...@@ -45,6 +45,14 @@ AssistantAbstractView { ...@@ -45,6 +45,14 @@ AssistantAbstractView {
onTextChanged: assistantModel.username = text onTextChanged: assistantModel.username = text
} }
} }
FormGroup {
label: qsTr('displayNameLabel')
TextField {
onTextChanged: assistantModel.displayName = text
}
}
} }
FormLine { FormLine {
......
...@@ -49,6 +49,16 @@ AssistantAbstractView { ...@@ -49,6 +49,16 @@ AssistantAbstractView {
} }
} }
} }
FormLine {
FormGroup {
label: qsTr('displayNameLabel')
TextField {
onTextChanged: assistantModel.displayName = text
}
}
}
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
......
...@@ -25,12 +25,12 @@ TabContainer { ...@@ -25,12 +25,12 @@ TabContainer {
FormLine { FormLine {
FormGroup { FormGroup {
label: qsTr('defaultDisplaynameLabel') label: qsTr('defaultDisplayNameLabel')
TextField { TextField {
text: AccountSettingsModel.primaryDisplayname text: AccountSettingsModel.primarydisplayName
onEditingFinished: AccountSettingsModel.primaryDisplayname = text onEditingFinished: AccountSettingsModel.primarydisplayName = text
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment