Change to Almman indent style

This commit is contained in:
Angela Mazzurco 2017-06-13 14:51:53 +02:00
parent 4b05555a5c
commit 9f26a0aec5
6 changed files with 98 additions and 61 deletions

View File

@ -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)

View File

@ -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
}

View File

@ -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}
}

View File

@ -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})

View File

@ -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)

View File

@ -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