Commit eaafc4b0 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(Popup): use style file

parent 885c16f9
import QtGraphicalEffects 1.0
import QtQuick 2.7 import QtQuick 2.7
import QtQuick.Controls 2.0
import Linphone 1.0
import Linphone.Styles 1.0 import Linphone.Styles 1.0
Rectangle { // ===================================================================
readonly property int entryHeight: 50 // Low component to display a list/menu in a popup.
// ===================================================================
Rectangle {
default property alias content: content.data
property int entryHeight
property int maxMenuHeight property int maxMenuHeight
// Ugly. Just ugly.
// `model` is a reference on a unknown component!
// See usage with SearchBox.
implicitHeight: { implicitHeight: {
var height = model.count * entryHeight var height = model.count * entryHeight
return height > maxMenuHeight ? maxMenuHeight : height return height > maxMenuHeight ? maxMenuHeight : height
...@@ -25,124 +29,11 @@ Rectangle { ...@@ -25,124 +29,11 @@ Rectangle {
} }
Rectangle { Rectangle {
anchors.fill: parent id: content
id: listContainer
ScrollableListView {
anchors.fill: parent anchors.fill: parent
id: list color: PopupStyle.backgroundColor
height: console.log(model.count) || count layer.enabled: true
layer.effect: PopupShadow { }
// TODO: Remove, use C++ model instead.
model: ListModel {
id: model
ListElement {
$presence: 'connected'
$sipAddress: 'jim.williams.zzzz.yyyy.kkkk.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'connected'
$sipAddress: 'toto.lala.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'disconnected'
$sipAddress: 'machin.truc.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'absent'
$sipAddress: 'hey.listen.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'do_not_disturb'
$sipAddress: 'valentin.cognito.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'do_not_disturb'
$sipAddress: 'charles.henri.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'disconnected'
$sipAddress: 'yesyes.nono.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'connected'
$sipAddress: 'nsa.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'connected'
$sipAddress: 'jim.williams.zzzz.yyyy.kkkk.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'connected'
$sipAddress: 'toto.lala.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'disconnected'
$sipAddress: 'machin.truc.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'absent'
$sipAddress: 'hey.listen.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'do_not_disturb'
$sipAddress: 'valentin.cognito.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'do_not_disturb'
$sipAddress: 'charles.henri.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'disconnected'
$sipAddress: 'yesyes.nono.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'connected'
$sipAddress: 'nsa.sip.linphone.org'
$username: 'Toto'
}
}
delegate: Contact {
presence: $presence
sipAddress: $sipAddress
username: $username
width: parent.width
actions: [
ActionButton {
icon: 'call'
onClicked: console.log('clicked')
},
ActionButton {
icon: 'cam'
onClicked: console.log('cam clicked')
}
]
}
}
}
PopupShadow {
anchors.fill: listContainer
source: listContainer
visible: true
} }
} }
...@@ -7,8 +7,13 @@ import Linphone.Styles 1.0 ...@@ -7,8 +7,13 @@ import Linphone.Styles 1.0
// =================================================================== // ===================================================================
Item { Item {
property alias placeholderText: searchField.placeholderText id: item
property alias delegate: list.delegate
property alias entryHeight: menu.entryHeight
property alias maxMenuHeight: menu.maxMenuHeight property alias maxMenuHeight: menu.maxMenuHeight
property alias model: list.model
property alias placeholderText: searchField.placeholderText
signal menuClosed () signal menuClosed ()
signal menuOpened () signal menuOpened ()
...@@ -55,6 +60,12 @@ Item { ...@@ -55,6 +60,12 @@ Item {
z: Constants.zPopup z: Constants.zPopup
Keys.onEscapePressed: _hideMenu() Keys.onEscapePressed: _hideMenu()
ScrollableListView {
id: list
anchors.fill: parent
}
} }
InvertedMouseArea { InvertedMouseArea {
......
...@@ -4,6 +4,8 @@ import QtQuick 2.7 ...@@ -4,6 +4,8 @@ import QtQuick 2.7
import Linphone 1.0 import Linphone 1.0
QtObject { QtObject {
property string backgroundColor: Colors.k
property QtObject shadow: QtObject { property QtObject shadow: QtObject {
property double radius: 8.0 property double radius: 8.0
......
...@@ -61,6 +61,7 @@ ApplicationWindow { ...@@ -61,6 +61,7 @@ ApplicationWindow {
Layout.fillWidth: true Layout.fillWidth: true
maxMenuHeight: 300 // See Hick's law for good choice. maxMenuHeight: 300 // See Hick's law for good choice.
placeholderText: qsTr('mainSearchBarPlaceholder') placeholderText: qsTr('mainSearchBarPlaceholder')
entryHeight: 50
onMenuClosed: content.enabled = true onMenuClosed: content.enabled = true
...@@ -70,6 +71,110 @@ ApplicationWindow { ...@@ -70,6 +71,110 @@ ApplicationWindow {
} }
content.enabled = false content.enabled = false
} }
model: ListModel {
id: model
ListElement {
$presence: 'connected'
$sipAddress: 'jim.williams.zzzz.yyyy.kkkk.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'connected'
$sipAddress: 'toto.lala.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'disconnected'
$sipAddress: 'machin.truc.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'absent'
$sipAddress: 'hey.listen.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'do_not_disturb'
$sipAddress: 'valentin.cognito.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'do_not_disturb'
$sipAddress: 'charles.henri.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'disconnected'
$sipAddress: 'yesyes.nono.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'connected'
$sipAddress: 'nsa.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'connected'
$sipAddress: 'jim.williams.zzzz.yyyy.kkkk.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'connected'
$sipAddress: 'toto.lala.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'disconnected'
$sipAddress: 'machin.truc.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'absent'
$sipAddress: 'hey.listen.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'do_not_disturb'
$sipAddress: 'valentin.cognito.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'do_not_disturb'
$sipAddress: 'charles.henri.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'disconnected'
$sipAddress: 'yesyes.nono.sip.linphone.org'
$username: 'Toto'
}
ListElement {
$presence: 'connected'
$sipAddress: 'nsa.sip.linphone.org'
$username: 'Toto'
}
}
delegate: Contact {
presence: $presence
sipAddress: $sipAddress
username: $username
width: parent.width
actions: [
ActionButton {
icon: 'call'
onClicked: console.log('clicked')
},
ActionButton {
icon: 'cam'
onClicked: console.log('cam clicked')
}
]
}
} }
// Start conference. // Start conference.
......
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