From 24ee1aa9382bdcf676913bb81a6e8183f76c4e2a Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 29 Sep 2016 11:57:13 +0200 Subject: [PATCH] feat(ManageAccounts): can select default account --- .../ui/modules/Linphone/InvertedMouseArea.qml | 4 +- .../Linphone/View/ScrollableListView.qml | 1 - tests/ui/views/MainWindow/MainWindow.qml | 8 +- tests/ui/views/ManageAccounts.qml | 286 +++++++++--------- 4 files changed, 158 insertions(+), 141 deletions(-) diff --git a/tests/ui/modules/Linphone/InvertedMouseArea.qml b/tests/ui/modules/Linphone/InvertedMouseArea.qml index c237967c8..547072c9c 100644 --- a/tests/ui/modules/Linphone/InvertedMouseArea.qml +++ b/tests/ui/modules/Linphone/InvertedMouseArea.qml @@ -83,6 +83,8 @@ Item { mapToItem(item.parent, mouse.x, mouse.y) )) { if (_timeout != null) { + // Remove existing timeout to avoid the creation of + // many children. Utils.clearTimeout(_timeout) } @@ -91,7 +93,7 @@ Item { // // It's useful to ensure the window's context is not // modified with the mouse event before the `onPressed` - // function. + // call. // // The timeout is destroyed with the `MouseArea` component. _timeout = Utils.setTimeout.call(this, 0, item.pressed.bind(this)) diff --git a/tests/ui/modules/Linphone/View/ScrollableListView.qml b/tests/ui/modules/Linphone/View/ScrollableListView.qml index 804251d03..0feb4bce8 100644 --- a/tests/ui/modules/Linphone/View/ScrollableListView.qml +++ b/tests/ui/modules/Linphone/View/ScrollableListView.qml @@ -9,6 +9,5 @@ ListView { ScrollBar.vertical: ForceScrollBar { } boundsBehavior: Flickable.StopAtBounds clip: true - highlightRangeMode: ListView.ApplyRange spacing: 0 } diff --git a/tests/ui/views/MainWindow/MainWindow.qml b/tests/ui/views/MainWindow/MainWindow.qml index 6d42fd2ac..ca1ce5020 100644 --- a/tests/ui/views/MainWindow/MainWindow.qml +++ b/tests/ui/views/MainWindow/MainWindow.qml @@ -12,6 +12,10 @@ ApplicationWindow { loaderContent.source = 'qrc:/ui/views/MainWindow/' + view + '.qml' } + function _manageAccounts () { + Utils.openWindow('ManageAccounts', window) + } + maximumHeight: 70 minimumHeight: 70 minimumWidth: 780 @@ -53,13 +57,13 @@ ApplicationWindow { MouseArea { anchors.fill: contactDescription - onClicked: Utils.openWindow('ManageAccounts', window) + onClicked: _manageAccounts() } // User actions. ActionButton { Layout.preferredWidth: 1 - onClicked: Utils.openWindow('ManageAccounts', window) + onClicked: _manageAccounts() } ActionButton { diff --git a/tests/ui/views/ManageAccounts.qml b/tests/ui/views/ManageAccounts.qml index 485567111..3f4565c83 100644 --- a/tests/ui/views/ManageAccounts.qml +++ b/tests/ui/views/ManageAccounts.qml @@ -5,149 +5,161 @@ import QtQuick.Layouts 1.3 import Linphone 1.0 DialogPlus { - descriptionText: qsTr('manageAccountsDescription') - minimumHeight: 328 - minimumWidth: 480 - title: qsTr('manageAccountsTitle') + descriptionText: qsTr('manageAccountsDescription') + minimumHeight: 328 + minimumWidth: 480 + title: qsTr('manageAccountsTitle') - buttons: TextButtonA { - text: qsTr('validate') - } + buttons: TextButtonA { + text: qsTr('validate') + onClicked: exit(0) + } - Item { - anchors.fill: parent + Item { + anchors.fill: parent - // TODO: Compute list max. - ScrollableListView { - anchors.fill: parent - id: accountsList + // TODO: Compute list max. + ScrollableListView { + id: accounts - // TODO: Remove, use C++ model instead. - model: ListModel { - ListElement { - presence: 'connected' - sipAddress: 'jim.williams.zzzz.yyyy.kkkk.sip.linphone.org' - isDefault: false - } - ListElement { - presence: 'connected' - sipAddress: 'toto.lala.sip.linphone.org' - isDefault: false - } - ListElement { - presence: 'disconnected' - sipAddress: 'machin.truc.sip.linphone.org' - isDefault: true - } - ListElement { - presence: 'absent' - sipAddress: 'hey.listen.sip.linphone.org' - isDefault: false - } - ListElement { - presence: 'do_not_disturb' - sipAddress: 'valentin.cognito.sip.linphone.org' - isDefault: false - } - ListElement { - presence: 'do_not_disturb' - sipAddress: 'charles.henri.sip.linphone.org' - isDefault: false - } - ListElement { - presence: 'disconnected' - sipAddress: 'yesyes.nono.sip.linphone.org' - isDefault: false - } - ListElement { - presence: 'connected' - sipAddress: 'nsa.sip.linphone.org' - isDefault: false - } - } - delegate: Item { - height: 34 - width: parent.width + anchors.fill: parent - Rectangle { - anchors.fill: parent - color: isDefault ? '#EAEAEA' : 'transparent' - id: accountLine + // TODO: Remove, use C++ model instead. + model: model1 - RowLayout { - anchors.fill: parent - spacing: 15 - anchors.leftMargin: 15 - anchors.rightMargin: 15 - - // Default account. - Item { - Layout.fillHeight: parent.height - Layout.preferredWidth: 20 - - Image { - anchors.fill: parent - fillMode: Image.PreserveAspectFit - source: isDefault ? 'qrc:/imgs/valid.svg' : '' - } - } - - // Sip account. - Item { - Layout.fillHeight: parent.height - Layout.fillWidth: true - - Text { - anchors.fill: parent - clip: true - color: '#59575A' - text: sipAddress; - verticalAlignment: Text.AlignVCenter - - MouseArea { - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - } - } - } - - // Presence. - Item { - Layout.fillHeight: parent.height - Layout.preferredWidth: 20 - - Image { - anchors.fill: parent - fillMode: Image.PreserveAspectFit - source: 'qrc:/imgs/led_' + presence + '.svg' - } - } - - // Update presence. - Item { - Layout.fillHeight: parent.height - Layout.preferredWidth: 160 - - TransparentComboBox { - anchors.fill: parent - model: ListModel { - 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 } - } - textRole: 'key' - } - } - } - } - } + delegate: Item { + function isDefaultAccount () { + return accounts.currentIndex === index } + + height: 34 + width: parent.width + + Rectangle { + anchors.fill: parent + color: isDefaultAccount() ? '#EAEAEA' : 'transparent' + id: accountLine + + RowLayout { + anchors.fill: parent + spacing: 15 + anchors.leftMargin: 15 + anchors.rightMargin: 15 + + // Default account. + Item { + Layout.fillHeight: parent.height + Layout.preferredWidth: 20 + + Image { + anchors.fill: parent + fillMode: Image.PreserveAspectFit + source: isDefaultAccount() ? 'qrc:/imgs/valid.svg' : '' + } + } + + // Sip account. + Item { + Layout.fillHeight: parent.height + Layout.fillWidth: true + + Text { + anchors.fill: parent + clip: true + color: '#59575A' + text: sipAddress; + verticalAlignment: Text.AlignVCenter + + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + onClicked: accounts.currentIndex = index + } + } + } + + // Presence. + Item { + Layout.fillHeight: parent.height + Layout.preferredWidth: 20 + + Image { + anchors.fill: parent + fillMode: Image.PreserveAspectFit + source: 'qrc:/imgs/led_' + presence + '.svg' + } + } + + // Update presence. + Item { + Layout.fillHeight: parent.height + Layout.preferredWidth: 160 + + TransparentComboBox { + anchors.fill: parent + model: model2 + textRole: 'key' + } + } + } + } + } } + } + + // ================================================================= + // TMP + // ================================================================= + + ListModel { + id: model1 + + 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' + } + } + + 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 } + } }