fix(chat): chat input accepts DnD for blocked users

- do not allow DND when the StatusChatInput is disabled
- remove `Global.dragArea` variable from the Global singleton
- move the `DropAreaPanel` into `StatusChatInput` and handle its
enabling from there

Fixes #16451
This commit is contained in:
Lukáš Tinkl 2024-10-07 14:31:53 +02:00 committed by Anastasiya
parent 92d8d601e5
commit bf666c20f5
8 changed files with 14 additions and 42 deletions

View File

@ -32,7 +32,6 @@ SplitView {
} }
Component.onCompleted: { Component.onCompleted: {
Utils.globalUtilsInst = globalUtilsMock.globalUtils Utils.globalUtilsInst = globalUtilsMock.globalUtils
Global.dragArea = null
globalUtilsMock.ready = true globalUtilsMock.ready = true
} }
} }

View File

@ -702,9 +702,5 @@ Item {
function isCompressedPubKey(publicKey) { function isCompressedPubKey(publicKey) {
return false return false
} }
Component.onCompleted: {
Global.dragArea = root
}
} }
} }

View File

@ -50,8 +50,6 @@ import mainui.activitycenter.popups 1.0
import SortFilterProxyModel 0.2 import SortFilterProxyModel 0.2
import "panels"
Item { Item {
id: appMain id: appMain
@ -1353,14 +1351,6 @@ Item {
ChatLayout { ChatLayout {
id: chatLayoutContainer id: chatLayoutContainer
Binding {
target: rootDropAreaPanel
property: "enabled"
value: chatLayoutContainer.currentIndex === 0 // Meaning: Chats / channels view
when: visible
restoreMode: Binding.RestoreBindingOrValue
}
sharedRootStore: appMain.sharedRootStore sharedRootStore: appMain.sharedRootStore
rootStore: ChatStores.RootStore { rootStore: ChatStores.RootStore {
contactsStore: appMain.rootStore.contactStore contactsStore: appMain.rootStore.contactStore
@ -1487,14 +1477,6 @@ Item {
readonly property bool isManageCommunityEnabledInAdvanced: appMain.rootStore.profileSectionStore.advancedStore.isManageCommunityOnTestModeEnabled readonly property bool isManageCommunityEnabledInAdvanced: appMain.rootStore.profileSectionStore.advancedStore.isManageCommunityOnTestModeEnabled
Binding {
target: rootDropAreaPanel
property: "enabled"
value: chatLayoutComponent.currentIndex === 0 // Meaning: Chats / channels view
when: visible
restoreMode: Binding.RestoreBindingOrValue
}
Connections { Connections {
target: Global target: Global
function onSwitchToCommunitySettings(communityId: string) { function onSwitchToCommunitySettings(communityId: string) {
@ -2153,13 +2135,6 @@ Item {
} }
} }
DropAreaPanel {
id: rootDropAreaPanel
width: appMain.width
height: appMain.height
}
Loader { Loader {
id: userAgreementLoader id: userAgreementLoader
active: production && !localAppSettings.testEnvironment active: production && !localAppSettings.testEnvironment

View File

@ -1,4 +1,5 @@
import QtQuick 2.14 import QtQuick 2.15
import utils 1.0 import utils 1.0
DropArea { DropArea {
@ -13,10 +14,6 @@ DropArea {
rptDraggedPreviews.model = [] rptDraggedPreviews.model = []
} }
Component.onCompleted: {
Global.dragArea = this;
}
onDropped: (drop) => { onDropped: (drop) => {
if (enabled) { if (enabled) {
droppedOnValidScreen(drop) droppedOnValidScreen(drop)
@ -42,7 +39,7 @@ DropArea {
onExited: cleanup() onExited: cleanup()
Loader { Loader {
active: root.containsDrag active: root.containsDrag && root.enabled
width: active ? parent.width : 0 width: active ? parent.width : 0
height: active ? parent.height : 0 height: active ? parent.height : 0
sourceComponent: Rectangle { sourceComponent: Rectangle {

View File

@ -2,3 +2,4 @@ AppMain 1.0 AppMain.qml
SplashScreen 1.0 SplashScreen.qml SplashScreen 1.0 SplashScreen.qml
Popups 1.0 Popups.qml Popups 1.0 Popups.qml
StatusTrayIcon 1.0 StatusTrayIcon.qml StatusTrayIcon 1.0 StatusTrayIcon.qml
DropAreaPanel 1.0 panels/DropAreaPanel.qml

View File

@ -1,8 +1,11 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Window 2.15 import QtQuick.Window 2.15
import QtGraphicalEffects 1.15 import QtGraphicalEffects 1.15
import shared.panels 1.0 import shared.panels 1.0
import utils 1.0
Item { Item {
id: root id: root

View File

@ -11,6 +11,8 @@ import shared.panels 1.0
import shared.popups 1.0 import shared.popups 1.0
import shared.stores 1.0 as SharedStores import shared.stores 1.0 as SharedStores
import mainui 1.0
//TODO remove this dependency //TODO remove this dependency
import AppLayouts.Chat.panels 1.0 import AppLayouts.Chat.panels 1.0
import AppLayouts.Chat.stores 1.0 as ChatStores import AppLayouts.Chat.stores 1.0 as ChatStores
@ -948,11 +950,11 @@ Rectangle {
messageInputField.forceActiveFocus(); messageInputField.forceActiveFocus();
} }
Connections { DropAreaPanel {
target: Global.dragArea enabled: control.visible && control.enabled
enabled: control.visible parent: Overlay.overlay
ignoreUnknownSignals: true anchors.fill: parent
function onDroppedOnValidScreen(drop) { onDroppedOnValidScreen: (drop) => {
let dropUrls = drop.urls let dropUrls = drop.urls
if (!drop.hasUrls) { if (!drop.hasUrls) {
console.warn("Trying to drop, list of URLs is empty tho; formats:", drop.formats) console.warn("Trying to drop, list of URLs is empty tho; formats:", drop.formats)

View File

@ -5,7 +5,6 @@ import QtQml 2.15
QtObject { QtObject {
id: root id: root
property var dragArea
property bool activityPopupOpened: false property bool activityPopupOpened: false
property int settingsSubsection: Constants.settingsSubsection.profile property int settingsSubsection: Constants.settingsSubsection.profile
property int settingsSubSubsection: -1 property int settingsSubSubsection: -1