mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Change to Almman indent style
This commit is contained in:
parent
4b05555a5c
commit
9f26a0aec5
@ -4,7 +4,8 @@ import QtQuick.Controls 2.0
|
|||||||
import "." // To load styles
|
import "." // To load styles
|
||||||
import "./components"
|
import "./components"
|
||||||
|
|
||||||
Item {
|
Item
|
||||||
|
{
|
||||||
|
|
||||||
id: chatBubbleDelegate
|
id: chatBubbleDelegate
|
||||||
height: bubble.height
|
height: bubble.height
|
||||||
@ -13,7 +14,8 @@ Item {
|
|||||||
property var styles: StyleChat.bubble
|
property var styles: StyleChat.bubble
|
||||||
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle
|
||||||
|
{
|
||||||
id: rootBubble
|
id: rootBubble
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
width: parent.width
|
width: parent.width
|
||||||
@ -37,7 +39,8 @@ Item {
|
|||||||
radius: styles.radius
|
radius: styles.radius
|
||||||
|
|
||||||
|
|
||||||
Text {
|
Text
|
||||||
|
{
|
||||||
id: sendersName
|
id: sendersName
|
||||||
visible: model.incoming
|
visible: model.incoming
|
||||||
text: (model.incoming)? model.author_name + ":" : ""
|
text: (model.incoming)? model.author_name + ":" : ""
|
||||||
@ -57,7 +60,8 @@ Item {
|
|||||||
mesageText.implicitWidth >= (rootBubble.width * styles.bubbleMaxWidth) )? implicitHeight : 0
|
mesageText.implicitWidth >= (rootBubble.width * styles.bubbleMaxWidth) )? implicitHeight : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text
|
||||||
|
{
|
||||||
id: timeText
|
id: timeText
|
||||||
text: getMessageTime()
|
text: getMessageTime()
|
||||||
color: styles.colorMessageTime
|
color: styles.colorMessageTime
|
||||||
@ -73,7 +77,8 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Text {
|
Text
|
||||||
|
{
|
||||||
id: mesageText
|
id: mesageText
|
||||||
text: model.msg
|
text: model.msg
|
||||||
width: rootBubble.width * styles.bubbleMaxWidth + timeText.width
|
width: rootBubble.width * styles.bubbleMaxWidth + timeText.width
|
||||||
@ -96,8 +101,8 @@ Item {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMessageTime(){
|
function getMessageTime()
|
||||||
|
{
|
||||||
var timeFormat = "hh:mm";
|
var timeFormat = "hh:mm";
|
||||||
var recvDate = new Date(model.recv_time*1000)
|
var recvDate = new Date(model.recv_time*1000)
|
||||||
|
|
||||||
|
@ -5,7 +5,8 @@ import QtQuick.Controls 2.0
|
|||||||
import org.retroshare.qml_components.LibresapiLocalClient 1.0
|
import org.retroshare.qml_components.LibresapiLocalClient 1.0
|
||||||
import Qt.labs.settings 1.0
|
import Qt.labs.settings 1.0
|
||||||
|
|
||||||
QtObject {
|
QtObject
|
||||||
|
{
|
||||||
|
|
||||||
id: chatCache
|
id: chatCache
|
||||||
|
|
||||||
@ -17,7 +18,8 @@ QtObject {
|
|||||||
signal lastMessageChanged(var chatI, var newLastMessage)
|
signal lastMessageChanged(var chatI, var newLastMessage)
|
||||||
|
|
||||||
|
|
||||||
function updateLastMessageCache (chatId, chatModel){
|
function updateLastMessageCache (chatId, chatModel)
|
||||||
|
{
|
||||||
console.log("updateLastMessageCache (chatId, chatModel)", chatId)
|
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
|
// 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]) {
|
if (!lastMessageList[chatId]) {
|
||||||
@ -33,24 +35,28 @@ QtObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateLastMessage (chatId, chatModel){
|
function updateLastMessage (chatId, chatModel)
|
||||||
|
{
|
||||||
console.log("updateLastMessage (chatId, chatModel)")
|
console.log("updateLastMessage (chatId, chatModel)")
|
||||||
var lastMessage = findChatLastMessage (chatModel)
|
var lastMessage = findChatLastMessage (chatModel)
|
||||||
lastMessageList[chatId].lastMessage = lastMessage
|
lastMessageList[chatId].lastMessage = lastMessage
|
||||||
lastMessageChanged(chatId, lastMessage)
|
lastMessageChanged(chatId, lastMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
function findChatLastMessage (chatModel){
|
function findChatLastMessage (chatModel)
|
||||||
|
{
|
||||||
var messagesData = JSON.parse(chatModel).data
|
var messagesData = JSON.parse(chatModel).data
|
||||||
return messagesData.slice(-1)[0]
|
return messagesData.slice(-1)[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
function findChatFirstMessage (chatModel){
|
function findChatFirstMessage (chatModel)
|
||||||
|
{
|
||||||
var messagesData = JSON.parse(chatModel).data
|
var messagesData = JSON.parse(chatModel).data
|
||||||
return messagesData.slice[0]
|
return messagesData.slice[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRemoteGXS (chatId, remoteGXS){
|
function setRemoteGXS (chatId, remoteGXS)
|
||||||
|
{
|
||||||
if (!lastMessageList[chatId]) {
|
if (!lastMessageList[chatId]) {
|
||||||
lastMessageList[chatId] = {}
|
lastMessageList[chatId] = {}
|
||||||
console.log("Last message cache created!")
|
console.log("Last message cache created!")
|
||||||
@ -64,7 +70,8 @@ QtObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getChatIdFromGxs (gxs){
|
function getChatIdFromGxs (gxs)
|
||||||
|
{
|
||||||
for (var key in lastMessageList) {
|
for (var key in lastMessageList) {
|
||||||
if ( lastMessageList[key].remoteGXS &&
|
if ( lastMessageList[key].remoteGXS &&
|
||||||
lastMessageList[key].remoteGXS.gxs === gxs ) {
|
lastMessageList[key].remoteGXS.gxs === gxs ) {
|
||||||
@ -74,12 +81,14 @@ QtObject {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGxsFromChatId (chatId){
|
function getGxsFromChatId (chatId)
|
||||||
|
{
|
||||||
if (lastMessageList[chatId]) return lastMessageList[chatId].remoteGXS
|
if (lastMessageList[chatId]) return lastMessageList[chatId].remoteGXS
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
function getChatLastMessage (chatId){
|
function getChatLastMessage (chatId)
|
||||||
|
{
|
||||||
if (lastMessageList[chatId]) {
|
if (lastMessageList[chatId]) {
|
||||||
return lastMessageList[chatId].lastMessage
|
return lastMessageList[chatId].lastMessage
|
||||||
}
|
}
|
||||||
|
@ -51,10 +51,11 @@ Item
|
|||||||
chatListView.positionViewAtEnd()
|
chatListView.positionViewAtEnd()
|
||||||
rsApi.request("/chat/mark_chat_as_read/"+chatId)
|
rsApi.request("/chat/mark_chat_as_read/"+chatId)
|
||||||
}
|
}
|
||||||
} )
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted:
|
||||||
|
{
|
||||||
refreshData()
|
refreshData()
|
||||||
toolBar.state = "CHATVIEW"
|
toolBar.state = "CHATVIEW"
|
||||||
gxsInfo= ChatCache.lastMessageCache.getGxsFromChatId(chatView.chatId)
|
gxsInfo= ChatCache.lastMessageCache.getGxsFromChatId(chatView.chatId)
|
||||||
@ -63,7 +64,8 @@ Item
|
|||||||
}
|
}
|
||||||
onFocusChanged: focus && refreshData()
|
onFocusChanged: focus && refreshData()
|
||||||
|
|
||||||
Component {
|
Component
|
||||||
|
{
|
||||||
id: userHash
|
id: userHash
|
||||||
|
|
||||||
ColorHash
|
ColorHash
|
||||||
@ -95,13 +97,15 @@ Item
|
|||||||
spacing: styles.bubbleSpacing
|
spacing: styles.bubbleSpacing
|
||||||
preferredHighlightBegin: 1
|
preferredHighlightBegin: 1
|
||||||
|
|
||||||
onHeightChanged: {
|
onHeightChanged:
|
||||||
|
{
|
||||||
chatListView.currentIndex = count - 1
|
chatListView.currentIndex = count - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item
|
||||||
|
{
|
||||||
|
|
||||||
property var styles: StyleChat.inferiorPanel
|
property var styles: StyleChat.inferiorPanel
|
||||||
|
|
||||||
@ -110,7 +114,8 @@ Item
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
|
||||||
Rectangle {
|
Rectangle
|
||||||
|
{
|
||||||
id: backgroundRectangle
|
id: backgroundRectangle
|
||||||
anchors.fill: parent.fill
|
anchors.fill: parent.fill
|
||||||
width: parent.width
|
width: parent.width
|
||||||
@ -119,7 +124,8 @@ Item
|
|||||||
border.color: inferiorPanel.styles.borderColor
|
border.color: inferiorPanel.styles.borderColor
|
||||||
}
|
}
|
||||||
|
|
||||||
BtnIcon {
|
BtnIcon
|
||||||
|
{
|
||||||
|
|
||||||
id: attachButton
|
id: attachButton
|
||||||
|
|
||||||
@ -137,7 +143,8 @@ Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RowLayout {
|
RowLayout
|
||||||
|
{
|
||||||
id: msgComposer
|
id: msgComposer
|
||||||
property var styles: StyleChat.inferiorPanel.msgComposer
|
property var styles: StyleChat.inferiorPanel.msgComposer
|
||||||
|
|
||||||
@ -151,7 +158,8 @@ Item
|
|||||||
|
|
||||||
height: (flickable.contentHeight < styles.maxHeight)? flickable.contentHeight : styles.maxHeight
|
height: (flickable.contentHeight < styles.maxHeight)? flickable.contentHeight : styles.maxHeight
|
||||||
|
|
||||||
Flickable {
|
Flickable
|
||||||
|
{
|
||||||
id: flickable
|
id: flickable
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
flickableDirection: Flickable.VerticalFlick
|
flickableDirection: Flickable.VerticalFlick
|
||||||
@ -182,7 +190,8 @@ Item
|
|||||||
|
|
||||||
focus: true
|
focus: true
|
||||||
|
|
||||||
onTextChanged: {
|
onTextChanged:
|
||||||
|
{
|
||||||
if (msgField.length == 0)
|
if (msgField.length == 0)
|
||||||
{
|
{
|
||||||
sendButton.state = ""
|
sendButton.state = ""
|
||||||
@ -199,7 +208,8 @@ Item
|
|||||||
if ((event.key === Qt.Key_Return || event.key === Qt.Key_Enter)
|
if ((event.key === Qt.Key_Return || event.key === Qt.Key_Enter)
|
||||||
&& !shiftPressed)
|
&& !shiftPressed)
|
||||||
{
|
{
|
||||||
if (sendButton.state == "SENDBTN" ) {
|
if (sendButton.state == "SENDBTN" )
|
||||||
|
{
|
||||||
chatView.sendMessage ()
|
chatView.sendMessage ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,14 +226,14 @@ Item
|
|||||||
shiftPressed = false
|
shiftPressed = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BtnIcon {
|
BtnIcon
|
||||||
|
{
|
||||||
|
|
||||||
id: emojiButton
|
id: emojiButton
|
||||||
|
|
||||||
@ -240,7 +250,8 @@ Item
|
|||||||
imgUrl: styles.emojiIconUrl
|
imgUrl: styles.emojiIconUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
BtnIcon {
|
BtnIcon
|
||||||
|
{
|
||||||
|
|
||||||
id: sendButton
|
id: sendButton
|
||||||
|
|
||||||
@ -259,7 +270,8 @@ Item
|
|||||||
|
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
if (sendButton.state == "SENDBTN" ) {
|
if (sendButton.state == "SENDBTN" )
|
||||||
|
{
|
||||||
chatView.sendMessage ()
|
chatView.sendMessage ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -285,16 +297,20 @@ Item
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
states: [
|
states:
|
||||||
State {
|
[
|
||||||
|
State
|
||||||
|
{
|
||||||
name: ""
|
name: ""
|
||||||
PropertyChanges { target: sendButton; icon: styles.microIconUrl}
|
PropertyChanges { target: sendButton; icon: styles.microIconUrl}
|
||||||
},
|
},
|
||||||
State {
|
State
|
||||||
|
{
|
||||||
name: "RECORDING"
|
name: "RECORDING"
|
||||||
PropertyChanges { target: sendButton; icon: styles.microMuteIconUrl}
|
PropertyChanges { target: sendButton; icon: styles.microMuteIconUrl}
|
||||||
},
|
},
|
||||||
State {
|
State
|
||||||
|
{
|
||||||
name: "SENDBTN"
|
name: "SENDBTN"
|
||||||
PropertyChanges { target: sendButton; icon: styles.sendIconUrl}
|
PropertyChanges { target: sendButton; icon: styles.sendIconUrl}
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,8 @@ Item
|
|||||||
TokensManager.registerToken(json.statetoken, refreshUnread)
|
TokensManager.registerToken(json.statetoken, refreshUnread)
|
||||||
contactsSortWorker.sendMessage(
|
contactsSortWorker.sendMessage(
|
||||||
{'action': 'refreshUnread', 'response': par.response})
|
{'action': 'refreshUnread', 'response': par.response})
|
||||||
json.data.forEach (function (chat){
|
json.data.forEach (function (chat)
|
||||||
|
{
|
||||||
ChatCache.lastMessageCache.updateLastMessageCache(chat.chat_id)
|
ChatCache.lastMessageCache.updateLastMessageCache(chat.chat_id)
|
||||||
ChatCache.lastMessageCache.setRemoteGXS (chat.chat_id, { gxs: chat.remote_author_id, name: chat.remote_author_name})
|
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
|
width: parent.width - searchIcon.width - 5
|
||||||
anchors.leftMargin: 5
|
anchors.leftMargin: 5
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle
|
||||||
|
{
|
||||||
border.width: 2
|
border.width: 2
|
||||||
radius: 5
|
radius: 5
|
||||||
border.color: searchText.focus ? "cornflowerblue" : "lightgrey"
|
border.color: searchText.focus ? "cornflowerblue" : "lightgrey"
|
||||||
color: searchText.focus ? "white" : "ghostwhite"
|
color: searchText.focus ? "white" : "ghostwhite"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onTextChanged:
|
onTextChanged:
|
||||||
contactsSortWorker.sendMessage(
|
contactsSortWorker.sendMessage(
|
||||||
{'action': 'searchContact', 'sexp': text})
|
{'action': 'searchContact', 'sexp': text})
|
||||||
|
@ -33,14 +33,14 @@ Item
|
|||||||
property var locale: Qt.locale()
|
property var locale: Qt.locale()
|
||||||
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle
|
||||||
|
{
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: contactItem.containsMouse ? "lightgrey" : "transparent"
|
color: contactItem.containsMouse ? "lightgrey" : "transparent"
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
|
||||||
|
|
||||||
MouseArea
|
MouseArea
|
||||||
{
|
{
|
||||||
id: contactItem
|
id: contactItem
|
||||||
@ -117,11 +117,7 @@ Item
|
|||||||
text: setTime()
|
text: setTime()
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
color: "darkslategrey"
|
color: "darkslategrey"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Item
|
Item
|
||||||
@ -130,8 +126,6 @@ Item
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height /2
|
height: parent.height /2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Text
|
Text
|
||||||
{
|
{
|
||||||
id: lastMessageSender
|
id: lastMessageSender
|
||||||
@ -204,7 +198,8 @@ Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted:
|
||||||
|
{
|
||||||
if (!chatId){
|
if (!chatId){
|
||||||
chatId = getChatIdFromGXS()
|
chatId = getChatIdFromGXS()
|
||||||
}
|
}
|
||||||
@ -214,7 +209,8 @@ Item
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections
|
||||||
|
{
|
||||||
target: ChatCache.lastMessageCache
|
target: ChatCache.lastMessageCache
|
||||||
onLastMessageChanged: {
|
onLastMessageChanged: {
|
||||||
if (!chatId) {
|
if (!chatId) {
|
||||||
@ -228,23 +224,26 @@ Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getChatLastMessage (chatId){
|
function getChatLastMessage (chatId)
|
||||||
|
{
|
||||||
return ChatCache.lastMessageCache.getChatLastMessage(chatId)
|
return ChatCache.lastMessageCache.getChatLastMessage(chatId)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getChatIdFromGXS (){
|
function getChatIdFromGXS ()
|
||||||
|
{
|
||||||
var id= ChatCache.lastMessageCache.getChatIdFromGxs(model.gxs_id)
|
var id= ChatCache.lastMessageCache.getChatIdFromGxs(model.gxs_id)
|
||||||
return ChatCache.lastMessageCache.getChatIdFromGxs(model.gxs_id)
|
return ChatCache.lastMessageCache.getChatIdFromGxs(model.gxs_id)
|
||||||
}
|
}
|
||||||
function setTime(){
|
function setTime()
|
||||||
if (!lastMessageData || lastMessageData.recv_time === undefined){
|
{
|
||||||
return ""
|
if (!lastMessageData || lastMessageData.recv_time === undefined) return ""
|
||||||
}
|
|
||||||
var timeFormat = "dd.MM.yyyy";
|
var timeFormat = "dd.MM.yyyy";
|
||||||
var recvDate = new Date(lastMessageData.recv_time*1000)
|
var recvDate = new Date(lastMessageData.recv_time*1000)
|
||||||
|
|
||||||
// Check if is today
|
// 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"
|
timeFormat = "hh:mm"
|
||||||
}
|
}
|
||||||
var timeString = Qt.formatDateTime(recvDate, timeFormat)
|
var timeString = Qt.formatDateTime(recvDate, timeFormat)
|
||||||
@ -259,7 +258,8 @@ Item
|
|||||||
"qrc:/ContactDetails.qml",
|
"qrc:/ContactDetails.qml",
|
||||||
{md: contactsListView.model.get(index)})
|
{md: contactsListView.model.get(index)})
|
||||||
}
|
}
|
||||||
function startDistantChatCB (par){
|
function startDistantChatCB (par)
|
||||||
|
{
|
||||||
var chId = JSON.parse(par.response).data.chat_id
|
var chId = JSON.parse(par.response).data.chat_id
|
||||||
ChatCache.lastMessageCache.setRemoteGXS(chId, { gxs: model.gxs_id, name: model.name})
|
ChatCache.lastMessageCache.setRemoteGXS(chId, { gxs: model.gxs_id, name: model.name})
|
||||||
contactsView.startChatCallback (par)
|
contactsView.startChatCallback (par)
|
||||||
|
@ -63,12 +63,14 @@ ApplicationWindow
|
|||||||
|
|
||||||
states:
|
states:
|
||||||
[
|
[
|
||||||
State {
|
State
|
||||||
|
{
|
||||||
name: "DEFAULT"
|
name: "DEFAULT"
|
||||||
PropertyChanges { target: toolBar; titleText: defaultLabel}
|
PropertyChanges { target: toolBar; titleText: defaultLabel}
|
||||||
PropertyChanges { target: toolBar; loaderSource: rsIcon}
|
PropertyChanges { target: toolBar; loaderSource: rsIcon}
|
||||||
},
|
},
|
||||||
State {
|
State
|
||||||
|
{
|
||||||
name: "CHATVIEW"
|
name: "CHATVIEW"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -166,9 +168,12 @@ ApplicationWindow
|
|||||||
id: stackView
|
id: stackView
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
focus: true
|
focus: true
|
||||||
onCurrentItemChanged: {
|
onCurrentItemChanged:
|
||||||
if (currentItem) {
|
{
|
||||||
if (currentItem.objectName != "chatView" && toolBar.state != "DEFAULT"){
|
if (currentItem)
|
||||||
|
{
|
||||||
|
if (currentItem.objectName != "chatView" && toolBar.state != "DEFAULT")
|
||||||
|
{
|
||||||
toolBar.state = "DEFAULT"
|
toolBar.state = "DEFAULT"
|
||||||
}
|
}
|
||||||
currentItem.focus = true
|
currentItem.focus = true
|
||||||
|
Loading…
Reference in New Issue
Block a user