Commit d37c3b81 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/modules/Linphone/SmartSearchBar): supports not registered sip addresses

parent 39e83ddb
...@@ -134,6 +134,16 @@ void SipAddressesModel::handleAllHistoryEntriesRemoved () { ...@@ -134,6 +134,16 @@ void SipAddressesModel::handleAllHistoryEntriesRemoved () {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
QString SipAddressesModel::interpretUrl (const QString &sip_address) {
shared_ptr<linphone::Address> 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) { bool SipAddressesModel::removeRow (int row, const QModelIndex &parent) {
return removeRows(row, 1, parent); return removeRows(row, 1, parent);
} }
......
...@@ -27,6 +27,8 @@ public: ...@@ -27,6 +27,8 @@ public:
Q_INVOKABLE void handleAllHistoryEntriesRemoved (); Q_INVOKABLE void handleAllHistoryEntriesRemoved ();
Q_INVOKABLE QString interpretUrl (const QString &sip_address);
private: private:
bool removeRow (int row, const QModelIndex &parent = QModelIndex()); bool removeRow (int row, const QModelIndex &parent = QModelIndex());
bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex()) override; bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex()) override;
......
...@@ -19,6 +19,7 @@ Rectangle { ...@@ -19,6 +19,7 @@ Rectangle {
property alias usernameColor: description.usernameColor property alias usernameColor: description.usernameColor
property var entry property var entry
property var _contact: entry.contact property var _contact: entry.contact
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
......
...@@ -19,57 +19,138 @@ SearchBox { ...@@ -19,57 +19,138 @@ SearchBox {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
header: MouseArea { header: Column {
id: headerContent 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 width: parent.width
onClicked: { spacing: 0
searchBox.hideMenu()
searchBox.addContact(searchBox.filter) // -------------------------------------------------------------------------
// 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 // Add contact button.
color: parent.pressed // -------------------------------------------------------------------------
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.pressed
: SmartSearchBarStyle.header.color.normal : SmartSearchBarStyle.header.color.normal
Text { Text {
anchors { anchors {
left: parent.left left: parent.left
leftMargin: SmartSearchBarStyle.header.leftMargin leftMargin: SmartSearchBarStyle.header.leftMargin
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
} }
font { font {
bold: true bold: true
pointSize: SmartSearchBarStyle.header.text.fontSize pointSize: SmartSearchBarStyle.header.text.fontSize
} }
color: headerContent.pressed color: addContactButton.pressed
? SmartSearchBarStyle.header.text.color.pressed ? SmartSearchBarStyle.header.text.color.pressed
: SmartSearchBarStyle.header.text.color.normal : SmartSearchBarStyle.header.text.color.normal
text: qsTr('addContact') text: qsTr('addContact')
} }
Icon { Icon {
anchors { anchors {
right: parent.right right: parent.right
rightMargin: SmartSearchBarStyle.header.rightMargin rightMargin: SmartSearchBarStyle.header.rightMargin
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
}
icon: 'contact_add'
iconSize: SmartSearchBarStyle.header.iconSize
} }
icon: 'contact_add'
iconSize: SmartSearchBarStyle.header.iconSize
} }
} }
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Entries. // Entries.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
delegate: Rectangle { delegate: Rectangle {
id: searchBoxEntry id: sipAddressEntry
color: SmartSearchBarStyle.entry.color.normal color: SmartSearchBarStyle.entry.color.normal
height: searchBox.entryHeight height: searchBox.entryHeight
...@@ -97,9 +178,9 @@ SearchBox { ...@@ -97,9 +178,9 @@ SearchBox {
} }
spacing: 0 spacing: 0
// --------------------------------------------------------------------- // -------------------------------------------------------------------
// Contact or address info. // Contact or address info.
// --------------------------------------------------------------------- // -------------------------------------------------------------------
Contact { Contact {
Layout.fillHeight: true Layout.fillHeight: true
...@@ -107,9 +188,9 @@ SearchBox { ...@@ -107,9 +188,9 @@ SearchBox {
entry: $entry entry: $entry
} }
// --------------------------------------------------------------------- // -------------------------------------------------------------------
// Actions // Actions
// --------------------------------------------------------------------- // -------------------------------------------------------------------
ActionBar { ActionBar {
iconSize: SmartSearchBarStyle.entry.iconSize iconSize: SmartSearchBarStyle.entry.iconSize
...@@ -155,7 +236,7 @@ SearchBox { ...@@ -155,7 +236,7 @@ SearchBox {
PropertyChanges { PropertyChanges {
color: SmartSearchBarStyle.entry.color.hovered color: SmartSearchBarStyle.entry.color.hovered
target: searchBoxEntry target: sipAddressEntry
} }
PropertyChanges { PropertyChanges {
......
...@@ -27,7 +27,7 @@ QtObject { ...@@ -27,7 +27,7 @@ QtObject {
} }
property QtObject header: QtObject { property QtObject header: QtObject {
property int height: 40 property int addButtonHeight: 40
property int iconSize: 22 property int iconSize: 22
property int leftMargin: 20 property int leftMargin: 20
property int rightMargin: 10 property int rightMargin: 10
......
...@@ -89,9 +89,7 @@ ColumnLayout { ...@@ -89,9 +89,7 @@ ColumnLayout {
_vcard = CoreManager.createDetachedVcardModel() _vcard = CoreManager.createDetachedVcardModel()
if (sipAddress && sipAddress.length > 0) { if (sipAddress && sipAddress.length > 0) {
_vcard.addSipAddress( _vcard.addSipAddress(sipAddress)
Utils.startsWith(sipAddress, 'sip:') ? sipAddress : 'sip:' + sipAddress
)
} }
_edition = true _edition = true
...@@ -215,12 +213,8 @@ ColumnLayout { ...@@ -215,12 +213,8 @@ ColumnLayout {
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
function _handleSipAddressChanged (index, defaultValue, newValue) { function _handleSipAddressChanged (index, defaultValue, newValue) {
if (!Utils.startsWith(newValue, 'sip:')) { if (newValue === defaultValue) {
newValue = 'sip:' + newValue return
if (newValue === defaultValue) {
return
}
} }
var so_far_so_good = (defaultValue.length === 0) var so_far_so_good = (defaultValue.length === 0)
......
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