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
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.popups 1.0
|
|
|
|
import shared.status 1.0
|
2021-10-28 20:23:30 +00:00
|
|
|
import shared.views.chat 1.0
|
|
|
|
|
|
|
|
import StatusQ.Layout 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
2021-10-01 15:58:36 +00:00
|
|
|
|
|
|
|
import "views"
|
|
|
|
import "panels"
|
|
|
|
import "panels/communities"
|
|
|
|
import "popups"
|
|
|
|
import "helpers"
|
|
|
|
import "controls"
|
|
|
|
import "stores"
|
2020-05-13 17:27:06 +00:00
|
|
|
|
2021-07-22 14:53:19 +00:00
|
|
|
StatusAppThreePanelLayout {
|
2021-10-21 22:39:53 +00:00
|
|
|
id: root
|
2020-05-27 17:10:50 +00:00
|
|
|
|
2021-07-22 14:53:19 +00:00
|
|
|
handle: SplitViewHandle { implicitWidth: 5 }
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
property var messageStore
|
|
|
|
property RootStore rootStore: RootStore {
|
2021-10-21 22:39:53 +00:00
|
|
|
messageStore: root.messageStore
|
2021-10-01 15:58:36 +00:00
|
|
|
}
|
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 {
|
2021-10-21 22:39:53 +00:00
|
|
|
target: root.rootStore.chatsModelInst.stickers
|
2021-03-08 19:24:39 +00:00
|
|
|
onStickerPacksLoaded: {
|
|
|
|
stickersLoaded = true;
|
|
|
|
}
|
|
|
|
}
|
2020-11-19 18:30:09 +00:00
|
|
|
|
2020-09-23 07:28:20 +00:00
|
|
|
property var onActivated: function () {
|
2021-10-21 22:39:53 +00:00
|
|
|
root.rootStore.chatsModelInst.channelView.restorePreviousActiveChannel();
|
|
|
|
chatColumn.onActivated();
|
2020-09-23 07:28:20 +00:00
|
|
|
}
|
|
|
|
|
2021-08-16 08:54:20 +00:00
|
|
|
StatusSearchLocationMenu {
|
|
|
|
id: searchPopupMenu
|
|
|
|
searchPopup: searchPopup
|
2021-10-21 22:39:53 +00:00
|
|
|
locationModel: root.rootStore.chatsModelInst.messageSearchViewController.locationMenuModel
|
2021-08-16 08:54:20 +00:00
|
|
|
|
|
|
|
onItemClicked: {
|
2021-10-21 22:39:53 +00:00
|
|
|
root.rootStore.chatsModelInst.messageSearchViewController.setSearchLocation(firstLevelItemValue, secondLevelItemValue)
|
2021-08-16 08:54:20 +00:00
|
|
|
if(searchPopup.searchText !== "")
|
|
|
|
searchMessages(searchPopup.searchText)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
property var searchMessages: Backpressure.debounce(searchPopup, 400, function (value) {
|
2021-10-21 22:39:53 +00:00
|
|
|
root.rootStore.chatsModelInst.messageSearchViewController.searchMessages(value)
|
2021-08-16 08:54:20 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
Connections {
|
2021-10-21 22:39:53 +00:00
|
|
|
target: root.rootStore.chatsModelInst.messageSearchViewController.locationMenuModel
|
2021-08-16 08:54:20 +00:00
|
|
|
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
|
2021-10-21 22:39:53 +00:00
|
|
|
searchResults: root.rootStore.chatsModelInst.messageSearchViewController.resultModel
|
2021-08-30 14:40:03 +00:00
|
|
|
|
|
|
|
formatTimestampFn: function (ts) {
|
2021-10-20 10:55:10 +00:00
|
|
|
return new Date(parseInt(ts, 10)).toLocaleString(Qt.locale(localAppSettings.locale))
|
2021-08-30 14:40:03 +00:00
|
|
|
}
|
|
|
|
|
2021-08-16 08:54:20 +00:00
|
|
|
onSearchTextChanged: {
|
|
|
|
searchMessages(searchPopup.searchText);
|
|
|
|
}
|
|
|
|
onAboutToHide: {
|
|
|
|
if (searchPopupMenu.visible) {
|
|
|
|
searchPopupMenu.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onClosed: {
|
|
|
|
searchPopupMenu.dismiss();
|
|
|
|
}
|
|
|
|
onOpened: {
|
|
|
|
searchPopup.resetSearchSelection();
|
2021-09-08 10:41:50 +00:00
|
|
|
searchPopup.forceActiveFocus()
|
2021-10-21 22:39:53 +00:00
|
|
|
root.rootStore.chatsModelInst.messageSearchViewController.prepareLocationMenuModel()
|
2021-08-16 08:54:20 +00:00
|
|
|
|
2021-10-21 22:39:53 +00:00
|
|
|
const jsonObj = root.rootStore.chatsModelInst.messageSearchViewController.getSearchLocationObject()
|
2021-08-16 08:54:20 +00:00
|
|
|
|
|
|
|
if (!jsonObj) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
let obj = JSON.parse(jsonObj)
|
|
|
|
if (obj.location === "") {
|
|
|
|
if(obj.subLocation === "") {
|
2021-10-21 22:39:53 +00:00
|
|
|
root.rootStore.chatsModelInst.messageSearchViewController.setSearchLocation("", "")
|
2021-08-16 08:54:20 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
searchPopup.setSearchSelection(obj.subLocation.text,
|
|
|
|
"",
|
|
|
|
obj.subLocation.imageSource,
|
|
|
|
obj.subLocation.isIdenticon,
|
|
|
|
obj.subLocation.iconName,
|
|
|
|
obj.subLocation.identiconColor)
|
|
|
|
|
2021-10-21 22:39:53 +00:00
|
|
|
root.rootStore.chatsModelInst.messageSearchViewController.setSearchLocation("", obj.subLocation.value)
|
2021-08-16 08:54:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (obj.location.title === "Chat") {
|
|
|
|
searchPopup.setSearchSelection(obj.subLocation.text,
|
|
|
|
"",
|
|
|
|
obj.subLocation.imageSource,
|
|
|
|
obj.subLocation.isIdenticon,
|
|
|
|
obj.subLocation.iconName,
|
|
|
|
obj.subLocation.identiconColor)
|
|
|
|
|
2021-10-21 22:39:53 +00:00
|
|
|
root.rootStore.chatsModelInst.messageSearchViewController.setSearchLocation(obj.location.value, obj.subLocation.value)
|
2021-08-16 08:54:20 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
searchPopup.setSearchSelection(obj.location.title,
|
|
|
|
obj.subLocation.text,
|
|
|
|
obj.location.imageSource,
|
|
|
|
obj.location.isIdenticon,
|
|
|
|
obj.location.iconName,
|
|
|
|
obj.location.identiconColor)
|
|
|
|
|
2021-10-21 22:39:53 +00:00
|
|
|
root.rootStore.chatsModelInst.messageSearchViewController.setSearchLocation(obj.location.value, obj.subLocation.value)
|
2021-08-16 08:54:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onResultItemClicked: {
|
|
|
|
searchPopup.close()
|
|
|
|
|
2021-10-21 22:39:53 +00:00
|
|
|
root.rootStore.chatsModelInst.switchToSearchedItem(itemId)
|
2021-08-16 08:54:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onResultItemTitleClicked: {
|
|
|
|
const pk = titleId
|
|
|
|
const userProfileImage = appMain.getProfileImage(pk)
|
2021-10-21 22:39:53 +00:00
|
|
|
return openProfilePopup(root.rootStore.chatsModelInst.userNameOrAlias(pk), pk, userProfileImage || root.rootStore.utilsModelInst.generateIdenticon(pk))
|
2021-08-16 08:54:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-11 13:23:41 +00:00
|
|
|
leftPanel: Loader {
|
2020-12-11 20:29:46 +00:00
|
|
|
id: contactColumnLoader
|
2021-10-20 09:50:50 +00:00
|
|
|
sourceComponent: localAccountSensitiveSettings.communitiesEnabled && root.rootStore.chatsModelInst.communities.activeCommunity.active ? communtiyColumnComponent : contactsColumnComponent
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
|
2021-10-28 10:01:10 +00:00
|
|
|
centerPanel: ChatColumnView {
|
2021-06-11 13:23:41 +00:00
|
|
|
id: chatColumn
|
2021-10-28 15:41:32 +00:00
|
|
|
rootStore: root.rootStore
|
2021-10-15 19:47:43 +00:00
|
|
|
chatGroupsListViewCount: contactColumnLoader.item.chatGroupsListViewCount
|
2021-06-11 13:23:41 +00:00
|
|
|
}
|
|
|
|
|
2021-10-20 09:50:50 +00:00
|
|
|
showRightPanel: (localAccountSensitiveSettings.expandUsersList && (localAccountSensitiveSettings.showOnlineUsers || chatsModel.communities.activeCommunity.active)
|
2021-10-06 20:05:13 +00:00
|
|
|
&& (chatsModel.channelView.activeChannel.chatType !== Constants.chatTypeOneToOne))
|
2021-10-20 09:50:50 +00:00
|
|
|
rightPanel: localAccountSensitiveSettings.communitiesEnabled && chatsModel.communities.activeCommunity.active ? communityUserListComponent : userListComponent
|
2021-07-22 14:53:19 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: communityUserListComponent
|
2021-10-01 15:58:36 +00:00
|
|
|
CommunityUserListPanel {
|
|
|
|
currentTime: chatColumn.currentTime
|
|
|
|
messageContextMenu: quickActionMessageOptionsMenu
|
2021-10-29 18:06:18 +00:00
|
|
|
profilePubKey: userProfile.pubKey
|
2021-10-21 22:39:53 +00:00
|
|
|
contactsList: root.rootStore.profileModelInst.contacts.list
|
|
|
|
community: root.rootStore.chatsModelInst.communities.activeCommunity
|
2021-10-29 21:15:33 +00:00
|
|
|
currentUserName: Utils.removeStatusEns(root.rootStore.profileModelInst.ens.preferredUsername
|
|
|
|
|| root.rootStore.profileModelInst.profile.username)
|
2021-11-22 11:08:09 +00:00
|
|
|
currentUserOnline: root.store.userProfileInst.userStatus
|
2021-10-01 15:58:36 +00:00
|
|
|
}
|
2021-07-22 14:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: userListComponent
|
2021-10-01 15:58:36 +00:00
|
|
|
UserListPanel {
|
|
|
|
currentTime: chatColumn.currentTime
|
|
|
|
userList: chatColumn.userList
|
|
|
|
messageContextMenu: quickActionMessageOptionsMenu
|
2021-10-29 18:06:18 +00:00
|
|
|
profilePubKey: userProfile.pubKey
|
2021-10-21 22:39:53 +00:00
|
|
|
contactsList: root.rootStore.profileModelInst.contacts.list
|
|
|
|
isOnline: root.rootStore.chatsModelInst.isOnline
|
2021-10-01 15:58:36 +00:00
|
|
|
}
|
2021-07-22 14:53:19 +00:00
|
|
|
}
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
Component {
|
|
|
|
id: contactsColumnComponent
|
2021-10-01 15:58:36 +00:00
|
|
|
ContactsColumnView {
|
2021-10-21 22:39:53 +00:00
|
|
|
store: root.rootStore
|
2021-07-20 15:22:09 +00:00
|
|
|
onOpenProfileClicked: {
|
2021-10-21 22:39:53 +00:00
|
|
|
root.profileButtonClicked();
|
2021-07-20 15:22:09 +00:00
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: communtiyColumnComponent
|
2021-10-01 15:58:36 +00:00
|
|
|
CommunityColumnView {
|
2021-10-21 22:39:53 +00:00
|
|
|
store: root.rootStore
|
2021-06-02 19:43:33 +00:00
|
|
|
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 {
|
2021-10-22 20:49:47 +00:00
|
|
|
store: root.rootStore
|
2021-05-25 19:38:18 +00:00
|
|
|
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"
|
2021-09-09 09:10:29 +00:00
|
|
|
header.title: qsTrId("remove-contact")
|
2020-10-02 13:02:56 +00:00
|
|
|
//% "Are you sure you want to remove this contact?"
|
|
|
|
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
|
|
|
|
onConfirmButtonClicked: {
|
2021-10-21 22:39:53 +00:00
|
|
|
if (root.rootStore.profileModelInst.contacts.isAdded(chatColumn.contactToRemove)) {
|
|
|
|
root.rootStore.profileModelInst.contacts.removeContact(chatColumn.contactToRemove)
|
2020-10-02 13:02:56 +00:00
|
|
|
}
|
|
|
|
removeContactConfirmationDialog.parentPopup.close();
|
|
|
|
removeContactConfirmationDialog.close();
|
|
|
|
}
|
|
|
|
}
|
2021-09-01 17:38:39 +00:00
|
|
|
|
2021-10-21 00:41:54 +00:00
|
|
|
MessageContextMenuView {
|
2021-09-01 17:38:39 +00:00
|
|
|
id: quickActionMessageOptionsMenu
|
2021-10-21 22:39:53 +00:00
|
|
|
store: root.rootStore
|
|
|
|
reactionModel: root.rootStore.emojiReactionsModel
|
2021-09-01 17:38:39 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
##^##*/
|