diff --git a/examples/qtquick/customtitlebar/MyTitleBar.qml b/examples/qtquick/customtitlebar/MyTitleBar.qml index fde6a1ae..334fd36e 100644 --- a/examples/qtquick/customtitlebar/MyTitleBar.qml +++ b/examples/qtquick/customtitlebar/MyTitleBar.qml @@ -19,7 +19,7 @@ KDDW.TitleBarBase { color: "black" border.color: "orange" border.width: 2 - height: visible ? 50 : 0 + heightWhenVisible: 50 Text { color: "orange" diff --git a/src/private/quick/qml/FloatingWindow.qml b/src/private/quick/qml/FloatingWindow.qml index eef1af25..777e2e98 100644 --- a/src/private/quick/qml/FloatingWindow.qml +++ b/src/private/quick/qml/FloatingWindow.qml @@ -17,7 +17,7 @@ Rectangle { readonly property QtObject floatingWindowCpp: parent readonly property QtObject titleBarCpp: floatingWindowCpp ? floatingWindowCpp.titleBar : null readonly property QtObject dropAreaCpp: floatingWindowCpp ? floatingWindowCpp.dropArea : null - readonly property int titleBarHeight: titleBar.height + readonly property int titleBarHeight: titleBar.heightWhenVisible readonly property int margins: 4 anchors.fill: parent @@ -28,9 +28,15 @@ Rectangle { width: 1 } + onTitleBarHeightChanged: { + if (floatingWindowCpp) + floatingWindowCpp.geometryUpdated(); + } + Loader { id: titleBar readonly property QtObject titleBarCpp: root.titleBarCpp + readonly property int heightWhenVisible: item.heightWhenVisible source: _kddw_widgetFactory.titleBarFilename anchors { @@ -39,11 +45,6 @@ Rectangle { right: parent.right margins: root.margins } - - onHeightChanged: { - if (floatingWindowCpp) - floatingWindowCpp.geometryUpdated(); - } } KDDW.DropArea { diff --git a/src/private/quick/qml/Frame.qml b/src/private/quick/qml/Frame.qml index b6cf7c27..4ec86b26 100644 --- a/src/private/quick/qml/Frame.qml +++ b/src/private/quick/qml/Frame.qml @@ -18,7 +18,7 @@ Rectangle { property QtObject frameCpp readonly property QtObject titleBarCpp: frameCpp ? frameCpp.titleBar : null - readonly property int nonContentsHeight: titleBar.height + tabbar.height + readonly property int nonContentsHeight: titleBar.heightWhenVisible + tabbar.height anchors.fill: parent @@ -34,6 +34,11 @@ Rectangle { frameCpp.setStackLayout(stackLayout); } + onNonContentsHeightChanged: { + if (frameCpp) + frameCpp.geometryUpdated(); + } + Loader { id: titleBar readonly property QtObject titleBarCpp: root.titleBarCpp diff --git a/src/private/quick/qml/TitleBar.qml b/src/private/quick/qml/TitleBar.qml index e3da0aa8..e265a4bb 100644 --- a/src/private/quick/qml/TitleBar.qml +++ b/src/private/quick/qml/TitleBar.qml @@ -25,7 +25,7 @@ TitleBarBase { readonly property QtObject closeButton: closeButton color: "#eff0f1" - height: visible ? 30 : 0 + heightWhenVisible: 30 Text { id: title diff --git a/src/private/quick/qml/TitleBarBase.qml b/src/private/quick/qml/TitleBarBase.qml index d4ab4548..6ede7212 100644 --- a/src/private/quick/qml/TitleBarBase.qml +++ b/src/private/quick/qml/TitleBarBase.qml @@ -32,6 +32,10 @@ Rectangle { // So the tests can send mouse events programatically readonly property QtObject mouseAreaForTests: dragMouseArea + /// The hight the title bar should have when visible. Override in your component with another value + /// Don't set 'hight' directly in the overridden component + property int heightWhenVisible: 30 + /// @brief Signal emitted by a TitleBar.qml component when the close button is clicked signal closeButtonClicked(); @@ -39,7 +43,8 @@ Rectangle { signal floatButtonClicked(); visible: titleBarCpp && titleBarCpp.visible - implicitHeight: 30 + height: visible ? heightWhenVisible : 0 + implicitHeight: heightWhenVisible MouseArea { id: dragMouseArea