feat(Timeline): supports the selection of contact

This commit is contained in:
Ronan Abhamon 2016-11-02 16:34:54 +01:00
parent bd3eb7482e
commit cc4e0252cc
5 changed files with 53 additions and 9 deletions

View file

@ -27,7 +27,7 @@ Item {
effect: ShaderEffect { effect: ShaderEffect {
property var image: imageContainer property var image: imageContainer
fragmentShader: " fragmentShader: '
uniform lowp sampler2D image; uniform lowp sampler2D image;
uniform lowp sampler2D mask; uniform lowp sampler2D mask;
uniform lowp float qt_Opacity; uniform lowp float qt_Opacity;
@ -39,7 +39,7 @@ Item {
texture2D(mask, qt_TexCoord0).a * texture2D(mask, qt_TexCoord0).a *
qt_Opacity; qt_Opacity;
} }
" '
} }
enabled: true enabled: true

View file

@ -7,7 +7,7 @@ import Common 1.0
QtObject { QtObject {
property QtObject sipAddress: QtObject { property QtObject sipAddress: QtObject {
property color color: Colors.d property color color: Colors.w
property int fontSize: 10 property int fontSize: 10
} }

View file

@ -7,9 +7,27 @@ import Common 1.0
QtObject { QtObject {
property QtObject contact: QtObject { property QtObject contact: QtObject {
property color colorA: Colors.g10
property color colorB: Colors.a
property int height: 60 property int height: 60
property QtObject backgroundColor: QtObject {
property color a: Colors.g10
property color b: Colors.a
property color selected: Colors.i
}
property QtObject sipAddress: QtObject {
property QtObject color: QtObject {
property color normal: Colors.w
property color selected: Colors.k
}
}
property QtObject username: QtObject {
property QtObject color: QtObject {
property color normal: Colors.j
property color selected: Colors.k
}
}
} }
property QtObject legend: QtObject { property QtObject legend: QtObject {

View file

@ -13,6 +13,14 @@ ColumnLayout {
signal clicked (var contact) signal clicked (var contact)
// -----------------------------------------------------------------
function resetSelectedItem () {
view.currentIndex = -1
}
// -----------------------------------------------------------------
spacing: 0 spacing: 0
Rectangle { Rectangle {
@ -51,6 +59,7 @@ ColumnLayout {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
currentIndex: -1
delegate: Item { delegate: Item {
height: TimelineStyle.contact.height height: TimelineStyle.contact.height
@ -58,10 +67,20 @@ ColumnLayout {
Contact { Contact {
anchors.fill: parent anchors.fill: parent
color: index % 2 == 0 color: view.currentIndex === index
? TimelineStyle.contact.colorA ? TimelineStyle.contact.backgroundColor.selected
: TimelineStyle.contact.colorB : (
index % 2 == 0
? TimelineStyle.contact.backgroundColor.a
: TimelineStyle.contact.backgroundColor.b
)
contact: $contact contact: $contact
sipAddressColor: view.currentIndex === index
? TimelineStyle.contact.sipAddress.color.selected
: TimelineStyle.contact.sipAddress.color.normal
usernameColor: view.currentIndex === index
? TimelineStyle.contact.username.color.selected
: TimelineStyle.contact.username.color.normal
} }
MouseArea { MouseArea {
@ -71,7 +90,10 @@ ColumnLayout {
: Qt.ArrowCursor : Qt.ArrowCursor
hoverEnabled: true hoverEnabled: true
onClicked: timeline.clicked($contact) onClicked: {
view.currentIndex = index
timeline.clicked($contact)
}
} }
} }
} }

View file

@ -138,6 +138,8 @@ ApplicationWindow {
}] }]
onEntrySelected: { onEntrySelected: {
timeline.resetSelectedItem()
if (entry === 0) { if (entry === 0) {
setView('Home') setView('Home')
} else if (entry === 1) { } else if (entry === 1) {
@ -148,6 +150,8 @@ ApplicationWindow {
// History. // History.
Timeline { Timeline {
id: timeline
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
model: ContactsListModel {} // Use History list. model: ContactsListModel {} // Use History list.