diff --git a/linphone-desktop/assets/languages/en.ts b/linphone-desktop/assets/languages/en.ts index 3a6717555..5fa26da64 100644 --- a/linphone-desktop/assets/languages/en.ts +++ b/linphone-desktop/assets/languages/en.ts @@ -543,7 +543,7 @@ Server url not configured. ManageAccounts manageAccountsDescription - Select your active account and choose all necessary presence status. + Select your active account and choose all necessary presence status. manageAccountsTitle @@ -551,47 +551,55 @@ Server url not configured. validate - VALIDATE + VALIDATE onlinePresence - Connected + Connected busyPresence - Busy + Busy beRightBackPresence - Be right back + Be right back awayPresence - Away + Away onThePhonePresence - On the phone + On the phone outToLunchPresence - Out to lunch + Out to lunch doNotDisturbPresence - Away + Away movedPresence - Moved + Moved usingAnotherMessagingServicePresence - Using another messaging service + Using another messaging service offlinePresence - Disconnected + Disconnected + + + ok + OK + + + selectAccountLabel + Select you active account diff --git a/linphone-desktop/assets/languages/fr.ts b/linphone-desktop/assets/languages/fr.ts index 9a9a592ef..cfac80e04 100644 --- a/linphone-desktop/assets/languages/fr.ts +++ b/linphone-desktop/assets/languages/fr.ts @@ -542,7 +542,7 @@ Url du serveur non configurée. ManageAccounts manageAccountsDescription - Sélectionner votre compte actif ainsi que vos status de présence. + Sélectionner votre compte actif ainsi que vos status de présence. manageAccountsTitle @@ -550,47 +550,55 @@ Url du serveur non configurée. validate - VALIDER + VALIDER onlinePresence - Disponible + Disponible busyPresence - Occupé + Occupé beRightBackPresence - De retour + De retour awayPresence - Absent + Absent onThePhonePresence - Au téléphone + Au téléphone outToLunchPresence - A table + A table doNotDisturbPresence - Ne pas déranger + Ne pas déranger movedPresence - Parti + Parti usingAnotherMessagingServicePresence - Utilisation d'un autre service de messagerie + Utilisation d'un autre service de messagerie offlinePresence - Déconnecté + Déconnecté + + + ok + OK + + + selectAccountLabel + Sélectionner votre compte principal diff --git a/linphone-desktop/resources.qrc b/linphone-desktop/resources.qrc index 07c9622f4..28435bd68 100644 --- a/linphone-desktop/resources.qrc +++ b/linphone-desktop/resources.qrc @@ -337,6 +337,7 @@ ui/views/App/Styles/Main/HomeStyle.qml ui/views/App/Styles/Main/MainWindowMenuBarStyle.qml ui/views/App/Styles/Main/MainWindowStyle.qml + ui/views/App/Styles/ManageAccountsStyle.qml ui/views/App/Styles/qmldir ui/views/App/Styles/Settings/SettingsWindowStyle.qml diff --git a/linphone-desktop/src/components/settings/AccountSettingsModel.cpp b/linphone-desktop/src/components/settings/AccountSettingsModel.cpp index 2c3a848d3..b95ba2e9e 100644 --- a/linphone-desktop/src/components/settings/AccountSettingsModel.cpp +++ b/linphone-desktop/src/components/settings/AccountSettingsModel.cpp @@ -29,10 +29,13 @@ // ============================================================================= -AccountSettingsModel::AccountSettingsModel (QObject *parent) : QObject(parent) { - m_default_proxy = CoreManager::getInstance()->getCore()->getDefaultProxyConfig(); +void AccountSettingsModel::setDefaultProxyConfig (const shared_ptr &proxy_config) { + CoreManager::getInstance()->getCore()->setDefaultProxyConfig(proxy_config); + emit accountUpdated(); } +// ----------------------------------------------------------------------------- + QString AccountSettingsModel::getUsername () const { shared_ptr address = getDefaultSipAddress(); const string &display_name = address->getDisplayName(); @@ -52,6 +55,8 @@ void AccountSettingsModel::setUsername (const QString &username) { emit accountUpdated(); } +// ----------------------------------------------------------------------------- + Presence::PresenceLevel AccountSettingsModel::getPresenceLevel () const { return Presence::Green; } @@ -60,15 +65,38 @@ Presence::PresenceStatus AccountSettingsModel::getPresenceStatus () const { return Presence::Online; } +// ----------------------------------------------------------------------------- + QString AccountSettingsModel::getSipAddress () const { return ::Utils::linphoneStringToQString(getDefaultSipAddress()->asStringUriOnly()); } +QVariantList AccountSettingsModel::getAccounts () const { + shared_ptr core = CoreManager::getInstance()->getCore(); + QVariantList accounts; + + { + QVariantMap account; + account["sipAddress"] = ::Utils::linphoneStringToQString(core->getPrimaryContactParsed()->asStringUriOnly()); + account["proxyConfig"].setValue(shared_ptr()); + accounts << account; + } + + for (const auto &proxy_config : core->getProxyConfigList()) { + QVariantMap account; + account["sipAddress"] = ::Utils::linphoneStringToQString(proxy_config->getIdentityAddress()->asStringUriOnly()); + account["proxyConfig"].setValue(proxy_config); + accounts << account; + } + + return accounts; +} + // ----------------------------------------------------------------------------- shared_ptr AccountSettingsModel::getDefaultSipAddress () const { - if (m_default_proxy) - return m_default_proxy->getIdentityAddress(); + shared_ptr core = CoreManager::getInstance()->getCore(); + shared_ptr proxy_config = core->getDefaultProxyConfig(); - return CoreManager::getInstance()->getCore()->getPrimaryContactParsed(); + return proxy_config ? proxy_config->getIdentityAddress() : core->getPrimaryContactParsed(); } diff --git a/linphone-desktop/src/components/settings/AccountSettingsModel.hpp b/linphone-desktop/src/components/settings/AccountSettingsModel.hpp index 11b1a36a5..08f9f0f0d 100644 --- a/linphone-desktop/src/components/settings/AccountSettingsModel.hpp +++ b/linphone-desktop/src/components/settings/AccountSettingsModel.hpp @@ -27,28 +27,22 @@ #include -// =================================================================== +// ============================================================================= class AccountSettingsModel : public QObject { Q_OBJECT; Q_PROPERTY(QString username READ getUsername WRITE setUsername NOTIFY accountUpdated); Q_PROPERTY(QString sipAddress READ getSipAddress NOTIFY accountUpdated); + Q_PROPERTY(QVariantList accounts READ getAccounts NOTIFY accountUpdated); - Q_PROPERTY( - Presence::PresenceLevel presenceLevel - READ getPresenceLevel - CONSTANT - ); - - Q_PROPERTY( - Presence::PresenceStatus presenceStatus - READ getPresenceStatus - CONSTANT - ); + Q_PROPERTY(Presence::PresenceLevel presenceLevel READ getPresenceLevel CONSTANT); + Q_PROPERTY(Presence::PresenceStatus presenceStatus READ getPresenceStatus CONSTANT); public: - AccountSettingsModel (QObject *parent = Q_NULLPTR); + AccountSettingsModel (QObject *parent = Q_NULLPTR) : QObject(parent) {} + + Q_INVOKABLE void setDefaultProxyConfig (const std::shared_ptr &proxy_config); signals: void accountUpdated (); @@ -61,10 +55,11 @@ private: Presence::PresenceStatus getPresenceStatus () const; QString getSipAddress () const; + QVariantList getAccounts () const; std::shared_ptr getDefaultSipAddress () const; - - std::shared_ptr m_default_proxy; }; +Q_DECLARE_METATYPE(std::shared_ptr ); + #endif // ACCOUNT_SETTINGS_MODEL_H_ diff --git a/linphone-desktop/ui/modules/Common/Form/ComboBox.qml b/linphone-desktop/ui/modules/Common/Form/ComboBox.qml index 29004747d..fb19d0c44 100644 --- a/linphone-desktop/ui/modules/Common/Form/ComboBox.qml +++ b/linphone-desktop/ui/modules/Common/Form/ComboBox.qml @@ -9,8 +9,6 @@ import Common.Styles 1.0 ComboBox { id: comboBox - textRole: 'key' - // --------------------------------------------------------------------------- background: Rectangle { @@ -67,7 +65,9 @@ ComboBox { font.bold: comboBox.currentIndex === index hoverEnabled: true - text: key + text: textRole.length + ? (typeof modelData !== 'undefined' ? modelData[textRole] : model[textRole]) + : modelData width: comboBox.width } } diff --git a/linphone-desktop/ui/views/App/ManageAccounts.qml b/linphone-desktop/ui/views/App/ManageAccounts.qml index ebf5fce0c..50c1bd1ca 100644 --- a/linphone-desktop/ui/views/App/ManageAccounts.qml +++ b/linphone-desktop/ui/views/App/ManageAccounts.qml @@ -1,139 +1,68 @@ import QtQuick 2.7 -import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 import Common 1.0 import Linphone 1.0 +import Utils 1.0 + +import App.Styles 1.0 + +// ============================================================================= DialogPlus { - descriptionText: qsTr('manageAccountsDescription') - minimumHeight: 328 - minimumWidth: 480 + buttons: [ + TextButtonB { + text: qsTr('ok') + + onClicked: exit(0) + } + ] + + centeredButtons: true title: qsTr('manageAccountsTitle') - buttons: TextButtonA { - text: qsTr('validate') - onClicked: exit(0) - } + height: ManageAccountsStyle.height + width: ManageAccountsStyle.width - // TODO: Compute list max. - ScrollableListView { - id: accounts + minimumHeight: ManageAccountsStyle.height + minimumWidth: ManageAccountsStyle.width + maximumHeight: ManageAccountsStyle.height + maximumWidth: ManageAccountsStyle.width - anchors.fill: parent - model: model1 // TMP + // --------------------------------------------------------------------------- - delegate: Item { - function isDefaultAccount () { - return accounts.currentIndex === index + Column { + anchors { + fill: parent + leftMargin: ManageAccountsStyle.leftMargin + rightMargin: ManageAccountsStyle.rightMargin + } + + spacing: ManageAccountsStyle.input.spacing + + Text { + color: ManageAccountsStyle.input.legend.color + elide: Text.ElideRight + + font { + bold: true + pointSize: ManageAccountsStyle.input.legend.fontSize } - height: 34 - width: parent.width - - Rectangle { - anchors.fill: parent - color: isDefaultAccount() ? '#EAEAEA' : 'transparent' - - RowLayout { - anchors.fill: parent - anchors.leftMargin: 15 - anchors.rightMargin: 15 - spacing: 15 - - // Is default account? - Icon { - Layout.preferredHeight: 20 - Layout.preferredWidth: 20 - icon: isDefaultAccount() ? 'valid' : '' - } - - // Sip account. - Text { - Layout.fillWidth: true - clip: true - color: '#59575A' - text: $sipAddress - verticalAlignment: Text.AlignVCenter - - MouseArea { - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - onClicked: accounts.currentIndex = index - } - } - - // Presence. - Icon { - Layout.preferredHeight: 20 // TMP - Layout.preferredWidth: 20 // TMP - icon: 'led_' + $presence - } - - // Update presence. - TransparentComboBox { - Layout.preferredWidth: 160 - model: model2 // TMP. - textRole: 'key' - } - } - } + text: qsTr('selectAccountLabel') } - } - // ================================================================= - // TMP - // ================================================================= + ComboBox { + id: email - ListModel { - id: model1 + currentIndex: Utils.findIndex(AccountSettingsModel.accounts, function (account) { + return account.sipAddress === AccountSettingsModel.sipAddress + }) - ListElement { - $presence: 'connected' - $sipAddress: 'jim.williams.zzzz.yyyy.kkkk.sip.linphone.org' - } - ListElement { - $presence: 'connected' - $sipAddress: 'toto.lala.sip.linphone.org' - } - ListElement { - $presence: 'disconnected' - $sipAddress: 'machin.truc.sip.linphone.org' - } - ListElement { - $presence: 'absent' - $sipAddress: 'hey.listen.sip.linphone.org' - } - ListElement { - $presence: 'do_not_disturb' - $sipAddress: 'valentin.cognito.sip.linphone.org' - } - ListElement { - $presence: 'do_not_disturb' - $sipAddress: 'charles.henri.sip.linphone.org' - } - ListElement { - $presence: 'disconnected' - $sipAddress: 'yesyes.nono.sip.linphone.org' - } - ListElement { - $presence: 'connected' - $sipAddress: 'nsa.sip.linphone.org' - } - } + model: AccountSettingsModel.accounts + textRole: 'sipAddress' - ListModel { - id: model2 - - ListElement { key: qsTr('onlinePresence'); value: 1 } - ListElement { key: qsTr('busyPresence'); value: 2 } - ListElement { key: qsTr('beRightBackPresence'); value: 3 } - ListElement { key: qsTr('awayPresence'); value: 4 } - ListElement { key: qsTr('onThePhonePresence'); value: 5 } - ListElement { key: qsTr('outToLunchPresence'); value: 6 } - ListElement { key: qsTr('doNotDisturbPresence'); value: 7 } - ListElement { key: qsTr('movedPresence'); value: 8 } - ListElement { key: qsTr('usingAnotherMessagingServicePresence'); value: 9 } - ListElement { key: qsTr('offlinePresence'); value: 10 } + onActivated: AccountSettingsModel.setDefaultProxyConfig(model[index].proxyConfig) + } } } diff --git a/linphone-desktop/ui/views/App/Settings/SettingsUi.qml b/linphone-desktop/ui/views/App/Settings/SettingsUi.qml index 0903a70a5..2707fbddc 100644 --- a/linphone-desktop/ui/views/App/Settings/SettingsUi.qml +++ b/linphone-desktop/ui/views/App/Settings/SettingsUi.qml @@ -41,6 +41,7 @@ TabContainer { }) } + textRole: 'key' model: ListModel {} Component.onCompleted: { diff --git a/linphone-desktop/ui/views/App/Styles/ManageAccountsStyle.qml b/linphone-desktop/ui/views/App/Styles/ManageAccountsStyle.qml new file mode 100644 index 000000000..ec174ff4e --- /dev/null +++ b/linphone-desktop/ui/views/App/Styles/ManageAccountsStyle.qml @@ -0,0 +1,22 @@ +pragma Singleton +import QtQuick 2.7 + +import Common 1.0 + +// ============================================================================= + +QtObject { + property int height: 316 + property int leftMargin: 35 + property int rightMargin: 35 + property int width: 480 + + property QtObject input: QtObject { + property int spacing: 6 + + property QtObject legend: QtObject { + property color color: Colors.j + property int fontSize: 10 + } + } +} diff --git a/linphone-desktop/ui/views/App/Styles/qmldir b/linphone-desktop/ui/views/App/Styles/qmldir index b63a99ee5..9c70701e7 100644 --- a/linphone-desktop/ui/views/App/Styles/qmldir +++ b/linphone-desktop/ui/views/App/Styles/qmldir @@ -5,6 +5,7 @@ module App.Styles # Views styles ----------------------------------------------------------------- singleton InviteFriendsStyle 1.0 InviteFriendsStyle.qml +singleton ManageAccountsStyle 1.0 ManageAccountsStyle.qml singleton CallStyle 1.0 Calls/CallStyle.qml singleton CallsWindowStyle 1.0 Calls/CallsWindowStyle.qml