From 7c6638f4e9446017b17f4b48371049584623a524 Mon Sep 17 00:00:00 2001 From: Angela Mazzurco Date: Tue, 13 Jun 2017 14:51:53 +0200 Subject: [PATCH] Change to Almman indent style --- retroshare-qml-app/src/ChatBubbleDelegate.qml | 19 ++++++---- retroshare-qml-app/src/ChatCache.qml | 27 +++++++++----- retroshare-qml-app/src/Contacts.qml | 8 +++-- .../src/GxsIdentityDelegate.qml | 36 +++++++++---------- retroshare-qml-app/src/main-app.qml | 15 +++++--- 5 files changed, 63 insertions(+), 42 deletions(-) diff --git a/retroshare-qml-app/src/ChatBubbleDelegate.qml b/retroshare-qml-app/src/ChatBubbleDelegate.qml index fc4f03f4a..3b620a5fd 100644 --- a/retroshare-qml-app/src/ChatBubbleDelegate.qml +++ b/retroshare-qml-app/src/ChatBubbleDelegate.qml @@ -4,7 +4,8 @@ import QtQuick.Controls 2.0 import "." // To load styles import "./components" -Item { +Item +{ id: chatBubbleDelegate height: bubble.height @@ -13,7 +14,8 @@ Item { property var styles: StyleChat.bubble - Rectangle { + Rectangle + { id: rootBubble anchors.fill: parent width: parent.width @@ -37,7 +39,8 @@ Item { radius: styles.radius - Text { + Text + { id: sendersName visible: model.incoming text: (model.incoming)? model.author_name + ":" : "" @@ -57,7 +60,8 @@ Item { mesageText.implicitWidth >= (rootBubble.width * styles.bubbleMaxWidth) )? implicitHeight : 0 } - Text { + Text + { id: timeText text: getMessageTime() color: styles.colorMessageTime @@ -73,7 +77,8 @@ Item { } - Text { + Text + { id: mesageText text: model.msg width: rootBubble.width * styles.bubbleMaxWidth + timeText.width @@ -96,8 +101,8 @@ Item { } - function getMessageTime(){ - + function getMessageTime() + { var timeFormat = "hh:mm"; var recvDate = new Date(model.recv_time*1000) diff --git a/retroshare-qml-app/src/ChatCache.qml b/retroshare-qml-app/src/ChatCache.qml index 92b1b277a..76902d027 100644 --- a/retroshare-qml-app/src/ChatCache.qml +++ b/retroshare-qml-app/src/ChatCache.qml @@ -5,7 +5,8 @@ import QtQuick.Controls 2.0 import org.retroshare.qml_components.LibresapiLocalClient 1.0 import Qt.labs.settings 1.0 -QtObject { +QtObject +{ id: chatCache @@ -17,7 +18,8 @@ QtObject { signal lastMessageChanged(var chatI, var newLastMessage) - function updateLastMessageCache (chatId, chatModel){ + function updateLastMessageCache (chatId, chatModel) + { console.log("updateLastMessageCache (chatId, chatModel)", chatId) // First creates the chat id object for don't wait to work with the object if is needed to call RS api if (!lastMessageList[chatId]) { @@ -33,24 +35,28 @@ QtObject { } } - function updateLastMessage (chatId, chatModel){ + function updateLastMessage (chatId, chatModel) + { console.log("updateLastMessage (chatId, chatModel)") var lastMessage = findChatLastMessage (chatModel) lastMessageList[chatId].lastMessage = lastMessage lastMessageChanged(chatId, lastMessage) } - function findChatLastMessage (chatModel){ + function findChatLastMessage (chatModel) + { var messagesData = JSON.parse(chatModel).data return messagesData.slice(-1)[0] } - function findChatFirstMessage (chatModel){ + function findChatFirstMessage (chatModel) + { var messagesData = JSON.parse(chatModel).data return messagesData.slice[0] } - function setRemoteGXS (chatId, remoteGXS){ + function setRemoteGXS (chatId, remoteGXS) + { if (!lastMessageList[chatId]) { lastMessageList[chatId] = {} console.log("Last message cache created!") @@ -64,7 +70,8 @@ QtObject { } } - function getChatIdFromGxs (gxs){ + function getChatIdFromGxs (gxs) + { for (var key in lastMessageList) { if ( lastMessageList[key].remoteGXS && lastMessageList[key].remoteGXS.gxs === gxs ) { @@ -74,12 +81,14 @@ QtObject { return "" } - function getGxsFromChatId (chatId){ + function getGxsFromChatId (chatId) + { if (lastMessageList[chatId]) return lastMessageList[chatId].remoteGXS return undefined } - function getChatLastMessage (chatId){ + function getChatLastMessage (chatId) + { if (lastMessageList[chatId]) { return lastMessageList[chatId].lastMessage } diff --git a/retroshare-qml-app/src/Contacts.qml b/retroshare-qml-app/src/Contacts.qml index 7c68bbe7f..8b3a8f754 100644 --- a/retroshare-qml-app/src/Contacts.qml +++ b/retroshare-qml-app/src/Contacts.qml @@ -101,7 +101,8 @@ Item TokensManager.registerToken(json.statetoken, refreshUnread) contactsSortWorker.sendMessage( {'action': 'refreshUnread', 'response': par.response}) - json.data.forEach (function (chat){ + json.data.forEach (function (chat) + { ChatCache.lastMessageCache.updateLastMessageCache(chat.chat_id) ChatCache.lastMessageCache.setRemoteGXS (chat.chat_id, { gxs: chat.remote_author_id, name: chat.remote_author_name}) }) @@ -176,13 +177,14 @@ Item width: parent.width - searchIcon.width - 5 anchors.leftMargin: 5 - background: Rectangle { + background: Rectangle + { border.width: 2 radius: 5 border.color: searchText.focus ? "cornflowerblue" : "lightgrey" color: searchText.focus ? "white" : "ghostwhite" - } + onTextChanged: contactsSortWorker.sendMessage( {'action': 'searchContact', 'sexp': text}) diff --git a/retroshare-qml-app/src/GxsIdentityDelegate.qml b/retroshare-qml-app/src/GxsIdentityDelegate.qml index bd53a029e..21ed893c0 100644 --- a/retroshare-qml-app/src/GxsIdentityDelegate.qml +++ b/retroshare-qml-app/src/GxsIdentityDelegate.qml @@ -33,14 +33,14 @@ Item property var locale: Qt.locale() - Rectangle { + Rectangle + { anchors.fill: parent color: contactItem.containsMouse ? "lightgrey" : "transparent" width: parent.width height: parent.height - MouseArea { id: contactItem @@ -117,11 +117,7 @@ Item text: setTime() anchors.right: parent.right color: "darkslategrey" - } - - - } Item @@ -130,8 +126,6 @@ Item width: parent.width height: parent.height /2 - - Text { id: lastMessageSender @@ -204,7 +198,8 @@ Item } - Component.onCompleted: { + Component.onCompleted: + { if (!chatId){ chatId = getChatIdFromGXS() } @@ -214,7 +209,8 @@ Item } } - Connections { + Connections + { target: ChatCache.lastMessageCache onLastMessageChanged: { if (!chatId) { @@ -228,23 +224,26 @@ Item } - function getChatLastMessage (chatId){ + function getChatLastMessage (chatId) + { return ChatCache.lastMessageCache.getChatLastMessage(chatId) } - function getChatIdFromGXS (){ + function getChatIdFromGXS () + { var id= ChatCache.lastMessageCache.getChatIdFromGxs(model.gxs_id) return ChatCache.lastMessageCache.getChatIdFromGxs(model.gxs_id) } - function setTime(){ - if (!lastMessageData || lastMessageData.recv_time === undefined){ - return "" - } + function setTime() + { + if (!lastMessageData || lastMessageData.recv_time === undefined) return "" + var timeFormat = "dd.MM.yyyy"; var recvDate = new Date(lastMessageData.recv_time*1000) // Check if is today - if ( new Date (lastMessageData.recv_time*1000).setHours(0,0,0,0) == new Date ().setHours(0,0,0,0)) { + if ( new Date (lastMessageData.recv_time*1000).setHours(0,0,0,0) == new Date ().setHours(0,0,0,0)) + { timeFormat = "hh:mm" } var timeString = Qt.formatDateTime(recvDate, timeFormat) @@ -259,7 +258,8 @@ Item "qrc:/ContactDetails.qml", {md: contactsListView.model.get(index)}) } - function startDistantChatCB (par){ + function startDistantChatCB (par) + { var chId = JSON.parse(par.response).data.chat_id ChatCache.lastMessageCache.setRemoteGXS(chId, { gxs: model.gxs_id, name: model.name}) contactsView.startChatCallback (par) diff --git a/retroshare-qml-app/src/main-app.qml b/retroshare-qml-app/src/main-app.qml index 2b40b54ef..4c0fe38de 100644 --- a/retroshare-qml-app/src/main-app.qml +++ b/retroshare-qml-app/src/main-app.qml @@ -63,12 +63,14 @@ ApplicationWindow states: [ - State { + State + { name: "DEFAULT" PropertyChanges { target: toolBar; titleText: defaultLabel} PropertyChanges { target: toolBar; loaderSource: rsIcon} }, - State { + State + { name: "CHATVIEW" } ] @@ -166,9 +168,12 @@ ApplicationWindow id: stackView anchors.fill: parent focus: true - onCurrentItemChanged: { - if (currentItem) { - if (currentItem.objectName != "chatView" && toolBar.state != "DEFAULT"){ + onCurrentItemChanged: + { + if (currentItem) + { + if (currentItem.objectName != "chatView" && toolBar.state != "DEFAULT") + { toolBar.state = "DEFAULT" } currentItem.focus = true