diff --git a/linphone-desktop/CMakeLists.txt b/linphone-desktop/CMakeLists.txt index a2dcfedc3..c7dc1cbdd 100644 --- a/linphone-desktop/CMakeLists.txt +++ b/linphone-desktop/CMakeLists.txt @@ -86,6 +86,7 @@ set(SOURCES src/app/providers/AvatarProvider.cpp src/app/providers/ThumbnailProvider.cpp src/app/translator/DefaultTranslator.cpp + src/components/assistant/AssistantModel.cpp src/components/call/CallModel.cpp src/components/calls/CallsListModel.cpp src/components/camera/Camera.cpp @@ -123,15 +124,17 @@ set(HEADERS src/app/providers/AvatarProvider.hpp src/app/providers/ThumbnailProvider.hpp src/app/translator/DefaultTranslator.hpp + src/components/assistant/AssistantModel.hpp src/components/camera/Camera.hpp - src/components/camera/MSFunctions.hpp src/components/call/CallModel.hpp src/components/calls/CallsListModel.hpp + src/components/camera/MSFunctions.hpp src/components/chat/ChatModel.hpp src/components/chat/ChatProxyModel.hpp src/components/codecs/AbstractCodecsModel.hpp src/components/codecs/AudioCodecsModel.hpp src/components/codecs/VideoCodecsModel.hpp + src/components/Components.hpp src/components/contact/ContactModel.hpp src/components/contact/VcardModel.hpp src/components/contacts/ContactsListModel.hpp diff --git a/linphone-desktop/assets/languages/en.ts b/linphone-desktop/assets/languages/en.ts index f93c6b93c..85c0c8f96 100644 --- a/linphone-desktop/assets/languages/en.ts +++ b/linphone-desktop/assets/languages/en.ts @@ -124,6 +124,49 @@ CREATE A LINPHONE ACCOUNT + + AssistantModel + + loginWithUsernameFailed + Login failed. Please check your username/password. + + + usernameStatusTooShort + Too short! (%1 characters min.) + + + usernameStatusTooLong + Too long! (%1 characters max.) + + + usernameStatusInvalidCharacters + Invalid characters detected. (regex: `%1`.) + + + usernameStatusInvalid + Invalid username. + + + passwordStatusTooShort + Too short! (%1 characters min.) + + + passwordStatusTooLong + Too long! (%1 characters max.) + + + passwordStatusInvalidCharacters + Invalid characters detected. (regex: `%1`.) + + + passwordStatusMissingCharacters + Missing characters: `%1`. + + + requestFailed + Unable to send the request. + + AssistantUseLinphoneSipAccount diff --git a/linphone-desktop/assets/languages/fr.ts b/linphone-desktop/assets/languages/fr.ts index 7d05b9ef1..8015ab83c 100644 --- a/linphone-desktop/assets/languages/fr.ts +++ b/linphone-desktop/assets/languages/fr.ts @@ -124,6 +124,49 @@ CRÉER UN COMPTE LINPHONE + + AssistantModel + + usernameStatusTooShort + Trop court ! (%1 caractères min.) + + + usernameStatusTooLong + Trop long ! (%1 caractères max.) + + + usernameStatusInvalidCharacters + Caractères invalides détectés. (regex: `%1`.) + + + usernameStatusInvalid + Nom d'utilisateur invalide. + + + passwordStatusTooShort + Trop court ! (%1 caractères min.) + + + passwordStatusTooLong + Trop long ! (%1 caractères max.)> + + + passwordStatusInvalidCharacters + Caractères invalides détectés. (regex: `%1`.) + + + passwordStatusMissingCharacters + Caractères manquants : `%1`. + + + requestFailed + Impossible d'envoyer la requête. + + + loginWithUsernameFailed + La connection a échouée. Merci de vérifier le nom d'utilisateur/mot de passe. + + AssistantUseLinphoneSipAccount diff --git a/linphone-desktop/resources.qrc b/linphone-desktop/resources.qrc index e77b6b600..9cfa758bf 100644 --- a/linphone-desktop/resources.qrc +++ b/linphone-desktop/resources.qrc @@ -263,10 +263,11 @@ ui/modules/Common/Window/Window.js ui/modules/Common/Window/Window.qml ui/modules/Linphone/Account/AccountStatus.qml + ui/modules/Linphone/Blocks/CardBlock.qml + ui/modules/Linphone/Blocks/RequestBlock.qml ui/modules/Linphone/Calls/CallControls.qml ui/modules/Linphone/Calls/Calls.js ui/modules/Linphone/Calls/Calls.qml - ui/modules/Linphone/CardBlock.qml ui/modules/Linphone/Chat/Chat.js ui/modules/Linphone/Chat/Chat.qml ui/modules/Linphone/Chat/Event.qml @@ -291,9 +292,10 @@ ui/modules/Linphone/qmldir ui/modules/Linphone/SmartSearchBar.qml ui/modules/Linphone/Styles/Account/AccountStatusStyle.qml + ui/modules/Linphone/Styles/Blocks/CardBlockStyle.qml + ui/modules/Linphone/Styles/Blocks/RequestBlockStyle.qml ui/modules/Linphone/Styles/Calls/CallControlsStyle.qml ui/modules/Linphone/Styles/Calls/CallsStyle.qml - ui/modules/Linphone/Styles/CardBlockStyle.qml ui/modules/Linphone/Styles/ChatStyle.qml ui/modules/Linphone/Styles/Codecs/CodecsViewerStyle.qml ui/modules/Linphone/Styles/Contact/AvatarStyle.qml diff --git a/linphone-desktop/src/app/App.cpp b/linphone-desktop/src/app/App.cpp index 2eaef604c..4af3af5c8 100644 --- a/linphone-desktop/src/app/App.cpp +++ b/linphone-desktop/src/app/App.cpp @@ -20,17 +20,7 @@ * Author: Ronan Abhamon */ -#include "../components/calls/CallsListModel.hpp" -#include "../components/camera/Camera.hpp" -#include "../components/chat/ChatProxyModel.hpp" -#include "../components/codecs/AudioCodecsModel.hpp" -#include "../components/codecs/VideoCodecsModel.hpp" -#include "../components/contacts/ContactsListProxyModel.hpp" -#include "../components/core/CoreManager.hpp" -#include "../components/presence/OwnPresenceModel.hpp" -#include "../components/settings/AccountSettingsModel.hpp" -#include "../components/smart-search-bar/SmartSearchBarModel.hpp" -#include "../components/timeline/TimelineModel.hpp" +#include "../components/Components.hpp" #include "../utils.hpp" #include "logger/Logger.hpp" @@ -269,6 +259,7 @@ void registerSingletonType (const char *name) { void App::registerTypes () { qInfo() << "Registering types..."; + qmlRegisterType("Linphone", 1, 0, "AssistantModel"); qmlRegisterType("Linphone", 1, 0, "Camera"); qmlRegisterType("Linphone", 1, 0, "ContactsListProxyModel"); qmlRegisterType("Linphone", 1, 0, "ChatModel"); @@ -291,10 +282,10 @@ void App::registerTypes () { ); registerSingletonType("AccountSettingsModel"); + registerSingletonType("AudioCodecsModel"); registerSingletonType("OwnPresenceModel"); registerSingletonType("Presence"); registerSingletonType("TimelineModel"); - registerSingletonType("AudioCodecsModel"); registerSingletonType("VideoCodecsModel"); registerSharedSingletonType(App, "App", App::getInstance); diff --git a/linphone-desktop/src/components/Components.hpp b/linphone-desktop/src/components/Components.hpp new file mode 100644 index 000000000..e340c3296 --- /dev/null +++ b/linphone-desktop/src/components/Components.hpp @@ -0,0 +1,34 @@ +/* + * Components.hpp + * Copyright (C) 2017 Belledonne Communications, Grenoble, France + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Created on: April 6, 2017 + * Author: Ronan Abhamon + */ + +#include "assistant/AssistantModel.hpp" +#include "calls/CallsListModel.hpp" +#include "camera/Camera.hpp" +#include "chat/ChatProxyModel.hpp" +#include "codecs/AudioCodecsModel.hpp" +#include "codecs/VideoCodecsModel.hpp" +#include "contacts/ContactsListProxyModel.hpp" +#include "core/CoreManager.hpp" +#include "presence/OwnPresenceModel.hpp" +#include "settings/AccountSettingsModel.hpp" +#include "smart-search-bar/SmartSearchBarModel.hpp" +#include "timeline/TimelineModel.hpp" diff --git a/linphone-desktop/src/components/assistant/AssistantModel.cpp b/linphone-desktop/src/components/assistant/AssistantModel.cpp new file mode 100644 index 000000000..bd1d33d9e --- /dev/null +++ b/linphone-desktop/src/components/assistant/AssistantModel.cpp @@ -0,0 +1,183 @@ +/* + * AssistantModel.cpp + * Copyright (C) 2017 Belledonne Communications, Grenoble, France + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Created on: April 6, 2017 + * Author: Ronan Abhamon + */ + +#include "../../utils.hpp" +#include "../core/CoreManager.hpp" + +#include "AssistantModel.hpp" + +#define DEFAULT_XMLRPC_URL "https://subscribe.linphone.org:444/wizard.php" + +using namespace std; + +// ============================================================================= + +class AssistantModel::Handlers : public linphone::AccountCreatorListener { +public: + Handlers (AssistantModel *assistant) { + m_assistant = assistant; + } + + void onCreateAccount ( + const shared_ptr &creator, + linphone::AccountCreatorStatus status, + const string &resp + ) override {} + + void onIsAccountExist ( + const shared_ptr &creator, + linphone::AccountCreatorStatus status, + const string & + ) override { + if (status == linphone::AccountCreatorStatusAccountExist || status == linphone::AccountCreatorStatusAccountExistWithAlias) { + CoreManager::getInstance()->getCore()->addProxyConfig(creator->configure()); + emit m_assistant->loginStatusChanged(""); + } else { + if (status == linphone::AccountCreatorStatusRequestFailed) + emit m_assistant->loginStatusChanged(tr("requestFailed")); + else + emit m_assistant->loginStatusChanged(tr("loginWithUsernameFailed")); + } + } + + void onActivateAccount ( + const shared_ptr &creator, + linphone::AccountCreatorStatus status, + const string &resp + ) override {} + + void onIsAccountActivated ( + const shared_ptr &creator, + linphone::AccountCreatorStatus status, + const string &resp + ) override {} + + void onLinkAccount ( + const shared_ptr &creator, + linphone::AccountCreatorStatus status, + const string &resp + ) override {} + + void onActivateAlias ( + const shared_ptr &creator, + linphone::AccountCreatorStatus status, + const string &resp + ) override {} + + void onIsAliasUsed ( + const shared_ptr &creator, + linphone::AccountCreatorStatus status, + const string &resp + ) override {} + + void onIsAccountLinked ( + const shared_ptr &creator, + linphone::AccountCreatorStatus status, + const string &resp + ) override {} + + void onRecoverAccount ( + const shared_ptr &creator, + linphone::AccountCreatorStatus status, + const string &resp + ) override {} + + void onUpdateAccount ( + const shared_ptr &creator, + linphone::AccountCreatorStatus status, + const string &resp + ) override {} + +private: + AssistantModel *m_assistant; +}; + +// ----------------------------------------------------------------------------- + +AssistantModel::AssistantModel (QObject *parent) : QObject(parent) { + m_handlers = make_shared(this); + + shared_ptr core = CoreManager::getInstance()->getCore(); + m_account_creator = core->createAccountCreator( + core->getConfig()->getString("assistant", "xmlrpc_url", DEFAULT_XMLRPC_URL) + ); + m_account_creator->setListener(m_handlers); +} + +// ----------------------------------------------------------------------------- + +void AssistantModel::setUsername (const QString &username) { + shared_ptr 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::setPassword (const QString &password) { + shared_ptr config = CoreManager::getInstance()->getCore()->getConfig(); + QString error; + + switch (m_account_creator->setPassword(::Utils::qStringToLinphoneString(password))) { + case linphone::AccountCreatorPasswordStatusOk: + break; + case linphone::AccountCreatorPasswordStatusTooShort: + error = tr("passwordStatusTooShort").arg(config->getInt("assistant", "password_min_length", 1)); + break; + case linphone::AccountCreatorPasswordStatusTooLong: + error = tr("passwordStatusTooLong").arg(config->getInt("assistant", "password_max_length", -1)); + break; + case linphone::AccountCreatorPasswordStatusInvalidCharacters: + error = tr("passwordStatusInvalidCharacters") + .arg(::Utils::linphoneStringToQString(config->getString("assistant", "password_regex", ""))); + break; + case linphone::AccountCreatorPasswordStatusMissingCharacters: + error = tr("passwordStatusMissingCharacters") + .arg(::Utils::linphoneStringToQString(config->getString("assistant", "missing_characters", ""))); + break; + } + + emit passwordChanged(password, error); +} + +// ----------------------------------------------------------------------------- + +void AssistantModel::login () { + m_account_creator->isAccountExist(); +} diff --git a/linphone-desktop/src/components/assistant/AssistantModel.hpp b/linphone-desktop/src/components/assistant/AssistantModel.hpp new file mode 100644 index 000000000..846e09296 --- /dev/null +++ b/linphone-desktop/src/components/assistant/AssistantModel.hpp @@ -0,0 +1,55 @@ +/* + * AssistantModel.hpp + * Copyright (C) 2017 Belledonne Communications, Grenoble, France + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Created on: April 6, 2017 + * Author: Ronan Abhamon + */ + +#ifndef ASSISTANT_MODEL_H_ +#define ASSISTANT_MODEL_H_ + +#include +#include + +// ============================================================================= + +class AssistantModel : public QObject { + class Handlers; + + Q_OBJECT; + +public: + AssistantModel (QObject *parent = Q_NULLPTR); + + Q_INVOKABLE void setUsername (const QString &username); + Q_INVOKABLE void setPassword (const QString &password); + + Q_INVOKABLE void login (); + +signals: + void usernameChanged (const QString &username, const QString &error); + void passwordChanged (const QString &password, const QString &error); + + void loginStatusChanged (const QString &error); + +private: + std::shared_ptr m_account_creator; + std::shared_ptr m_handlers; +}; + +#endif // ASSISTANT_MODEL_H_ diff --git a/linphone-desktop/ui/modules/Common/Constants/Colors.qml b/linphone-desktop/ui/modules/Common/Constants/Colors.qml index 2560edf57..529c20a42 100644 --- a/linphone-desktop/ui/modules/Common/Constants/Colors.qml +++ b/linphone-desktop/ui/modules/Common/Constants/Colors.qml @@ -38,4 +38,6 @@ QtObject { property color x: '#96A5B1' property color y: '#D0D8DE' property color z: '#17A81A' + + property color error: '#FF0000' } diff --git a/linphone-desktop/ui/modules/Common/Form/Fields/TextField.qml b/linphone-desktop/ui/modules/Common/Form/Fields/TextField.qml index 399a500b7..b17fcc6f2 100644 --- a/linphone-desktop/ui/modules/Common/Form/Fields/TextField.qml +++ b/linphone-desktop/ui/modules/Common/Form/Fields/TextField.qml @@ -12,11 +12,14 @@ Controls.TextField { id: textField property alias icon: icon.icon + property string error: '' property var tools background: Rectangle { border { - color: TextFieldStyle.background.border.color + color: textField.error.length > 0 + ? TextFieldStyle.background.border.color.error + : TextFieldStyle.background.border.color.normal width: TextFieldStyle.background.border.width } @@ -39,7 +42,9 @@ Controls.TextField { id: toolsContainer border { - color: TextFieldStyle.background.border.color + color: textField.error.length > 0 + ? TextFieldStyle.background.border.color.error + : TextFieldStyle.background.border.color.normal width: TextFieldStyle.background.border.width } diff --git a/linphone-desktop/ui/modules/Common/Form/Placements/Form.qml b/linphone-desktop/ui/modules/Common/Form/Placements/Form.qml index e09b45520..78da135eb 100644 --- a/linphone-desktop/ui/modules/Common/Form/Placements/Form.qml +++ b/linphone-desktop/ui/modules/Common/Form/Placements/Form.qml @@ -7,6 +7,7 @@ import Common.Styles 1.0 Column { property alias title: title.text + property bool dealWithErrors: false property int orientation: Qt.Horizontal // --------------------------------------------------------------------------- diff --git a/linphone-desktop/ui/modules/Common/Form/Placements/FormGroup.qml b/linphone-desktop/ui/modules/Common/Form/Placements/FormGroup.qml index 169fa590c..9364ad49a 100644 --- a/linphone-desktop/ui/modules/Common/Form/Placements/FormGroup.qml +++ b/linphone-desktop/ui/modules/Common/Form/Placements/FormGroup.qml @@ -9,6 +9,7 @@ Loader { property string label readonly property int orientation: parent.orientation + readonly property bool dealWithErrors: parent.dealWithErrors default property var _content: null diff --git a/linphone-desktop/ui/modules/Common/Form/Placements/FormLine.qml b/linphone-desktop/ui/modules/Common/Form/Placements/FormLine.qml index bcf1cd838..bb79ddd17 100644 --- a/linphone-desktop/ui/modules/Common/Form/Placements/FormLine.qml +++ b/linphone-desktop/ui/modules/Common/Form/Placements/FormLine.qml @@ -15,6 +15,7 @@ Row { return curWidth < maxWidth ? curWidth : maxWidth } readonly property int orientation: parent.orientation + readonly property bool dealWithErrors: parent.dealWithErrors // --------------------------------------------------------------------------- diff --git a/linphone-desktop/ui/modules/Common/Form/Placements/FormVGroup.qml b/linphone-desktop/ui/modules/Common/Form/Placements/FormVGroup.qml index 27c8bcdf1..ab59b91c1 100644 --- a/linphone-desktop/ui/modules/Common/Form/Placements/FormVGroup.qml +++ b/linphone-desktop/ui/modules/Common/Form/Placements/FormVGroup.qml @@ -54,4 +54,20 @@ ColumnLayout { } } } + + Text { + Layout.fillWidth: true + Layout.preferredHeight: FormVGroupStyle.error.height + + color: FormVGroupStyle.error.color + elide: Text.ElideRight + + font { + italic: true + pointSize: FormVGroupStyle.error.fontSize + } + + text: _content && _content.error && _content.error.length ? _content.error : '' + visible: parent.parent.dealWithErrors + } } diff --git a/linphone-desktop/ui/modules/Common/Styles/Form/Fields/TextFieldStyle.qml b/linphone-desktop/ui/modules/Common/Styles/Form/Fields/TextFieldStyle.qml index 7ee2b57a4..529c0f78f 100644 --- a/linphone-desktop/ui/modules/Common/Styles/Form/Fields/TextFieldStyle.qml +++ b/linphone-desktop/ui/modules/Common/Styles/Form/Fields/TextFieldStyle.qml @@ -13,7 +13,11 @@ QtObject { property int radius: 4 property QtObject border: QtObject { - property color color: Colors.c + property QtObject color: QtObject { + property color error: Colors.error + property color normal: Colors.c + } + property int width: 1 } diff --git a/linphone-desktop/ui/modules/Common/Styles/Form/Placements/FormVGroupStyle.qml b/linphone-desktop/ui/modules/Common/Styles/Form/Placements/FormVGroupStyle.qml index e7e6db8dd..1dda212e7 100644 --- a/linphone-desktop/ui/modules/Common/Styles/Form/Placements/FormVGroupStyle.qml +++ b/linphone-desktop/ui/modules/Common/Styles/Form/Placements/FormVGroupStyle.qml @@ -12,6 +12,12 @@ QtObject { property int maxWidth: 400 } + property QtObject error: QtObject { + property color color: Colors.error + property int fontSize: 10 + property int height: 16 + } + property QtObject legend: QtObject { property color color: Colors.j property int fontSize: 10 diff --git a/linphone-desktop/ui/modules/Linphone/CardBlock.qml b/linphone-desktop/ui/modules/Linphone/Blocks/CardBlock.qml similarity index 100% rename from linphone-desktop/ui/modules/Linphone/CardBlock.qml rename to linphone-desktop/ui/modules/Linphone/Blocks/CardBlock.qml diff --git a/linphone-desktop/ui/modules/Linphone/Blocks/RequestBlock.qml b/linphone-desktop/ui/modules/Linphone/Blocks/RequestBlock.qml new file mode 100644 index 000000000..dec143cee --- /dev/null +++ b/linphone-desktop/ui/modules/Linphone/Blocks/RequestBlock.qml @@ -0,0 +1,60 @@ +import QtQuick 2.7 + +import Common 1.0 +import Linphone.Styles 1.0 + +// ============================================================================= + +Item { + id: block + + property var action + readonly property alias loading: block._loading + + property bool _loading: false + + // ---------------------------------------------------------------------------- + + function execute () { + block._loading = true + action() + } + + function stop (error) { + errorBlock.text = error + block._loading = false + } + + // ---------------------------------------------------------------------------- + + height: RequestBlockStyle.height + + Text { + id: errorBlock + + color: RequestBlockStyle.error.color + elide: Text.ElideRight + + font { + italic: true + pointSize: RequestBlockStyle.error.fontSize + } + + height: parent.height + width: parent.width + + horizontalAlignment: Text.AlignHCenter + wrapMode: Text.WordWrap + + visible: !block.loading + } + + BusyIndicator { + anchors.centerIn: parent + + height: RequestBlockStyle.loadingIndicator.height + width: RequestBlockStyle.loadingIndicator.width + + running: block.loading + } +} diff --git a/linphone-desktop/ui/modules/Linphone/Styles/CardBlockStyle.qml b/linphone-desktop/ui/modules/Linphone/Styles/Blocks/CardBlockStyle.qml similarity index 100% rename from linphone-desktop/ui/modules/Linphone/Styles/CardBlockStyle.qml rename to linphone-desktop/ui/modules/Linphone/Styles/Blocks/CardBlockStyle.qml diff --git a/linphone-desktop/ui/modules/Linphone/Styles/Blocks/RequestBlockStyle.qml b/linphone-desktop/ui/modules/Linphone/Styles/Blocks/RequestBlockStyle.qml new file mode 100644 index 000000000..8ccebca70 --- /dev/null +++ b/linphone-desktop/ui/modules/Linphone/Styles/Blocks/RequestBlockStyle.qml @@ -0,0 +1,20 @@ +pragma Singleton +import QtQuick 2.7 + +import Common 1.0 + +// ============================================================================= + +QtObject { + property int height: 60 + + property QtObject error: QtObject { + property color color: Colors.error + property int fontSize: 11 + } + + property QtObject loadingIndicator: QtObject { + property int height: 20 + property int width: 20 + } +} diff --git a/linphone-desktop/ui/modules/Linphone/Styles/qmldir b/linphone-desktop/ui/modules/Linphone/Styles/qmldir index 3e691cb5f..9682d909c 100644 --- a/linphone-desktop/ui/modules/Linphone/Styles/qmldir +++ b/linphone-desktop/ui/modules/Linphone/Styles/qmldir @@ -6,7 +6,8 @@ module Linphone.Styles singleton AccountStatusStyle 1.0 Account/AccountStatusStyle.qml -singleton CardBlockStyle 1.0 CardBlockStyle.qml +singleton CardBlockStyle 1.0 Blocks/CardBlockStyle.qml +singleton RequestBlockStyle 1.0 Blocks/RequestBlockStyle.qml singleton ChatStyle 1.0 ChatStyle.qml diff --git a/linphone-desktop/ui/modules/Linphone/qmldir b/linphone-desktop/ui/modules/Linphone/qmldir index ca67e14fd..280bc4707 100644 --- a/linphone-desktop/ui/modules/Linphone/qmldir +++ b/linphone-desktop/ui/modules/Linphone/qmldir @@ -8,7 +8,8 @@ module Linphone AccountStatus 1.0 Account/AccountStatus.qml -CardBlock 1.0 CardBlock.qml +CardBlock 1.0 Blocks/CardBlock.qml +RequestBlock 1.0 Blocks/RequestBlock.qml Calls 1.0 Calls/Calls.qml diff --git a/linphone-desktop/ui/views/App/Main/Assistant/AssistantUseLinphoneSipAccount.qml b/linphone-desktop/ui/views/App/Main/Assistant/AssistantUseLinphoneSipAccount.qml index d66dfa5d2..23d343e76 100644 --- a/linphone-desktop/ui/views/App/Main/Assistant/AssistantUseLinphoneSipAccount.qml +++ b/linphone-desktop/ui/views/App/Main/Assistant/AssistantUseLinphoneSipAccount.qml @@ -1,19 +1,17 @@ import QtQuick 2.7 import Common 1.0 +import Linphone 1.0 import App.Styles 1.0 // ============================================================================= AssistantAbstractView { - mainAction: (function () { - console.log('TODO') - }) - + mainAction: requestBlock.execute mainActionEnabled: { var item = loader.item - return item && item.mainActionEnabled + return item && item.mainActionEnabled && !requestBlock.loading } mainActionLabel: qsTr('confirmAction') @@ -30,6 +28,7 @@ AssistantAbstractView { Form { property bool mainActionEnabled: country.currentIndex !== -1 && phoneNumber.text + dealWithErrors: true orientation: Qt.Vertical FormLine { @@ -62,8 +61,15 @@ AssistantAbstractView { id: emailAddressForm Form { - property bool mainActionEnabled: username.length && password.text + 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 { @@ -72,6 +78,8 @@ AssistantAbstractView { TextField { id: username + + onTextChanged: assistantModel.setUsername(text) } } } @@ -82,6 +90,8 @@ AssistantAbstractView { TextField { id: password + + onTextChanged: assistantModel.setPassword(text) } } } @@ -92,7 +102,6 @@ AssistantAbstractView { Column { anchors.fill: parent - spacing: AssistantUseLinphoneSipAccountStyle.spacing Loader { id: loader @@ -107,5 +116,28 @@ AssistantAbstractView { text: qsTr('useUsernameToLogin') width: AssistantUseLinphoneSipAccountStyle.checkBox.width } + + RequestBlock { + id: requestBlock + + action: assistantModel.login + width: parent.width + } + } + + // --------------------------------------------------------------------------- + + AssistantModel { + id: assistantModel + + onUsernameChanged: loader.item.usernameError = error + onPasswordChanged: loader.item.passwordError = error + + onLoginStatusChanged: { + requestBlock.stop(error) + if (!error.length) { + window.setView('Home') + } + } } } diff --git a/linphone-desktop/ui/views/App/Styles/Main/Assistant/AssistantUseLinphoneSipAccountStyle.qml b/linphone-desktop/ui/views/App/Styles/Main/Assistant/AssistantUseLinphoneSipAccountStyle.qml index bf2190daa..2caddd29a 100644 --- a/linphone-desktop/ui/views/App/Styles/Main/Assistant/AssistantUseLinphoneSipAccountStyle.qml +++ b/linphone-desktop/ui/views/App/Styles/Main/Assistant/AssistantUseLinphoneSipAccountStyle.qml @@ -4,8 +4,6 @@ import QtQuick 2.7 // ============================================================================= QtObject { - property int spacing: 20 - property QtObject checkBox: QtObject { property int width: 300 }