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"
|
2021-03-08 19:24:39 +00:00
|
|
|
import "../../../shared/status"
|
2020-05-25 20:34:26 +00:00
|
|
|
import "."
|
2021-08-06 15:44:57 +00:00
|
|
|
import "./data"
|
2020-10-02 13:02:56 +00:00
|
|
|
import "components"
|
2021-07-22 14:53:19 +00:00
|
|
|
import "./ChatColumn"
|
|
|
|
import "./CommunityComponents"
|
2020-05-13 17:27:06 +00:00
|
|
|
|
2021-06-11 13:23:41 +00:00
|
|
|
import StatusQ.Layout 0.1
|
2021-08-16 08:54:20 +00:00
|
|
|
import StatusQ.Popups 0.1
|
2021-06-11 13:23:41 +00:00
|
|
|
|
2021-07-22 14:53:19 +00:00
|
|
|
StatusAppThreePanelLayout {
|
2020-06-23 20:49:04 +00:00
|
|
|
id: chatView
|
2020-05-27 17:10:50 +00:00
|
|
|
|
2021-07-22 14:53:19 +00:00
|
|
|
handle: SplitViewHandle { implicitWidth: 5 }
|
|
|
|
|
2020-11-19 18:30:09 +00:00
|
|
|
property alias chatColumn: chatColumn
|
2021-03-08 19:24:39 +00:00
|
|
|
property bool stickersLoaded: false
|
2021-07-20 15:22:09 +00:00
|
|
|
signal profileButtonClicked()
|
2021-03-08 19:24:39 +00:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: chatsModel.stickers
|
|
|
|
onStickerPacksLoaded: {
|
|
|
|
stickersLoaded = true;
|
|
|
|
}
|
|
|
|
}
|
2020-11-19 18:30:09 +00:00
|
|
|
|
2020-09-23 07:28:20 +00:00
|
|
|
property var onActivated: function () {
|
2021-06-17 22:09:00 +00:00
|
|
|
chatsModel.channelView.restorePreviousActiveChannel()
|
2020-09-23 07:28:20 +00:00
|
|
|
chatColumn.onActivated()
|
|
|
|
}
|
|
|
|
|
2021-08-16 08:54:20 +00:00
|
|
|
StatusSearchLocationMenu {
|
|
|
|
id: searchPopupMenu
|
|
|
|
searchPopup: searchPopup
|
|
|
|
locationModel: chatsModel.messageSearchViewController.locationMenuModel
|
|
|
|
|
|
|
|
onItemClicked: {
|
|
|
|
chatsModel.messageSearchViewController.setSearchLocation(firstLevelItemValue, secondLevelItemValue)
|
|
|
|
if(searchPopup.searchText !== "")
|
|
|
|
searchMessages(searchPopup.searchText)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
property var searchMessages: Backpressure.debounce(searchPopup, 400, function (value) {
|
|
|
|
chatsModel.messageSearchViewController.searchMessages(value)
|
|
|
|
})
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: chatsModel.messageSearchViewController.locationMenuModel
|
|
|
|
onModelAboutToBeReset: {
|
|
|
|
for (var i = 2; i <= searchPopupMenu.count; i++) {
|
|
|
|
//clear menu
|
|
|
|
if (!!searchPopupMenu.takeItem(i)) {
|
|
|
|
searchPopupMenu.removeItem(searchPopupMenu.takeItem(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusSearchPopup {
|
|
|
|
id: searchPopup
|
|
|
|
|
|
|
|
noResultsLabel: qsTr("No results")
|
|
|
|
defaultSearchLocationText: qsTr("Anywhere")
|
|
|
|
|
|
|
|
searchOptionsPopupMenu: searchPopupMenu
|
|
|
|
searchResults: chatsModel.messageSearchViewController.resultModel
|
2021-08-30 14:40:03 +00:00
|
|
|
|
|
|
|
formatTimestampFn: function (ts) {
|
|
|
|
return new Date(parseInt(ts, 10)).toLocaleString(Qt.locale(globalSettings.locale))
|
|
|
|
}
|
|
|
|
|
2021-08-16 08:54:20 +00:00
|
|
|
onSearchTextChanged: {
|
|
|
|
searchMessages(searchPopup.searchText);
|
|
|
|
}
|
|
|
|
onAboutToHide: {
|
|
|
|
if (searchPopupMenu.visible) {
|
|
|
|
searchPopupMenu.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onClosed: {
|
|
|
|
searchPopupMenu.dismiss();
|
|
|
|
}
|
|
|
|
onOpened: {
|
|
|
|
searchPopup.resetSearchSelection();
|
|
|
|
chatsModel.messageSearchViewController.prepareLocationMenuModel()
|
|
|
|
|
|
|
|
const jsonObj = chatsModel.messageSearchViewController.getSearchLocationObject()
|
|
|
|
|
|
|
|
if (!jsonObj) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
let obj = JSON.parse(jsonObj)
|
|
|
|
if (obj.location === "") {
|
|
|
|
if(obj.subLocation === "") {
|
|
|
|
chatsModel.messageSearchViewController.setSearchLocation("", "")
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
searchPopup.setSearchSelection(obj.subLocation.text,
|
|
|
|
"",
|
|
|
|
obj.subLocation.imageSource,
|
|
|
|
obj.subLocation.isIdenticon,
|
|
|
|
obj.subLocation.iconName,
|
|
|
|
obj.subLocation.identiconColor)
|
|
|
|
|
|
|
|
chatsModel.messageSearchViewController.setSearchLocation("", obj.subLocation.value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (obj.location.title === "Chat") {
|
|
|
|
searchPopup.setSearchSelection(obj.subLocation.text,
|
|
|
|
"",
|
|
|
|
obj.subLocation.imageSource,
|
|
|
|
obj.subLocation.isIdenticon,
|
|
|
|
obj.subLocation.iconName,
|
|
|
|
obj.subLocation.identiconColor)
|
|
|
|
|
|
|
|
chatsModel.messageSearchViewController.setSearchLocation(obj.location.value, obj.subLocation.value)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
searchPopup.setSearchSelection(obj.location.title,
|
|
|
|
obj.subLocation.text,
|
|
|
|
obj.location.imageSource,
|
|
|
|
obj.location.isIdenticon,
|
|
|
|
obj.location.iconName,
|
|
|
|
obj.location.identiconColor)
|
|
|
|
|
|
|
|
chatsModel.messageSearchViewController.setSearchLocation(obj.location.value, obj.subLocation.value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onResultItemClicked: {
|
|
|
|
searchPopup.close()
|
|
|
|
|
|
|
|
chatsModel.switchToSearchedItem(itemId)
|
|
|
|
}
|
|
|
|
|
|
|
|
onResultItemTitleClicked: {
|
|
|
|
const pk = titleId
|
|
|
|
const userProfileImage = appMain.getProfileImage(pk)
|
|
|
|
return openProfilePopup(chatsModel.userNameOrAlias(pk), pk, userProfileImage || utilsModel.generateIdenticon(pk))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-11 13:23:41 +00:00
|
|
|
leftPanel: Loader {
|
2020-12-11 20:29:46 +00:00
|
|
|
id: contactColumnLoader
|
2021-02-11 20:37:31 +00:00
|
|
|
sourceComponent: appSettings.communitiesEnabled && chatsModel.communities.activeCommunity.active ? communtiyColumnComponent : contactsColumnComponent
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 14:53:19 +00:00
|
|
|
centerPanel: ChatColumn {
|
2021-06-11 13:23:41 +00:00
|
|
|
id: chatColumn
|
|
|
|
chatGroupsListViewCount: contactColumnLoader.item.chatGroupsListViewCount
|
|
|
|
}
|
|
|
|
|
2021-07-22 14:53:19 +00:00
|
|
|
showRightPanel: chatColumn.showUsers && (chatsModel.channelView.activeChannel.chatType !== Constants.chatTypeOneToOne)
|
|
|
|
rightPanel: appSettings.communitiesEnabled && chatsModel.communities.activeCommunity.active ? communityUserListComponent : userListComponent
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: communityUserListComponent
|
|
|
|
CommunityUserList { currentTime: chatColumn.currentTime }
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: userListComponent
|
2021-08-19 13:04:52 +00:00
|
|
|
UserList { currentTime: chatColumn.currentTime; userList: chatColumn.userList;}
|
2021-07-22 14:53:19 +00:00
|
|
|
}
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
Component {
|
|
|
|
id: contactsColumnComponent
|
|
|
|
ContactsColumn {
|
2021-07-20 15:22:09 +00:00
|
|
|
onOpenProfileClicked: {
|
|
|
|
chatView.profileButtonClicked();
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: communtiyColumnComponent
|
2021-06-02 19:43:33 +00:00
|
|
|
CommunityColumn {
|
|
|
|
pinnedMessagesPopupComponent: chatColumn.pinnedMessagesPopupComponent
|
|
|
|
}
|
2020-05-13 17:27:06 +00:00
|
|
|
}
|
|
|
|
|
2021-02-17 20:36:10 +00:00
|
|
|
Component {
|
|
|
|
id: groupInfoPopupComponent
|
2021-05-25 19:38:18 +00:00
|
|
|
GroupInfoPopup {
|
|
|
|
pinnedMessagesPopupComponent: chatColumn.pinnedMessagesPopupComponent
|
|
|
|
}
|
2021-02-17 20:36:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-08 19:24:39 +00:00
|
|
|
Component {
|
|
|
|
id: statusStickerPackClickPopup
|
|
|
|
StatusStickerPackClickPopup{
|
|
|
|
onClosed: {
|
|
|
|
destroy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-02 13:02:56 +00:00
|
|
|
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)) {
|
2021-07-22 14:53:19 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
##^##*/
|