2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
2020-06-23 18:51:10 +00:00
|
|
|
import QtQuick.Controls 2.13
|
2020-06-23 20:49:04 +00:00
|
|
|
import Qt.labs.settings 1.0
|
2020-05-19 19:44:45 +00:00
|
|
|
import "../../../imports"
|
2020-06-23 18:51:10 +00:00
|
|
|
import "../../../shared"
|
2020-05-25 20:34:26 +00:00
|
|
|
import "."
|
2020-10-02 13:02:56 +00:00
|
|
|
import "components"
|
2020-05-13 17:27:06 +00:00
|
|
|
|
|
|
|
SplitView {
|
2020-06-23 20:49:04 +00:00
|
|
|
id: chatView
|
2020-06-23 18:51:10 +00:00
|
|
|
handle: SplitViewHandle {}
|
2020-05-27 17:10:50 +00:00
|
|
|
|
2020-11-19 18:30:09 +00:00
|
|
|
property alias chatColumn: chatColumn
|
|
|
|
|
2020-09-23 07:28:20 +00:00
|
|
|
property var onActivated: function () {
|
2020-12-17 10:40:37 +00:00
|
|
|
chatsModel.restorePreviousActiveChannel()
|
2020-09-23 07:28:20 +00:00
|
|
|
chatColumn.onActivated()
|
|
|
|
}
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
function openPopup(popupComponent, params = {}) {
|
|
|
|
const popup = popupComponent.createObject(chatView, params);
|
|
|
|
popup.open()
|
|
|
|
return popup
|
|
|
|
}
|
|
|
|
|
2020-12-11 20:38:10 +00:00
|
|
|
function getContactListObject(dataModel) {
|
|
|
|
const nbContacts = profileModel.contacts.list.rowCount()
|
|
|
|
const contacts = []
|
|
|
|
let contact
|
|
|
|
for (let i = 0; i < nbContacts; i++) {
|
|
|
|
contact = {
|
|
|
|
name: profileModel.contacts.list.rowData(i, "name"),
|
|
|
|
localNickname: profileModel.contacts.list.rowData(i, "localNickname"),
|
|
|
|
pubKey: profileModel.contacts.list.rowData(i, "pubKey"),
|
|
|
|
address: profileModel.contacts.list.rowData(i, "address"),
|
|
|
|
identicon: profileModel.contacts.list.rowData(i, "identicon"),
|
|
|
|
thumbnailImage: profileModel.contacts.list.rowData(i, "thumbnailImage"),
|
|
|
|
isUser: false,
|
|
|
|
isContact: profileModel.contacts.list.rowData(i, "isContact") !== "false"
|
|
|
|
}
|
|
|
|
|
|
|
|
contacts.push(contact)
|
|
|
|
if (dataModel) {
|
|
|
|
dataModel.append(contact);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return contacts
|
|
|
|
}
|
|
|
|
|
2020-09-15 19:47:13 +00:00
|
|
|
Connections {
|
2021-02-18 19:14:31 +00:00
|
|
|
target: appMain
|
2020-09-15 19:47:13 +00:00
|
|
|
onSettingsLoaded: {
|
|
|
|
// Add recent
|
|
|
|
chatView.restoreState(appSettings.chatSplitView)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Component.onDestruction: appSettings.chatSplitView = this.saveState()
|
2020-06-23 20:49:04 +00:00
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
Loader {
|
|
|
|
id: contactColumnLoader
|
2020-12-21 17:59:02 +00:00
|
|
|
SplitView.preferredWidth: Style.current.leftTabPrefferedSize
|
|
|
|
SplitView.minimumWidth: Style.current.leftTabMinimumWidth
|
|
|
|
SplitView.maximumWidth: Style.current.leftTabMaximumWidth
|
2021-01-05 16:36:42 +00:00
|
|
|
sourceComponent: appSettings.communitiesEnabled && chatsModel.activeCommunity.active ? communtiyColumnComponent : contactsColumnComponent
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: contactsColumnComponent
|
|
|
|
ContactsColumn {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: communtiyColumnComponent
|
2020-12-21 17:59:02 +00:00
|
|
|
CommunityColumn {}
|
2020-05-13 17:27:06 +00:00
|
|
|
}
|
|
|
|
|
2021-02-17 20:36:10 +00:00
|
|
|
Component {
|
|
|
|
id: groupInfoPopupComponent
|
|
|
|
GroupInfoPopup {}
|
|
|
|
}
|
|
|
|
|
2020-05-25 20:34:26 +00:00
|
|
|
ChatColumn {
|
2020-05-13 17:27:06 +00:00
|
|
|
id: chatColumn
|
2020-12-11 20:29:46 +00:00
|
|
|
chatGroupsListViewCount: contactColumnLoader.item.chatGroupsListViewCount
|
2020-05-13 17:27:06 +00:00
|
|
|
}
|
2020-10-02 13:02:56 +00:00
|
|
|
|
|
|
|
function openProfilePopup(userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam, parentPopup){
|
|
|
|
var popup = profilePopupComponent.createObject(chatView);
|
|
|
|
if(parentPopup){
|
|
|
|
popup.parentPopup = parentPopup;
|
|
|
|
}
|
|
|
|
popup.openPopup(profileModel.profile.pubKey !== fromAuthorParam, userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
property Component profilePopupComponent: ProfilePopup {
|
|
|
|
id: profilePopup
|
2021-01-12 20:51:00 +00:00
|
|
|
height: 504
|
2020-10-02 13:02:56 +00:00
|
|
|
onClosed: {
|
|
|
|
if(profilePopup.parentPopup){
|
|
|
|
profilePopup.parentPopup.close();
|
|
|
|
}
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ConfirmationDialog {
|
|
|
|
id: removeContactConfirmationDialog
|
|
|
|
// % "Remove contact"
|
|
|
|
title: qsTrId("remove-contact")
|
|
|
|
//% "Are you sure you want to remove this contact?"
|
|
|
|
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
|
|
|
|
onConfirmButtonClicked: {
|
2020-12-06 22:15:51 +00:00
|
|
|
if (profileModel.contacts.isAdded(chatColumn.contactToRemove)) {
|
|
|
|
profileModel.contacts.removeContact(chatColumn.contactToRemove)
|
2020-10-02 13:02:56 +00:00
|
|
|
}
|
|
|
|
removeContactConfirmationDialog.parentPopup.close();
|
|
|
|
removeContactConfirmationDialog.close();
|
|
|
|
}
|
|
|
|
}
|
2020-05-13 17:27:06 +00:00
|
|
|
}
|
2020-05-25 20:34:26 +00:00
|
|
|
|
2020-05-13 17:27:06 +00:00
|
|
|
/*##^##
|
|
|
|
Designer {
|
2020-06-23 18:51:10 +00:00
|
|
|
D{i:0;formeditorColor:"#ffffff";formeditorZoom:1.25;height:770;width:1152}
|
2020-05-13 17:27:06 +00:00
|
|
|
}
|
|
|
|
##^##*/
|