From eebd3472ae511e9d11167aebfbcd051a32136f42 Mon Sep 17 00:00:00 2001 From: Mahmoud Badri Date: Tue, 12 Mar 2024 14:19:05 +0200 Subject: [PATCH] QmlDesigner: Close CustomComboBox's popup on view scroll Also remove the taskbar window (on Windows) that appears when the popup appears, and make the FlagsComboBox buttons smaller Fixes: QDS-12215 Change-Id: Ief8ab3b746a3d18b391b46a391cb53e775ecd624 Reviewed-by: Miikka Heikkinen Reviewed-by: Qt CI Patch Build Bot --- .../imports/HelperWidgets/FlagsComboBox.qml | 2 ++ .../imports/HelperWidgets/PropertyEditorPane.qml | 1 + .../imports/StudioControls/CustomComboBox.qml | 16 +++++++++++----- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/FlagsComboBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/FlagsComboBox.qml index 05a97e7a145..8bc9ad44282 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/FlagsComboBox.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/FlagsComboBox.qml @@ -73,6 +73,7 @@ StudioControls.CustomComboBox { HelperWidgets.Button { text: qsTr("Select All") + width: 80 onClicked: { let allFlags = 0 @@ -84,6 +85,7 @@ StudioControls.CustomComboBox { } HelperWidgets.Button { text: qsTr("Select None") + width: 80 onClicked: root.backendValue.value = 0 } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/PropertyEditorPane.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/PropertyEditorPane.qml index f35a21f4533..7046ca48e14 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/PropertyEditorPane.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/PropertyEditorPane.qml @@ -17,6 +17,7 @@ Rectangle { Component.onCompleted: Controller.mainScrollView = mainScrollView default property alias content: mainColumn.children + property alias scrollView: mainScrollView // Called from C++ to close context menu on focus out function closeContextMenu() { diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/CustomComboBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/CustomComboBox.qml index ba39201bdc8..88ebfaadb03 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/CustomComboBox.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/CustomComboBox.qml @@ -12,8 +12,6 @@ StudioControls.ComboBox { required property Component popupComponent - required property Item mainRoot - readonly property int popupHeight: Math.min(800, popupLoader.height + 2) property alias popupItem: popupLoader.item @@ -23,8 +21,8 @@ StudioControls.ComboBox { popup.height: 0 function calculateWindowGeometry() { - let gPos = globalPos(mainRoot.mapFromItem(root, 0, 0)) - let scrRect = screenRect(); + let gPos = globalPos(itemPane.mapFromItem(root, 0, 0)) + let scrRect = screenRect() window.width = Math.max(root.width - root.actionIndicator.width, popupLoader.width + 2) // 2: scrollView left and right 1px margins @@ -70,10 +68,18 @@ StudioControls.ComboBox { } } + Connections { + target: itemPane.scrollView + + function onContentYChanged() { + window.hide() // TODO: a better solution is to move the window instead of hiding + } + } + Window { id: window - flags: Qt.Dialog | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint + flags: Qt.Tool | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint onActiveFocusItemChanged: { if (!window.activeFocusItem && !root.hovered && root.popup.opened)