From 4a90436e8ec0dc45a081765eb16510310e641972 Mon Sep 17 00:00:00 2001 From: Angela Mazzurco Date: Thu, 8 Jun 2017 16:21:33 +0200 Subject: [PATCH] Change toolbar label on chat view opened with the name of remote --- retroshare-qml-app/src/ChatBubbleDelegate.qml | 5 ++++ retroshare-qml-app/src/ChatView.qml | 2 ++ retroshare-qml-app/src/main-app.qml | 25 +++++++++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/retroshare-qml-app/src/ChatBubbleDelegate.qml b/retroshare-qml-app/src/ChatBubbleDelegate.qml index 80650e07d..6b458ede6 100644 --- a/retroshare-qml-app/src/ChatBubbleDelegate.qml +++ b/retroshare-qml-app/src/ChatBubbleDelegate.qml @@ -94,6 +94,11 @@ Item { } + Component.onCompleted: { + toolBar.state = "CHATVIEW" + toolBar.titleText = model.author_name + } + function getMessageTime(){ var timeFormat = "hh:mm"; diff --git a/retroshare-qml-app/src/ChatView.qml b/retroshare-qml-app/src/ChatView.qml index 0794959ab..625ceb1c4 100644 --- a/retroshare-qml-app/src/ChatView.qml +++ b/retroshare-qml-app/src/ChatView.qml @@ -27,6 +27,8 @@ Item property string chatId property int token: 0 + property string objectName:"chatView" + function refreshData() { diff --git a/retroshare-qml-app/src/main-app.qml b/retroshare-qml-app/src/main-app.qml index 497119d69..033bf2088 100644 --- a/retroshare-qml-app/src/main-app.qml +++ b/retroshare-qml-app/src/main-app.qml @@ -57,6 +57,18 @@ ApplicationWindow header: 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 { @@ -68,7 +80,8 @@ ApplicationWindow } Label { - text: "RetroShare" + id: toolBarText + text: defaultLabel anchors.verticalCenter: parent.verticalCenter anchors.left: rsIcon.right anchors.leftMargin: 20 @@ -135,7 +148,15 @@ ApplicationWindow id: stackView anchors.fill: parent 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: if (event.key === Qt.Key_Back && stackView.depth > 1) {