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>
<name>ManageAccounts</name>
<message>
<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>
<source>manageAccountsTitle</source>
......@@ -551,47 +551,55 @@ Server url not configured.</translation>
</message>
<message>
<source>validate</source>
<translation>VALIDATE</translation>
<translation type="vanished">VALIDATE</translation>
</message>
<message>
<source>onlinePresence</source>
<translation>Connected</translation>
<translation type="vanished">Connected</translation>
</message>
<message>
<source>busyPresence</source>
<translation>Busy</translation>
<translation type="vanished">Busy</translation>
</message>
<message>
<source>beRightBackPresence</source>
<translation>Be right back</translation>
<translation type="vanished">Be right back</translation>
</message>
<message>
<source>awayPresence</source>
<translation>Away</translation>
<translation type="vanished">Away</translation>
</message>
<message>
<source>onThePhonePresence</source>
<translation>On the phone</translation>
<translation type="vanished">On the phone</translation>
</message>
<message>
<source>outToLunchPresence</source>
<translation>Out to lunch</translation>
<translation type="vanished">Out to lunch</translation>
</message>
<message>
<source>doNotDisturbPresence</source>
<translation>Away</translation>
<translation type="vanished">Away</translation>
</message>
<message>
<source>movedPresence</source>
<translation>Moved</translation>
<translation type="vanished">Moved</translation>
</message>
<message>
<source>usingAnotherMessagingServicePresence</source>
<translation>Using another messaging service</translation>
<translation type="vanished">Using another messaging service</translation>
</message>
<message>
<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>
</context>
<context>
......
......@@ -542,7 +542,7 @@ Url du serveur non configurée.</translation>
<name>ManageAccounts</name>
<message>
<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>
<source>manageAccountsTitle</source>
......@@ -550,47 +550,55 @@ Url du serveur non configurée.</translation>
</message>
<message>
<source>validate</source>
<translation>VALIDER</translation>
<translation type="vanished">VALIDER</translation>
</message>
<message>
<source>onlinePresence</source>
<translation>Disponible</translation>
<translation type="vanished">Disponible</translation>
</message>
<message>
<source>busyPresence</source>
<translation>Occupé</translation>
<translation type="vanished">Occupé</translation>
</message>
<message>
<source>beRightBackPresence</source>
<translation>De retour</translation>
<translation type="vanished">De retour</translation>
</message>
<message>
<source>awayPresence</source>
<translation>Absent</translation>
<translation type="vanished">Absent</translation>
</message>
<message>
<source>onThePhonePresence</source>
<translation>Au téléphone</translation>
<translation type="vanished">Au téléphone</translation>
</message>
<message>
<source>outToLunchPresence</source>
<translation>A table</translation>
<translation type="vanished">A table</translation>
</message>
<message>
<source>doNotDisturbPresence</source>
<translation>Ne pas déranger</translation>
<translation type="vanished">Ne pas déranger</translation>
</message>
<message>
<source>movedPresence</source>
<translation>Parti</translation>
<translation type="vanished">Parti</translation>
</message>
<message>
<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>
<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>
</context>
<context>
......
......@@ -337,6 +337,7 @@
<file>ui/views/App/Styles/Main/HomeStyle.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/ManageAccountsStyle.qml</file>
<file>ui/views/App/Styles/qmldir</file>
<file>ui/views/App/Styles/Settings/SettingsWindowStyle.qml</file>
</qresource>
......
......@@ -29,10 +29,13 @@
// =============================================================================
AccountSettingsModel::AccountSettingsModel (QObject *parent) : QObject(parent) {
m_default_proxy = CoreManager::getInstance()->getCore()->getDefaultProxyConfig();
void AccountSettingsModel::setDefaultProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxy_config) {
CoreManager::getInstance()->getCore()->setDefaultProxyConfig(proxy_config);
emit accountUpdated();
}
// -----------------------------------------------------------------------------
QString AccountSettingsModel::getUsername () const {
shared_ptr<linphone::Address> 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<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 {
if (m_default_proxy)
return m_default_proxy->getIdentityAddress();
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
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 @@
#include <QObject>
// ===================================================================
// =============================================================================
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<linphone::ProxyConfig> &proxy_config);
signals:
void accountUpdated ();
......@@ -61,10 +55,11 @@ private:
Presence::PresenceStatus getPresenceStatus () const;
QString getSipAddress () const;
QVariantList getAccounts () 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_
......@@ -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
}
}
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
title: qsTr('manageAccountsTitle')
buttons: [
TextButtonB {
text: qsTr('ok')
buttons: TextButtonA {
text: qsTr('validate')
onClicked: exit(0)
}
]
// TODO: Compute list max.
ScrollableListView {
id: accounts
anchors.fill: parent
model: model1 // TMP
delegate: Item {
function isDefaultAccount () {
return accounts.currentIndex === index
}
centeredButtons: true
title: qsTr('manageAccountsTitle')
height: 34
width: parent.width
height: ManageAccountsStyle.height
width: ManageAccountsStyle.width
Rectangle {
anchors.fill: parent
color: isDefaultAccount() ? '#EAEAEA' : 'transparent'
minimumHeight: ManageAccountsStyle.height
minimumWidth: ManageAccountsStyle.width
maximumHeight: ManageAccountsStyle.height
maximumWidth: ManageAccountsStyle.width
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' : ''
Column {
anchors {
fill: parent
leftMargin: ManageAccountsStyle.leftMargin
rightMargin: ManageAccountsStyle.rightMargin
}
// Sip account.
spacing: ManageAccountsStyle.input.spacing
Text {
Layout.fillWidth: true
clip: true
color: '#59575A'
text: $sipAddress
verticalAlignment: Text.AlignVCenter
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: accounts.currentIndex = index
}
}
color: ManageAccountsStyle.input.legend.color
elide: Text.ElideRight
// Presence.
Icon {
Layout.preferredHeight: 20 // TMP
Layout.preferredWidth: 20 // TMP
icon: 'led_' + $presence
font {
bold: true
pointSize: ManageAccountsStyle.input.legend.fontSize
}
// 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)
}
}
}
......@@ -41,6 +41,7 @@ TabContainer {
})
}
textRole: 'key'
model: ListModel {}
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
# 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
......
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