Commit 36a308b7 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/modules/Linphone/SmartSearchBar):

  - it uses a style file
  - provide signals handlers
parent 4634f4ce
...@@ -486,6 +486,13 @@ ...@@ -486,6 +486,13 @@
<translation>Search contact or enter SIP address</translation> <translation>Search contact or enter SIP address</translation>
</message> </message>
</context> </context>
<context>
<name>SmartSearchBar</name>
<message>
<source>addContact</source>
<translation>ADD CONTACT</translation>
</message>
</context>
<context> <context>
<name>Timeline</name> <name>Timeline</name>
<message> <message>
......
...@@ -474,6 +474,13 @@ ...@@ -474,6 +474,13 @@
<translation>Rechercher un contact ou entrer une adresse SIP</translation> <translation>Rechercher un contact ou entrer une adresse SIP</translation>
</message> </message>
</context> </context>
<context>
<name>SmartSearchBar</name>
<message>
<source>addContact</source>
<translation>AJOUTER CONTACT</translation>
</message>
</context>
<context> <context>
<name>Timeline</name> <name>Timeline</name>
<message> <message>
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
<file>assets/images/contact_add_hovered.svg</file> <file>assets/images/contact_add_hovered.svg</file>
<file>assets/images/contact_add_normal.svg</file> <file>assets/images/contact_add_normal.svg</file>
<file>assets/images/contact_add_pressed.svg</file> <file>assets/images/contact_add_pressed.svg</file>
<file>assets/images/contact_add.svg</file>
<file>assets/images/contact_card_photo_disabled.svg</file> <file>assets/images/contact_card_photo_disabled.svg</file>
<file>assets/images/contact_card_photo_hovered.svg</file> <file>assets/images/contact_card_photo_hovered.svg</file>
<file>assets/images/contact_card_photo_normal.svg</file> <file>assets/images/contact_card_photo_normal.svg</file>
...@@ -222,6 +223,7 @@ ...@@ -222,6 +223,7 @@
<file>ui/modules/Linphone/Styles/NotificationStyle.qml</file> <file>ui/modules/Linphone/Styles/NotificationStyle.qml</file>
<file>ui/modules/Linphone/Styles/Presence/PresenceStringStyle.qml</file> <file>ui/modules/Linphone/Styles/Presence/PresenceStringStyle.qml</file>
<file>ui/modules/Linphone/Styles/qmldir</file> <file>ui/modules/Linphone/Styles/qmldir</file>
<file>ui/modules/Linphone/Styles/SmartSearchBarStyle.qml</file>
<file>ui/modules/Linphone/Styles/TimelineStyle.qml</file> <file>ui/modules/Linphone/Styles/TimelineStyle.qml</file>
<file>ui/modules/Linphone/Timeline.qml</file> <file>ui/modules/Linphone/Timeline.qml</file>
<file>ui/scripts/LinphoneUtils/linphone-utils.js</file> <file>ui/scripts/LinphoneUtils/linphone-utils.js</file>
......
import QtQuick 2.7 import QtQuick 2.7
import Common 1.0
import Utils 1.0 import Utils 1.0
// ============================================================================= // =============================================================================
...@@ -7,8 +8,7 @@ import Utils 1.0 ...@@ -7,8 +8,7 @@ import Utils 1.0
// ============================================================================= // =============================================================================
AbstractDropDownMenu { AbstractDropDownMenu {
// Can be computed, but for performance usage, it must be given // Can be computed, but for performance usage, it must be given in attribute.
// in attribute.
property int entryHeight property int entryHeight
property int maxMenuHeight property int maxMenuHeight
...@@ -22,6 +22,9 @@ AbstractDropDownMenu { ...@@ -22,6 +22,9 @@ AbstractDropDownMenu {
var height = list.count * entryHeight var height = list.count * entryHeight
if (list.headerPositioning === ListView.OverlayHeader) { if (list.headerPositioning === ListView.OverlayHeader) {
// Workaround to force header layout.
list.headerItem.z = Constants.zMax
height += list.headerItem.height height += list.headerItem.height
} }
......
...@@ -12,9 +12,10 @@ import Utils 1.0 ...@@ -12,9 +12,10 @@ import Utils 1.0
Item { Item {
id: searchBox id: searchBox
property alias header: list.header readonly property alias filter: searchField.text
property alias delegate: list.delegate property alias delegate: list.delegate
property alias header: list.header
property alias entryHeight: menu.entryHeight property alias entryHeight: menu.entryHeight
property alias maxMenuHeight: menu.maxMenuHeight property alias maxMenuHeight: menu.maxMenuHeight
......
...@@ -3,26 +3,75 @@ import QtQuick.Layouts 1.3 ...@@ -3,26 +3,75 @@ import QtQuick.Layouts 1.3
import Common 1.0 import Common 1.0
import Linphone 1.0 import Linphone 1.0
import Linphone.Styles 1.0
// ============================================================================= // =============================================================================
SearchBox { SearchBox {
id: searchBox id: searchBox
header: Rectangle { // ---------------------------------------------------------------------------
color: '#4B5964'
height: 40 signal addContact (string sipAddress)
signal launchChat (string sipAddress)
signal launchCall (string sipAddress)
signal launchVideoCall (string sipAddress)
// ---------------------------------------------------------------------------
header: MouseArea {
id: headerContent
height: SmartSearchBarStyle.header.height
width: parent.width width: parent.width
MouseArea { onClicked: {
searchBox.hideMenu()
searchBox.addContact(searchBox.filter)
}
Rectangle {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true 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
? 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
}
icon: 'contact_add'
iconSize: SmartSearchBarStyle.header.iconSize
}
} }
} }
// ---------------------------------------------------------------------------
// Entries.
// ---------------------------------------------------------------------------
delegate: Rectangle { delegate: Rectangle {
id: searchBoxEntry id: searchBoxEntry
color: SmartSearchBarStyle.entry.color.normal
height: searchBox.entryHeight height: searchBox.entryHeight
width: parent ? parent.width : 0 width: parent ? parent.width : 0
...@@ -32,7 +81,7 @@ SearchBox { ...@@ -32,7 +81,7 @@ SearchBox {
anchors.left: parent.left anchors.left: parent.left
color: 'transparent' color: 'transparent'
height: parent.height height: parent.height
width: 5 width: SmartSearchBarStyle.entry.indicator.width
} }
MouseArea { MouseArea {
...@@ -44,12 +93,12 @@ SearchBox { ...@@ -44,12 +93,12 @@ SearchBox {
RowLayout { RowLayout {
anchors { anchors {
fill: parent fill: parent
rightMargin: 10 rightMargin: SmartSearchBarStyle.entry.rightMargin
} }
spacing: 0 spacing: 0
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// Contact or address info // Contact or address info.
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
Contact { Contact {
...@@ -63,35 +112,39 @@ SearchBox { ...@@ -63,35 +112,39 @@ SearchBox {
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
ActionBar { ActionBar {
iconSize: 36 iconSize: SmartSearchBarStyle.entry.iconSize
ActionButton { ActionButton {
icon: 'video_call' icon: 'video_call'
onClicked: CallsWindow.show() onClicked: {
searchBox.hideMenu()
searchBox.launchVideoCall($entry.sipAddress)
}
} }
ActionButton { ActionButton {
icon: 'call' icon: 'call'
onClicked: CallsWindow.show() onClicked: {
searchBox.hideMenu()
searchBox.launchCall($entry.sipAddress)
}
} }
ActionButton { ActionButton {
icon: 'chat' icon: 'chat'
onClicked: { onClicked: {
searchBox.hideMenu() searchBox.hideMenu()
window.ensureCollapsed() searchBox.launchChat($entry.sipAddress)
window.setView('Conversation', {
sipAddress: $entry.sipAddress
})
} }
} }
} }
} }
} }
// Separator.
Rectangle { Rectangle {
color: '#CBCBCB' color: SmartSearchBarStyle.entry.separator.color
height: 1 height: SmartSearchBarStyle.entry.separator.height
width: parent.width width: parent.width
} }
...@@ -101,12 +154,12 @@ SearchBox { ...@@ -101,12 +154,12 @@ SearchBox {
when: mouseArea.containsMouse when: mouseArea.containsMouse
PropertyChanges { PropertyChanges {
color: '#D0D8DE' color: SmartSearchBarStyle.entry.color.hovered
target: searchBoxEntry target: searchBoxEntry
} }
PropertyChanges { PropertyChanges {
color: '#FF5E00' color: SmartSearchBarStyle.entry.indicator.color
target: indicator target: indicator
} }
} }
......
pragma Singleton
import QtQuick 2.7
import Common 1.0
// =============================================================================
QtObject {
property QtObject entry: QtObject {
property int rightMargin: 10
property int iconSize: 36
property QtObject color: QtObject {
property color normal: Colors.k
property color hovered: Colors.y
}
property QtObject indicator: QtObject {
property color color: Colors.i
property int width: 5
}
property QtObject separator: QtObject {
property color color: Colors.c
property int height: 1
}
}
property QtObject header: QtObject {
property int height: 40
property int iconSize: 22
property int leftMargin: 20
property int rightMargin: 10
property QtObject color: QtObject {
property color normal: Colors.j
property color pressed: Colors.i
}
property QtObject text: QtObject {
property int fontSize: 9
property QtObject color: QtObject {
property color normal: Colors.k
property color pressed: Colors.k
}
}
}
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module Linphone.Style module Linphone.Style
# Components styles -------------------------------------------------- # Components styles ------------------------------------------------------------
singleton AccountStatusStyle 1.0 Account/AccountStatusStyle.qml singleton AccountStatusStyle 1.0 Account/AccountStatusStyle.qml
...@@ -16,4 +16,6 @@ singleton NotificationStyle 1.0 NotificationStyle.qml ...@@ -16,4 +16,6 @@ singleton NotificationStyle 1.0 NotificationStyle.qml
singleton PresenceStringStyle 1.0 Presence/PresenceStringStyle.qml singleton PresenceStringStyle 1.0 Presence/PresenceStringStyle.qml
singleton SmartSearchBarStyle 1.0 SmartSearchBarStyle.qml
singleton TimelineStyle 1.0 TimelineStyle.qml singleton TimelineStyle 1.0 TimelineStyle.qml
...@@ -146,6 +146,21 @@ ApplicationWindow { ...@@ -146,6 +146,21 @@ ApplicationWindow {
placeholderText: qsTr('mainSearchBarPlaceholder') placeholderText: qsTr('mainSearchBarPlaceholder')
model: SmartSearchBarModel {} model: SmartSearchBarModel {}
onAddContact: {
window.ensureCollapsed()
window.setView('ContactEdit', {
sipAddress: sipAddress
})
}
onLaunchCall: CallsWindow.show()
onLaunchChat: {
window.ensureCollapsed()
window.setView('Conversation', {
sipAddress: sipAddress
})
}
onLaunchVideoCall: CallsWindow.show()
} }
} }
} }
......
...@@ -2,6 +2,7 @@ pragma Singleton ...@@ -2,6 +2,7 @@ pragma Singleton
import QtQuick 2.7 import QtQuick 2.7
import Common 1.0 import Common 1.0
import Linphone.Styles 1.0
// ============================================================================= // =============================================================================
...@@ -30,7 +31,7 @@ QtObject { ...@@ -30,7 +31,7 @@ QtObject {
} }
property QtObject searchBox: QtObject { property QtObject searchBox: QtObject {
property int entryHeight: 51 property int entryHeight: 50 + SmartSearchBarStyle.entry.separator.height
property int maxHeight: 300 // See Hick's law for good choice. property int maxHeight: 300 // See Hick's law for good choice.
} }
......
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