Commit 7339b7e4 authored by Ghislain MARY's avatar Ghislain MARY

Handle presence.

parent 28815a2e
......@@ -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
......
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 40.3 (33839) - http://www.bohemiancoding.com/sketch -->
<title>status_username_available</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="status_username_available">
<circle fill="#9ECD1D" transform="translate(8.000000, 8.000000) rotate(-180.000000) translate(-8.000000, -8.000000) " cx="8" cy="8" r="8"></circle>
<path d="M6.28571429,12 L9.71428571,8.57142857 M6.28859181,5.14285714 L9.71428571,8.57142857" stroke="#FFFFFF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" transform="translate(8.000000, 8.571429) rotate(-270.000000) translate(-8.000000, -8.571429) "></path>
</g>
</g>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 40.3 (33839) - http://www.bohemiancoding.com/sketch -->
<title>status_username_absent</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="status_username_absent">
<circle fill="#EFAE00" transform="translate(8.000000, 8.000000) rotate(-180.000000) translate(-8.000000, -8.000000) " cx="8" cy="8" r="8"></circle>
<path d="M6.28571429,12 L9.71428571,8.57142857 M6.28859181,5.14285714 L9.71428571,8.57142857" stroke="#FFFFFF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" transform="translate(8.000000, 8.571429) rotate(-270.000000) translate(-8.000000, -8.571429) "></path>
</g>
</g>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 40.3 (33839) - http://www.bohemiancoding.com/sketch -->
<title>status_username_busy</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="status_username_busy">
<circle fill="#DC4100" transform="translate(8.000000, 8.000000) rotate(-180.000000) translate(-8.000000, -8.000000) " cx="8" cy="8" r="8"></circle>
<path d="M6.28571429,12 L9.71428571,8.57142857 M6.28859181,5.14285714 L9.71428571,8.57142857" stroke="#FFFFFF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" transform="translate(8.000000, 8.571429) rotate(-270.000000) translate(-8.000000, -8.571429) "></path>
</g>
</g>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 40.3 (33839) - http://www.bohemiancoding.com/sketch -->
<title>status_username_disconnected</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="status_username_disconnected">
<circle fill="#B1B1B1" transform="translate(8.000000, 8.000000) rotate(-180.000000) translate(-8.000000, -8.000000) " cx="8" cy="8" r="8"></circle>
<path d="M6.28571429,12 L9.71428571,8.57142857 M6.28859181,5.14285714 L9.71428571,8.57142857" stroke="#FFFFFF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" transform="translate(8.000000, 8.571429) rotate(-270.000000) translate(-8.000000, -8.571429) "></path>
</g>
</g>
</svg>
\ No newline at end of file
......@@ -586,48 +586,28 @@ Server url not configured.</translation>
<source>selectAccountLabel</source>
<translation type="unfinished">Select you active account</translation>
</message>
<message>
<source>selectPresenceLabel</source>
<translation>Select a presence status</translation>
</message>
</context>
<context>
<name>PresenceString</name>
<name>Presence</name>
<message>
<source>presenceOnline</source>
<translation type="unfinished"></translation>
<translation>Available</translation>
</message>
<message>
<source>presenceOutToLunch</source>
<translation type="unfinished"></translation>
<source>presenceBusy</source>
<translation>Busy</translation>
</message>
<message>
<source>presenceDoNotDisturb</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>presenceMoved</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>presenceUsingAnotherMessagingService</source>
<translation type="unfinished"></translation>
<translation>Do not disturb</translation>
</message>
<message>
<source>presenceOffline</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>presenceUnknown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>presenceBeRightBack</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>presenceAway</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>presenceOnThePhone</source>
<translation type="unfinished"></translation>
<translation>Offline</translation>
</message>
</context>
<context>
......
......@@ -586,48 +586,39 @@ Url du serveur non configurée.</translation>
<source>selectAccountLabel</source>
<translation type="unfinished">Sélectionner votre compte principal</translation>
</message>
<message>
<source>selectPresenceLabel</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PresenceString</name>
<name>Presence</name>
<message>
<source>presenceOnline</source>
<translation>En ligne</translation>
<translation type="unfinished">En ligne</translation>
</message>
<message>
<source>presenceOutToLunch</source>
<source>presenceBusy</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>presenceDoNotDisturb</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>presenceMoved</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>presenceUsingAnotherMessagingService</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>presenceOffline</source>
<translation>Hors-ligne</translation>
</message>
<message>
<source>presenceUnknown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>presenceBeRightBack</source>
<translation type="unfinished"></translation>
<translation type="unfinished">Hors-ligne</translation>
</message>
</context>
<context>
<name>PresenceString</name>
<message>
<source>presenceAway</source>
<translation type="unfinished"></translation>
<source>presenceOnline</source>
<translation type="vanished">En ligne</translation>
</message>
<message>
<source>presenceOnThePhone</source>
<translation type="unfinished"></translation>
<source>presenceOffline</source>
<translation type="vanished">Hors-ligne</translation>
</message>
</context>
<context>
......
......@@ -45,10 +45,6 @@
<file>assets/images/chat_normal.svg</file>
<file>assets/images/chat_pressed.svg</file>
<file>assets/images/chat_send.svg</file>
<file>assets/images/chevron_green.svg</file>
<file>assets/images/chevron_orange.svg</file>
<file>assets/images/chevron_red.svg</file>
<file>assets/images/chevron_white.svg</file>
<file>assets/images/collapse.svg</file>
<file>assets/images/contact_add_hovered.svg</file>
<file>assets/images/contact_add_normal.svg</file>
......@@ -283,7 +279,6 @@
<file>ui/modules/Linphone/Notifications/NotificationReceivedFileMessage.qml</file>
<file>ui/modules/Linphone/Notifications/NotificationReceivedMessage.qml</file>
<file>ui/modules/Linphone/Presence/PresenceLevel.qml</file>
<file>ui/modules/Linphone/Presence/PresenceString.qml</file>
<file>ui/modules/Linphone/qmldir</file>
<file>ui/modules/Linphone/SmartSearchBar.qml</file>
<file>ui/modules/Linphone/Styles/Account/AccountStatusStyle.qml</file>
......@@ -300,7 +295,6 @@
<file>ui/modules/Linphone/Styles/Notifications/NotificationReceivedFileMessageStyle.qml</file>
<file>ui/modules/Linphone/Styles/Notifications/NotificationReceivedMessageStyle.qml</file>
<file>ui/modules/Linphone/Styles/Notifications/NotificationStyle.qml</file>
<file>ui/modules/Linphone/Styles/Presence/PresenceStringStyle.qml</file>
<file>ui/modules/Linphone/Styles/qmldir</file>
<file>ui/modules/Linphone/Styles/SmartSearchBarStyle.qml</file>
<file>ui/modules/Linphone/Styles/TimelineStyle.qml</file>
......
......@@ -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<ContactObserver>(
"Linphone", 1, 0, "ContactObserver", "ContactObserver is uncreatable."
);
qmlRegisterUncreatableType<Presence>(
"Linphone", 1, 0, "Presence", "Presence is uncreatable."
);
qmlRegisterUncreatableType<VcardModel>(
"Linphone", 1, 0, "VcardModel", "VcardModel is uncreatable."
);
......@@ -290,6 +288,20 @@ void App::registerTypes () {
}
);
qmlRegisterSingletonType<Presence>(
"Linphone", 1, 0, "Presence",
[](QQmlEngine *, QJSEngine *) -> QObject *{
return new Presence();
}
);
qmlRegisterSingletonType<PresenceStatusModel>(
"Linphone", 1, 0, "PresenceStatusModel",
[](QQmlEngine *, QJSEngine *) -> QObject *{
return new PresenceStatusModel();
}
);
qmlRegisterSingletonType<SettingsModel>(
"Linphone", 1, 0, "SettingsModel",
[](QQmlEngine *, QJSEngine *) -> QObject *{
......
......@@ -35,6 +35,7 @@ ContactModel::ContactModel (shared_ptr<linphone::Friend> linphone_friend) {
m_vcard = make_shared<VcardModel>(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<Presence::PresenceStatus>(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<Presence::PresenceStatus>(m_linphone_friend->getConsolidatedPresence());
}
Presence::PresenceLevel ContactModel::getPresenceLevel () const {
......
......@@ -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);
......
......@@ -67,6 +67,16 @@ void CoreHandlers::onMessageReceived (
}
}
void CoreHandlers::onNotifyPresenceReceivedForUriOrTel (
const shared_ptr<linphone::Core> &,
const shared_ptr<linphone::Friend> &lf,
const string &,
const shared_ptr<linphone::PresenceModel> &
) {
ContactModel *contact_model = &lf->getData<ContactModel>("contact-model");
if (contact_model) contact_model->presenceReceived();
}
void CoreHandlers::onRegistrationStateChanged (
const shared_ptr<linphone::Core> &core,
const shared_ptr<linphone::ProxyConfig> &config,
......
......@@ -57,6 +57,13 @@ private:
const std::shared_ptr<linphone::ChatMessage> &message
) override;
void onNotifyPresenceReceivedForUriOrTel (
const std::shared_ptr<linphone::Core> &lc,
const std::shared_ptr<linphone::Friend> &lf,
const std::string &uri_or_tel,
const std::shared_ptr<linphone::PresenceModel> &presence_model
) override;
void onRegistrationStateChanged (
const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ProxyConfig> &config,
......
/*
* 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 <QtDebug>
#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";
}
}
......@@ -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_
/*
* 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 <QtDebug>
#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<Presence::PresenceStatus>(CoreManager::getInstance()->getCore()->getConsolidatedPresence());
}
void PresenceStatusModel::setPresenceStatus (Presence::PresenceStatus status) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
core->setConsolidatedPresence(static_cast<linphone::ConsolidatedPresence>(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;
}
/*
* 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 <QObject>
// =============================================================================
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_
......@@ -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 {
......
......@@ -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
......
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()
}
pragma Singleton
import QtQuick 2.7
import Common 1.0
// =============================================================================
QtObject {
property color color: Colors.w
property int fontSize: 10
}
......@@ -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
......@@ -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
......
......@@ -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)
}
}
}
......
......@@ -160,6 +160,7 @@ Controls1.ApplicationWindow {
Layout.preferredWidth: MainWindowStyle.accountStatus.width
account: AccountSettingsModel
presence: PresenceStatusModel
TooltipArea {
text: AccountSettingsModel.sipAddress
......
......@@ -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')
......
......@@ -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
......
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