fix(Chats): Drag/drop image files is only available for community channels

- Drag/drop images are available from all chat types (1:1 , group chats and community channels).
- In case of community settings views, it is disabled.

Fixes #9630
This commit is contained in:
Noelia 2023-02-27 13:11:51 +01:00 committed by Noelia
parent 7b250b20b8
commit d6467923e4
2 changed files with 20 additions and 25 deletions

View File

@ -5,6 +5,7 @@ import QtMultimedia 5.13
import Qt.labs.qmlmodels 1.0 import Qt.labs.qmlmodels 1.0
import Qt.labs.platform 1.1 import Qt.labs.platform 1.1
import QtQml.Models 2.14 import QtQml.Models 2.14
import QtQml 2.15
import AppLayouts.Wallet 1.0 import AppLayouts.Wallet 1.0
import AppLayouts.Node 1.0 import AppLayouts.Node 1.0
@ -761,8 +762,15 @@ Item {
ChatLayout { ChatLayout {
id: chatLayoutContainer id: chatLayoutContainer
rootStore: appMain.rootChatStore Binding {
target: rootDropAreaPanel
property: "enabled"
value: chatLayoutContainer.currentIndex === 0 // Meaning: Chats / channels view
when: visible
restoreMode: Binding.RestoreBindingOrValue
}
rootStore: appMain.rootChatStore
chatView.emojiPopup: statusEmojiPopup chatView.emojiPopup: statusEmojiPopup
chatView.stickersPopup: statusStickersPopupLoader.item chatView.stickersPopup: statusStickersPopupLoader.item
@ -858,6 +866,16 @@ Item {
Layout.fillHeight: true Layout.fillHeight: true
sourceComponent: ChatLayout { sourceComponent: ChatLayout {
id: chatLayoutComponent
Binding {
target: rootDropAreaPanel
property: "enabled"
value: chatLayoutComponent.currentIndex === 0 // Meaning: Chats / channels view
when: visible
restoreMode: Binding.RestoreBindingOrValue
}
chatView.emojiPopup: statusEmojiPopup chatView.emojiPopup: statusEmojiPopup
chatView.stickersPopup: statusStickersPopupLoader.item chatView.stickersPopup: statusStickersPopupLoader.item
@ -1172,32 +1190,10 @@ Item {
} }
} }
Connections {
target: appMain.rootStore.mainModuleInst
function onActiveSectionChanged() {
let communitySectionModule = appMain.rootStore.mainModuleInst.getCommunitySectionModule()
if (communitySectionModule)
rootDropAreaPanel.activeChatType = communitySectionModule.activeItem.type
}
}
DropAreaPanel { DropAreaPanel {
id: rootDropAreaPanel id: rootDropAreaPanel
width: appMain.width width: appMain.width
height: appMain.height height: appMain.height
activeChatType: appMain.rootStore.mainModuleInst.getCommunitySectionModule() ? appMain.rootStore.mainModuleInst.getCommunitySectionModule().activeItem.type
: 0
enabled: !drag.source && (
// in chat view
(appMain.rootStore.mainModuleInst.activeSection.sectionType === Constants.appSection.chat &&
(
// in a one-to-one chat
activeChatType === Constants.chatType.oneToOne ||
// in a private group chat
activeChatType === Constants.chatType.privateGroupChat
)
) ||
// In community section
appMain.rootStore.mainModuleInst.activeSection.sectionType === Constants.appSection.community)
} }
} }

View File

@ -6,7 +6,6 @@ DropArea {
property bool enabled: false property bool enabled: false
property alias droppedUrls: rptDraggedPreviews.model property alias droppedUrls: rptDraggedPreviews.model
property int activeChatType
signal droppedOnValidScreen(var drop) signal droppedOnValidScreen(var drop)