diff --git a/tests/imgs/led_connected.svg b/tests/imgs/led_green.svg
similarity index 100%
rename from tests/imgs/led_connected.svg
rename to tests/imgs/led_green.svg
diff --git a/tests/imgs/led_absent.svg b/tests/imgs/led_orange.svg
similarity index 100%
rename from tests/imgs/led_absent.svg
rename to tests/imgs/led_orange.svg
diff --git a/tests/imgs/led_do_not_disturb.svg b/tests/imgs/led_red.svg
similarity index 100%
rename from tests/imgs/led_do_not_disturb.svg
rename to tests/imgs/led_red.svg
diff --git a/tests/imgs/led_disconnected.svg b/tests/imgs/led_white.svg
similarity index 100%
rename from tests/imgs/led_disconnected.svg
rename to tests/imgs/led_white.svg
diff --git a/tests/linphone.pro b/tests/linphone.pro
index 966afb8e2..fbfde45ad 100644
--- a/tests/linphone.pro
+++ b/tests/linphone.pro
@@ -9,6 +9,8 @@ RESOURCES = resources.qrc
SOURCES = \
src/app.cpp \
src/main.cpp \
+ src/models/contacts/ContactModel.cpp \
+ src/models/contacts/ContactsListModel.cpp \
src/models/notification/NotificationModel.cpp \
src/models/settings/AccountSettingsListModel.cpp \
src/models/settings/AccountSettingsModel.cpp \
@@ -16,6 +18,8 @@ SOURCES = \
HEADERS = \
src/app.hpp \
+ src/models/contacts/ContactModel.hpp \
+ src/models/contacts/ContactsListModel.hpp \
src/models/notification/NotificationModel.hpp \
src/models/settings/AccountSettingsListModel.hpp \
src/models/settings/AccountSettingsModel.hpp \
diff --git a/tests/resources.qrc b/tests/resources.qrc
index 07702d6d3..7f99d9664 100644
--- a/tests/resources.qrc
+++ b/tests/resources.qrc
@@ -14,10 +14,10 @@
imgs/history.svg
imgs/home.svg
imgs/incoming_call.svg
- imgs/led_absent.svg
- imgs/led_connected.svg
- imgs/led_disconnected.svg
- imgs/led_do_not_disturb.svg
+ imgs/led_green.svg
+ imgs/led_orange.svg
+ imgs/led_red.svg
+ imgs/led_white.svg
imgs/linphone.png
imgs/lost_incoming_call.svg
imgs/lost_outgoing_call.svg
@@ -36,6 +36,7 @@
ui/modules/Linphone/Contact/Avatar.qml
ui/modules/Linphone/Contact/ContactDescription.qml
ui/modules/Linphone/Contact/Contact.qml
+ ui/modules/Linphone/Contact/PresenceLevel.qml
ui/modules/Linphone/Dialog/ConfirmDialog.qml
ui/modules/Linphone/Dialog/DialogDescription.qml
ui/modules/Linphone/Dialog/DialogPlus.qml
diff --git a/tests/src/main.cpp b/tests/src/main.cpp
index c0868f487..3b8cff2d6 100644
--- a/tests/src/main.cpp
+++ b/tests/src/main.cpp
@@ -9,6 +9,7 @@
#include
#include "app.hpp"
+#include "models/contacts/ContactsListModel.hpp"
#include "models/notification/NotificationModel.hpp"
// ===================================================================
@@ -46,7 +47,22 @@ void setTrayIcon (QQmlApplicationEngine &engine) {
tray_icon->show();
}
+void registerTypes () {
+ qmlRegisterUncreatableType(
+ "Linphone", 1, 0, "ContactModel", "ContactModel is uncreatable"
+ );
+}
+
+void addContextProperties (QQmlApplicationEngine &engine) {
+ QQmlContext *context = engine.rootContext();
+
+ context->setContextProperty("Notification", new NotificationModel());
+ context->setContextProperty("ContactsList", new ContactsListModel());
+}
+
int main (int argc, char *argv[]) {
+ registerTypes();
+
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
App app(argc, argv);
QQmlApplicationEngine engine;
@@ -69,9 +85,7 @@ int main (int argc, char *argv[]) {
else
setTrayIcon(engine);
- // Warning: Add global context Notification for all views!
- NotificationModel notification;
- engine.rootContext()->setContextProperty("Notification", ¬ification);
+ addContextProperties(engine);
// Run!
return app.exec();
diff --git a/tests/src/models/contacts/ContactModel.cpp b/tests/src/models/contacts/ContactModel.cpp
new file mode 100644
index 000000000..46de9a4f5
--- /dev/null
+++ b/tests/src/models/contacts/ContactModel.cpp
@@ -0,0 +1,3 @@
+#include "ContactModel.hpp"
+
+// ===================================================================
diff --git a/tests/src/models/contacts/ContactModel.hpp b/tests/src/models/contacts/ContactModel.hpp
new file mode 100644
index 000000000..6ddb65508
--- /dev/null
+++ b/tests/src/models/contacts/ContactModel.hpp
@@ -0,0 +1,130 @@
+#ifndef CONTACT_MODEL_H
+#define CONTACT_MODEL_H
+
+#include
+
+// ===================================================================
+
+class ContactModel : public QObject {
+ Q_OBJECT;
+
+ Q_PROPERTY(
+ QString username
+ READ getUsername
+ WRITE setUsername
+ NOTIFY contactUpdated
+ );
+
+ Q_PROPERTY(
+ QString avatar
+ READ getAvatar
+ WRITE setAvatar
+ NOTIFY contactUpdated
+ );
+
+ Q_PROPERTY(
+ Presence presence
+ READ getPresence
+ CONSTANT
+ );
+
+ Q_PROPERTY(
+ PresenceLevel presenceLevel
+ READ getPresenceLevel
+ CONSTANT
+ );
+
+ Q_PROPERTY(
+ QStringList sipAddresses
+ READ getSipAddresses
+ WRITE setSipAddresses
+ NOTIFY contactUpdated
+ );
+
+public:
+ enum Presence {
+ Online,
+ BeRightBack,
+ Away,
+ OnThePhone,
+ OutToLunch,
+ DoNotDisturb,
+ Moved,
+ UsingAnotherMessagingService,
+ Offline
+ };
+ Q_ENUM(Presence);
+
+ enum PresenceLevel {
+ Green,
+ Orange,
+ Red,
+ White
+ };
+ Q_ENUM(PresenceLevel);
+
+ ContactModel (QObject *parent = Q_NULLPTR) : QObject(parent) { }
+ ContactModel (
+ const QString &username,
+ const QString &avatar,
+ const Presence &presence,
+ const QStringList &sip_addresses
+ ): ContactModel() {
+ m_username = username;
+ m_avatar = avatar;
+ m_presence = presence;
+ m_sip_addresses = sip_addresses;
+ }
+
+signals:
+ void contactUpdated ();
+
+private:
+ QString getUsername () const {
+ return m_username;
+ }
+
+ void setUsername (const QString &username) {
+ m_username = username;
+ }
+
+ QString getAvatar () const {
+ return m_avatar;
+ }
+
+ void setAvatar (const QString &avatar) {
+ m_avatar = avatar;
+ }
+
+ Presence getPresence () const {
+ return m_presence;
+ }
+
+ PresenceLevel getPresenceLevel () const {
+ if (m_presence == Online)
+ return Green;
+ if (m_presence == DoNotDisturb)
+ return Red;
+ if (m_presence == Offline)
+ return White;
+
+ return Orange;
+ }
+
+ QStringList getSipAddresses () const {
+ return m_sip_addresses;
+ }
+
+ void setSipAddresses (const QStringList &sip_addresses) {
+ m_sip_addresses = sip_addresses;
+ }
+
+ QString m_username;
+ QString m_avatar;
+ Presence m_presence = Online;
+ QStringList m_sip_addresses;
+};
+
+Q_DECLARE_METATYPE(ContactModel*);
+
+#endif // CONTACT_MODEL_H
diff --git a/tests/src/models/contacts/ContactsListModel.cpp b/tests/src/models/contacts/ContactsListModel.cpp
new file mode 100644
index 000000000..0b7e1af1a
--- /dev/null
+++ b/tests/src/models/contacts/ContactsListModel.cpp
@@ -0,0 +1,3 @@
+#include "ContactsListModel.hpp"
+
+// ===================================================================
diff --git a/tests/src/models/contacts/ContactsListModel.hpp b/tests/src/models/contacts/ContactsListModel.hpp
new file mode 100644
index 000000000..bab653f18
--- /dev/null
+++ b/tests/src/models/contacts/ContactsListModel.hpp
@@ -0,0 +1,55 @@
+#ifndef CONTACTS_LIST_MODEL_H
+#define CONTACTS_LIST_MODEL_H
+
+#include
+
+#include "ContactModel.hpp"
+
+// ===================================================================
+
+class ContactsListModel : public QAbstractListModel {
+ Q_OBJECT
+
+public:
+ enum Roles {
+ ContactRole = Qt::UserRole + 1
+ };
+
+ ContactsListModel (QObject *parent = Q_NULLPTR): QAbstractListModel(parent) {
+ m_list << new ContactModel("Toto Roi", "", ContactModel::Online, QStringList("toto.linphone.sip.linphone.org"));
+ m_list << new ContactModel("Mary Boreno", "", ContactModel::Online, QStringList("toto.linphone.sip.linphone.org"));
+ m_list << new ContactModel("Cecelia Cyler", "", ContactModel::Online, QStringList("toto.linphone.sip.linphone.org"));
+ m_list << new ContactModel("Daniel Elliott", "", ContactModel::Online, QStringList("toto.linphone.sip.linphone.org"));
+ m_list << new ContactModel("Effie Forton", "", ContactModel::Online, QStringList("toto.linphone.sip.linphone.org"));
+ m_list << new ContactModel("Agnes Hurner", "", ContactModel::Online, QStringList("toto.linphone.sip.linphone.org"));
+ m_list << new ContactModel("Luke Lemin", "", ContactModel::Online, QStringList("toto.linphone.sip.linphone.org"));
+ m_list << new ContactModel("Olga Manning", "", ContactModel::Online, QStringList("toto.linphone.sip.linphone.org"));
+ m_list << new ContactModel("Isabella Ahornton", "", ContactModel::Online, QStringList("toto.linphone.sip.linphone.org"));
+ m_list << new ContactModel("Mary Boreno", "", ContactModel::Online, QStringList("toto.linphone.sip.linphone.org"));
+ }
+
+ int rowCount (const QModelIndex &) const {
+ return m_list.count();
+ }
+
+ QHash roleNames () const {
+ QHash roles;
+ roles[ContactRole] = "$contact";
+ return roles;
+ }
+
+ QVariant data (const QModelIndex &index, int role) const {
+ if (index.row() < 0 || index.row() >= m_list.count())
+ return QVariant();
+
+ if (role == ContactRole)
+ return QVariant::fromValue(m_list[index.row()]);
+
+ return QVariant();
+ }
+
+private:
+ QList m_list;
+};
+
+#endif // CONTACTS_LIST_MODEL_H
diff --git a/tests/ui/modules/Linphone/Contact/Avatar.qml b/tests/ui/modules/Linphone/Contact/Avatar.qml
index 4f5c11b9a..f305cd915 100644
--- a/tests/ui/modules/Linphone/Contact/Avatar.qml
+++ b/tests/ui/modules/Linphone/Contact/Avatar.qml
@@ -8,7 +8,7 @@ import Linphone.Styles 1.0
Item {
property alias image: imageToFilter.source
- property string presence
+ property alias presenceLevel: presenceLevel.level
property string username
function _computeInitials () {
@@ -57,13 +57,12 @@ Item {
}
// Presence.
- Icon {
+ PresenceLevel {
+ id: presenceLevel
+
anchors.bottom: parent.bottom
anchors.right: parent.right
height: parent.height / 3
- icon: presence
- ? 'led_' + presence
- : ''
width: parent.width / 3
}
}
diff --git a/tests/ui/modules/Linphone/Contact/Contact.qml b/tests/ui/modules/Linphone/Contact/Contact.qml
index 6015b2d89..a7a8fb32d 100644
--- a/tests/ui/modules/Linphone/Contact/Contact.qml
+++ b/tests/ui/modules/Linphone/Contact/Contact.qml
@@ -9,7 +9,7 @@ import Linphone.Styles 1.0
Item {
property alias actions: actionBar.data
property alias image: avatar.image
- property alias presence: avatar.presence
+ property alias presenceLevel: avatar.presenceLevel
property alias sipAddress: description.sipAddress
property alias username: avatar.username
diff --git a/tests/ui/modules/Linphone/Contact/PresenceLevel.qml b/tests/ui/modules/Linphone/Contact/PresenceLevel.qml
new file mode 100644
index 000000000..e7dcc581d
--- /dev/null
+++ b/tests/ui/modules/Linphone/Contact/PresenceLevel.qml
@@ -0,0 +1,29 @@
+import QtQuick 2.7
+
+import Linphone 1.0
+
+// ===================================================================
+
+Icon {
+ property int level: -1
+
+ function _getColorString () {
+ if (level === ContactModel.Green) {
+ return 'green'
+ }
+ if (level === ContactModel.Orange) {
+ return 'orange'
+ }
+ if (level === ContactModel.Red) {
+ return 'red'
+ }
+ if (level === ContactModel.White) {
+ return 'white'
+ }
+ }
+
+ icon: {
+ var level = _getColorString()
+ return level ? 'led_' + level : ''
+ }
+}
diff --git a/tests/ui/modules/Linphone/Styles/Contact/AvatarStyle.qml b/tests/ui/modules/Linphone/Styles/Contact/AvatarStyle.qml
new file mode 100644
index 000000000..8c02bbe29
--- /dev/null
+++ b/tests/ui/modules/Linphone/Styles/Contact/AvatarStyle.qml
@@ -0,0 +1,16 @@
+pragma Singleton
+import QtQuick 2.7
+
+QtObject {
+ property QtObject initials: QtObject {
+ property color color: '#FFFFFF'
+
+ property int fontSize: 10
+ }
+
+ property QtObject mask: QtObject {
+ property color color: '#8F8F8F'
+
+ property int radius: 50
+ }
+}
diff --git a/tests/ui/modules/Linphone/Styles/Contact/ContactDescriptionStyle.qml b/tests/ui/modules/Linphone/Styles/Contact/ContactDescriptionStyle.qml
new file mode 100644
index 000000000..4eded4e4b
--- /dev/null
+++ b/tests/ui/modules/Linphone/Styles/Contact/ContactDescriptionStyle.qml
@@ -0,0 +1,16 @@
+pragma Singleton
+import QtQuick 2.7
+
+QtObject {
+ property QtObject sipAddress: QtObject {
+ property color color: '#5A585B'
+
+ property int fontSize: 10
+ }
+
+ property QtObject username: QtObject {
+ property color color: '#5A585B'
+
+ property int fontSize: 11
+ }
+}
diff --git a/tests/ui/modules/Linphone/Styles/Contact/ContactStyle.qml b/tests/ui/modules/Linphone/Styles/Contact/ContactStyle.qml
new file mode 100644
index 000000000..e5e5b77a7
--- /dev/null
+++ b/tests/ui/modules/Linphone/Styles/Contact/ContactStyle.qml
@@ -0,0 +1,10 @@
+pragma Singleton
+import QtQuick 2.7
+
+QtObject {
+ property int contentHeight: 32
+ property int height: 50
+ property int leftMargin: 14
+ property int rightMargin: 14
+ property int spacing: 14
+}
diff --git a/tests/ui/modules/Linphone/Timeline.qml b/tests/ui/modules/Linphone/Timeline.qml
index 66d74c6bd..f6d530074 100644
--- a/tests/ui/modules/Linphone/Timeline.qml
+++ b/tests/ui/modules/Linphone/Timeline.qml
@@ -44,7 +44,7 @@ ColumnLayout {
Layout.fillWidth: true
delegate: Contact {
- presence: $presence
+ presenceLevel: $presence
sipAddress: $sipAddress
username: $username
width: parent.width
diff --git a/tests/ui/modules/Linphone/qmldir b/tests/ui/modules/Linphone/qmldir
index 35670b58e..42c0147ed 100644
--- a/tests/ui/modules/Linphone/qmldir
+++ b/tests/ui/modules/Linphone/qmldir
@@ -21,6 +21,7 @@ Collapse 1.0 Collapse.qml
Avatar 1.0 Contact/Avatar.qml
Contact 1.0 Contact/Contact.qml
ContactDescription 1.0 Contact/ContactDescription.qml
+PresenceLevel 1.0 Contact/PresenceLevel.qml
# Dialog
DialogPlus 1.0 Dialog/DialogPlus.qml
diff --git a/tests/ui/views/MainWindow/Contacts.qml b/tests/ui/views/MainWindow/Contacts.qml
index 5bf730de0..03b8caac9 100644
--- a/tests/ui/views/MainWindow/Contacts.qml
+++ b/tests/ui/views/MainWindow/Contacts.qml
@@ -58,94 +58,8 @@ ColumnLayout {
anchors.fill: parent
spacing: 2
- // TODO: Remove, use C++ model instead.
- model: ListModel {
- ListElement {
- $image: ''
- $presence: 'connected'
- $username: 'Isabella Ahornton'
- }
- ListElement {
- $image: ''
- $presence: 'connected'
- $username: 'Mary Boreno'
- }
- ListElement {
- $image: ''
- $presence: 'disconnected'
- $username: 'Cecelia Cyler'
- }
- ListElement {
- $image: ''
- $presence: 'absent'
- $username: 'Daniel Elliott'
- }
- ListElement {
- $image: ''
- $presence: 'do_not_disturb'
- $username: 'Effie Forton'
- }
- ListElement {
- $image: ''
- $presence: 'do_not_disturb'
- $username: 'Agnes Hurner'
- }
- ListElement {
- $image: ''
- $presence: 'disconnected'
- $username: 'Luke Leming'
- }
- ListElement {
- $image: ''
- $presence: 'connected'
- $username: 'Olga Manning'
- }
- ListElement {
- $image: ''
- $presence: 'connected'
- $username: 'Isabella Ahornton'
- }
- ListElement {
- $image: ''
- $presence: 'connected'
- $username: 'Mary Boreno'
- }
- ListElement {
- $image: ''
- $presence: 'disconnected'
- $username: 'Cecelia Cyler'
- }
- ListElement {
- $image: ''
- $presence: 'disconnected'
- $username: 'Toto'
- }
- ListElement {
- $image: ''
- $presence: 'absent'
- $username: 'Daniel Elliott'
- }
- ListElement {
- $image: ''
- $presence: 'do_not_disturb'
- $username: 'Effie Forton'
- }
- ListElement {
- $image: ''
- $presence: 'do_not_disturb'
- $username: 'Agnes Hurner'
- }
- ListElement {
- $image: ''
- $presence: 'disconnected'
- $username: 'Luke Leming'
- }
- ListElement {
- $image: ''
- $presence: 'connected'
- $username: 'Olga Manning'
- }
- }
+ model: ContactsList
+
delegate: Rectangle {
color: '#FFFFFF'
height: 50
@@ -174,8 +88,8 @@ ColumnLayout {
Avatar {
Layout.fillHeight: parent.height
Layout.preferredWidth: 30
- image: $image
- username: $username
+ image: $contact.avatar
+ username: $contact.username
}
// Presence.
@@ -183,10 +97,9 @@ ColumnLayout {
Layout.fillHeight: parent.height
Layout.preferredWidth: 20
- Image {
+ PresenceLevel {
anchors.fill: parent
- fillMode: Image.PreserveAspectFit
- source: 'qrc:/imgs/led_' + $presence + '.svg'
+ level: $contact.presenceLevel
}
}
@@ -200,7 +113,7 @@ ColumnLayout {
clip: true
color: '#5A585B'
font.bold: true
- text: $username
+ text: $contact.username
verticalAlignment: Text.AlignVCenter
}
}
diff --git a/tests/ui/views/MainWindow/MainWindow.qml b/tests/ui/views/MainWindow/MainWindow.qml
index 020e95808..30b61c959 100644
--- a/tests/ui/views/MainWindow/MainWindow.qml
+++ b/tests/ui/views/MainWindow/MainWindow.qml
@@ -90,7 +90,7 @@ ApplicationWindow {
model: model1
delegate: Contact {
- presence: $presence
+ presenceLevel: $presence
sipAddress: $sipAddress
username: $username
width: parent.width
@@ -160,42 +160,42 @@ ApplicationWindow {
model: ListModel {
ListElement {
- $presence: 'connected'
+ $presence: 0
$sipAddress: 'jim.williams.zzzz.yyyy.kkkk.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'connected'
+ $presence: 0
$sipAddress: 'toto.lala.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'disconnected'
+ $presence: 0
$sipAddress: 'machin.truc.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'absent'
+ $presence: 0
$sipAddress: 'hey.listen.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'do_not_disturb'
+ $presence: 0
$sipAddress: 'valentin.cognito.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'do_not_disturb'
+ $presence: 0
$sipAddress: 'charles.henri.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'disconnected'
+ $presence: 0
$sipAddress: 'yesyes.nono.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'connected'
+ $presence: 0
$sipAddress: 'nsa.sip.linphone.org'
$username: 'Toto'
}
@@ -239,82 +239,82 @@ ApplicationWindow {
id: model1
ListElement {
- $presence: 'connected'
+ $presence: 0
$sipAddress: 'jim.williams.zzzz.yyyy.kkkk.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'connected'
+ $presence: 0
$sipAddress: 'toto.lala.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'disconnected'
+ $presence: 0
$sipAddress: 'machin.truc.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'absent'
+ $presence: 0
$sipAddress: 'hey.listen.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'do_not_disturb'
+ $presence: 0
$sipAddress: 'valentin.cognito.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'do_not_disturb'
+ $presence: 0
$sipAddress: 'charles.henri.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'disconnected'
+ $presence: 0
$sipAddress: 'yesyes.nono.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'connected'
+ $presence: 0
$sipAddress: 'nsa.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'connected'
+ $presence: 0
$sipAddress: 'jim.williams.zzzz.yyyy.kkkk.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'connected'
+ $presence: 0
$sipAddress: 'toto.lala.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'disconnected'
+ $presence: 0
$sipAddress: 'machin.truc.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'absent'
+ $presence: 0
$sipAddress: 'hey.listen.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'do_not_disturb'
+ $presence: 0
$sipAddress: 'valentin.cognito.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'do_not_disturb'
+ $presence: 0
$sipAddress: 'charles.henri.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'disconnected'
+ $presence: 0
$sipAddress: 'yesyes.nono.sip.linphone.org'
$username: 'Toto'
}
ListElement {
- $presence: 'connected'
+ $presence: 0
$sipAddress: 'nsa.sip.linphone.org'
$username: 'Toto'
}