Popup : Close all popups by pressing escape

Using a key OnPressed instead of Shortcut
Making all popups closable with escape (focus true and a close policy)

GitLab: #1234
Change-Id: I1a612834c439aea94a59e91cb915b18b4ef5cf84
This commit is contained in:
lcoursodon
2023-07-03 10:44:40 -04:00
committed by Sébastien Blin
parent c8ec980a3b
commit fe2f3258b2
11 changed files with 26 additions and 14 deletions

View File

@@ -47,6 +47,7 @@ Popup {
// A popup is invisible until opened.
visible: false
focus: true
closePolicy: autoClose ? (Popup.CloseOnEscape | Popup.CloseOnPressOutside) : Popup.NoAutoClose
Rectangle {

View File

@@ -42,6 +42,7 @@ Popup {
padding: 0
visible: false
focus: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
Rectangle {

View File

@@ -30,6 +30,9 @@ Popup {
padding: 0
property list<Action> menuTypoActionsSecond
focus: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
contentItem: ListView {
id: listViewTypoSecond

View File

@@ -49,6 +49,9 @@ Popup {
property bool closeWithoutAnimation: false
property var emojiPicker
focus: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
function xPositionProvider(width) {
// Use the width at function scope to retrigger property evaluation.
const listViewWidth = listView.width

View File

@@ -149,13 +149,12 @@ Rectangle {
onActivated: layoutManager.toggleWindowFullScreen()
}
Shortcut {
sequence: "Escape"
context: Qt.ApplicationShortcut
onActivated: {
MessagesAdapter.replyToId = ""
MessagesAdapter.editId = ""
layoutManager.popFullScreenItem()
Keys.onPressed: function (keyEvent) {
if (keyEvent.key === Qt.Key_Escape) {
MessagesAdapter.replyToId = "";
MessagesAdapter.editId = "";
layoutManager.popFullScreenItem();
keyEvent.accepted = true;
}
}

View File

@@ -40,6 +40,9 @@ Popup {
color: JamiTheme.transparentColor
}
focus: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
contentItem: ColumnLayout {
spacing: 0

View File

@@ -220,10 +220,7 @@ Rectangle {
Keys.onShortcutOverride: function (keyEvent) {
if (keyEvent.key === Qt.Key_Escape) {
if (emojiPicker != null && emojiPicker.opened) {
emojiPicker.closeEmojiPicker();
}
else if (recordBox != null && recordBox.opened) {
if (recordBox != null && recordBox.opened) {
recordBox.closeRecorder();
}
else if (PositionManager.isMapActive(CurrentAccount.id)){

View File

@@ -51,6 +51,9 @@ Popup {
signal validatePhoto(string photo)
modal: true
closePolicy: Popup.CloseOnPressOutsideParent
function openRecorder(vid) {
isVideo = vid;
updateState(RecordBox.States.INIT);
@@ -121,9 +124,6 @@ Popup {
time.text = min + ":" + sec;
}
modal: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
onActiveFocusChanged: {
if (visible) {
closeRecorder();

View File

@@ -32,6 +32,9 @@ Popup {
required property ListView listView
signal emojiIsPicked(string content)
focus: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
// Close the picker when attached to a listView that receives height/scroll
// property changes.
property real listViewHeight: listView ? listView.height : 0

View File

@@ -42,6 +42,7 @@ Popup {
padding: 0
visible: false
focus: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
Rectangle {
id: container

View File

@@ -42,6 +42,7 @@ Popup {
padding: 0
visible: false
focus: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
Rectangle {