Change toolbar label on chat view opened with the name of remote

This commit is contained in:
Angela Mazzurco 2017-06-08 16:21:33 +02:00
parent 69ed518555
commit 4a90436e8e
3 changed files with 30 additions and 2 deletions

View File

@ -94,6 +94,11 @@ Item {
} }
Component.onCompleted: {
toolBar.state = "CHATVIEW"
toolBar.titleText = model.author_name
}
function getMessageTime(){ function getMessageTime(){
var timeFormat = "hh:mm"; var timeFormat = "hh:mm";

View File

@ -27,6 +27,8 @@ Item
property string chatId property string chatId
property int token: 0 property int token: 0
property string objectName:"chatView"
function refreshData() function refreshData()
{ {

View File

@ -57,6 +57,18 @@ ApplicationWindow
header: ToolBar header: ToolBar
{ {
id: toolBar id: toolBar
property alias titleText: toolBarText.text
property string defaultLabel: "RetroShare"
states: [
State {
name: "DEFAULT"
PropertyChanges { target: toolBar; titleText: defaultLabel}
},
State {
name: "CHATVIEW"
}
]
Image Image
{ {
@ -68,7 +80,8 @@ ApplicationWindow
} }
Label Label
{ {
text: "RetroShare" id: toolBarText
text: defaultLabel
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.left: rsIcon.right anchors.left: rsIcon.right
anchors.leftMargin: 20 anchors.leftMargin: 20
@ -135,7 +148,15 @@ ApplicationWindow
id: stackView id: stackView
anchors.fill: parent anchors.fill: parent
focus: true focus: true
onCurrentItemChanged: if (currentItem) currentItem.focus = true onCurrentItemChanged: {
if (currentItem) {
if (currentItem.objectName != "chatView" && toolBar.state != "DEFAULT"){
toolBar.state = "DEFAULT"
}
currentItem.focus = true
}
}
Keys.onReleased: Keys.onReleased:
if (event.key === Qt.Key_Back && stackView.depth > 1) if (event.key === Qt.Key_Back && stackView.depth > 1)
{ {