From 9f26a0aec56d0ac06ee26ef1d582f5a417963a51 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/ChatView.qml | 54 ++++++++++++------- retroshare-qml-app/src/Contacts.qml | 8 +-- .../src/GxsIdentityDelegate.qml | 36 ++++++------- retroshare-qml-app/src/main-app.qml | 15 ++++-- 6 files changed, 98 insertions(+), 61 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/ChatView.qml b/retroshare-qml-app/src/ChatView.qml index 1a14a378b..2c171bc54 100644 --- a/retroshare-qml-app/src/ChatView.qml +++ b/retroshare-qml-app/src/ChatView.qml @@ -51,10 +51,11 @@ Item chatListView.positionViewAtEnd() rsApi.request("/chat/mark_chat_as_read/"+chatId) } - } ) + }) } - Component.onCompleted: { + Component.onCompleted: + { refreshData() toolBar.state = "CHATVIEW" gxsInfo= ChatCache.lastMessageCache.getGxsFromChatId(chatView.chatId) @@ -63,7 +64,8 @@ Item } onFocusChanged: focus && refreshData() - Component { + Component + { id: userHash ColorHash @@ -95,13 +97,15 @@ Item spacing: styles.bubbleSpacing preferredHighlightBegin: 1 - onHeightChanged: { + onHeightChanged: + { chatListView.currentIndex = count - 1 } } - Item { + Item + { property var styles: StyleChat.inferiorPanel @@ -110,7 +114,8 @@ Item width: parent.width anchors.bottom: parent.bottom - Rectangle { + Rectangle + { id: backgroundRectangle anchors.fill: parent.fill width: parent.width @@ -119,7 +124,8 @@ Item border.color: inferiorPanel.styles.borderColor } - BtnIcon { + BtnIcon + { id: attachButton @@ -137,7 +143,8 @@ Item } - RowLayout { + RowLayout + { id: msgComposer property var styles: StyleChat.inferiorPanel.msgComposer @@ -151,7 +158,8 @@ Item height: (flickable.contentHeight < styles.maxHeight)? flickable.contentHeight : styles.maxHeight - Flickable { + Flickable + { id: flickable anchors.fill: parent flickableDirection: Flickable.VerticalFlick @@ -182,7 +190,8 @@ Item focus: true - onTextChanged: { + onTextChanged: + { if (msgField.length == 0) { sendButton.state = "" @@ -199,7 +208,8 @@ Item if ((event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && !shiftPressed) { - if (sendButton.state == "SENDBTN" ) { + if (sendButton.state == "SENDBTN" ) + { chatView.sendMessage () } } @@ -216,14 +226,14 @@ Item shiftPressed = false } } - } } } - BtnIcon { + BtnIcon + { id: emojiButton @@ -240,7 +250,8 @@ Item imgUrl: styles.emojiIconUrl } - BtnIcon { + BtnIcon + { id: sendButton @@ -259,7 +270,8 @@ Item onClicked: { - if (sendButton.state == "SENDBTN" ) { + if (sendButton.state == "SENDBTN" ) + { chatView.sendMessage () } } @@ -285,16 +297,20 @@ Item } - states: [ - State { + states: + [ + State + { name: "" PropertyChanges { target: sendButton; icon: styles.microIconUrl} }, - State { + State + { name: "RECORDING" PropertyChanges { target: sendButton; icon: styles.microMuteIconUrl} }, - State { + State + { name: "SENDBTN" PropertyChanges { target: sendButton; icon: styles.sendIconUrl} } 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