Commit 4634f4ce authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/modules/Common/SearchBox): supports headers

parent e017c542
...@@ -4,9 +4,9 @@ import Common 1.0 ...@@ -4,9 +4,9 @@ import Common 1.0
import Common.Styles 1.0 import Common.Styles 1.0
import Utils 1.0 import Utils 1.0
// =================================================================== // =============================================================================
// Low component to display a list/menu in a popup. // Low component to display a list/menu in a popup.
// =================================================================== // =============================================================================
Item { Item {
id: menu id: menu
...@@ -27,7 +27,7 @@ Item { ...@@ -27,7 +27,7 @@ Item {
signal menuClosed signal menuClosed
signal menuOpened signal menuOpened
// ----------------------------------------------------------------- // ---------------------------------------------------------------------------
function isOpen () { function isOpen () {
return _isOpen return _isOpen
...@@ -58,7 +58,7 @@ Item { ...@@ -58,7 +58,7 @@ Item {
throw new Error('Virtual method must be implemented.') throw new Error('Virtual method must be implemented.')
} }
// ----------------------------------------------------------------- // ---------------------------------------------------------------------------
implicitHeight: 0 implicitHeight: 0
opacity: 0 opacity: 0
...@@ -74,7 +74,7 @@ Item { ...@@ -74,7 +74,7 @@ Item {
} }
} }
// Block clicks, wheel... below menu. // Handle clicks, wheel... below menu.
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
...@@ -100,14 +100,13 @@ Item { ...@@ -100,14 +100,13 @@ Item {
enabled: parent.visible enabled: parent.visible
onPressed: { onPressed: {
if (launcher != null && pointIsInItem(launcher)) { if (launcher == null || !pointIsInItem(launcher)) {
return hideMenu()
} }
hideMenu()
} }
} }
// ----------------------------------------------------------------- // ---------------------------------------------------------------------------
states: State { states: State {
name: 'opened' name: 'opened'
......
...@@ -3,7 +3,7 @@ import QtQuick.Window 2.2 ...@@ -3,7 +3,7 @@ import QtQuick.Window 2.2
import Common.Styles 1.0 import Common.Styles 1.0
// =================================================================== // =============================================================================
Item { Item {
id: wrapper id: wrapper
...@@ -27,7 +27,7 @@ Item { ...@@ -27,7 +27,7 @@ Item {
_isOpen = false _isOpen = false
} }
// ----------------------------------------------------------------- // ---------------------------------------------------------------------------
// DO NOT TOUCH THIS PROPERTIES. // DO NOT TOUCH THIS PROPERTIES.
...@@ -51,12 +51,11 @@ Item { ...@@ -51,12 +51,11 @@ Item {
Item { Item {
id: content id: content
// Fake parent.
property var $parent: wrapper property var $parent: wrapper
} }
} }
// ----------------------------------------------------------------- // ---------------------------------------------------------------------------
states: State { states: State {
name: 'opened' name: 'opened'
......
import QtQuick 2.7
import Utils 1.0 import Utils 1.0
// ============================================================================= // =============================================================================
...@@ -11,13 +13,18 @@ AbstractDropDownMenu { ...@@ -11,13 +13,18 @@ AbstractDropDownMenu {
property int maxMenuHeight property int maxMenuHeight
function _computeHeight () { function _computeHeight () {
var list = _content[0] Utils.assert(_content != null && _content.length > 0, '`_content` cannot be null and must exists.')
var list = _content[0]
Utils.assert(list != null, 'No list found.') Utils.assert(list != null, 'No list found.')
Utils.assert(Utils.qmlTypeof(list, 'QQuickListView'), 'No list view parameter.') Utils.assert(Utils.qmlTypeof(list, 'QQuickListView'), 'No list view parameter.')
var height = list.count * entryHeight var height = list.count * entryHeight
if (list.headerPositioning === ListView.OverlayHeader) {
height += list.headerItem.height
}
return (maxMenuHeight !== undefined && height > maxMenuHeight) return (maxMenuHeight !== undefined && height > maxMenuHeight)
? maxMenuHeight ? maxMenuHeight
: height : height
......
// =================================================================== import Utils 1.0
// =============================================================================
// Menu which supports menu like `ActionMenu` or `Menu`. // Menu which supports menu like `ActionMenu` or `Menu`.
// =================================================================== // =============================================================================
AbstractDropDownMenu { AbstractDropDownMenu {
function _computeHeight () { function _computeHeight () {
......
...@@ -2,7 +2,7 @@ import QtGraphicalEffects 1.0 ...@@ -2,7 +2,7 @@ import QtGraphicalEffects 1.0
import Common.Styles 1.0 import Common.Styles 1.0
// =================================================================== // =============================================================================
DropShadow { DropShadow {
color: PopupStyle.shadow.color color: PopupStyle.shadow.color
......
...@@ -12,7 +12,7 @@ import Utils 1.0 ...@@ -12,7 +12,7 @@ import Utils 1.0
Item { Item {
id: searchBox id: searchBox
property alias header: menu.header property alias header: list.header
property alias delegate: list.delegate property alias delegate: list.delegate
property alias entryHeight: menu.entryHeight property alias entryHeight: menu.entryHeight
...@@ -105,6 +105,7 @@ Item { ...@@ -105,6 +105,7 @@ Item {
id: list id: list
anchors.fill: parent anchors.fill: parent
headerPositioning: header ? ListView.OverlayHeader : ListView.InlineFooter
} }
} }
} }
......
...@@ -3,7 +3,7 @@ import QtQuick.Controls 2.0 ...@@ -3,7 +3,7 @@ import QtQuick.Controls 2.0
import Common 1.0 import Common 1.0
// =================================================================== // =============================================================================
ListView { ListView {
ScrollBar.vertical: ForceScrollBar { ScrollBar.vertical: ForceScrollBar {
......
...@@ -34,7 +34,7 @@ Rectangle { ...@@ -34,7 +34,7 @@ Rectangle {
Layout.preferredHeight: ContactStyle.contentHeight Layout.preferredHeight: ContactStyle.contentHeight
Layout.preferredWidth: ContactStyle.contentHeight Layout.preferredWidth: ContactStyle.contentHeight
image: _contact && _contact.vcard.avatar image: _contact && _contact.vcard.avatar
presenceLevel: _contact ? contact.presenceLevel : Presence.White presenceLevel: _contact ? _contact.presenceLevel : Presence.White
username: LinphoneUtils.getContactUsername(_contact || sipAddress) username: LinphoneUtils.getContactUsername(_contact || sipAddress)
} }
......
...@@ -3,7 +3,6 @@ import QtQuick.Layouts 1.3 ...@@ -3,7 +3,6 @@ import QtQuick.Layouts 1.3
import Common 1.0 import Common 1.0
import Linphone 1.0 import Linphone 1.0
import LinphoneUtils 1.0
// ============================================================================= // =============================================================================
...@@ -13,7 +12,12 @@ SearchBox { ...@@ -13,7 +12,12 @@ SearchBox {
header: Rectangle { header: Rectangle {
color: '#4B5964' color: '#4B5964'
height: 40 height: 40
width: 10 width: parent.width
MouseArea {
anchors.fill: parent
hoverEnabled: true
}
} }
delegate: Rectangle { delegate: Rectangle {
...@@ -40,34 +44,18 @@ SearchBox { ...@@ -40,34 +44,18 @@ SearchBox {
RowLayout { RowLayout {
anchors { anchors {
fill: parent fill: parent
leftMargin: 22
rightMargin: 10 rightMargin: 10
} }
spacing: 15 spacing: 0
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// Contact or address info // Contact or address info
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
Avatar { Contact {
id: avatar
Layout.preferredHeight: 30
Layout.preferredWidth: 30
image: $entry.contact && $entry.contact.vcard.avatar
presenceLevel: $entry.contact ? $entry.contact.presenceLevel : -1
username: LinphoneUtils.getContactUsername($entry.contact || $entry.sipAddress)
}
ContactDescription {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
sipAddress: $entry.sipAddress sipAddress: $entry.sipAddress
sipAddressColor: '#A1A1A1'
username: avatar.username
usernameColor: '#4B5964'
} }
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
......
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