From 4050f41ce2bd5ea42bc8f01c50ac9c92e016eab8 Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Sun, 21 Feb 2021 01:26:39 +0200 Subject: [PATCH] Don't have on-screen keyboard and drawer visible simultaneously Also, removed unnecessary closeRequested() signal. --- qml/components/MessageListViewItem.qml | 8 +++++--- qml/pages/ChatPage.qml | 17 ++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 5a8ea23..cde7e1e 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -80,9 +80,11 @@ ListItem { } Connections { - target: messageOptionsDrawer - onCloseRequested: { - messageListItem.additionalOptionsOpened = false; + target: additionalOptionsOpened ? messageOptionsDrawer : null + onOpenChanged: { + if (!messageOptionsDrawer.open) { + additionalOptionsOpened = false + } } } diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index ca6867b..4db590b 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -750,16 +750,10 @@ Page { jointModel.push(messageOptionsModel[i]); } drawerListView.model = jointModel; + focus = true // Take the focus away from the text field } } - signal closeRequested(); - - function closeDrawer() { - messageOptionsDrawer.closeRequested(); - messageOptionsDrawer.open = false; - } - anchors.fill: parent dock: chatPage.isPortrait ? Dock.Bottom : Dock.Right backgroundSize: chatPage.isPortrait ? height / 3 : width / 2 @@ -793,7 +787,7 @@ Page { icon.source: "image://theme/icon-m-clear" anchors.verticalCenter: parent.verticalCenter onClicked: { - messageOptionsDrawer.closeDrawer(); + messageOptionsDrawer.open = false } } } @@ -808,7 +802,7 @@ Page { } onClicked: { modelData.action(); - messageOptionsDrawer.closeDrawer(); + messageOptionsDrawer.open = false } hidden: !modelData.visible } @@ -1919,6 +1913,11 @@ Page { controlSendButton(); textReplacementTimer.restart(); } + onActiveFocusChanged: { + if (activeFocus) { + messageOptionsDrawer.open = false + } + } } IconButton {