From ee86c54537a9b9e49714b4c77d1af507c9c132e2 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 31 Oct 2016 11:20:57 +0100 Subject: [PATCH] feat(app): add `PresenceStatus` and used in `MainWindow` --- tests/resources.qrc | 2 +- .../Linphone/Account/AccountStatus.qml | 32 ++++++++++++---- .../Linphone/Contact/ContactDescription.qml | 1 - .../Linphone/Contact/PresenceLevel.qml | 30 --------------- tests/ui/modules/Linphone/PresenceLevel.qml | 38 +++++++++++++++++++ .../Styles/Account/AccountStatusStyle.qml | 9 +++++ tests/ui/modules/Linphone/qmldir | 4 +- tests/ui/scripts/Utils/utils.js | 2 +- tests/ui/views/App/MainWindow/MainWindow.qml | 2 +- .../App/Styles/MainWindow/MainWindowStyle.qml | 1 + 10 files changed, 78 insertions(+), 43 deletions(-) delete mode 100644 tests/ui/modules/Linphone/Contact/PresenceLevel.qml create mode 100644 tests/ui/modules/Linphone/PresenceLevel.qml diff --git a/tests/resources.qrc b/tests/resources.qrc index c056a8060..a6cde16e8 100644 --- a/tests/resources.qrc +++ b/tests/resources.qrc @@ -120,7 +120,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/PresenceLevel.qml ui/modules/Linphone/qmldir ui/modules/Linphone/Select/SelectContact.qml ui/modules/Linphone/Styles/Account/AccountStatusStyle.qml diff --git a/tests/ui/modules/Linphone/Account/AccountStatus.qml b/tests/ui/modules/Linphone/Account/AccountStatus.qml index 1c2bb6f54..7dc1316c6 100644 --- a/tests/ui/modules/Linphone/Account/AccountStatus.qml +++ b/tests/ui/modules/Linphone/Account/AccountStatus.qml @@ -1,5 +1,7 @@ import QtQuick 2.7 +import QtQuick.Layouts 1.3 +import Linphone 1.0 import Linphone.Styles 1.0 import Utils 1.0 @@ -9,16 +11,30 @@ Item { Column { anchors.fill: parent - Text { - clip: true - color: AccountStatusStyle.username.color - elide: Text.ElideRight - font.bold: true - font.pointSize: AccountStatusStyle.username.fontSize + RowLayout { height: parent.height / 2 - text: AccountSettingsModel.username - verticalAlignment: Text.AlignBottom + spacing: AccountStatusStyle.horizontalSpacing width: parent.width + + PresenceLevel { + Layout.preferredHeight: AccountStatusStyle.presenceLevel.size + Layout.preferredWidth: AccountStatusStyle.presenceLevel.size + icon: 'chevron' + level: AccountSettingsModel.presenceLevel + Layout.alignment: Qt.AlignBottom + Layout.bottomMargin: AccountStatusStyle.presenceLevel.bottoMargin + } + + Text { + Layout.fillHeight: true + Layout.fillWidth: true + color: AccountStatusStyle.username.color + elide: Text.ElideRight + font.bold: true + font.pointSize: AccountStatusStyle.username.fontSize + text: AccountSettingsModel.username + verticalAlignment: Text.AlignBottom + } } Text { diff --git a/tests/ui/modules/Linphone/Contact/ContactDescription.qml b/tests/ui/modules/Linphone/Contact/ContactDescription.qml index 0db8dac5b..fa69de0cd 100644 --- a/tests/ui/modules/Linphone/Contact/ContactDescription.qml +++ b/tests/ui/modules/Linphone/Contact/ContactDescription.qml @@ -15,7 +15,6 @@ Column { Text { id: username - clip: true color: usernameColor elide: Text.ElideRight font.bold: true diff --git a/tests/ui/modules/Linphone/Contact/PresenceLevel.qml b/tests/ui/modules/Linphone/Contact/PresenceLevel.qml deleted file mode 100644 index 2e2e3c35f..000000000 --- a/tests/ui/modules/Linphone/Contact/PresenceLevel.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 2.7 - -import Common 1.0 -import Linphone 1.0 - -// =================================================================== - -Icon { - property int level: -1 - - 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 ? 'led_' + level : '' - } -} diff --git a/tests/ui/modules/Linphone/PresenceLevel.qml b/tests/ui/modules/Linphone/PresenceLevel.qml new file mode 100644 index 000000000..1fa84b702 --- /dev/null +++ b/tests/ui/modules/Linphone/PresenceLevel.qml @@ -0,0 +1,38 @@ +import QtQuick 2.7 + +import Common 1.0 +import Linphone 1.0 + +// =================================================================== + +// Wrapper to use `icon` property. +Item { + property int level: -1 + property string icon: 'led' + + Icon { + anchors.fill: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 + : '' + } + } +} diff --git a/tests/ui/modules/Linphone/Styles/Account/AccountStatusStyle.qml b/tests/ui/modules/Linphone/Styles/Account/AccountStatusStyle.qml index d5f6a6a03..e9a8dbefe 100644 --- a/tests/ui/modules/Linphone/Styles/Account/AccountStatusStyle.qml +++ b/tests/ui/modules/Linphone/Styles/Account/AccountStatusStyle.qml @@ -3,7 +3,16 @@ import QtQuick 2.7 import Common 1.0 +// =================================================================== + QtObject { + property int horizontalSpacing: 6 + + property QtObject presenceLevel: QtObject { + property int bottomMargin: 2 + property int size: 16 + } + property QtObject sipAddress: QtObject { property color color: Colors.j75 property int fontSize: 10 diff --git a/tests/ui/modules/Linphone/qmldir b/tests/ui/modules/Linphone/qmldir index 786e73a49..2c04c64e0 100644 --- a/tests/ui/modules/Linphone/qmldir +++ b/tests/ui/modules/Linphone/qmldir @@ -19,7 +19,9 @@ Chat 1.0 Chat/Chat.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 + +# PresenceLevel +PresenceLevel 1.0 PresenceLevel.qml # Select SelectContact 1.0 Select/SelectContact.qml diff --git a/tests/ui/scripts/Utils/utils.js b/tests/ui/scripts/Utils/utils.js index 9cb5090bf..259a30526 100644 --- a/tests/ui/scripts/Utils/utils.js +++ b/tests/ui/scripts/Utils/utils.js @@ -16,7 +16,7 @@ function openWindow (window, parent, options) { object = Qt.createQmlObject(window, parent) } else { var component = Qt.createComponent( - 'qrc:/ui/views/' + window + '.qml' + 'qrc:/ui/views/App/' + window + '.qml' ) if (component.status !== Component.Ready) { diff --git a/tests/ui/views/App/MainWindow/MainWindow.qml b/tests/ui/views/App/MainWindow/MainWindow.qml index 819c519b9..69dcb1c4e 100644 --- a/tests/ui/views/App/MainWindow/MainWindow.qml +++ b/tests/ui/views/App/MainWindow/MainWindow.qml @@ -100,7 +100,7 @@ ApplicationWindow { Layout.fillHeight: true Layout.maximumWidth: MainWindowStyle.menu.width Layout.preferredWidth: MainWindowStyle.menu.width - spacing: 0 + spacing: MainWindowStyle.menu.spacing Menu { entryHeight: MainWindowStyle.menu.entryHeight diff --git a/tests/ui/views/App/Styles/MainWindow/MainWindowStyle.qml b/tests/ui/views/App/Styles/MainWindow/MainWindowStyle.qml index 3024cd6e0..d316cda96 100644 --- a/tests/ui/views/App/Styles/MainWindow/MainWindowStyle.qml +++ b/tests/ui/views/App/Styles/MainWindow/MainWindowStyle.qml @@ -14,6 +14,7 @@ QtObject { property QtObject menu: QtObject { property int entryHeight: 50 + property int spacing: 0 property int width: 250 }