From 1327a2c7cee174dc982a5fbfbf6102c93e18eaeb Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Wed, 13 Sep 2023 17:56:31 +0200 Subject: [PATCH] QmlDesigner: Add transient scroll bar Add transient scroll bar to connections editor Change-Id: Id4afd661da2fcdeacd2a4a0de0e0b9999c14dec2 Reviewed-by: Thomas Hartmann Reviewed-by: Qt CI Patch Build Bot --- .../connectionseditor/BindingsListView.qml | 18 ++++++++++++++++++ .../connectionseditor/ConnectionsListView.qml | 19 ++++++++++++++++--- .../qmldesigner/connectionseditor/Main.qml | 8 ++++++++ .../connectionseditor/PropertiesListView.qml | 18 ++++++++++++++++++ src/libs/advanceddockingsystem/dockwidget.cpp | 9 ++++++++- 5 files changed, 68 insertions(+), 4 deletions(-) diff --git a/share/qtcreator/qmldesigner/connectionseditor/BindingsListView.qml b/share/qtcreator/qmldesigner/connectionseditor/BindingsListView.qml index d2252bba95b..07a6fa7c8db 100644 --- a/share/qtcreator/qmldesigner/connectionseditor/BindingsListView.qml +++ b/share/qtcreator/qmldesigner/connectionseditor/BindingsListView.qml @@ -13,10 +13,28 @@ ListView { property StudioTheme.ControlStyle style: StudioTheme.Values.viewBarButtonStyle + property bool adsFocus: false + clip: true interactive: true highlightMoveDuration: 0 highlightResizeDuration: 0 + boundsMovement: Flickable.StopAtBounds + boundsBehavior: Flickable.StopAtBounds + + HoverHandler { id: hoverHandler } + + ScrollBar.vertical: HelperWidgets.ScrollBar { + id: verticalScrollBar + parent: root + x: root.width - verticalScrollBar.width + y: 0 + height: root.availableHeight + orientation: Qt.Vertical + + show: (hoverHandler.hovered || root.focus || verticalScrollBar.inUse || root.adsFocus) + && verticalScrollBar.isNeeded + } onVisibleChanged: { dialog.hide() diff --git a/share/qtcreator/qmldesigner/connectionseditor/ConnectionsListView.qml b/share/qtcreator/qmldesigner/connectionseditor/ConnectionsListView.qml index 909ca187e6f..e48c0b48603 100644 --- a/share/qtcreator/qmldesigner/connectionseditor/ConnectionsListView.qml +++ b/share/qtcreator/qmldesigner/connectionseditor/ConnectionsListView.qml @@ -13,14 +13,27 @@ ListView { property StudioTheme.ControlStyle style: StudioTheme.Values.viewBarButtonStyle + property bool adsFocus: false + clip: true interactive: true highlightMoveDuration: 0 highlightResizeDuration: 0 + boundsMovement: Flickable.StopAtBounds + boundsBehavior: Flickable.StopAtBounds - ScrollBar.vertical: ScrollBar { - id: comboBoxPopupScrollBar - visible: root.height < root.contentHeight + HoverHandler { id: hoverHandler } + + ScrollBar.vertical: HelperWidgets.ScrollBar { + id: verticalScrollBar + parent: root + x: root.width - verticalScrollBar.width + y: 0 + height: root.availableHeight + orientation: Qt.Vertical + + show: (hoverHandler.hovered || root.focus || verticalScrollBar.inUse || root.adsFocus) + && verticalScrollBar.isNeeded } onVisibleChanged: { diff --git a/share/qtcreator/qmldesigner/connectionseditor/Main.qml b/share/qtcreator/qmldesigner/connectionseditor/Main.qml index 6e47848b12e..4c6dd50c625 100644 --- a/share/qtcreator/qmldesigner/connectionseditor/Main.qml +++ b/share/qtcreator/qmldesigner/connectionseditor/Main.qml @@ -14,6 +14,11 @@ Rectangle { color: StudioTheme.Values.themePanelBackground + property bool adsFocus: false + // objectName is used by the dock widget to find this particular ScrollView + // and set the ads focus on it. + objectName: "__mainSrollView" + Column { id: column anchors.fill: parent @@ -109,6 +114,7 @@ Rectangle { width: parent.width height: parent.height - toolbar.height - column.spacing model: ConnectionsEditorEditorBackend.connectionModel + adsFocus: root.adsFocus } BindingsListView { @@ -116,6 +122,7 @@ Rectangle { width: parent.width height: parent.height - toolbar.height - column.spacing model: ConnectionsEditorEditorBackend.bindingModel + adsFocus: root.adsFocus } PropertiesListView { @@ -123,6 +130,7 @@ Rectangle { width: parent.width height: parent.height - toolbar.height - column.spacing model: ConnectionsEditorEditorBackend.dynamicPropertiesModel + adsFocus: root.adsFocus } } } diff --git a/share/qtcreator/qmldesigner/connectionseditor/PropertiesListView.qml b/share/qtcreator/qmldesigner/connectionseditor/PropertiesListView.qml index bf1ed237cb5..2f4382020b3 100644 --- a/share/qtcreator/qmldesigner/connectionseditor/PropertiesListView.qml +++ b/share/qtcreator/qmldesigner/connectionseditor/PropertiesListView.qml @@ -13,10 +13,28 @@ ListView { property StudioTheme.ControlStyle style: StudioTheme.Values.viewBarButtonStyle + property bool adsFocus: false + clip: true interactive: true highlightMoveDuration: 0 highlightResizeDuration: 0 + boundsMovement: Flickable.StopAtBounds + boundsBehavior: Flickable.StopAtBounds + + HoverHandler { id: hoverHandler } + + ScrollBar.vertical: HelperWidgets.ScrollBar { + id: verticalScrollBar + parent: root + x: root.width - verticalScrollBar.width + y: 0 + height: root.availableHeight + orientation: Qt.Vertical + + show: (hoverHandler.hovered || root.focus || verticalScrollBar.inUse || root.adsFocus) + && verticalScrollBar.isNeeded + } onVisibleChanged: { dialog.hide() diff --git a/src/libs/advanceddockingsystem/dockwidget.cpp b/src/libs/advanceddockingsystem/dockwidget.cpp index bb6dd00b322..f2e0e72249f 100644 --- a/src/libs/advanceddockingsystem/dockwidget.cpp +++ b/src/libs/advanceddockingsystem/dockwidget.cpp @@ -457,6 +457,8 @@ void DockWidget::setFocused(bool focused) if (d->m_scrollArea) d->m_scrollArea->setProperty("focused", focused); + const QString customObjectName = QString("__mainSrollView"); + QList quickWidgets = d->m_widget->findChildren(); for (const auto &quickWidget : std::as_const(quickWidgets)) { @@ -464,7 +466,12 @@ void DockWidget::setFocused(bool focused) if (!rootItem) continue; - QQuickItem *scrollView = rootItem->findChild("__mainSrollView"); + if (rootItem->objectName() == customObjectName) { + rootItem->setProperty("adsFocus", focused); + continue; + } + + QQuickItem *scrollView = rootItem->findChild(customObjectName); if (!scrollView) continue;