EffectMaker: Fix combo box open/close behavior

Fixed inconsistent opening and closing of preview and add effect popups,
when clicking on the content part of the combo box.
Also, pressing Escape now closes opened combobox popups.

Fixes: QDS-11307
Change-Id: I3b3fddbaa743c77fd60833378ab809b17a8f1a84
Reviewed-by: Amr Elsayed <amr.elsayed@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Miikka Heikkinen
2023-11-20 16:35:35 +02:00
parent af656a3b53
commit 9d0fd52a7c
2 changed files with 28 additions and 2 deletions

View File

@@ -78,7 +78,7 @@ StudioControls.ComboBox {
flags: Qt.Dialog | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint flags: Qt.Dialog | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
onActiveFocusItemChanged: { onActiveFocusItemChanged: {
if (!window.activeFocusItem && !root.indicator.hover && root.popup.opened) if (!window.activeFocusItem && !root.hovered && root.popup.opened)
root.popup.close() root.popup.close()
} }
@@ -87,6 +87,7 @@ StudioControls.ComboBox {
color: StudioTheme.Values.themePanelBackground color: StudioTheme.Values.themePanelBackground
border.color: StudioTheme.Values.themeInteraction border.color: StudioTheme.Values.themeInteraction
border.width: 1 border.width: 1
focus: true
HelperWidgets.ScrollView { HelperWidgets.ScrollView {
anchors.fill: parent anchors.fill: parent
@@ -126,6 +127,11 @@ StudioControls.ComboBox {
} }
} }
} }
Keys.onPressed: function(event) {
if (event.key === Qt.Key_Escape && root.popup.opened)
root.popup.close()
}
} }
} }
} }

View File

@@ -90,6 +90,20 @@ StudioControls.ComboBox {
anchors.fill: parent anchors.fill: parent
anchors.margins: 1 anchors.margins: 1
} }
MouseArea {
anchors.fill: parent
enabled: true
acceptedButtons: Qt.LeftButton
cursorShape: Qt.PointingHandCursor
onPressed: (mouse) => {
if (root.popup.opened)
root.popup.close()
else
root.popup.open()
mouse.accepted = true
}
}
} }
Window { Window {
@@ -98,7 +112,7 @@ StudioControls.ComboBox {
flags: Qt.Dialog | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint flags: Qt.Dialog | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
onActiveFocusItemChanged: { onActiveFocusItemChanged: {
if (!window.activeFocusItem && !root.indicator.hover && root.popup.opened) if (!window.activeFocusItem && !root.hovered && root.popup.opened)
root.popup.close() root.popup.close()
} }
@@ -107,6 +121,7 @@ StudioControls.ComboBox {
color: StudioTheme.Values.themePanelBackground color: StudioTheme.Values.themePanelBackground
border.color: StudioTheme.Values.themeInteraction border.color: StudioTheme.Values.themeInteraction
border.width: 1 border.width: 1
focus: true
HelperWidgets.ScrollView { HelperWidgets.ScrollView {
anchors.fill: parent anchors.fill: parent
@@ -153,6 +168,11 @@ StudioControls.ComboBox {
} }
} }
} }
Keys.onPressed: function(event) {
if (event.key === Qt.Key_Escape && root.popup.opened)
root.popup.close()
}
} }
} }
} }