Commit 85ce8f71 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/views/App/Main/Assistant): creation in progress

parent 749e0051
...@@ -53,17 +53,20 @@ ...@@ -53,17 +53,20 @@
<source>withEmailAddress</source> <source>withEmailAddress</source>
<translation>WITH AN EMAIL ADDRESS</translation> <translation>WITH AN EMAIL ADDRESS</translation>
</message> </message>
</context>
<context>
<name>AssistantCreateLinphoneSipAccountWithEmail</name>
<message> <message>
<source>countryLabel</source> <source>createLinphoneSipAccountTitle</source>
<translation>Your country</translation> <translation>CREATE A LINPHONE ACCOUNT</translation>
</message> </message>
<message> <message>
<source>phoneNumberLabel</source> <source>confirmAction</source>
<translation>Phone number</translation> <translation>CREATE</translation>
</message> </message>
<message> <message>
<source>usernameLabel</source> <source>usernameLabel</source>
<translation>Username (optional)</translation> <translation>Username</translation>
</message> </message>
<message> <message>
<source>emailLabel</source> <source>emailLabel</source>
...@@ -78,8 +81,27 @@ ...@@ -78,8 +81,27 @@
<translation>Password confirmation</translation> <translation>Password confirmation</translation>
</message> </message>
<message> <message>
<source>confirmAction</source> <source>passwordConfirmationError</source>
<translation>CREATE</translation> <translation>The passwords you entered do not match.</translation>
</message>
</context>
<context>
<name>AssistantCreateLinphoneSipAccountWithPhoneNumber</name>
<message>
<source>createLinphoneSipAccountTitle</source>
<translation>CREATE A LINPHONE ACCOUNT</translation>
</message>
<message>
<source>countryLabel</source>
<translation>Your country</translation>
</message>
<message>
<source>phoneNumberLabel</source>
<translation>Phone number</translation>
</message>
<message>
<source>usernameLabel</source>
<translation>Username</translation>
</message> </message>
</context> </context>
<context> <context>
...@@ -166,6 +188,22 @@ ...@@ -166,6 +188,22 @@
<source>requestFailed</source> <source>requestFailed</source>
<translation>Unable to send the request.</translation> <translation>Unable to send the request.</translation>
</message> </message>
<message>
<source>emailStatusMalformed</source>
<translation>Malformed email.</translation>
</message>
<message>
<source>emailStatusMalformedInvalidCharacters</source>
<translation>Malformed email or invalid characters.</translation>
</message>
<message>
<source>cannotSendSms</source>
<translation>Server error: Cannot send sms.</translation>
</message>
<message>
<source>accountAlreadyExists</source>
<translation>Account already exists.</translation>
</message>
</context> </context>
<context> <context>
<name>AssistantUseLinphoneSipAccount</name> <name>AssistantUseLinphoneSipAccount</name>
...@@ -177,6 +215,13 @@ ...@@ -177,6 +215,13 @@
<source>useLinphoneSipAccountTitle</source> <source>useLinphoneSipAccountTitle</source>
<translation>USE A LINPHONE ACCOUNT</translation> <translation>USE A LINPHONE ACCOUNT</translation>
</message> </message>
<message>
<source>useUsernameToLogin</source>
<translation>Use username and password rather than your phone number.</translation>
</message>
</context>
<context>
<name>AssistantUseLinphoneSipAccountWithPhoneNumber</name>
<message> <message>
<source>countryLabel</source> <source>countryLabel</source>
<translation>Your country</translation> <translation>Your country</translation>
...@@ -185,10 +230,9 @@ ...@@ -185,10 +230,9 @@
<source>phoneNumberLabel</source> <source>phoneNumberLabel</source>
<translation>Phone number</translation> <translation>Phone number</translation>
</message> </message>
<message> </context>
<source>useUsernameToLogin</source> <context>
<translation>Use username and password rather than your phone number.</translation> <name>AssistantUseLinphoneSipAccountWithUsername</name>
</message>
<message> <message>
<source>usernameLabel</source> <source>usernameLabel</source>
<translation>Username</translation> <translation>Username</translation>
......
...@@ -53,13 +53,16 @@ ...@@ -53,13 +53,16 @@
<source>withEmailAddress</source> <source>withEmailAddress</source>
<translation>AVER UNE ADRESSE E-MAIL</translation> <translation>AVER UNE ADRESSE E-MAIL</translation>
</message> </message>
</context>
<context>
<name>AssistantCreateLinphoneSipAccountWithEmail</name>
<message> <message>
<source>countryLabel</source> <source>createLinphoneSipAccountTitle</source>
<translation>Votre pays</translation> <translation>CRÉER UN COMPTE LINPHONE</translation>
</message> </message>
<message> <message>
<source>phoneNumberLabel</source> <source>confirmAction</source>
<translation>Numéro de téléphone</translation> <translation>CRÉER</translation>
</message> </message>
<message> <message>
<source>usernameLabel</source> <source>usernameLabel</source>
...@@ -78,8 +81,27 @@ ...@@ -78,8 +81,27 @@
<translation>Confirmation du mot de passe</translation> <translation>Confirmation du mot de passe</translation>
</message> </message>
<message> <message>
<source>confirmAction</source> <source>passwordConfirmationError</source>
<translation>CREATE</translation> <translation>Les mots de passe ne correspondent pas.</translation>
</message>
</context>
<context>
<name>AssistantCreateLinphoneSipAccountWithPhoneNumber</name>
<message>
<source>createLinphoneSipAccountTitle</source>
<translation>CRÉER UN COMPTE LINPHONE</translation>
</message>
<message>
<source>countryLabel</source>
<translation>Votre pays</translation>
</message>
<message>
<source>phoneNumberLabel</source>
<translation>Numéro de téléphone</translation>
</message>
<message>
<source>usernameLabel</source>
<translation>Nom d&apos;utilisateur</translation>
</message> </message>
</context> </context>
<context> <context>
...@@ -166,6 +188,22 @@ ...@@ -166,6 +188,22 @@
<source>loginWithUsernameFailed</source> <source>loginWithUsernameFailed</source>
<translation>La connection a échouée. Merci de vérifier le nom d&apos;utilisateur/mot de passe.</translation> <translation>La connection a échouée. Merci de vérifier le nom d&apos;utilisateur/mot de passe.</translation>
</message> </message>
<message>
<source>emailStatusMalformed</source>
<translation>Adresse malformée.</translation>
</message>
<message>
<source>emailStatusMalformedInvalidCharacters</source>
<translation>Adresse malformée ou caractères invalides.</translation>
</message>
<message>
<source>cannotSendSms</source>
<translation>Erreur serveur : impossible d&apos;envoyer un sms.</translation>
</message>
<message>
<source>accountAlreadyExists</source>
<translation>Le compte existe déjà.</translation>
</message>
</context> </context>
<context> <context>
<name>AssistantUseLinphoneSipAccount</name> <name>AssistantUseLinphoneSipAccount</name>
...@@ -177,6 +215,13 @@ ...@@ -177,6 +215,13 @@
<source>useLinphoneSipAccountTitle</source> <source>useLinphoneSipAccountTitle</source>
<translation>UTILISER UN COMPTE LINPHONE</translation> <translation>UTILISER UN COMPTE LINPHONE</translation>
</message> </message>
<message>
<source>useUsernameToLogin</source>
<translation>Utiliser un nom et mot de passe plutôt que votre numéro de téléphone.</translation>
</message>
</context>
<context>
<name>AssistantUseLinphoneSipAccountWithPhoneNumber</name>
<message> <message>
<source>countryLabel</source> <source>countryLabel</source>
<translation>Votre pays</translation> <translation>Votre pays</translation>
...@@ -185,10 +230,9 @@ ...@@ -185,10 +230,9 @@
<source>phoneNumberLabel</source> <source>phoneNumberLabel</source>
<translation>Numéro de téléphone</translation> <translation>Numéro de téléphone</translation>
</message> </message>
<message> </context>
<source>useUsernameToLogin</source> <context>
<translation>Utiliser un nom et mot de passe plutôt que votre numéro de téléphone.</translation> <name>AssistantUseLinphoneSipAccountWithUsername</name>
</message>
<message> <message>
<source>usernameLabel</source> <source>usernameLabel</source>
<translation>Nom d&apos;utilisateur</translation> <translation>Nom d&apos;utilisateur</translation>
...@@ -283,27 +327,27 @@ Url du serveur non configurée.</translation> ...@@ -283,27 +327,27 @@ Url du serveur non configurée.</translation>
<name>CodecsViewer</name> <name>CodecsViewer</name>
<message> <message>
<source>codecMime</source> <source>codecMime</source>
<translation type="unfinished"></translation> <translation>Nom</translation>
</message> </message>
<message> <message>
<source>codecEncoderDescription</source> <source>codecEncoderDescription</source>
<translation type="unfinished"></translation> <translation>Description</translation>
</message> </message>
<message> <message>
<source>codecEncoderClockRate</source> <source>codecEncoderClockRate</source>
<translation type="unfinished"></translation> <translation>Fréquence (Hz)</translation>
</message> </message>
<message> <message>
<source>codecBitrate</source> <source>codecBitrate</source>
<translation type="unfinished"></translation> <translation>Débit (Kbit/s)</translation>
</message> </message>
<message> <message>
<source>codecRecvFmtp</source> <source>codecRecvFmtp</source>
<translation type="unfinished"></translation> <translation>Paramètres</translation>
</message> </message>
<message> <message>
<source>codecStatus</source> <source>codecStatus</source>
<translation type="unfinished"></translation> <translation>status</translation>
</message> </message>
</context> </context>
<context> <context>
......
...@@ -327,9 +327,13 @@ ...@@ -327,9 +327,13 @@
<file>ui/views/App/Calls/OutgoingCall.qml</file> <file>ui/views/App/Calls/OutgoingCall.qml</file>
<file>ui/views/App/Main/Assistant/AssistantAbstractView.qml</file> <file>ui/views/App/Main/Assistant/AssistantAbstractView.qml</file>
<file>ui/views/App/Main/Assistant/AssistantCreateLinphoneSipAccount.qml</file> <file>ui/views/App/Main/Assistant/AssistantCreateLinphoneSipAccount.qml</file>
<file>ui/views/App/Main/Assistant/AssistantCreateLinphoneSipAccountWithEmail.qml</file>
<file>ui/views/App/Main/Assistant/AssistantCreateLinphoneSipAccountWithPhoneNumber.qml</file>
<file>ui/views/App/Main/Assistant/AssistantFetchRemoteConfiguration.qml</file> <file>ui/views/App/Main/Assistant/AssistantFetchRemoteConfiguration.qml</file>
<file>ui/views/App/Main/Assistant/AssistantHome.qml</file> <file>ui/views/App/Main/Assistant/AssistantHome.qml</file>
<file>ui/views/App/Main/Assistant/AssistantUseLinphoneSipAccount.qml</file> <file>ui/views/App/Main/Assistant/AssistantUseLinphoneSipAccount.qml</file>
<file>ui/views/App/Main/Assistant/AssistantUseLinphoneSipAccountWithPhoneNumber.qml</file>
<file>ui/views/App/Main/Assistant/AssistantUseLinphoneSipAccountWithUsername.qml</file>
<file>ui/views/App/Main/Assistant/AssistantUseOtherSipAccount.qml</file> <file>ui/views/App/Main/Assistant/AssistantUseOtherSipAccount.qml</file>
<file>ui/views/App/Main/Assistant.qml</file> <file>ui/views/App/Main/Assistant.qml</file>
<file>ui/views/App/Main/ContactEdit.js</file> <file>ui/views/App/Main/ContactEdit.js</file>
......
...@@ -37,11 +37,22 @@ public: ...@@ -37,11 +37,22 @@ public:
m_assistant = assistant; m_assistant = assistant;
} }
// void onCreateAccount ( void onCreateAccount (
// const shared_ptr<linphone::AccountCreator> &creator, const shared_ptr<linphone::AccountCreator> &,
// linphone::AccountCreatorStatus status, linphone::AccountCreatorStatus status,
// const string &resp const string &
// ) override {} ) override {
if (status == linphone::AccountCreatorStatusAccountCreated)
emit m_assistant->createStatusChanged("");
else {
if (status == linphone::AccountCreatorStatusRequestFailed)
emit m_assistant->createStatusChanged(tr("requestFailed"));
else if (status == linphone::AccountCreatorStatusServerError)
emit m_assistant->createStatusChanged(tr("cannotSendSms"));
else
emit m_assistant->createStatusChanged(tr("accountAlreadyExists"));
}
}
void onIsAccountExist ( void onIsAccountExist (
const shared_ptr<linphone::AccountCreator> &creator, const shared_ptr<linphone::AccountCreator> &creator,
...@@ -125,29 +136,22 @@ AssistantModel::AssistantModel (QObject *parent) : QObject(parent) { ...@@ -125,29 +136,22 @@ AssistantModel::AssistantModel (QObject *parent) : QObject(parent) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void AssistantModel::setUsername (const QString &username) { void AssistantModel::setEmail (const QString &email) {
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig(); shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
QString error; QString error;
switch (m_account_creator->setUsername(::Utils::qStringToLinphoneString(username))) { switch (m_account_creator->setEmail(::Utils::qStringToLinphoneString(email))) {
case linphone::AccountCreatorUsernameStatusOk: case linphone::AccountCreatorEmailStatusOk:
break; break;
case linphone::AccountCreatorUsernameStatusTooShort: case linphone::AccountCreatorEmailStatusMalformed:
error = tr("usernameStatusTooShort").arg(config->getInt("assistant", "username_min_length", 1)); error = tr("emailStatusMalformed");
break;
case linphone::AccountCreatorUsernameStatusTooLong:
error = tr("usernameStatusTooLong").arg(config->getInt("assistant", "username_max_length", -1));
break;
case linphone::AccountCreatorUsernameStatusInvalidCharacters:
error = tr("usernameStatusInvalidCharacters")
.arg(::Utils::linphoneStringToQString(config->getString("assistant", "username_regex", "")));
break; break;
case linphone::AccountCreatorUsernameStatusInvalid: case linphone::AccountCreatorEmailStatusInvalidCharacters:
error = tr("usernameStatusInvalid"); error = tr("emailStatusMalformedInvalidCharacters");
break; break;
} }
emit usernameChanged(username, error); emit emailChanged(email, error);
} }
void AssistantModel::setPassword (const QString &password) { void AssistantModel::setPassword (const QString &password) {
...@@ -185,8 +189,46 @@ void AssistantModel::setPhoneNumber (const QString &phone_number) { ...@@ -185,8 +189,46 @@ void AssistantModel::setPhoneNumber (const QString &phone_number) {
emit phoneNumberChanged(phone_number, error); emit phoneNumberChanged(phone_number, error);
} }
void AssistantModel::setUsername (const QString &username) {
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
QString error;
switch (m_account_creator->setUsername(::Utils::qStringToLinphoneString(username))) {
case linphone::AccountCreatorUsernameStatusOk:
break;
case linphone::AccountCreatorUsernameStatusTooShort:
error = tr("usernameStatusTooShort").arg(config->getInt("assistant", "username_min_length", 1));
break;
case linphone::AccountCreatorUsernameStatusTooLong:
error = tr("usernameStatusTooLong").arg(config->getInt("assistant", "username_max_length", -1));
break;
case linphone::AccountCreatorUsernameStatusInvalidCharacters:
error = tr("usernameStatusInvalidCharacters")
.arg(::Utils::linphoneStringToQString(config->getString("assistant", "username_regex", "")));
break;
case linphone::AccountCreatorUsernameStatusInvalid:
error = tr("usernameStatusInvalid");
break;
}
emit usernameChanged(username, error);
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void AssistantModel::create () {
m_account_creator->createAccount();
}
void AssistantModel::login () { void AssistantModel::login () {
m_account_creator->isAccountExist(); m_account_creator->isAccountExist();
} }
void AssistantModel::reset () {
m_account_creator->reset();
emit emailChanged("", "");
emit passwordChanged("", "");
emit phoneNumberChanged("", "");
emit usernameChanged("", "");
}
...@@ -36,17 +36,22 @@ class AssistantModel : public QObject { ...@@ -36,17 +36,22 @@ class AssistantModel : public QObject {
public: public:
AssistantModel (QObject *parent = Q_NULLPTR); AssistantModel (QObject *parent = Q_NULLPTR);
Q_INVOKABLE void setUsername (const QString &username); Q_INVOKABLE void setEmail (const QString &email);
Q_INVOKABLE void setPassword (const QString &password); Q_INVOKABLE void setPassword (const QString &password);
Q_INVOKABLE void setPhoneNumber (const QString &phone_number); Q_INVOKABLE void setPhoneNumber (const QString &phone_number);
Q_INVOKABLE void setUsername (const QString &username);
Q_INVOKABLE void create ();
Q_INVOKABLE void login (); Q_INVOKABLE void login ();
Q_INVOKABLE void reset ();
signals: signals:
void usernameChanged (const QString &username, const QString &error); void emailChanged (const QString &email, const QString &error);
void passwordChanged (const QString &password, const QString &error); void passwordChanged (const QString &password, const QString &error);
void phoneNumberChanged (const QString &phone_number, const QString &error); void phoneNumberChanged (const QString &phone_number, const QString &error);
void usernameChanged (const QString &username, const QString &error);
void createStatusChanged (const QString &error);
void loginStatusChanged (const QString &error); void loginStatusChanged (const QString &error);
private: private:
......
...@@ -15,7 +15,7 @@ QtObject { ...@@ -15,7 +15,7 @@ QtObject {
property QtObject error: QtObject { property QtObject error: QtObject {
property color color: Colors.error property color color: Colors.error
property int fontSize: 10 property int fontSize: 10
property int height: 16 property int height: 11
} }
property QtObject legend: QtObject { property QtObject legend: QtObject {
......
...@@ -44,13 +44,17 @@ Item { ...@@ -44,13 +44,17 @@ Item {
width: parent.width width: parent.width
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
padding: RequestBlockStyle.error.padding
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
visible: !block.loading visible: !block.loading
} }
BusyIndicator { BusyIndicator {
anchors.centerIn: parent anchors {
horizontalCenter: parent.horizontalCenter
top: parent.top
}
height: RequestBlockStyle.loadingIndicator.height height: RequestBlockStyle.loadingIndicator.height
width: RequestBlockStyle.loadingIndicator.width width: RequestBlockStyle.loadingIndicator.width
......
...@@ -11,6 +11,7 @@ QtObject { ...@@ -11,6 +11,7 @@ QtObject {
property QtObject error: QtObject { property QtObject error: QtObject {
property color color: Colors.error property color color: Colors.error
property int fontSize: 11 property int fontSize: 11
property int padding: 4
} }
property QtObject loadingIndicator: QtObject { property QtObject loadingIndicator: QtObject {
......
...@@ -61,6 +61,8 @@ Item { ...@@ -61,6 +61,8 @@ Item {
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
width: parent.width width: parent.width
visible: text.length > 0
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
......
...@@ -7,133 +7,11 @@ import App.Styles 1.0 ...@@ -7,133 +7,11 @@ import App.Styles 1.0
// ============================================================================= // =============================================================================
AssistantAbstractView { AssistantAbstractView {
id: view
description: qsTr('createLinphoneSipAccountDescription') description: qsTr('createLinphoneSipAccountDescription')
title: qsTr('createLinphoneSipAccountTitle') title: qsTr('createLinphoneSipAccountTitle')
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Create with phone number. // Menu.
// ---------------------------------------------------------------------------
Component {
id: phoneNumberView
AssistantAbstractView {
mainAction: (function () {
console.log('TODO')
})
mainActionEnabled: country.currentIndex !== -1 &&
phoneNumber.text.length
mainActionLabel: qsTr('confirmAction')
title: view.title
Form {
anchors.fill: parent
orientation: Qt.Vertical
FormLine {
FormGroup {
label: qsTr('countryLabel')
ComboBox {
id: country
}
}
}
FormLine {
FormGroup {
label: qsTr('phoneNumberLabel')
TextField {
id: phoneNumber
}
}
}
FormLine {
FormGroup {
label: qsTr('usernameLabel')
TextField {}
}
}
}
}
}
// ---------------------------------------------------------------------------
// Create with email address.
// ---------------------------------------------------------------------------
Component {
id: emailAddressView
AssistantAbstractView {
mainAction: (function () {
console.log('TODO')
})
mainActionEnabled: username.text.length
&& email.text.length
&& password.text.length
&& passwordConfirmation.text === password.text
mainActionLabel: qsTr('confirmAction')
title: view.title
Form {
anchors.fill: parent
orientation: Qt.Vertical
FormLine {
FormGroup {
label: qsTr('usernameLabel')
TextField {
id: username
}
}
}
FormLine {
FormGroup {
label: qsTr('emailLabel')
TextField {
id: email
}
}
}
FormLine {
FormGroup {
label: qsTr('passwordLabel')
TextField {
id: password
}
}
}
FormLine {
FormGroup {
label: qsTr('passwordConfirmationLabel')
TextField {
id: passwordConfirmation
}
}
}
}
}
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
Column { Column {
...@@ -147,7 +25,7 @@ AssistantAbstractView { ...@@ -147,7 +25,7 @@ AssistantAbstractView {
height: AssistantCreateLinphoneSipAccountStyle.buttons.button.height height: AssistantCreateLinphoneSipAccountStyle.buttons.button.height
width: parent.width width: parent.width
onClicked: assistant.pushView(phoneNumberView) onClicked: assistant.pushView('AssistantCreateLinphoneSipAccountWithPhoneNumber')
} }
TextButtonA { TextButtonA {
...@@ -156,7 +34,7 @@ AssistantAbstractView { ...@@ -156,7 +34,7 @@ AssistantAbstractView {
height: AssistantCreateLinphoneSipAccountStyle.buttons.button.height height: AssistantCreateLinphoneSipAccountStyle.buttons.button.height
width: parent.width width: parent.width
onClicked: assistant.pushView(emailAddressView) onClicked: assistant.pushView('AssistantCreateLinphoneSipAccountWithEmail')
} }
} }
} }
import QtQuick 2.7
import Common 1.0
import Linphone 1.0
import App.Styles 1.0
// =============================================================================
AssistantAbstractView {
id: view
property alias emailError: email.error
property alias passwordError: password.error
property alias usernameError: username.error
title: qsTr('createLinphoneSipAccountTitle')
mainAction: requestBlock.execute
mainActionEnabled: email.text.length
&& password.text.length
&& passwordConfirmation.text === password.text
&& username.text.length
&& !emailError.length
&& !passwordError.length
&& !requestBlock.loading
&& !usernameError.length
mainActionLabel: qsTr('confirmAction')
Column {
anchors.fill: parent
Form {
dealWithErrors: true
orientation: Qt.Vertical
width: parent.width
FormLine {
FormGroup {
label: qsTr('usernameLabel')
TextField {
id: username
onTextChanged: assistantModel.setUsername(text)
}
}
}
FormLine {
FormGroup {
label: qsTr('emailLabel')
TextField {
id: email
onTextChanged: assistantModel.setEmail(text)
}
}
}
FormLine {
FormGroup {
label: qsTr('passwordLabel')
TextField {
id: password
onTextChanged: assistantModel.setPassword(text)
}
}
}
FormLine {
FormGroup {
label: qsTr('passwordConfirmationLabel')
TextField {
id: passwordConfirmation
onTextChanged: error = password.text !== text
? qsTr('passwordConfirmationError')
: ''
}
}
}
}
RequestBlock {
id: requestBlock
action: assistantModel.create
width: parent.width
}
}
// ---------------------------------------------------------------------------
// Assistant.
// ---------------------------------------------------------------------------
AssistantModel {
id: assistantModel
onEmailChanged: emailError = error
onPasswordChanged: passwordError = error
onUsernameChanged: usernameError = error
onCreateStatusChanged: {
requestBlock.stop(error)
if (!error.length) {
// TODO.
}
}
}
}
import QtQuick 2.7
import Common 1.0
import Linphone 1.0
import App.Styles 1.0
// =============================================================================
AssistantAbstractView {
id: view
property alias usernameError: username.error
title: qsTr('createLinphoneSipAccountTitle')
Form {
anchors.fill: parent
dealWithErrors: true
orientation: Qt.Vertical
FormLine {
FormGroup {
label: qsTr('countryLabel')
ComboBox {
id: country
}
}
}
FormLine {
FormGroup {
label: qsTr('phoneNumberLabel')
TextField {
id: phoneNumber
}
}
}
FormLine {
FormGroup {
label: qsTr('usernameLabel')
TextField {
id: username
onTextChanged: assistantModel.setUsername(text)
}
}
}
}
// ---------------------------------------------------------------------------
// Assistant.
// ---------------------------------------------------------------------------
AssistantModel {
id: assistantModel
onUsernameChanged: usernameError = error
onCreateStatusChanged: {
requestBlock.stop(error)
if (!error.length) {
// TODO.
}
}
}
}
...@@ -13,91 +13,10 @@ AssistantAbstractView { ...@@ -13,91 +13,10 @@ AssistantAbstractView {
var item = loader.item var item = loader.item
return item && item.mainActionEnabled && !requestBlock.loading return item && item.mainActionEnabled && !requestBlock.loading
} }
mainActionLabel: qsTr('confirmAction') mainActionLabel: qsTr('confirmAction')
title: qsTr('useLinphoneSipAccountTitle') title: qsTr('useLinphoneSipAccountTitle')
// ---------------------------------------------------------------------------
// Login with phone number.
// ---------------------------------------------------------------------------
Component {
id: phoneNumberForm
Form {
property bool mainActionEnabled: country.currentIndex !== -1 && phoneNumber.text
dealWithErrors: true
orientation: Qt.Vertical
FormLine {
FormGroup {
label: qsTr('countryLabel')
ComboBox {
id: country
}
}
}
FormLine {
FormGroup {
label: qsTr('phoneNumberLabel')
TextField {
id: phoneNumber
}
}
}
}
}
// ---------------------------------------------------------------------------
// Login with email address.
// ---------------------------------------------------------------------------
Component {
id: emailAddressForm
Form {
property bool mainActionEnabled: username.length &&
password.text &&
!usernameError.length &&
!passwordError.length
property alias usernameError: username.error
property alias passwordError: password.error
dealWithErrors: true
orientation: Qt.Vertical
FormLine {
FormGroup {
label: qsTr('usernameLabel')
TextField {
id: username
onTextChanged: assistantModel.setUsername(text)
}
}
}
FormLine {
FormGroup {
label: qsTr('passwordLabel')
TextField {
id: password
onTextChanged: assistantModel.setPassword(text)
}
}
}
}
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
Column { Column {
...@@ -106,7 +25,9 @@ AssistantAbstractView { ...@@ -106,7 +25,9 @@ AssistantAbstractView {
Loader { Loader {
id: loader id: loader
sourceComponent: checkBox.checked ? emailAddressForm : phoneNumberForm source: 'AssistantUseLinphoneSipAccountWith' + (
checkBox.checked ? 'Username' : 'PhoneNumber'
) + '.qml'
width: parent.width width: parent.width
} }
...@@ -116,7 +37,10 @@ AssistantAbstractView { ...@@ -116,7 +37,10 @@ AssistantAbstractView {
text: qsTr('useUsernameToLogin') text: qsTr('useUsernameToLogin')
width: AssistantUseLinphoneSipAccountStyle.checkBox.width width: AssistantUseLinphoneSipAccountStyle.checkBox.width
onClicked: requestBlock.stop('') onClicked: {
assistantModel.reset()
requestBlock.stop('')
}
} }
RequestBlock { RequestBlock {
...@@ -127,13 +51,24 @@ AssistantAbstractView { ...@@ -127,13 +51,24 @@ AssistantAbstractView {
} }
} }
// ---------------------------------------------------------------------------
// Assistant.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
AssistantModel { AssistantModel {
id: assistantModel id: assistantModel
onUsernameChanged: loader.item.usernameError = error onPasswordChanged: {
onPasswordChanged: loader.item.passwordError = error if (checkBox.checked) {
loader.item.passwordError = error
}
}
onUsernameChanged: {
if (checkBox.checked) {
loader.item.usernameError = error
}
}
onLoginStatusChanged: { onLoginStatusChanged: {
requestBlock.stop(error) requestBlock.stop(error)
......
import Common 1.0
// =============================================================================
Form {
property bool mainActionEnabled: country.currentIndex !== -1 && phoneNumber.text
dealWithErrors: true
orientation: Qt.Vertical
FormLine {
FormGroup {
label: qsTr('countryLabel')
ComboBox {
id: country
}
}
}
FormLine {
FormGroup {
label: qsTr('phoneNumberLabel')
TextField {
id: phoneNumber
}
}
}
}
import Common 1.0
// =============================================================================
Form {
property alias passwordError: password.error
property alias usernameError: username.error
property bool mainActionEnabled: password.text &&
username.length &&
!passwordError.length &&
!usernameError.length
dealWithErrors: true
orientation: Qt.Vertical
FormLine {
FormGroup {
label: qsTr('usernameLabel')
TextField {
id: username
onTextChanged: assistantModel.setUsername(text)
}
}
}
FormLine {
FormGroup {
label: qsTr('passwordLabel')
TextField {
id: password
onTextChanged: assistantModel.setPassword(text)
}
}
}
}
...@@ -12,20 +12,20 @@ QtObject { ...@@ -12,20 +12,20 @@ QtObject {
property QtObject description: QtObject { property QtObject description: QtObject {
property color color: Colors.g property color color: Colors.g
property int height: 40
property int fontSize: 10 property int fontSize: 10
property int height: 40
} }
property QtObject title: QtObject { property QtObject title: QtObject {
property color color: Colors.g property color color: Colors.g
property int height: 40
property int fontSize: 11 property int fontSize: 11
property int height: 40
} }
} }
property QtObject buttons: QtObject { property QtObject buttons: QtObject {
property int maxWidth: 690
property int height: 90 property int height: 90
property int maxWidth: 690
property int spacing: 5 property int spacing: 5
} }
} }
bzrtp @ 1d092f58
Subproject commit b5b5e00d49e000a84e69c473eb9cea7fdf5cab35 Subproject commit 1d092f58ec8e04c617e2288577cbedfab7bf9e6a
linphone @ a3fbb53b
Subproject commit b1ec18f963eca39cd8f4f8cac379b3c9598297e4 Subproject commit a3fbb53b246b53f5c19a5a8a6a0b9f7947e9d970
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