From b2ee8acafaec2827793256c59db9749117c2cefb Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Fri, 25 Aug 2023 16:53:39 +0200 Subject: [PATCH] QmlDesigner: Add QML views transient scrollbars * Add transient scrollbars to all QML based views * Remove version from QtQuick imports * Fix missing AssetsLibraryBackend reference in AssetsDelegate Task-number: QDS-9549 Change-Id: I7ab2e52106efae07caa37763b5b0592cfbf57c2e Reviewed-by: Qt CI Patch Build Bot Reviewed-by: Reviewed-by: Thomas Hartmann --- .../assetsLibraryQmlSources/AssetDelegate.qml | 2 +- .../assetsLibraryQmlSources/Assets.qml | 6 +- .../assetsLibraryQmlSources/AssetsView.qml | 18 +++- .../EmptyMaterialEditorPane.qml | 3 +- .../MaterialEditorPane.qml | 8 +- .../QtQuick/ItemPane.qml | 12 +-- .../QtQuick/QtObjectPane.qml | 4 +- .../QtQuick3D/Object3DPane.qml | 17 ++-- .../HelperWidgets/PropertyEditorPane.qml | 16 ++-- .../imports/HelperWidgets/ScrollBar.qml | 89 +++++++++++++++++++ .../imports/HelperWidgets/ScrollView.qml | 55 ++++++++---- .../imports/HelperWidgets/qmldir | 1 + .../qmldesigner/stateseditor/Main.qml | 22 ++++- .../EmptyTextureEditorPane.qml | 3 +- .../TextureEditorPane.qml | 8 +- src/libs/advanceddockingsystem/CMakeLists.txt | 2 +- src/libs/advanceddockingsystem/dockwidget.cpp | 20 ++++- src/libs/advanceddockingsystem/dockwidget.h | 4 +- .../connectioneditor/connectionview.cpp | 7 +- .../qmldesigner/qmldesignerconstants.h | 1 + .../studio/studioquickwidget.h | 4 + 21 files changed, 236 insertions(+), 66 deletions(-) create mode 100644 share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ScrollBar.qml diff --git a/share/qtcreator/qmldesigner/assetsLibraryQmlSources/AssetDelegate.qml b/share/qtcreator/qmldesigner/assetsLibraryQmlSources/AssetDelegate.qml index 12f5ebf4c15..6a511c72524 100644 --- a/share/qtcreator/qmldesigner/assetsLibraryQmlSources/AssetDelegate.qml +++ b/share/qtcreator/qmldesigner/assetsLibraryQmlSources/AssetDelegate.qml @@ -156,7 +156,7 @@ TreeViewDelegate { mouseArea.allowTooltip = true } - onPositionChanged: tooltipBackend.reposition() + onPositionChanged: AssetsLibraryBackend.tooltipBackend.reposition() onPressed: (mouse) => { mouseArea.forceActiveFocus() diff --git a/share/qtcreator/qmldesigner/assetsLibraryQmlSources/Assets.qml b/share/qtcreator/qmldesigner/assetsLibraryQmlSources/Assets.qml index 6520a5f4092..cfa40209950 100644 --- a/share/qtcreator/qmldesigner/assetsLibraryQmlSources/Assets.qml +++ b/share/qtcreator/qmldesigner/assetsLibraryQmlSources/Assets.qml @@ -260,10 +260,12 @@ Item { AssetsView { id: assetsView - assetsRoot: root - contextMenu: contextMenu + width: parent.width height: parent.height - assetsView.y + + assetsRoot: root + contextMenu: contextMenu focus: true } } diff --git a/share/qtcreator/qmldesigner/assetsLibraryQmlSources/AssetsView.qml b/share/qtcreator/qmldesigner/assetsLibraryQmlSources/AssetsView.qml index e4380a19b39..98b85d85c96 100644 --- a/share/qtcreator/qmldesigner/assetsLibraryQmlSources/AssetsView.qml +++ b/share/qtcreator/qmldesigner/assetsLibraryQmlSources/AssetsView.qml @@ -15,6 +15,11 @@ TreeView { boundsBehavior: Flickable.StopAtBounds rowSpacing: 5 + 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" + property var assetsModel: AssetsLibraryBackend.assetsModel property var rootView: AssetsLibraryBackend.rootView property var tooltipBackend: AssetsLibraryBackend.tooltipBackend @@ -46,9 +51,18 @@ TreeView { return -1 } - ScrollBar.vertical: HelperWidgets.VerticalScrollBar { + HoverHandler { id: hoverHandler } + + ScrollBar.vertical: HelperWidgets.ScrollBar { id: verticalScrollBar - scrollBarVisible: root.contentHeight > root.height + parent: root + x: root.width - verticalScrollBar.width + y: 0 + height: root.availableHeight + orientation: Qt.Vertical + + show: (hoverHandler.hovered || root.adsFocus || verticalScrollBar.inUse) + && verticalScrollBar.isNeeded } model: assetsModel diff --git a/share/qtcreator/qmldesigner/materialEditorQmlSources/EmptyMaterialEditorPane.qml b/share/qtcreator/qmldesigner/materialEditorQmlSources/EmptyMaterialEditorPane.qml index c8b2ab7ef6c..005b4dfff1d 100644 --- a/share/qtcreator/qmldesigner/materialEditorQmlSources/EmptyMaterialEditorPane.qml +++ b/share/qtcreator/qmldesigner/materialEditorQmlSources/EmptyMaterialEditorPane.qml @@ -1,8 +1,7 @@ // Copyright (C) 2022 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -import QtQuick 2.15 -import QtQuick.Layouts 1.15 +import QtQuick import QtQuickDesignerTheme 1.0 import HelperWidgets 2.0 import StudioTheme 1.0 as StudioTheme diff --git a/share/qtcreator/qmldesigner/materialEditorQmlSources/MaterialEditorPane.qml b/share/qtcreator/qmldesigner/materialEditorQmlSources/MaterialEditorPane.qml index 0816d01ec4c..0187cde6951 100644 --- a/share/qtcreator/qmldesigner/materialEditorQmlSources/MaterialEditorPane.qml +++ b/share/qtcreator/qmldesigner/materialEditorQmlSources/MaterialEditorPane.qml @@ -1,7 +1,7 @@ // Copyright (C) 2022 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -import QtQuick 2.15 +import QtQuick import QtQuickDesignerTheme 1.0 import HelperWidgets 2.0 @@ -56,12 +56,12 @@ PropertyEditorPane { anchors.left: parent.left anchors.right: parent.right - visible: theSource !== "" + visible: specificsTwo.theSource !== "" sourceComponent: specificQmlComponent onTheSourceChanged: { - active = false - active = true + specificsTwo.active = false + specificsTwo.active = true } } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml index 943b35aeed3..60bd415a6af 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml @@ -1,9 +1,9 @@ // Copyright (C) 2021 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuick.Layouts 1.15 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts import HelperWidgets 2.0 import StudioControls 1.0 as StudioControls import StudioTheme 1.0 as StudioTheme @@ -116,12 +116,12 @@ PropertyEditorPane { anchors.left: parent.left anchors.right: parent.right - visible: theSource !== "" + visible: specificsTwo.theSource !== "" sourceComponent: specificQmlComponent onTheSourceChanged: { - active = false - active = true + specificsTwo.active = false + specificsTwo.active = true } } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/QtObjectPane.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/QtObjectPane.qml index 59b08175576..36d39f829cf 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/QtObjectPane.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/QtObjectPane.qml @@ -1,8 +1,8 @@ // Copyright (C) 2021 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -import QtQuick 2.15 -import QtQuick.Layouts 1.15 +import QtQuick +import QtQuick.Layouts import QtQuickDesignerTheme 1.0 import HelperWidgets 2.0 import StudioTheme 1.0 as StudioTheme diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick3D/Object3DPane.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick3D/Object3DPane.qml index 04691f5b1ef..c532281d6f5 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick3D/Object3DPane.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick3D/Object3DPane.qml @@ -1,8 +1,8 @@ // Copyright (C) 2021 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -import QtQuick 2.15 -import QtQuick.Layouts 1.15 +import QtQuick +import QtQuick.Layouts import QtQuickDesignerTheme 1.0 import HelperWidgets 2.0 import StudioTheme 1.0 as StudioTheme @@ -25,16 +25,17 @@ PropertyEditorPane { Loader { id: specificsTwo - anchors.left: parent.left - anchors.right: parent.right - visible: theSource !== "" - sourceComponent: specificQmlComponent property string theSource: specificQmlData + anchors.left: parent.left + anchors.right: parent.right + visible: specificsTwo.theSource !== "" + sourceComponent: specificQmlComponent + onTheSourceChanged: { - active = false - active = true + specificsTwo.active = false + specificsTwo.active = true } } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/PropertyEditorPane.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/PropertyEditorPane.qml index 17a62874c25..26151ec9165 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/PropertyEditorPane.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/PropertyEditorPane.qml @@ -1,15 +1,16 @@ // Copyright (C) 2021 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuick.Layouts 1.15 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts import QtQuickDesignerTheme 1.0 -import HelperWidgets 2.0 +import HelperWidgets 2.0 as HelperWidgets import StudioTheme 1.0 as StudioTheme Rectangle { id: itemPane + width: 320 height: 400 color: Theme.qmlDesignerBackgroundColorDarkAlternate() @@ -19,8 +20,7 @@ Rectangle { default property alias content: mainColumn.children // Called from C++ to close context menu on focus out - function closeContextMenu() - { + function closeContextMenu() { Controller.closeContextMenu() } @@ -29,9 +29,9 @@ Rectangle { onClicked: forceActiveFocus() } - ScrollView { + HelperWidgets.ScrollView { id: mainScrollView - clip: true + //clip: true anchors.fill: parent interactive: !Controller.contextMenuOpened diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ScrollBar.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ScrollBar.qml new file mode 100644 index 00000000000..7a710e720d2 --- /dev/null +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ScrollBar.qml @@ -0,0 +1,89 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +import QtQuick +import QtQuick.Templates as T +import StudioTheme 1.0 as StudioTheme + +T.ScrollBar { + id: control + + property bool show: false + property bool otherInUse: false + property bool isNeeded: control.size < 1.0 + property bool inUse: control.hovered || control.pressed + property int thickness: control.inUse || control.otherInUse ? 10 : 8 + + property bool scrollBarVisible: parent.childrenRect.height > parent.height + + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + hoverEnabled: true + padding: 0 + minimumSize: orientation === Qt.Horizontal ? height / width : width / height + + opacity: 0.0 + + contentItem: Rectangle { + implicitWidth: control.thickness + implicitHeight: control.thickness + radius: width / 2 + color: "#D9D9D9" + } + + background: Rectangle { + id: controlTrack + color: "#D9D9D9" + opacity: control.inUse || control.otherInUse ? 0.3 : 0.0 + radius: width / 2 + + Behavior on opacity { + PropertyAnimation { + duration: 100 + easing.type: Easing.InOutQuad + } + } + } + + states: [ + State { + name: "show" + when: control.show + PropertyChanges { + target: control + opacity: 1.0 + } + }, + State { + name: "hide" + when: !control.show + PropertyChanges { + target: control + opacity: 0.0 + } + } + ] + + transitions: Transition { + from: "show" + SequentialAnimation { + PauseAnimation { duration: 450 } + NumberAnimation { + target: control + duration: 200 + property: "opacity" + to: 0.0 + } + } + } + + Behavior on thickness { + PropertyAnimation { + duration: 100 + easing.type: Easing.InOutQuad + } + } +} diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ScrollView.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ScrollView.qml index 8b898a1c2d3..f33d0dd35bc 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ScrollView.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ScrollView.qml @@ -1,8 +1,8 @@ -// Copyright (C) 2021 The Qt Company Ltd. +// Copyright (C) 2023 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -import QtQuick 2.15 -import QtQuick.Controls 2.15 +import QtQuick +//import QtQuick.Controls as C import StudioTheme 1.0 as StudioTheme Flickable { @@ -12,29 +12,54 @@ Flickable { property alias verticalThickness: verticalScrollBar.width readonly property bool verticalScrollBarVisible: verticalScrollBar.scrollBarVisible readonly property bool horizontalScrollBarVisible: horizontalScrollBar.scrollBarVisible - readonly property bool bothVisible: verticalScrollBarVisible && horizontalScrollBarVisible + readonly property bool bothVisible: flickable.verticalScrollBarVisible + && flickable.horizontalScrollBarVisible property real temporaryHeight: 0 - contentWidth: areaItem.childrenRect.width - contentHeight: Math.max(areaItem.childrenRect.height, flickable.temporaryHeight) - boundsBehavior: Flickable.StopAtBounds - default property alias content: areaItem.children - Item { - id: areaItem - } + 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" - ScrollBar.horizontal: HorizontalScrollBar { + HoverHandler { id: hoverHandler } + + ScrollBar.horizontal: ScrollBar { id: horizontalScrollBar parent: flickable - scrollBarVisible: flickable.contentWidth > flickable.width + x: 0 + y: flickable.height - horizontalScrollBar.height + width: flickable.availableWidth - (verticalScrollBar.isNeeded ? verticalScrollBar.thickness : 0) + orientation: Qt.Horizontal + + show: (hoverHandler.hovered || flickable.focus || flickable.adsFocus + || horizontalScrollBar.inUse || horizontalScrollBar.otherInUse) + && horizontalScrollBar.isNeeded + otherInUse: verticalScrollBar.inUse } - ScrollBar.vertical: VerticalScrollBar { + ScrollBar.vertical: ScrollBar { id: verticalScrollBar parent: flickable - scrollBarVisible: flickable.contentHeight > flickable.height + x: flickable.width - verticalScrollBar.width + y: 0 + height: flickable.availableHeight - (horizontalScrollBar.isNeeded ? horizontalScrollBar.thickness : 0) + orientation: Qt.Vertical + + show: (hoverHandler.hovered || flickable.focus || flickable.adsFocus + || horizontalScrollBar.inUse || horizontalScrollBar.otherInUse) + && verticalScrollBar.isNeeded + otherInUse: horizontalScrollBar.inUse } + + contentWidth: areaItem.childrenRect.width + contentHeight: Math.max(areaItem.childrenRect.height, flickable.temporaryHeight) + + boundsMovement: Flickable.StopAtBounds + boundsBehavior: Flickable.StopAtBounds + + Item { id: areaItem } + } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/qmldir b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/qmldir index 9c19a45e2ef..1e475a665c2 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/qmldir +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/qmldir @@ -59,6 +59,7 @@ PropertyEditorPane 2.0 PropertyEditorPane.qml PropertyLabel 2.0 PropertyLabel.qml PaddingSection 2.0 PaddingSection.qml RoundedPanel 2.0 RoundedPanel.qml +ScrollBar 2.0 ScrollBar.qml ScrollView 2.0 ScrollView.qml SecondColumnLayout 2.0 SecondColumnLayout.qml Section 2.0 Section.qml diff --git a/share/qtcreator/qmldesigner/stateseditor/Main.qml b/share/qtcreator/qmldesigner/stateseditor/Main.qml index 13f26884bcf..7e8ad669327 100644 --- a/share/qtcreator/qmldesigner/stateseditor/Main.qml +++ b/share/qtcreator/qmldesigner/stateseditor/Main.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick -import QtQuick.Controls +import QtQuick.Controls.Basic as Basic import StatesEditor import HelperWidgets 2.0 as HelperWidgets import StudioControls 1.0 as StudioControls @@ -567,28 +567,42 @@ Rectangle { height: root.isLandscape ? root.height - toolBar.height - (2 * root.padding) : root.scrollViewHeight clip: true - ScrollView { + Basic.ScrollView { id: scrollView + + 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" + anchors.fill: parent anchors.topMargin: root.topMargin anchors.leftMargin: root.leftMargin - ScrollBar.horizontal: StateScrollBar { + ScrollBar.horizontal: HelperWidgets.ScrollBar { id: horizontalBar parent: scrollView x: scrollView.leftPadding y: scrollView.height - height width: scrollView.availableWidth orientation: Qt.Horizontal + + show: (scrollView.hovered || scrollView.focus || scrollView.adsFocus) + && horizontalBar.isNeeded + otherInUse: verticalBar.inUse } - ScrollBar.vertical: StateScrollBar { + ScrollBar.vertical: HelperWidgets.ScrollBar { id: verticalBar parent: scrollView x: scrollView.mirrored ? 0 : scrollView.width - width y: scrollView.topPadding height: scrollView.availableHeight orientation: Qt.Vertical + + show: (scrollView.hovered || scrollView.focus || scrollView.adsFocus) + && verticalBar.isNeeded + otherInUse: horizontalBar.inUse } Flickable { diff --git a/share/qtcreator/qmldesigner/textureEditorQmlSource/EmptyTextureEditorPane.qml b/share/qtcreator/qmldesigner/textureEditorQmlSource/EmptyTextureEditorPane.qml index 70fa841461a..72f1c464f92 100644 --- a/share/qtcreator/qmldesigner/textureEditorQmlSource/EmptyTextureEditorPane.qml +++ b/share/qtcreator/qmldesigner/textureEditorQmlSource/EmptyTextureEditorPane.qml @@ -1,8 +1,7 @@ // Copyright (C) 2022 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -import QtQuick 2.15 -import QtQuick.Layouts 1.15 +import QtQuick import QtQuickDesignerTheme 1.0 import HelperWidgets 2.0 import StudioTheme 1.0 as StudioTheme diff --git a/share/qtcreator/qmldesigner/textureEditorQmlSource/TextureEditorPane.qml b/share/qtcreator/qmldesigner/textureEditorQmlSource/TextureEditorPane.qml index 2098eda5165..ddf452d6f0f 100644 --- a/share/qtcreator/qmldesigner/textureEditorQmlSource/TextureEditorPane.qml +++ b/share/qtcreator/qmldesigner/textureEditorQmlSource/TextureEditorPane.qml @@ -1,7 +1,7 @@ // Copyright (C) 2022 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -import QtQuick 2.15 +import QtQuick import QtQuickDesignerTheme 1.0 import HelperWidgets 2.0 @@ -44,12 +44,12 @@ PropertyEditorPane { anchors.left: parent.left anchors.right: parent.right - visible: theSource !== "" + visible: specificsTwo.theSource !== "" sourceComponent: specificQmlComponent onTheSourceChanged: { - active = false - active = true + specificsTwo.active = false + specificsTwo.active = true } } diff --git a/src/libs/advanceddockingsystem/CMakeLists.txt b/src/libs/advanceddockingsystem/CMakeLists.txt index 2ec5c94b422..66608852137 100644 --- a/src/libs/advanceddockingsystem/CMakeLists.txt +++ b/src/libs/advanceddockingsystem/CMakeLists.txt @@ -1,5 +1,5 @@ add_qtc_library(AdvancedDockingSystem - DEPENDS Qt::Widgets Qt::Core Qt::Gui Qt::Xml Utils + DEPENDS Qt::Widgets Qt::Core Qt::Gui Qt::Xml Qt::QuickWidgets Utils SOURCES ads_globals.cpp ads_globals.h advanceddockingsystemtr.h diff --git a/src/libs/advanceddockingsystem/dockwidget.cpp b/src/libs/advanceddockingsystem/dockwidget.cpp index 75d00438322..bb6dd00b322 100644 --- a/src/libs/advanceddockingsystem/dockwidget.cpp +++ b/src/libs/advanceddockingsystem/dockwidget.cpp @@ -6,7 +6,6 @@ #include "ads_globals.h" #include "ads_globals_p.h" #include "autohidedockcontainer.h" -#include "autohidesidebar.h" #include "autohidetab.h" #include "dockareawidget.h" #include "dockcomponentsfactory.h" @@ -20,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -27,6 +27,7 @@ #include #include #include +#include namespace ADS { /** @@ -452,8 +453,25 @@ void DockWidget::setFocused(bool focused) return; d->m_focused = focused; + if (d->m_scrollArea) d->m_scrollArea->setProperty("focused", focused); + + QList quickWidgets = d->m_widget->findChildren(); + + for (const auto &quickWidget : std::as_const(quickWidgets)) { + QQuickItem *rootItem = quickWidget->rootObject(); + if (!rootItem) + continue; + + QQuickItem *scrollView = rootItem->findChild("__mainSrollView"); + if (!scrollView) + continue; + + scrollView->setProperty("adsFocus", focused); + } + + emit focusedChanged(); } bool DockWidget::isFocused() const diff --git a/src/libs/advanceddockingsystem/dockwidget.h b/src/libs/advanceddockingsystem/dockwidget.h index 72ac4789cb6..65495cc04d6 100644 --- a/src/libs/advanceddockingsystem/dockwidget.h +++ b/src/libs/advanceddockingsystem/dockwidget.h @@ -32,7 +32,7 @@ class AutoHideSideBar; class ADS_EXPORT DockWidget : public QFrame { Q_OBJECT - Q_PROPERTY(bool focused READ isFocused WRITE setFocused) + Q_PROPERTY(bool focused READ isFocused WRITE setFocused NOTIFY focusedChanged) private: DockWidgetPrivate *d; ///< private data (pimpl) @@ -639,6 +639,8 @@ signals: * The features parameter gives the new value of the property. */ void featuresChanged(DockWidgetFeatures features); + + void focusedChanged(); }; // class DockWidget } // namespace ADS diff --git a/src/plugins/qmldesigner/components/connectioneditor/connectionview.cpp b/src/plugins/qmldesigner/components/connectioneditor/connectionview.cpp index 5ee81b86a15..78625efd388 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/connectionview.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/connectionview.cpp @@ -13,10 +13,11 @@ #include #include -#include #include -#include +#include #include +#include +#include #include @@ -59,7 +60,7 @@ public: this, &ConnectionViewQuickWidget::reloadQmlSource); - //setObjectName(Constants::OBJECT_NAME_STATES_EDITOR); + quickWidget()->setObjectName(Constants::OBJECT_NAME_CONNECTION_EDITOR); setResizeMode(QQuickWidget::SizeRootObjectToView); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); diff --git a/src/plugins/qmldesigner/qmldesignerconstants.h b/src/plugins/qmldesigner/qmldesignerconstants.h index 3a2d591a1bf..7e01b7de793 100644 --- a/src/plugins/qmldesigner/qmldesignerconstants.h +++ b/src/plugins/qmldesigner/qmldesignerconstants.h @@ -168,6 +168,7 @@ const char OBJECT_NAME_TOP_FEEDBACK[] = "QQuickWidgetQDSFeedback"; const char OBJECT_NAME_NEW_DIALOG[] = "QQuickWidgetQDSNewDialog"; const char OBJECT_NAME_SPLASH_SCREEN[] = "QQuickWidgetSplashScreen"; const char OBJECT_NAME_WELCOME_PAGE[] = "QQuickWidgetQDSWelcomePage"; +const char OBJECT_NAME_CONNECTION_EDITOR[] = "QQuickWidgetConnectionEditor"; const char ENVIRONMENT_SHOW_QML_ERRORS[] = "QMLDESIGNER_SHOW_QML_ERRORS"; diff --git a/src/plugins/qmldesignerbase/studio/studioquickwidget.h b/src/plugins/qmldesignerbase/studio/studioquickwidget.h index 61c2ff8922f..165db562e21 100644 --- a/src/plugins/qmldesignerbase/studio/studioquickwidget.h +++ b/src/plugins/qmldesignerbase/studio/studioquickwidget.h @@ -147,6 +147,7 @@ public: class QMLDESIGNERBASE_EXPORT StudioQuickWidget : public QWidget { Q_OBJECT + public: explicit StudioQuickWidget(QWidget *parent = nullptr); @@ -168,6 +169,9 @@ public: StudioPropertyMap *registerPropertyMap(const QByteArray &name); QQuickWidget *quickWidget() const; +signals: + void adsFocusChanged(); + private: QQuickWidget *m_quickWidget = nullptr; };