aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickcontrols/basic
diff options
context:
space:
mode:
authorTor Arne Vestbø <[email protected]>2024-12-04 18:53:26 +0100
committerTor Arne Vestbø <[email protected]>2024-12-19 12:39:38 +0100
commit3cdece6d7e08a53774820af6708a16ad3075e9c6 (patch)
treee7f6cd34ca6d5d92a24dc648ee4bcb7d378b1fe7 /src/quickcontrols/basic
parent17a3458418e5308584443168495a80afc64b5fab (diff)
Take safe areas into account for Qt Quick Controls ToolBar and MenuBar
A ToolBar and MenuBar is commonly placed in the header/footer/menuBar of an ApplicationWindow, where we don't do any automatic padding to account for the safe area. By adding the safe area margins as padding to the controls, we ensure that the control's background flows into the non-safe area, while the content item of the control (the toolbar or menu bar content) is kept within the safe area. Pick-to: 6.9 Change-Id: I5fad7394beaa01ae8ed142e4e2e42c5bffaab9fa Reviewed-by: Richard Moe Gustavsen <[email protected]>
Diffstat (limited to 'src/quickcontrols/basic')
-rw-r--r--src/quickcontrols/basic/MenuBar.qml5
-rw-r--r--src/quickcontrols/basic/ToolBar.qml5
2 files changed, 10 insertions, 0 deletions
diff --git a/src/quickcontrols/basic/MenuBar.qml b/src/quickcontrols/basic/MenuBar.qml
index 4b72ae9acf..9c74e1165b 100644
--- a/src/quickcontrols/basic/MenuBar.qml
+++ b/src/quickcontrols/basic/MenuBar.qml
@@ -13,6 +13,11 @@ T.MenuBar {
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
implicitContentHeight + topPadding + bottomPadding)
+ topPadding: SafeArea.margins.top
+ leftPadding: SafeArea.margins.left
+ rightPadding: SafeArea.margins.right
+ bottomPadding: SafeArea.margins.bottom
+
delegate: MenuBarItem { }
contentItem: Row {
diff --git a/src/quickcontrols/basic/ToolBar.qml b/src/quickcontrols/basic/ToolBar.qml
index dd621356b7..33da781da1 100644
--- a/src/quickcontrols/basic/ToolBar.qml
+++ b/src/quickcontrols/basic/ToolBar.qml
@@ -13,6 +13,11 @@ T.ToolBar {
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
implicitContentHeight + topPadding + bottomPadding)
+ topPadding: SafeArea.margins.top
+ leftPadding: SafeArea.margins.left
+ rightPadding: SafeArea.margins.right
+ bottomPadding: SafeArea.margins.bottom
+
background: Rectangle {
implicitHeight: 40
color: control.palette.button