Commit 37d0ac55 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/views/App/ManageAccounts): account selection is supported

parent 4a2674be
...@@ -543,7 +543,7 @@ Server url not configured.</translation> ...@@ -543,7 +543,7 @@ Server url not configured.</translation>
<name>ManageAccounts</name> <name>ManageAccounts</name>
<message> <message>
<source>manageAccountsDescription</source> <source>manageAccountsDescription</source>
<translation>Select your active account and choose all necessary presence status.</translation> <translation type="vanished">Select your active account and choose all necessary presence status.</translation>
</message> </message>
<message> <message>
<source>manageAccountsTitle</source> <source>manageAccountsTitle</source>
...@@ -551,47 +551,55 @@ Server url not configured.</translation> ...@@ -551,47 +551,55 @@ Server url not configured.</translation>
</message> </message>
<message> <message>
<source>validate</source> <source>validate</source>
<translation>VALIDATE</translation> <translation type="vanished">VALIDATE</translation>
</message> </message>
<message> <message>
<source>onlinePresence</source> <source>onlinePresence</source>
<translation>Connected</translation> <translation type="vanished">Connected</translation>
</message> </message>
<message> <message>
<source>busyPresence</source> <source>busyPresence</source>
<translation>Busy</translation> <translation type="vanished">Busy</translation>
</message> </message>
<message> <message>
<source>beRightBackPresence</source> <source>beRightBackPresence</source>
<translation>Be right back</translation> <translation type="vanished">Be right back</translation>
</message> </message>
<message> <message>
<source>awayPresence</source> <source>awayPresence</source>
<translation>Away</translation> <translation type="vanished">Away</translation>
</message> </message>
<message> <message>
<source>onThePhonePresence</source> <source>onThePhonePresence</source>
<translation>On the phone</translation> <translation type="vanished">On the phone</translation>
</message> </message>
<message> <message>
<source>outToLunchPresence</source> <source>outToLunchPresence</source>
<translation>Out to lunch</translation> <translation type="vanished">Out to lunch</translation>
</message> </message>
<message> <message>
<source>doNotDisturbPresence</source> <source>doNotDisturbPresence</source>
<translation>Away</translation> <translation type="vanished">Away</translation>
</message> </message>
<message> <message>
<source>movedPresence</source> <source>movedPresence</source>
<translation>Moved</translation> <translation type="vanished">Moved</translation>
</message> </message>
<message> <message>
<source>usingAnotherMessagingServicePresence</source> <source>usingAnotherMessagingServicePresence</source>
<translation>Using another messaging service</translation> <translation type="vanished">Using another messaging service</translation>
</message> </message>
<message> <message>
<source>offlinePresence</source> <source>offlinePresence</source>
<translation>Disconnected</translation> <translation type="vanished">Disconnected</translation>
</message>
<message>
<source>ok</source>
<translation>OK</translation>
</message>
<message>
<source>selectAccountLabel</source>
<translation>Select you active account</translation>
</message> </message>
</context> </context>
<context> <context>
......
...@@ -542,7 +542,7 @@ Url du serveur non configurée.</translation> ...@@ -542,7 +542,7 @@ Url du serveur non configurée.</translation>
<name>ManageAccounts</name> <name>ManageAccounts</name>
<message> <message>
<source>manageAccountsDescription</source> <source>manageAccountsDescription</source>
<translation>Sélectionner votre compte actif ainsi que vos status de présence.</translation> <translation type="vanished">Sélectionner votre compte actif ainsi que vos status de présence.</translation>
</message> </message>
<message> <message>
<source>manageAccountsTitle</source> <source>manageAccountsTitle</source>
...@@ -550,47 +550,55 @@ Url du serveur non configurée.</translation> ...@@ -550,47 +550,55 @@ Url du serveur non configurée.</translation>
</message> </message>
<message> <message>
<source>validate</source> <source>validate</source>
<translation>VALIDER</translation> <translation type="vanished">VALIDER</translation>
</message> </message>
<message> <message>
<source>onlinePresence</source> <source>onlinePresence</source>
<translation>Disponible</translation> <translation type="vanished">Disponible</translation>
</message> </message>
<message> <message>
<source>busyPresence</source> <source>busyPresence</source>
<translation>Occupé</translation> <translation type="vanished">Occupé</translation>
</message> </message>
<message> <message>
<source>beRightBackPresence</source> <source>beRightBackPresence</source>
<translation>De retour</translation> <translation type="vanished">De retour</translation>
</message> </message>
<message> <message>
<source>awayPresence</source> <source>awayPresence</source>
<translation>Absent</translation> <translation type="vanished">Absent</translation>
</message> </message>
<message> <message>
<source>onThePhonePresence</source> <source>onThePhonePresence</source>
<translation>Au téléphone</translation> <translation type="vanished">Au téléphone</translation>
</message> </message>
<message> <message>
<source>outToLunchPresence</source> <source>outToLunchPresence</source>
<translation>A table</translation> <translation type="vanished">A table</translation>
</message> </message>
<message> <message>
<source>doNotDisturbPresence</source> <source>doNotDisturbPresence</source>
<translation>Ne pas déranger</translation> <translation type="vanished">Ne pas déranger</translation>
</message> </message>
<message> <message>
<source>movedPresence</source> <source>movedPresence</source>
<translation>Parti</translation> <translation type="vanished">Parti</translation>
</message> </message>
<message> <message>
<source>usingAnotherMessagingServicePresence</source> <source>usingAnotherMessagingServicePresence</source>
<translation>Utilisation d&apos;un autre service de messagerie</translation> <translation type="vanished">Utilisation d&apos;un autre service de messagerie</translation>
</message> </message>
<message> <message>
<source>offlinePresence</source> <source>offlinePresence</source>
<translation>Déconnecté</translation> <translation type="vanished">Déconnecté</translation>
</message>
<message>
<source>ok</source>
<translation>OK</translation>
</message>
<message>
<source>selectAccountLabel</source>
<translation>Sélectionner votre compte principal</translation>
</message> </message>
</context> </context>
<context> <context>
......
...@@ -337,6 +337,7 @@ ...@@ -337,6 +337,7 @@
<file>ui/views/App/Styles/Main/HomeStyle.qml</file> <file>ui/views/App/Styles/Main/HomeStyle.qml</file>
<file>ui/views/App/Styles/Main/MainWindowMenuBarStyle.qml</file> <file>ui/views/App/Styles/Main/MainWindowMenuBarStyle.qml</file>
<file>ui/views/App/Styles/Main/MainWindowStyle.qml</file> <file>ui/views/App/Styles/Main/MainWindowStyle.qml</file>
<file>ui/views/App/Styles/ManageAccountsStyle.qml</file>
<file>ui/views/App/Styles/qmldir</file> <file>ui/views/App/Styles/qmldir</file>
<file>ui/views/App/Styles/Settings/SettingsWindowStyle.qml</file> <file>ui/views/App/Styles/Settings/SettingsWindowStyle.qml</file>
</qresource> </qresource>
......
...@@ -29,10 +29,13 @@ ...@@ -29,10 +29,13 @@
// ============================================================================= // =============================================================================
AccountSettingsModel::AccountSettingsModel (QObject *parent) : QObject(parent) { void AccountSettingsModel::setDefaultProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxy_config) {
m_default_proxy = CoreManager::getInstance()->getCore()->getDefaultProxyConfig(); CoreManager::getInstance()->getCore()->setDefaultProxyConfig(proxy_config);
emit accountUpdated();
} }
// -----------------------------------------------------------------------------
QString AccountSettingsModel::getUsername () const { QString AccountSettingsModel::getUsername () const {
shared_ptr<linphone::Address> address = getDefaultSipAddress(); shared_ptr<linphone::Address> address = getDefaultSipAddress();
const string &display_name = address->getDisplayName(); const string &display_name = address->getDisplayName();
...@@ -52,6 +55,8 @@ void AccountSettingsModel::setUsername (const QString &username) { ...@@ -52,6 +55,8 @@ void AccountSettingsModel::setUsername (const QString &username) {
emit accountUpdated(); emit accountUpdated();
} }
// -----------------------------------------------------------------------------
Presence::PresenceLevel AccountSettingsModel::getPresenceLevel () const { Presence::PresenceLevel AccountSettingsModel::getPresenceLevel () const {
return Presence::Green; return Presence::Green;
} }
...@@ -60,15 +65,38 @@ Presence::PresenceStatus AccountSettingsModel::getPresenceStatus () const { ...@@ -60,15 +65,38 @@ Presence::PresenceStatus AccountSettingsModel::getPresenceStatus () const {
return Presence::Online; return Presence::Online;
} }
// -----------------------------------------------------------------------------
QString AccountSettingsModel::getSipAddress () const { QString AccountSettingsModel::getSipAddress () const {
return ::Utils::linphoneStringToQString(getDefaultSipAddress()->asStringUriOnly()); return ::Utils::linphoneStringToQString(getDefaultSipAddress()->asStringUriOnly());
} }
QVariantList AccountSettingsModel::getAccounts () const {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
QVariantList accounts;
{
QVariantMap account;
account["sipAddress"] = ::Utils::linphoneStringToQString(core->getPrimaryContactParsed()->asStringUriOnly());
account["proxyConfig"].setValue(shared_ptr<linphone::ProxyConfig>());
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<linphone::Address> AccountSettingsModel::getDefaultSipAddress () const { shared_ptr<linphone::Address> AccountSettingsModel::getDefaultSipAddress () const {
if (m_default_proxy) shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
return m_default_proxy->getIdentityAddress(); shared_ptr<linphone::ProxyConfig> proxy_config = core->getDefaultProxyConfig();
return CoreManager::getInstance()->getCore()->getPrimaryContactParsed(); return proxy_config ? proxy_config->getIdentityAddress() : core->getPrimaryContactParsed();
} }
...@@ -27,28 +27,22 @@ ...@@ -27,28 +27,22 @@
#include <QObject> #include <QObject>
// =================================================================== // =============================================================================
class AccountSettingsModel : public QObject { class AccountSettingsModel : public QObject {
Q_OBJECT; Q_OBJECT;
Q_PROPERTY(QString username READ getUsername WRITE setUsername NOTIFY accountUpdated); Q_PROPERTY(QString username READ getUsername WRITE setUsername NOTIFY accountUpdated);
Q_PROPERTY(QString sipAddress READ getSipAddress NOTIFY accountUpdated); Q_PROPERTY(QString sipAddress READ getSipAddress NOTIFY accountUpdated);
Q_PROPERTY(QVariantList accounts READ getAccounts NOTIFY accountUpdated);
Q_PROPERTY( Q_PROPERTY(Presence::PresenceLevel presenceLevel READ getPresenceLevel CONSTANT);
Presence::PresenceLevel presenceLevel Q_PROPERTY(Presence::PresenceStatus presenceStatus READ getPresenceStatus CONSTANT);
READ getPresenceLevel
CONSTANT
);
Q_PROPERTY(
Presence::PresenceStatus presenceStatus
READ getPresenceStatus
CONSTANT
);
public: public:
AccountSettingsModel (QObject *parent = Q_NULLPTR); AccountSettingsModel (QObject *parent = Q_NULLPTR) : QObject(parent) {}
Q_INVOKABLE void setDefaultProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxy_config);
signals: signals:
void accountUpdated (); void accountUpdated ();
...@@ -61,10 +55,11 @@ private: ...@@ -61,10 +55,11 @@ private:
Presence::PresenceStatus getPresenceStatus () const; Presence::PresenceStatus getPresenceStatus () const;
QString getSipAddress () const; QString getSipAddress () const;
QVariantList getAccounts () const;
std::shared_ptr<linphone::Address> getDefaultSipAddress () const; std::shared_ptr<linphone::Address> getDefaultSipAddress () const;
std::shared_ptr<linphone::ProxyConfig> m_default_proxy;
}; };
Q_DECLARE_METATYPE(std::shared_ptr<linphone::ProxyConfig> );
#endif // ACCOUNT_SETTINGS_MODEL_H_ #endif // ACCOUNT_SETTINGS_MODEL_H_
...@@ -9,8 +9,6 @@ import Common.Styles 1.0 ...@@ -9,8 +9,6 @@ import Common.Styles 1.0
ComboBox { ComboBox {
id: comboBox id: comboBox
textRole: 'key'
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
background: Rectangle { background: Rectangle {
...@@ -67,7 +65,9 @@ ComboBox { ...@@ -67,7 +65,9 @@ ComboBox {
font.bold: comboBox.currentIndex === index font.bold: comboBox.currentIndex === index
hoverEnabled: true hoverEnabled: true
text: key text: textRole.length
? (typeof modelData !== 'undefined' ? modelData[textRole] : model[textRole])
: modelData
width: comboBox.width width: comboBox.width
} }
} }
import QtQuick 2.7 import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import Common 1.0 import Common 1.0
import Linphone 1.0 import Linphone 1.0
import Utils 1.0
import App.Styles 1.0
// =============================================================================
DialogPlus { DialogPlus {
descriptionText: qsTr('manageAccountsDescription') buttons: [
minimumHeight: 328 TextButtonB {
minimumWidth: 480 text: qsTr('ok')
onClicked: exit(0)
}
]
centeredButtons: true
title: qsTr('manageAccountsTitle') title: qsTr('manageAccountsTitle')
buttons: TextButtonA { height: ManageAccountsStyle.height
text: qsTr('validate') width: ManageAccountsStyle.width
onClicked: exit(0)
}
// TODO: Compute list max. minimumHeight: ManageAccountsStyle.height
ScrollableListView { minimumWidth: ManageAccountsStyle.width
id: accounts maximumHeight: ManageAccountsStyle.height
maximumWidth: ManageAccountsStyle.width
anchors.fill: parent // ---------------------------------------------------------------------------
model: model1 // TMP
delegate: Item { Column {
function isDefaultAccount () { anchors {
return accounts.currentIndex === index fill: parent
} leftMargin: ManageAccountsStyle.leftMargin
rightMargin: ManageAccountsStyle.rightMargin
}
spacing: ManageAccountsStyle.input.spacing
height: 34 Text {
width: parent.width color: ManageAccountsStyle.input.legend.color
elide: Text.ElideRight
Rectangle {
anchors.fill: parent font {
color: isDefaultAccount() ? '#EAEAEA' : 'transparent' bold: true
pointSize: ManageAccountsStyle.input.legend.fontSize
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')
} }
}
// ================================================================= ComboBox {
// TMP id: email
// =================================================================
ListModel { currentIndex: Utils.findIndex(AccountSettingsModel.accounts, function (account) {
id: model1 return account.sipAddress === AccountSettingsModel.sipAddress
})
ListElement { model: AccountSettingsModel.accounts
$presence: 'connected' textRole: 'sipAddress'
$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'
}
}
ListModel { onActivated: AccountSettingsModel.setDefaultProxyConfig(model[index].proxyConfig)
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 }
} }
} }
...@@ -41,6 +41,7 @@ TabContainer { ...@@ -41,6 +41,7 @@ TabContainer {
}) })
} }
textRole: 'key'
model: ListModel {} model: ListModel {}
Component.onCompleted: { Component.onCompleted: {
......
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
}
}
}
...@@ -5,6 +5,7 @@ module App.Styles ...@@ -5,6 +5,7 @@ module App.Styles
# Views styles ----------------------------------------------------------------- # Views styles -----------------------------------------------------------------
singleton InviteFriendsStyle 1.0 InviteFriendsStyle.qml singleton InviteFriendsStyle 1.0 InviteFriendsStyle.qml
singleton ManageAccountsStyle 1.0 ManageAccountsStyle.qml
singleton CallStyle 1.0 Calls/CallStyle.qml singleton CallStyle 1.0 Calls/CallStyle.qml
singleton CallsWindowStyle 1.0 Calls/CallsWindowStyle.qml singleton CallsWindowStyle 1.0 Calls/CallsWindowStyle.qml
......
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