mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-02-03 12:49:29 +00:00
feat(ui/modules/Common/SearchBox): supports headers
This commit is contained in:
parent
e017c5423a
commit
4634f4ceec
9 changed files with 36 additions and 40 deletions
|
|
@ -4,9 +4,9 @@ import Common 1.0
|
|||
import Common.Styles 1.0
|
||||
import Utils 1.0
|
||||
|
||||
// ===================================================================
|
||||
// =============================================================================
|
||||
// Low component to display a list/menu in a popup.
|
||||
// ===================================================================
|
||||
// =============================================================================
|
||||
|
||||
Item {
|
||||
id: menu
|
||||
|
|
@ -27,7 +27,7 @@ Item {
|
|||
signal menuClosed
|
||||
signal menuOpened
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function isOpen () {
|
||||
return _isOpen
|
||||
|
|
@ -58,7 +58,7 @@ Item {
|
|||
throw new Error('Virtual method must be implemented.')
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
implicitHeight: 0
|
||||
opacity: 0
|
||||
|
|
@ -74,7 +74,7 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
// Block clicks, wheel... below menu.
|
||||
// Handle clicks, wheel... below menu.
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
|
|
@ -100,14 +100,13 @@ Item {
|
|||
enabled: parent.visible
|
||||
|
||||
onPressed: {
|
||||
if (launcher != null && pointIsInItem(launcher)) {
|
||||
return
|
||||
if (launcher == null || !pointIsInItem(launcher)) {
|
||||
hideMenu()
|
||||
}
|
||||
hideMenu()
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
states: State {
|
||||
name: 'opened'
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import QtQuick.Window 2.2
|
|||
|
||||
import Common.Styles 1.0
|
||||
|
||||
// ===================================================================
|
||||
// =============================================================================
|
||||
|
||||
Item {
|
||||
id: wrapper
|
||||
|
|
@ -27,7 +27,7 @@ Item {
|
|||
_isOpen = false
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// DO NOT TOUCH THIS PROPERTIES.
|
||||
|
||||
|
|
@ -51,12 +51,11 @@ Item {
|
|||
Item {
|
||||
id: content
|
||||
|
||||
// Fake parent.
|
||||
property var $parent: wrapper
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
states: State {
|
||||
name: 'opened'
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import QtQuick 2.7
|
||||
|
||||
import Utils 1.0
|
||||
|
||||
// =============================================================================
|
||||
|
|
@ -11,13 +13,18 @@ AbstractDropDownMenu {
|
|||
property int maxMenuHeight
|
||||
|
||||
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(Utils.qmlTypeof(list, 'QQuickListView'), 'No list view parameter.')
|
||||
|
||||
var height = list.count * entryHeight
|
||||
|
||||
if (list.headerPositioning === ListView.OverlayHeader) {
|
||||
height += list.headerItem.height
|
||||
}
|
||||
|
||||
return (maxMenuHeight !== undefined && height > maxMenuHeight)
|
||||
? maxMenuHeight
|
||||
: height
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// ===================================================================
|
||||
import Utils 1.0
|
||||
|
||||
// =============================================================================
|
||||
// Menu which supports menu like `ActionMenu` or `Menu`.
|
||||
// ===================================================================
|
||||
// =============================================================================
|
||||
|
||||
AbstractDropDownMenu {
|
||||
function _computeHeight () {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import QtGraphicalEffects 1.0
|
|||
|
||||
import Common.Styles 1.0
|
||||
|
||||
// ===================================================================
|
||||
// =============================================================================
|
||||
|
||||
DropShadow {
|
||||
color: PopupStyle.shadow.color
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import Utils 1.0
|
|||
Item {
|
||||
id: searchBox
|
||||
|
||||
property alias header: menu.header
|
||||
property alias header: list.header
|
||||
|
||||
property alias delegate: list.delegate
|
||||
property alias entryHeight: menu.entryHeight
|
||||
|
|
@ -105,6 +105,7 @@ Item {
|
|||
id: list
|
||||
|
||||
anchors.fill: parent
|
||||
headerPositioning: header ? ListView.OverlayHeader : ListView.InlineFooter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import QtQuick.Controls 2.0
|
|||
|
||||
import Common 1.0
|
||||
|
||||
// ===================================================================
|
||||
// =============================================================================
|
||||
|
||||
ListView {
|
||||
ScrollBar.vertical: ForceScrollBar {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ Rectangle {
|
|||
Layout.preferredHeight: ContactStyle.contentHeight
|
||||
Layout.preferredWidth: ContactStyle.contentHeight
|
||||
image: _contact && _contact.vcard.avatar
|
||||
presenceLevel: _contact ? contact.presenceLevel : Presence.White
|
||||
presenceLevel: _contact ? _contact.presenceLevel : Presence.White
|
||||
username: LinphoneUtils.getContactUsername(_contact || sipAddress)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import QtQuick.Layouts 1.3
|
|||
|
||||
import Common 1.0
|
||||
import Linphone 1.0
|
||||
import LinphoneUtils 1.0
|
||||
|
||||
// =============================================================================
|
||||
|
||||
|
|
@ -13,7 +12,12 @@ SearchBox {
|
|||
header: Rectangle {
|
||||
color: '#4B5964'
|
||||
height: 40
|
||||
width: 10
|
||||
width: parent.width
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
}
|
||||
}
|
||||
|
||||
delegate: Rectangle {
|
||||
|
|
@ -40,34 +44,18 @@ SearchBox {
|
|||
RowLayout {
|
||||
anchors {
|
||||
fill: parent
|
||||
leftMargin: 22
|
||||
rightMargin: 10
|
||||
}
|
||||
spacing: 15
|
||||
spacing: 0
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Contact or address info
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
Avatar {
|
||||
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 {
|
||||
Contact {
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
|
||||
sipAddress: $entry.sipAddress
|
||||
sipAddressColor: '#A1A1A1'
|
||||
username: avatar.username
|
||||
usernameColor: '#4B5964'
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue