diff --git a/tests/src/components/sip-addresses/SipAddressesModel.cpp b/tests/src/components/sip-addresses/SipAddressesModel.cpp index 9bda676ef..f165b3852 100644 --- a/tests/src/components/sip-addresses/SipAddressesModel.cpp +++ b/tests/src/components/sip-addresses/SipAddressesModel.cpp @@ -134,6 +134,16 @@ void SipAddressesModel::handleAllHistoryEntriesRemoved () { // ----------------------------------------------------------------------------- +QString SipAddressesModel::interpretUrl (const QString &sip_address) { + shared_ptr l_address = CoreManager::getInstance()->getCore()->interpretUrl( + ::Utils::qStringToLinphoneString(sip_address) + ); + + return l_address ? ::Utils::linphoneStringToQString(l_address->asStringUriOnly()) : ""; +} + +// ----------------------------------------------------------------------------- + bool SipAddressesModel::removeRow (int row, const QModelIndex &parent) { return removeRows(row, 1, parent); } diff --git a/tests/src/components/sip-addresses/SipAddressesModel.hpp b/tests/src/components/sip-addresses/SipAddressesModel.hpp index 9b96a82ff..6f2e14c39 100644 --- a/tests/src/components/sip-addresses/SipAddressesModel.hpp +++ b/tests/src/components/sip-addresses/SipAddressesModel.hpp @@ -27,6 +27,8 @@ public: Q_INVOKABLE void handleAllHistoryEntriesRemoved (); + Q_INVOKABLE QString interpretUrl (const QString &sip_address); + private: bool removeRow (int row, const QModelIndex &parent = QModelIndex()); bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex()) override; diff --git a/tests/ui/modules/Linphone/Contact/Contact.qml b/tests/ui/modules/Linphone/Contact/Contact.qml index 6f8e89ace..7d653b032 100644 --- a/tests/ui/modules/Linphone/Contact/Contact.qml +++ b/tests/ui/modules/Linphone/Contact/Contact.qml @@ -19,6 +19,7 @@ Rectangle { property alias usernameColor: description.usernameColor property var entry + property var _contact: entry.contact // --------------------------------------------------------------------------- diff --git a/tests/ui/modules/Linphone/SmartSearchBar.qml b/tests/ui/modules/Linphone/SmartSearchBar.qml index 5b2bbcecc..93864de34 100644 --- a/tests/ui/modules/Linphone/SmartSearchBar.qml +++ b/tests/ui/modules/Linphone/SmartSearchBar.qml @@ -19,57 +19,138 @@ SearchBox { // --------------------------------------------------------------------------- - header: MouseArea { - id: headerContent + header: Column { + readonly property string interpretableSipAddress: SipAddressesModel.interpretUrl(searchBox.filter) - height: SmartSearchBarStyle.header.height + height: { + var height = SmartSearchBarStyle.header.addButtonHeight + return defaultContact.visible ? height + searchBox.entryHeight : height + } width: parent.width - onClicked: { - searchBox.hideMenu() - searchBox.addContact(searchBox.filter) + spacing: 0 + + // ------------------------------------------------------------------------- + // Default contact. + // ------------------------------------------------------------------------- + + Loader { + id: defaultContact + + height: searchBox.entryHeight + width: parent.width + + visible: interpretableSipAddress.length > 0 + + sourceComponent: Rectangle { + anchors.fill: parent + color: SmartSearchBarStyle.entry.color.normal + + RowLayout { + anchors { + fill: parent + rightMargin: SmartSearchBarStyle.entry.rightMargin + } + spacing: 0 + + Contact { + id: contact + + Layout.fillHeight: true + Layout.fillWidth: true + entry: Object ({ + sipAddress: interpretableSipAddress + }) + } + + ActionBar { + iconSize: SmartSearchBarStyle.entry.iconSize + + ActionButton { + icon: 'video_call' + onClicked: { + searchBox.hideMenu() + searchBox.launchVideoCall(interpretableSipAddress) + } + } + + ActionButton { + icon: 'call' + onClicked: { + searchBox.hideMenu() + searchBox.launchCall(interpretableSipAddress) + } + } + + ActionButton { + icon: 'chat' + onClicked: { + searchBox.hideMenu() + searchBox.launchChat(interpretableSipAddress) + } + } + } + } + } } - Rectangle { - anchors.fill: parent - color: parent.pressed + // ------------------------------------------------------------------------- + // Add contact button. + // ------------------------------------------------------------------------- + + MouseArea { + id: addContactButton + + height: SmartSearchBarStyle.header.addButtonHeight + width: parent.width + + onClicked: { + searchBox.hideMenu() + searchBox.addContact(interpretableSipAddress) + } + + Rectangle { + anchors.fill: parent + color: parent.pressed ? SmartSearchBarStyle.header.color.pressed : SmartSearchBarStyle.header.color.normal - Text { - anchors { - left: parent.left - leftMargin: SmartSearchBarStyle.header.leftMargin - verticalCenter: parent.verticalCenter - } - font { - bold: true - pointSize: SmartSearchBarStyle.header.text.fontSize - } - color: headerContent.pressed + Text { + anchors { + left: parent.left + leftMargin: SmartSearchBarStyle.header.leftMargin + verticalCenter: parent.verticalCenter + } + font { + bold: true + pointSize: SmartSearchBarStyle.header.text.fontSize + } + color: addContactButton.pressed ? SmartSearchBarStyle.header.text.color.pressed : SmartSearchBarStyle.header.text.color.normal - text: qsTr('addContact') - } - - Icon { - anchors { - right: parent.right - rightMargin: SmartSearchBarStyle.header.rightMargin - verticalCenter: parent.verticalCenter + text: qsTr('addContact') + } + + Icon { + anchors { + right: parent.right + rightMargin: SmartSearchBarStyle.header.rightMargin + verticalCenter: parent.verticalCenter + } + icon: 'contact_add' + iconSize: SmartSearchBarStyle.header.iconSize } - icon: 'contact_add' - iconSize: SmartSearchBarStyle.header.iconSize } } } + // --------------------------------------------------------------------------- // Entries. // --------------------------------------------------------------------------- delegate: Rectangle { - id: searchBoxEntry + id: sipAddressEntry color: SmartSearchBarStyle.entry.color.normal height: searchBox.entryHeight @@ -97,9 +178,9 @@ SearchBox { } spacing: 0 - // --------------------------------------------------------------------- + // ------------------------------------------------------------------- // Contact or address info. - // --------------------------------------------------------------------- + // ------------------------------------------------------------------- Contact { Layout.fillHeight: true @@ -107,9 +188,9 @@ SearchBox { entry: $entry } - // --------------------------------------------------------------------- + // ------------------------------------------------------------------- // Actions - // --------------------------------------------------------------------- + // ------------------------------------------------------------------- ActionBar { iconSize: SmartSearchBarStyle.entry.iconSize @@ -155,7 +236,7 @@ SearchBox { PropertyChanges { color: SmartSearchBarStyle.entry.color.hovered - target: searchBoxEntry + target: sipAddressEntry } PropertyChanges { diff --git a/tests/ui/modules/Linphone/Styles/SmartSearchBarStyle.qml b/tests/ui/modules/Linphone/Styles/SmartSearchBarStyle.qml index 4f206a013..9922f5435 100644 --- a/tests/ui/modules/Linphone/Styles/SmartSearchBarStyle.qml +++ b/tests/ui/modules/Linphone/Styles/SmartSearchBarStyle.qml @@ -27,7 +27,7 @@ QtObject { } property QtObject header: QtObject { - property int height: 40 + property int addButtonHeight: 40 property int iconSize: 22 property int leftMargin: 20 property int rightMargin: 10 diff --git a/tests/ui/views/App/MainWindow/ContactEdit.qml b/tests/ui/views/App/MainWindow/ContactEdit.qml index 5adadbf25..db79454b2 100644 --- a/tests/ui/views/App/MainWindow/ContactEdit.qml +++ b/tests/ui/views/App/MainWindow/ContactEdit.qml @@ -89,9 +89,7 @@ ColumnLayout { _vcard = CoreManager.createDetachedVcardModel() if (sipAddress && sipAddress.length > 0) { - _vcard.addSipAddress( - Utils.startsWith(sipAddress, 'sip:') ? sipAddress : 'sip:' + sipAddress - ) + _vcard.addSipAddress(sipAddress) } _edition = true @@ -215,12 +213,8 @@ ColumnLayout { // ----------------------------------------------------------------------- function _handleSipAddressChanged (index, defaultValue, newValue) { - if (!Utils.startsWith(newValue, 'sip:')) { - newValue = 'sip:' + newValue - - if (newValue === defaultValue) { - return - } + if (newValue === defaultValue) { + return } var so_far_so_good = (defaultValue.length === 0)