From 7339b7e4a8065b4bac454be8812b6f43f4df58d7 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 17 Mar 2017 14:55:24 +0100 Subject: [PATCH] Handle presence. --- linphone-desktop/CMakeLists.txt | 3 + .../assets/images/chevron_green.svg | 13 --- .../assets/images/chevron_orange.svg | 13 --- .../assets/images/chevron_red.svg | 13 --- .../assets/images/chevron_white.svg | 13 --- linphone-desktop/assets/languages/en.ts | 40 +++------ linphone-desktop/assets/languages/fr.ts | 39 ++++----- linphone-desktop/resources.qrc | 6 -- linphone-desktop/src/app/App.cpp | 18 ++++- .../src/components/contact/ContactModel.cpp | 9 ++- .../src/components/contact/ContactModel.hpp | 8 +- .../src/components/core/CoreHandlers.cpp | 10 +++ .../src/components/core/CoreHandlers.hpp | 7 ++ .../src/components/presence/Presence.cpp | 69 ++++++++++++++++ .../src/components/presence/Presence.hpp | 26 ++---- .../presence/PresenceStatusModel.cpp | 81 +++++++++++++++++++ .../presence/PresenceStatusModel.hpp | 55 +++++++++++++ .../Linphone/Account/AccountStatus.qml | 6 +- .../Linphone/Presence/PresenceLevel.qml | 23 +----- .../Linphone/Presence/PresenceString.qml | 44 ---------- .../Styles/Presence/PresenceStringStyle.qml | 11 --- .../ui/modules/Linphone/Styles/qmldir | 2 - linphone-desktop/ui/modules/Linphone/qmldir | 1 - .../ui/views/App/Main/Contacts.qml | 7 +- .../ui/views/App/Main/MainWindow.qml | 1 + .../ui/views/App/ManageAccountsWindow.qml | 18 +++++ .../views/App/Styles/Main/ContactsStyle.qml | 2 + 27 files changed, 316 insertions(+), 222 deletions(-) delete mode 100644 linphone-desktop/assets/images/chevron_green.svg delete mode 100644 linphone-desktop/assets/images/chevron_orange.svg delete mode 100644 linphone-desktop/assets/images/chevron_red.svg delete mode 100644 linphone-desktop/assets/images/chevron_white.svg create mode 100644 linphone-desktop/src/components/presence/Presence.cpp create mode 100644 linphone-desktop/src/components/presence/PresenceStatusModel.cpp create mode 100644 linphone-desktop/src/components/presence/PresenceStatusModel.hpp delete mode 100644 linphone-desktop/ui/modules/Linphone/Presence/PresenceString.qml delete mode 100644 linphone-desktop/ui/modules/Linphone/Styles/Presence/PresenceStringStyle.qml diff --git a/linphone-desktop/CMakeLists.txt b/linphone-desktop/CMakeLists.txt index e39feca1e..ba1a1335e 100644 --- a/linphone-desktop/CMakeLists.txt +++ b/linphone-desktop/CMakeLists.txt @@ -90,6 +90,8 @@ set(SOURCES src/components/core/CoreHandlers.cpp src/components/core/CoreManager.cpp src/components/notifier/Notifier.cpp + src/components/presence/Presence.cpp + src/components/presence/PresenceStatusModel.cpp src/components/settings/AccountSettingsModel.cpp src/components/settings/SettingsModel.cpp src/components/sip-addresses/SipAddressesModel.cpp @@ -121,6 +123,7 @@ set(HEADERS src/components/core/CoreManager.hpp src/components/notifier/Notifier.hpp src/components/presence/Presence.hpp + src/components/presence/PresenceStatusModel.hpp src/components/settings/AccountSettingsModel.hpp src/components/settings/SettingsModel.hpp src/components/sip-addresses/SipAddressesModel.hpp diff --git a/linphone-desktop/assets/images/chevron_green.svg b/linphone-desktop/assets/images/chevron_green.svg deleted file mode 100644 index a1cfb74ab..000000000 --- a/linphone-desktop/assets/images/chevron_green.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - status_username_available - Created with Sketch. - - - - - - - - \ No newline at end of file diff --git a/linphone-desktop/assets/images/chevron_orange.svg b/linphone-desktop/assets/images/chevron_orange.svg deleted file mode 100644 index 60e37c283..000000000 --- a/linphone-desktop/assets/images/chevron_orange.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - status_username_absent - Created with Sketch. - - - - - - - - \ No newline at end of file diff --git a/linphone-desktop/assets/images/chevron_red.svg b/linphone-desktop/assets/images/chevron_red.svg deleted file mode 100644 index 3332d4311..000000000 --- a/linphone-desktop/assets/images/chevron_red.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - status_username_busy - Created with Sketch. - - - - - - - - \ No newline at end of file diff --git a/linphone-desktop/assets/images/chevron_white.svg b/linphone-desktop/assets/images/chevron_white.svg deleted file mode 100644 index 6a0e645c3..000000000 --- a/linphone-desktop/assets/images/chevron_white.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - status_username_disconnected - Created with Sketch. - - - - - - - - \ No newline at end of file diff --git a/linphone-desktop/assets/languages/en.ts b/linphone-desktop/assets/languages/en.ts index a4929d2ea..5f8940778 100644 --- a/linphone-desktop/assets/languages/en.ts +++ b/linphone-desktop/assets/languages/en.ts @@ -586,48 +586,28 @@ Server url not configured. selectAccountLabel Select you active account + + selectPresenceLabel + Select a presence status + - PresenceString + Presence presenceOnline - + Available - presenceOutToLunch - + presenceBusy + Busy presenceDoNotDisturb - - - - presenceMoved - - - - presenceUsingAnotherMessagingService - + Do not disturb presenceOffline - - - - presenceUnknown - - - - presenceBeRightBack - - - - presenceAway - - - - presenceOnThePhone - + Offline diff --git a/linphone-desktop/assets/languages/fr.ts b/linphone-desktop/assets/languages/fr.ts index 759d1f6e4..66a45e4e1 100644 --- a/linphone-desktop/assets/languages/fr.ts +++ b/linphone-desktop/assets/languages/fr.ts @@ -586,15 +586,19 @@ Url du serveur non configurée. selectAccountLabel Sélectionner votre compte principal + + selectPresenceLabel + + - PresenceString + Presence presenceOnline - En ligne + En ligne - presenceOutToLunch + presenceBusy @@ -602,32 +606,19 @@ Url du serveur non configurée. - presenceMoved - + presenceOffline + Hors-ligne + + + PresenceString - presenceUsingAnotherMessagingService - + presenceOnline + En ligne presenceOffline - Hors-ligne - - - presenceUnknown - - - - presenceBeRightBack - - - - presenceAway - - - - presenceOnThePhone - + Hors-ligne diff --git a/linphone-desktop/resources.qrc b/linphone-desktop/resources.qrc index 243d156f0..49481aec7 100644 --- a/linphone-desktop/resources.qrc +++ b/linphone-desktop/resources.qrc @@ -45,10 +45,6 @@ assets/images/chat_normal.svg assets/images/chat_pressed.svg assets/images/chat_send.svg - assets/images/chevron_green.svg - assets/images/chevron_orange.svg - assets/images/chevron_red.svg - assets/images/chevron_white.svg assets/images/collapse.svg assets/images/contact_add_hovered.svg assets/images/contact_add_normal.svg @@ -283,7 +279,6 @@ ui/modules/Linphone/Notifications/NotificationReceivedFileMessage.qml ui/modules/Linphone/Notifications/NotificationReceivedMessage.qml ui/modules/Linphone/Presence/PresenceLevel.qml - ui/modules/Linphone/Presence/PresenceString.qml ui/modules/Linphone/qmldir ui/modules/Linphone/SmartSearchBar.qml ui/modules/Linphone/Styles/Account/AccountStatusStyle.qml @@ -300,7 +295,6 @@ ui/modules/Linphone/Styles/Notifications/NotificationReceivedFileMessageStyle.qml ui/modules/Linphone/Styles/Notifications/NotificationReceivedMessageStyle.qml ui/modules/Linphone/Styles/Notifications/NotificationStyle.qml - ui/modules/Linphone/Styles/Presence/PresenceStringStyle.qml ui/modules/Linphone/Styles/qmldir ui/modules/Linphone/Styles/SmartSearchBarStyle.qml ui/modules/Linphone/Styles/TimelineStyle.qml diff --git a/linphone-desktop/src/app/App.cpp b/linphone-desktop/src/app/App.cpp index 02d4d0f7e..6617620d7 100644 --- a/linphone-desktop/src/app/App.cpp +++ b/linphone-desktop/src/app/App.cpp @@ -25,6 +25,7 @@ #include "../components/chat/ChatProxyModel.hpp" #include "../components/contacts/ContactsListProxyModel.hpp" #include "../components/core/CoreManager.hpp" +#include "../components/presence/PresenceStatusModel.hpp" #include "../components/settings/AccountSettingsModel.hpp" #include "../components/smart-search-bar/SmartSearchBarModel.hpp" #include "../components/timeline/TimelineModel.hpp" @@ -248,9 +249,6 @@ void App::registerTypes () { qmlRegisterUncreatableType( "Linphone", 1, 0, "ContactObserver", "ContactObserver is uncreatable." ); - qmlRegisterUncreatableType( - "Linphone", 1, 0, "Presence", "Presence is uncreatable." - ); qmlRegisterUncreatableType( "Linphone", 1, 0, "VcardModel", "VcardModel is uncreatable." ); @@ -290,6 +288,20 @@ void App::registerTypes () { } ); + qmlRegisterSingletonType( + "Linphone", 1, 0, "Presence", + [](QQmlEngine *, QJSEngine *) -> QObject *{ + return new Presence(); + } + ); + + qmlRegisterSingletonType( + "Linphone", 1, 0, "PresenceStatusModel", + [](QQmlEngine *, QJSEngine *) -> QObject *{ + return new PresenceStatusModel(); + } + ); + qmlRegisterSingletonType( "Linphone", 1, 0, "SettingsModel", [](QQmlEngine *, QJSEngine *) -> QObject *{ diff --git a/linphone-desktop/src/components/contact/ContactModel.cpp b/linphone-desktop/src/components/contact/ContactModel.cpp index 6a8e280fa..b47a04883 100644 --- a/linphone-desktop/src/components/contact/ContactModel.cpp +++ b/linphone-desktop/src/components/contact/ContactModel.cpp @@ -35,6 +35,7 @@ ContactModel::ContactModel (shared_ptr linphone_friend) { m_vcard = make_shared(linphone_friend->getVcard()); App::getInstance()->getEngine()->setObjectOwnership(m_vcard.get(), QQmlEngine::CppOwnership); + m_linphone_friend->setData("contact-model", *this); } ContactModel::ContactModel (VcardModel *vcard) { @@ -48,6 +49,12 @@ ContactModel::ContactModel (VcardModel *vcard) { engine->setObjectOwnership(vcard, QQmlEngine::CppOwnership); } +void ContactModel::presenceReceived () { + Presence::PresenceStatus status = static_cast(m_linphone_friend->getConsolidatedPresence()); + emit presenceStatusChanged(status); + emit presenceLevelChanged(Presence::getPresenceLevel(status)); +} + void ContactModel::startEdit () { m_linphone_friend->edit(); m_old_sip_addresses = m_vcard->getSipAddresses(); @@ -98,7 +105,7 @@ void ContactModel::abortEdit () { } Presence::PresenceStatus ContactModel::getPresenceStatus () const { - return Presence::PresenceStatus::Offline; + return static_cast(m_linphone_friend->getConsolidatedPresence()); } Presence::PresenceLevel ContactModel::getPresenceLevel () const { diff --git a/linphone-desktop/src/components/contact/ContactModel.hpp b/linphone-desktop/src/components/contact/ContactModel.hpp index 87721774a..ffc22ef74 100644 --- a/linphone-desktop/src/components/contact/ContactModel.hpp +++ b/linphone-desktop/src/components/contact/ContactModel.hpp @@ -31,8 +31,8 @@ class ContactModel : public QObject { Q_OBJECT; - Q_PROPERTY(Presence::PresenceStatus presenceStatus READ getPresenceStatus NOTIFY contactUpdated); - Q_PROPERTY(Presence::PresenceLevel presenceLevel READ getPresenceLevel NOTIFY contactUpdated); + Q_PROPERTY(Presence::PresenceStatus presenceStatus READ getPresenceStatus NOTIFY presenceStatusChanged); + Q_PROPERTY(Presence::PresenceLevel presenceLevel READ getPresenceLevel NOTIFY presenceLevelChanged); Q_PROPERTY(VcardModel * vcard READ getVcardModelPtr NOTIFY contactUpdated); friend class ContactsListModel; @@ -48,12 +48,16 @@ public: return m_vcard; } + void presenceReceived (); + Q_INVOKABLE void startEdit (); Q_INVOKABLE void endEdit (); Q_INVOKABLE void abortEdit (); signals: void contactUpdated (); + void presenceStatusChanged (Presence::PresenceStatus status); + void presenceLevelChanged (Presence::PresenceLevel level); void sipAddressAdded (const QString &sip_address); void sipAddressRemoved (const QString &sip_address); diff --git a/linphone-desktop/src/components/core/CoreHandlers.cpp b/linphone-desktop/src/components/core/CoreHandlers.cpp index 4abf12ebd..3c96cc307 100644 --- a/linphone-desktop/src/components/core/CoreHandlers.cpp +++ b/linphone-desktop/src/components/core/CoreHandlers.cpp @@ -67,6 +67,16 @@ void CoreHandlers::onMessageReceived ( } } +void CoreHandlers::onNotifyPresenceReceivedForUriOrTel ( + const shared_ptr &, + const shared_ptr &lf, + const string &, + const shared_ptr & +) { + ContactModel *contact_model = &lf->getData("contact-model"); + if (contact_model) contact_model->presenceReceived(); +} + void CoreHandlers::onRegistrationStateChanged ( const shared_ptr &core, const shared_ptr &config, diff --git a/linphone-desktop/src/components/core/CoreHandlers.hpp b/linphone-desktop/src/components/core/CoreHandlers.hpp index 2953ed964..a6340745d 100644 --- a/linphone-desktop/src/components/core/CoreHandlers.hpp +++ b/linphone-desktop/src/components/core/CoreHandlers.hpp @@ -57,6 +57,13 @@ private: const std::shared_ptr &message ) override; + void onNotifyPresenceReceivedForUriOrTel ( + const std::shared_ptr &lc, + const std::shared_ptr &lf, + const std::string &uri_or_tel, + const std::shared_ptr &presence_model + ) override; + void onRegistrationStateChanged ( const std::shared_ptr &core, const std::shared_ptr &config, diff --git a/linphone-desktop/src/components/presence/Presence.cpp b/linphone-desktop/src/components/presence/Presence.cpp new file mode 100644 index 000000000..a049cb03e --- /dev/null +++ b/linphone-desktop/src/components/presence/Presence.cpp @@ -0,0 +1,69 @@ +/* + * Presence.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: March 14, 2017 + * Author: Ghislain MARY + */ + +#include + +#include "Presence.hpp" + +// ============================================================================= + +Presence::PresenceLevel Presence::getPresenceLevel (const PresenceStatus &status) { + switch (status) { + case Online: + return Green; + case Busy: + return Orange; + case DoNotDisturb: + return Red; + case Offline: + default: + return White; + } +} + +QString Presence::getPresenceStatusAsString (const PresenceStatus &status) { + switch (status) { + case Online: + return tr("presenceOnline"); + case Busy: + return tr("presenceBusy"); + case DoNotDisturb: + return tr("presenceDoNotDisturb"); + case Offline: + default: + return tr("presenceOffline"); + } +} + +QString Presence::getPresenceLevelIconName (const PresenceLevel &level) { + switch (level) { + case Green: + return "led_green"; + case Orange: + return "led_orange"; + case Red: + return "led_red"; + case White: + default: + return "led_white"; + } +} diff --git a/linphone-desktop/src/components/presence/Presence.hpp b/linphone-desktop/src/components/presence/Presence.hpp index c48dbc79c..7f642166c 100644 --- a/linphone-desktop/src/components/presence/Presence.hpp +++ b/linphone-desktop/src/components/presence/Presence.hpp @@ -33,15 +33,10 @@ class Presence : public QObject { public: enum PresenceStatus { - Online, - BeRightBack, - Away, - OnThePhone, - OutToLunch, - DoNotDisturb, - Moved, - UsingAnotherMessagingService, - Offline + Online = linphone::ConsolidatedPresenceOnline, + Busy = linphone::ConsolidatedPresenceBusy, + DoNotDisturb = linphone::ConsolidatedPresenceDoNotDisturb, + Offline = linphone::ConsolidatedPresenceOffline }; Q_ENUM(PresenceStatus); @@ -59,16 +54,9 @@ public: ~Presence () = default; - static PresenceLevel getPresenceLevel (const PresenceStatus &presenceStatus) { - if (presenceStatus == Online) - return Green; - if (presenceStatus == DoNotDisturb) - return Red; - if (presenceStatus == Offline) - return White; - - return Orange; - } + static PresenceLevel getPresenceLevel (const PresenceStatus &status); + Q_INVOKABLE static QString getPresenceStatusAsString (const PresenceStatus &status); + Q_INVOKABLE static QString getPresenceLevelIconName (const PresenceLevel &level); }; #endif // PRESENCE_H_ diff --git a/linphone-desktop/src/components/presence/PresenceStatusModel.cpp b/linphone-desktop/src/components/presence/PresenceStatusModel.cpp new file mode 100644 index 000000000..fe36ad77b --- /dev/null +++ b/linphone-desktop/src/components/presence/PresenceStatusModel.cpp @@ -0,0 +1,81 @@ +/* + * PresenceStatusModel.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: March 14, 2017 + * Author: Ghislain MARY + */ + +#include + +#include "../../utils.hpp" +#include "../core/CoreManager.hpp" + +#include "PresenceStatusModel.hpp" + +// ============================================================================= + +Presence::PresenceLevel PresenceStatusModel::getPresenceLevel () const { + return Presence::getPresenceLevel(getPresenceStatus()); +} + +Presence::PresenceStatus PresenceStatusModel::getPresenceStatus () const { + return static_cast(CoreManager::getInstance()->getCore()->getConsolidatedPresence()); +} + +void PresenceStatusModel::setPresenceStatus (Presence::PresenceStatus status) { + shared_ptr core = CoreManager::getInstance()->getCore(); + core->setConsolidatedPresence(static_cast(status)); + emit presenceStatusChanged(status); + emit presenceLevelChanged(Presence::getPresenceLevel(status)); +} + +// ----------------------------------------------------------------------------- + +QVariantList PresenceStatusModel::getStatuses () const { + QVariantList statuses; + + QVariantMap online_status; + online_status["presenceLevel"] = Presence::Green; + online_status["presenceStatus"] = Presence::Online; + online_status["presenceIcon"] = Presence::getPresenceLevelIconName(Presence::Green); + online_status["presenceLabel"] = Presence::getPresenceStatusAsString(Presence::Online); + statuses << online_status; + + QVariantMap busy_status; + busy_status["presenceLevel"] = Presence::Orange; + busy_status["presenceStatus"] = Presence::Busy; + busy_status["presenceIcon"] = Presence::getPresenceLevelIconName(Presence::Orange); + busy_status["presenceLabel"] = Presence::getPresenceStatusAsString(Presence::Busy); + statuses << busy_status; + + QVariantMap do_not_disturb_status; + do_not_disturb_status["presenceLevel"] = Presence::Red; + do_not_disturb_status["presenceStatus"] = Presence::DoNotDisturb; + do_not_disturb_status["presenceIcon"] = Presence::getPresenceLevelIconName(Presence::Red); + do_not_disturb_status["presenceLabel"] = Presence::getPresenceStatusAsString(Presence::DoNotDisturb); + statuses << do_not_disturb_status; + + QVariantMap offline_status; + offline_status["presenceLevel"] = Presence::White; + offline_status["presenceStatus"] = Presence::Offline; + offline_status["presenceIcon"] = Presence::getPresenceLevelIconName(Presence::White); + offline_status["presenceLabel"] = Presence::getPresenceStatusAsString(Presence::Offline); + statuses << offline_status; + + return statuses; +} diff --git a/linphone-desktop/src/components/presence/PresenceStatusModel.hpp b/linphone-desktop/src/components/presence/PresenceStatusModel.hpp new file mode 100644 index 000000000..edfddbc79 --- /dev/null +++ b/linphone-desktop/src/components/presence/PresenceStatusModel.hpp @@ -0,0 +1,55 @@ +/* + * PresenceStatusModel.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: March 14, 2017 + * Author: Ghislain MARY + */ + +#ifndef PRESENCE_STATUS_MODEL_H_ +#define PRESENCE_STATUS_MODEL_H_ + +#include "../presence/Presence.hpp" + +#include + +// ============================================================================= + +class PresenceStatusModel : public QObject { + Q_OBJECT; + + Q_PROPERTY(QVariantList statuses READ getStatuses CONSTANT); + + Q_PROPERTY(Presence::PresenceLevel presenceLevel READ getPresenceLevel NOTIFY presenceLevelChanged); + Q_PROPERTY(Presence::PresenceStatus presenceStatus READ getPresenceStatus WRITE setPresenceStatus NOTIFY presenceStatusChanged); + +public: + PresenceStatusModel (QObject *parent = Q_NULLPTR) : QObject(parent) {} + +signals: + void presenceLevelChanged(Presence::PresenceLevel level); + void presenceStatusChanged(Presence::PresenceStatus status); + +private: + Presence::PresenceLevel getPresenceLevel () const; + Presence::PresenceStatus getPresenceStatus () const; + void setPresenceStatus (Presence::PresenceStatus status); + + QVariantList getStatuses () const; +}; + +#endif // PRESENCE_STATUS_MODEL_H_ diff --git a/linphone-desktop/ui/modules/Linphone/Account/AccountStatus.qml b/linphone-desktop/ui/modules/Linphone/Account/AccountStatus.qml index 72a248031..c2dde2a66 100644 --- a/linphone-desktop/ui/modules/Linphone/Account/AccountStatus.qml +++ b/linphone-desktop/ui/modules/Linphone/Account/AccountStatus.qml @@ -12,6 +12,7 @@ Item { // --------------------------------------------------------------------------- property var account + property var presence signal clicked @@ -27,11 +28,10 @@ Item { PresenceLevel { Layout.alignment: Qt.AlignBottom - Layout.bottomMargin: AccountStatusStyle.presenceLevel.bottoMargin + Layout.bottomMargin: AccountStatusStyle.presenceLevel.bottomMargin Layout.preferredHeight: AccountStatusStyle.presenceLevel.size Layout.preferredWidth: AccountStatusStyle.presenceLevel.size - icon: 'chevron' - level: account.presenceLevel + level: presence.presenceLevel } Text { diff --git a/linphone-desktop/ui/modules/Linphone/Presence/PresenceLevel.qml b/linphone-desktop/ui/modules/Linphone/Presence/PresenceLevel.qml index a69485dbf..41196c6ab 100644 --- a/linphone-desktop/ui/modules/Linphone/Presence/PresenceLevel.qml +++ b/linphone-desktop/ui/modules/Linphone/Presence/PresenceLevel.qml @@ -8,32 +8,11 @@ import Linphone 1.0 // Wrapper to use `icon` property. Item { property int level: -1 - property string icon: 'led' Icon { anchors.centerIn: parent - function _getColorString () { - if (level === Presence.Green) { - return 'green' - } - if (level === Presence.Orange) { - return 'orange' - } - if (level === Presence.Red) { - return 'red' - } - if (level === Presence.White) { - return 'white' - } - } - - icon: { - var level = _getColorString() - return level - ? parent.icon + '_' + level - : '' - } + icon: Presence.getPresenceLevelIconName(level) iconSize: parent.height > parent.width ? parent.width : parent.height diff --git a/linphone-desktop/ui/modules/Linphone/Presence/PresenceString.qml b/linphone-desktop/ui/modules/Linphone/Presence/PresenceString.qml deleted file mode 100644 index 5e58dc90d..000000000 --- a/linphone-desktop/ui/modules/Linphone/Presence/PresenceString.qml +++ /dev/null @@ -1,44 +0,0 @@ -import QtQuick 2.7 - -import Linphone 1.0 -import Linphone.Styles 1.0 - -// ============================================================================= - -Text { - property int status: -1 - - // --------------------------------------------------------------------------- - - function _getStatusString () { - switch (status) { - case Presence.Online: - return qsTr('presenceOnline') - case Presence.BeRightBack: - return qsTr('presenceBeRightBack') - case Presence.Away: - return qsTr('presenceAway') - case Presence.OnThePhone: - return qsTr('presenceOnThePhone') - case Presence.OutToLunch: - return qsTr('presenceOutToLunch') - case Presence.DoNotDisturb: - return qsTr('presenceDoNotDisturb') - case Presence.Moved: - return qsTr('presenceMoved') - case Presence.UsingAnotherMessagingService: - return qsTr('presenceUsingAnotherMessagingService') - case Presence.Offline: - return qsTr('presenceOffline') - default: - return qsTr('presenceUnknown') - } - } - - // --------------------------------------------------------------------------- - - color: PresenceStringStyle.color - elide: Text.ElideRight - font.pointSize: PresenceStringStyle.fontSize - text: _getStatusString() -} diff --git a/linphone-desktop/ui/modules/Linphone/Styles/Presence/PresenceStringStyle.qml b/linphone-desktop/ui/modules/Linphone/Styles/Presence/PresenceStringStyle.qml deleted file mode 100644 index f02f8aa31..000000000 --- a/linphone-desktop/ui/modules/Linphone/Styles/Presence/PresenceStringStyle.qml +++ /dev/null @@ -1,11 +0,0 @@ -pragma Singleton -import QtQuick 2.7 - -import Common 1.0 - -// ============================================================================= - -QtObject { - property color color: Colors.w - property int fontSize: 10 -} diff --git a/linphone-desktop/ui/modules/Linphone/Styles/qmldir b/linphone-desktop/ui/modules/Linphone/Styles/qmldir index cde60fa38..39058d533 100644 --- a/linphone-desktop/ui/modules/Linphone/Styles/qmldir +++ b/linphone-desktop/ui/modules/Linphone/Styles/qmldir @@ -25,8 +25,6 @@ singleton NotificationReceivedCallStyle 1.0 Notifications/NotificationRec singleton NotificationReceivedMessageStyle 1.0 Notifications/NotificationReceivedMessageStyle.qml singleton NotificationReceivedFileMessageStyle 1.0 Notifications/NotificationReceivedFileMessageStyle.qml -singleton PresenceStringStyle 1.0 Presence/PresenceStringStyle.qml - singleton SmartSearchBarStyle 1.0 SmartSearchBarStyle.qml singleton TimelineStyle 1.0 TimelineStyle.qml diff --git a/linphone-desktop/ui/modules/Linphone/qmldir b/linphone-desktop/ui/modules/Linphone/qmldir index 3ffd1148e..476c1a3e8 100644 --- a/linphone-desktop/ui/modules/Linphone/qmldir +++ b/linphone-desktop/ui/modules/Linphone/qmldir @@ -21,7 +21,6 @@ ContactDescription 1.0 Contact/ContactDescription.qml SipAddressesMenu 1.0 Menus/SipAddressesMenu.qml PresenceLevel 1.0 Presence/PresenceLevel.qml -PresenceString 1.0 Presence/PresenceString.qml SmartSearchBar 1.0 SmartSearchBar.qml diff --git a/linphone-desktop/ui/views/App/Main/Contacts.qml b/linphone-desktop/ui/views/App/Main/Contacts.qml index 99bebaef6..d8029db91 100644 --- a/linphone-desktop/ui/views/App/Main/Contacts.qml +++ b/linphone-desktop/ui/views/App/Main/Contacts.qml @@ -111,9 +111,12 @@ ColumnLayout { level: $contact.presenceLevel } - PresenceString { + Text { Layout.fillWidth: true - status: $contact.presenceStatus + color: ContactsStyle.contact.presenceStringColor + elide: Text.ElideRight + font.pointSize: ContactsStyle.contact.presenceStringFontSize + text: Presence.getPresenceStatusAsString($contact.presenceStatus) } } } diff --git a/linphone-desktop/ui/views/App/Main/MainWindow.qml b/linphone-desktop/ui/views/App/Main/MainWindow.qml index 0ce421fff..7f617e2e1 100644 --- a/linphone-desktop/ui/views/App/Main/MainWindow.qml +++ b/linphone-desktop/ui/views/App/Main/MainWindow.qml @@ -160,6 +160,7 @@ Controls1.ApplicationWindow { Layout.preferredWidth: MainWindowStyle.accountStatus.width account: AccountSettingsModel + presence: PresenceStatusModel TooltipArea { text: AccountSettingsModel.sipAddress diff --git a/linphone-desktop/ui/views/App/ManageAccountsWindow.qml b/linphone-desktop/ui/views/App/ManageAccountsWindow.qml index 94ebb9af9..cab1dbd85 100644 --- a/linphone-desktop/ui/views/App/ManageAccountsWindow.qml +++ b/linphone-desktop/ui/views/App/ManageAccountsWindow.qml @@ -40,6 +40,24 @@ DialogPlus { rightMargin: ManageAccountsWindowStyle.rightMargin } + FormLine { + FormGroup { + label: qsTr('selectPresenceLabel') + + ComboBox { + currentIndex: Utils.findIndex(PresenceStatusModel.statuses, function (status) { + return status.presenceStatus == PresenceStatusModel.presenceStatus + }) + + model: PresenceStatusModel.statuses + iconRole: 'presenceIcon' + textRole: 'presenceLabel' + + onActivated: PresenceStatusModel.presenceStatus = model[index].presenceStatus + } + } + } + FormLine { FormGroup { label: qsTr('selectAccountLabel') diff --git a/linphone-desktop/ui/views/App/Styles/Main/ContactsStyle.qml b/linphone-desktop/ui/views/App/Styles/Main/ContactsStyle.qml index 77e7e10c6..4c520f43f 100644 --- a/linphone-desktop/ui/views/App/Styles/Main/ContactsStyle.qml +++ b/linphone-desktop/ui/views/App/Styles/Main/ContactsStyle.qml @@ -25,6 +25,8 @@ QtObject { property int presenceLevelSize: 12 property int rightMargin: 25 property int spacing: 15 + property int presenceStringFontSize: 10 + property color presenceStringColor: Colors.w property QtObject backgroundColor: QtObject { property color normal: Colors.k